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

body {
  font-family: sans-serif;
  font-size: 16px;
  line-height: 1.75;
  min-height: 100vh;
}

main {
  flex: 1;
  max-width: 740px;
  min-width: 0; /* prevents flex overflow on narrow screens */
  padding: 2rem 1.5rem 4rem;
}

pre, code {
  font-family: monospace;
  font-size: 13px;
}

pre {
  padding: 1rem 1.25rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: 1.25rem 0;
  line-height: 1.6;
}

p { margin: 0 0 1rem; }
h1 { font-size: 28px; font-weight: 500; margin-bottom: 0.5rem; }
h2 { font-size: 18px; font-weight: 500; margin: 2rem 0 0.75rem; }
h3 { font-size: 15px; font-weight: 500; margin: 1.5rem 0 0.5rem; }

main ul {
  padding-left: 1.5rem;
  list-style-type: disc;
}

main ul ul {
  padding-left: 1.5rem;
  list-style-type: circle;
}

figure { margin: 1.5rem 0; }
figure img { display: block; }
figcaption {
  font-size: 12px;
  text-align: center;
  margin-top: 0.4rem;
}

/* ── Layout configuration variables ───────────────────── */
:root {
  --toc-width: 20%;           /* sidebar TOC width as % of page */
  --layout-max-width: 1200px; /* maximum total page width */
  --sidebar-breakpoint: 768px;/* below this: TOC stacks above content */
}

/* ── Page layout: TOC sidebar + main content ──────────── */
.page-layout {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  max-width: var(--layout-max-width);
  margin: 0 auto;
}

.toc-sidebar {
  width: var(--toc-width);
  flex-shrink: 0;
  padding: 2rem 1rem 2rem 1.5rem;
  position: sticky;
  top: 1rem;
  align-self: flex-start;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
}

.toc-title {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

/* h1 flush, h2 indented once, h3 indented twice */
#toc-list { list-style: none; padding: 0; margin: 0; }
#toc-list li { margin: 0.25rem 0; }
#toc-list li.toc-h1 { padding-left: 0; }
#toc-list li.toc-h2 { padding-left: 0.75rem; }
#toc-list li.toc-h3 { padding-left: 1.5rem; }
#toc-list li.toc-h2::before { content: '● '; font-size: 8px; vertical-align: middle; }
#toc-list li.toc-h3::before { content: '○ '; font-size: 8px; vertical-align: middle; }

/* Below breakpoint: stack TOC above content */
@media (max-width: 768px) {
  .page-layout { flex-direction: column; }
  .toc-sidebar {
    position: static;
    width: 100%;
    max-height: none;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid;
  }
}

nav.lesson-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  max-width: var(--layout-max-width);
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  font-size: 13px;
  border-bottom: 1px solid;
}

nav.lesson-nav .nav-links { margin-left: auto; display: flex; gap: 1rem; }

nav.bottom-nav {
  display: flex;
  justify-content: space-between;
  max-width: var(--layout-max-width);
  margin: 3rem auto 0;
  padding: 1rem 1.5rem 0;
  font-size: 13px;
  border-top: 1px solid;
}

select#theme-picker {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid;
}

.lesson-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.accent-rule {
  display: none;
  width: 100%;
  height: 2px;
  margin-bottom: 1.25rem;
}

