/* Syntax Reference Page Styles */

:root {
  --font-mono: 'Monaco', 'Menlo', 'Consolas', monospace;
  --color-bg: #f8f9fa;
  --color-panel: #ffffff;
  --color-border: #e1e4e8;
  --color-text: #24292e;
  --color-text-secondary: #586069;
  --color-primary: #0366d6;
  --color-code-bg: #f6f8fa;
  --color-heading: #1b1f23;
  --sidebar-width: 220px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-panel);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-heading);
}

header nav a {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.9rem;
}

header nav a:hover {
  text-decoration: underline;
}

#back-btn, #breakout-btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

#back-btn {
  background: var(--color-primary);
  color: white;
}

#back-btn:hover {
  background: #0256c7;
}

#breakout-btn {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

#breakout-btn:hover {
  background: var(--color-bg);
}

header nav {
  display: flex;
  gap: 0.5rem;
}

/* Main Layout */
main {
  display: flex;
  max-width: 100%;
  margin: 0 auto;
  min-height: calc(100vh - 120px);
}

/* Table of Contents Sidebar */
#toc {
  position: sticky;
  top: 70px;
  width: var(--sidebar-width);
  height: fit-content;
  padding: 1.5rem;
  flex-shrink: 0;
}

#toc h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
}

#toc ul {
  list-style: none;
}

#toc li {
  margin-bottom: 0.5rem;
}

#toc .toc-subsections {
  margin-top: 0.25rem;
  margin-left: 0.75rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--color-border);
}

#toc .toc-subsections li {
  margin-bottom: 0.25rem;
}

#toc .toc-subsections a {
  font-size: 0.8rem;
}

#toc a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  display: block;
  padding: 0.25rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
  transition: all 0.15s ease;
}

#toc a:hover {
  color: var(--color-primary);
  border-left-color: var(--color-primary);
}

/* Content Area */
#content {
  flex: 1;
  max-width: 1000px;
  padding: 2rem 3rem;
  background: var(--color-panel);
  border-left: 1px solid var(--color-border);
}

/* Right spacer to balance the layout */
main::after {
  content: "";
  flex: 1;
  background: var(--color-panel);
}

/* Sections */
section {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-border);
}

section:last-child {
  border-bottom: none;
}

/* Subsections - no extra spacing/border */
section.subsection {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: none;
  margin-left: 0.5rem;
  padding-left: 1rem;
  border-left: 2px solid var(--color-border);
}

section h2 {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--color-heading);
  margin-bottom: 1rem;
  padding-top: 1rem;
}

section h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-heading);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

section.subsection h3 {
  margin-top: 0;
  color: var(--color-primary);
}

section h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-heading);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

section h5 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

section p {
  margin-bottom: 1rem;
  color: var(--color-text);
}

section ul, section ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

section li {
  margin-bottom: 0.5rem;
}

/* Inline Code */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-code-bg);
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

/* Code Blocks */
.code-block {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.code-block code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Reference Tables */
.ref-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.ref-table th,
.ref-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.ref-table th {
  background: var(--color-code-bg);
  font-weight: 600;
  color: var(--color-heading);
}

.ref-table tr:hover {
  background: var(--color-code-bg);
}

.ref-table code {
  background: #fff;
  border: 1px solid var(--color-border);
}

/* Info Box */
.info-box {
  background: #f1f8ff;
  border: 1px solid #c8e1ff;
  border-left: 4px solid var(--color-primary);
  border-radius: 4px;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}

.info-box h4 {
  color: var(--color-primary);
  margin-bottom: 0.75rem;
}

.info-box p {
  margin-bottom: 0.75rem;
}

.info-box p:last-child {
  margin-bottom: 0;
}

.info-box ol {
  margin: 0.75rem 0;
  padding-left: 1.25rem;
}

.info-box li {
  margin-bottom: 0.25rem;
}

.info-box code {
  background: #fff;
}

/* Key List */
.key-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.key-list li {
  margin: 0;
}

.key-list code {
  display: inline-block;
}

/* Keyword/Function List */
.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem 0;
}

.keyword-list code {
  display: inline-block;
}

/* Color Grid */
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.color-swatch {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--color-panel);
}

.swatch-preview {
  height: 50px;
  border-bottom: 1px solid var(--color-border);
}

.swatch-info {
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.swatch-info code {
  font-size: 0.8rem;
  background: none;
  padding: 0;
}

.swatch-info .hex {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--color-text-secondary);
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-panel);
}

/* Responsive */
@media (max-width: 900px) {
  main {
    flex-direction: column;
  }

  #toc {
    position: static;
    width: 100%;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-panel);
  }

  #toc ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
  }

  #toc li {
    margin: 0;
  }

  #toc a {
    border-left: none;
    padding-left: 0;
  }

  #content {
    padding: 1.5rem;
    border: none;
  }
}

@media (max-width: 600px) {
  header {
    padding: 1rem;
    flex-direction: column;
    gap: 0.5rem;
  }

  header h1 {
    font-size: 1.25rem;
  }

  section h2 {
    font-size: 1.5rem;
  }

  .ref-table {
    font-size: 0.8rem;
  }

  .ref-table th,
  .ref-table td {
    padding: 0.5rem;
  }

  .color-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}