/* ── Theme: Dark + Accent (default) ───────────────────── */
body.theme-dark {
  background: #1a1a2e;
  color: #8892a4;
}
body.theme-dark h1,
body.theme-dark h2,
body.theme-dark h3 { color: #e2e8f0; }
body.theme-dark h2 { color: #c4b5fd; }
body.theme-dark a { color: #a78bfa; }
body.theme-dark code { color: #a78bfa; }
body.theme-dark pre { background: #12122a; border: 1px solid #2a2a4a; color: #a78bfa; }
body.theme-dark .lesson-label { color: #a78bfa; }
body.theme-dark nav.lesson-nav { border-color: #2a2a4a; color: #6c6f93; }
body.theme-dark nav.bottom-nav { border-color: #2a2a4a; }
body.theme-dark nav.bottom-nav a { color: #a78bfa; }
body.theme-dark select#theme-picker { background: #12122a; color: #a78bfa; border-color: #2a2a4a; }
body.theme-dark .accent-rule { display: block; background: linear-gradient(90deg, #7c3aed, #4f46e5); }
body.theme-dark figcaption { color: #8892a4; }

/* ── Theme: Terminal ──────────────────────────────────── */
body.theme-terminal {
  background: #0d1117;
  color: #8d96a0;
  font-family: monospace;
}
body.theme-terminal h1,
body.theme-terminal h2,
body.theme-terminal h3 { color: #e6edf3; font-family: monospace; }
body.theme-terminal h2 { color: #58a6ff; }
body.theme-terminal a { color: #58a6ff; }
body.theme-terminal code { color: #79c0ff; }
body.theme-terminal pre { background: #161b22; border: 1px solid #21262d; color: #79c0ff; }
body.theme-terminal .lesson-label { color: #3fb950; }
body.theme-terminal nav.lesson-nav { border-color: #21262d; color: #3fb950; font-family: monospace; }
body.theme-terminal nav.bottom-nav { border-color: #21262d; }
body.theme-terminal nav.bottom-nav a { color: #58a6ff; }
body.theme-terminal select#theme-picker { background: #161b22; color: #58a6ff; border-color: #21262d; font-family: monospace; }
body.theme-terminal figcaption { color: #8d96a0; font-family: monospace; }

/* ── Theme: Clean Docs ────────────────────────────────── */
body.theme-docs {
  background: #ffffff;
  color: #444;
}
body.theme-docs h1,
body.theme-docs h2,
body.theme-docs h3 { color: #111; }
body.theme-docs a { color: #185FA5; }
body.theme-docs code { color: #185FA5; }
body.theme-docs pre { background: #f4f4f4; color: #111; }
body.theme-docs .lesson-label { background: #E6F1FB; color: #185FA5; display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; }
body.theme-docs nav.lesson-nav { border-color: #e0e0e0; color: #666; }
body.theme-docs nav.bottom-nav { border-color: #e0e0e0; }
body.theme-docs nav.bottom-nav a { color: #185FA5; }
body.theme-docs select#theme-picker { background: #fff; color: #333; border-color: #ccc; }
body.theme-docs figcaption { color: #666; }

/* ── Theme: Editorial ─────────────────────────────────── */
body.theme-editorial {
  background: #faf8f5;
  color: #5F5E5A;
  font-family: Georgia, serif;
}
body.theme-editorial h1,
body.theme-editorial h2,
body.theme-editorial h3 { color: #2C2C2A; font-family: Georgia, serif; }
body.theme-editorial a { color: #993C1D; }
body.theme-editorial code { font-family: monospace; color: #444441; }
body.theme-editorial pre { background: #f0ede8; border-left: 3px solid #993C1D; border-radius: 0 4px 4px 0; color: #2C2C2A; font-family: monospace; }
body.theme-editorial .lesson-label { color: #888780; letter-spacing: 0.15em; }
body.theme-editorial nav.lesson-nav { border-color: #dddbd5; color: #888780; font-family: Georgia, serif; }
body.theme-editorial nav.bottom-nav { border-color: #dddbd5; }
body.theme-editorial nav.bottom-nav a { color: #993C1D; }
body.theme-editorial select#theme-picker { background: #faf8f5; color: #5F5E5A; border-color: #dddbd5; font-family: Georgia, serif; }
body.theme-editorial .accent-rule { display: block; background: #993C1D; width: 36px; height: 3px; }
body.theme-editorial figcaption { color: #888780; font-family: Georgia, serif; }

/* ── Syntax Highlighting: Dark (VS Code dark) ─────────── */
body.theme-dark .highlight,
body.theme-dark .highlight pre { background: #1e1e1e; color: #d4d4d4; }
body.theme-dark .highlight .c  { color: #6a9955 } /* Comment */
body.theme-dark .highlight .k  { color: #569cd6 } /* Keyword */
body.theme-dark .highlight .kt { color: #569cd6 } /* Keyword type */
body.theme-dark .highlight .cp { color: #569cd6 } /* Preprocessor */
body.theme-dark .highlight .s  { color: #ce9178 } /* String */
body.theme-dark .highlight .n  { color: #9cdcfe } /* Name */
body.theme-dark .highlight .nf { color: #dcdcaa } /* Function name */
body.theme-dark .highlight .o  { color: #d4d4d4 } /* Operator */
body.theme-dark .highlight .p  { color: #d4d4d4 } /* Punctuation */
body.theme-dark .highlight .mi { color: #b5cea8 } /* Integer */
body.theme-dark .highlight .mf { color: #b5cea8 } /* Float */
 
/* ── Syntax Highlighting: Terminal (high contrast green) ─ */
body.theme-terminal .highlight,
body.theme-terminal .highlight pre { background: #0d1117; color: #e6edf3; }
body.theme-terminal .highlight .c  { color: #3fb950 } /* Comment — bright green */
body.theme-terminal .highlight .k  { color: #ff7b72 } /* Keyword — red */
body.theme-terminal .highlight .kt { color: #ff7b72 } /* Keyword type */
body.theme-terminal .highlight .cp { color: #ff7b72 } /* Preprocessor */
body.theme-terminal .highlight .s  { color: #a5d6ff } /* String — light blue */
body.theme-terminal .highlight .n  { color: #79c0ff } /* Name — blue */
body.theme-terminal .highlight .nf { color: #d2a8ff } /* Function — purple */
body.theme-terminal .highlight .o  { color: #e6edf3 } /* Operator */
body.theme-terminal .highlight .p  { color: #e6edf3 } /* Punctuation */
body.theme-terminal .highlight .mi { color: #f8c500 } /* Integer — yellow */
body.theme-terminal .highlight .mf { color: #f8c500 } /* Float */
 
/* ── Syntax Highlighting: Docs (light, high contrast) ──── */
body.theme-docs .highlight,
body.theme-docs .highlight pre { background: #f6f8fa; color: #24292f; }
body.theme-docs .highlight .c  { color: #6e7781 } /* Comment */
body.theme-docs .highlight .k  { color: #cf222e } /* Keyword — red */
body.theme-docs .highlight .kt { color: #cf222e } /* Keyword type */
body.theme-docs .highlight .cp { color: #cf222e } /* Preprocessor */
body.theme-docs .highlight .s  { color: #0a3069 } /* String — dark blue */
body.theme-docs .highlight .n  { color: #24292f } /* Name */
body.theme-docs .highlight .nf { color: #8250df } /* Function — purple */
body.theme-docs .highlight .o  { color: #24292f } /* Operator */
body.theme-docs .highlight .p  { color: #24292f } /* Punctuation */
body.theme-docs .highlight .mi { color: #0550ae } /* Integer — blue */
body.theme-docs .highlight .mf { color: #0550ae } /* Float */
 
/* ── Syntax Highlighting: Editorial (warm sepia) ────────── */
body.theme-editorial .highlight,
body.theme-editorial .highlight pre { background: #f0ede8; color: #2C2C2A; }
body.theme-editorial .highlight .c  { color: #7a7062 } /* Comment */
body.theme-editorial .highlight .k  { color: #8c2d0e } /* Keyword — dark red */
body.theme-editorial .highlight .kt { color: #8c2d0e } /* Keyword type */
body.theme-editorial .highlight .cp { color: #8c2d0e } /* Preprocessor */
body.theme-editorial .highlight .s  { color: #4a6741 } /* String — forest green */
body.theme-editorial .highlight .n  { color: #2C2C2A } /* Name */
body.theme-editorial .highlight .nf { color: #5c3d8f } /* Function — muted purple */
body.theme-editorial .highlight .o  { color: #2C2C2A } /* Operator */
body.theme-editorial .highlight .p  { color: #2C2C2A } /* Punctuation */
body.theme-editorial .highlight .mi { color: #1a5c8a } /* Integer — dark blue */
body.theme-editorial .highlight .mf { color: #1a5c8a } /* Float */


/* ── TOC sidebar theme colors ─────────────────────────── */
body.theme-dark .toc-sidebar   { border-color: #2a2a4a; }
body.theme-dark .toc-title     { color: #a78bfa; }
body.theme-dark #toc-list a    { color: #a78bfa; text-decoration: none; }
body.theme-dark #toc-list a:hover { color: #c4b5fd; }

body.theme-terminal .toc-sidebar { border-color: #21262d; }
body.theme-terminal .toc-title   { color: #3fb950; }
body.theme-terminal #toc-list a  { color: #58a6ff; text-decoration: none; }
body.theme-terminal #toc-list a:hover { color: #79c0ff; }

body.theme-docs .toc-sidebar   { border-color: #e0e0e0; }
body.theme-docs .toc-title     { color: #185FA5; }
body.theme-docs #toc-list a    { color: #185FA5; text-decoration: none; }
body.theme-docs #toc-list a:hover { color: #0d3d6e; }

body.theme-editorial .toc-sidebar { border-color: #dddbd5; font-family: Georgia, serif; }
body.theme-editorial .toc-title   { color: #993C1D; }
body.theme-editorial #toc-list a  { color: #993C1D; text-decoration: none; }
body.theme-editorial #toc-list a:hover { color: #5F5E5A; }
