/* Styles for the generated pages (lessons, phases, curriculum index).
   Same tokens and type as the landing page: a flight-test datasheet, ruled, one orange accent. */
:root {
  --paper: #f2f4f7; --paper-2: #e7ebf0; --ink: #0f1620; --ink-2: #4a5666; --rule: #c9d1db;
  --blue: #214f7e; --blue-soft: #d9e4f0; --orange: #d9571a; --orange-ink: #ffffff; --ok: #2b7a4b;
  --code-bg: #e9edf2;
  --hl-kw: #8a3ab9; --hl-str: #2b7a4b; --hl-num: #b0461a; --hl-com: #6b7685; --hl-fn: #214f7e;
  --font-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 4px;
  --nav-h: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0b1119; --paper-2: #121a25; --ink: #e8edf4; --ink-2: #9aa7b8; --rule: #27323f;
    --blue: #8db2db; --blue-soft: #16263a; --orange: #ff7a3d; --orange-ink: #16110d; --ok: #63c48a;
    --code-bg: #101822;
    --hl-kw: #c79bf2; --hl-str: #7fd19b; --hl-num: #ffa070; --hl-com: #7d8a9c; --hl-fn: #8db2db;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0b1119; --paper-2: #121a25; --ink: #e8edf4; --ink-2: #9aa7b8; --rule: #27323f;
  --blue: #8db2db; --blue-soft: #16263a; --orange: #ff7a3d; --orange-ink: #16110d; --ok: #63c48a;
  --code-bg: #101822;
  --hl-kw: #c79bf2; --hl-str: #7fd19b; --hl-num: #ffa070; --hl-com: #7d8a9c; --hl-fn: #8db2db;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: 1.0625rem; line-height: 1.65;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 0.18em; }
a:hover { text-decoration-color: var(--orange); }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; }
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.015em; line-height: 1.15; text-wrap: balance; }
img { max-width: 100%; height: auto; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 0.9rem; }
.eyebrow { margin: 0; font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.eyebrow::before { content: "// "; color: var(--orange); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 100; background: var(--orange); color: var(--orange-ink); padding: 8px 12px; border-radius: var(--radius); }

/* Nav */
.nav { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.nav-in { max-width: 1440px; margin: 0 auto; padding-inline: clamp(16px, 3vw, 32px); display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: var(--nav-h); }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 0.98rem; letter-spacing: -0.01em; text-decoration: none; min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand svg { width: 26px; height: 26px; flex: none; }
.nav-links { display: flex; gap: clamp(12px, 2vw, 26px); font-family: var(--font-display); font-weight: 500; font-size: 0.9rem; flex: none; }
.nav-links a { text-decoration: none; color: var(--ink-2); }
.nav-links a:hover, .nav-links .gh { color: var(--ink); }
@media (max-width: 560px) { .nav-links a[href$="ROADMAP.md"] { display: none; } }

/* Buttons */
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 0.92rem; padding: 11px 16px; border-radius: var(--radius); text-decoration: none; border: 1.5px solid transparent; }
.btn-primary { background: var(--orange); color: var(--orange-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--orange) 88%, var(--ink)); }
.btn-ghost { border-color: var(--rule); }
.btn-ghost:hover { border-color: var(--ink); }

/* Lesson shell: lessons in the phase | article | on this page */
.shell { max-width: 1440px; margin: 0 auto; padding-inline: clamp(16px, 3vw, 32px); display: grid; grid-template-columns: 260px minmax(0, 1fr) 210px; gap: clamp(24px, 3vw, 48px); align-items: start; }
.article { min-width: 0; max-width: 780px; padding-block: 28px 64px; }
@media (max-width: 1240px) { .shell { grid-template-columns: 240px minmax(0, 1fr); } .toc { display: none; } }
@media (max-width: 920px) { .shell { grid-template-columns: minmax(0, 1fr); gap: 0; } }

.side { position: sticky; top: var(--nav-h); max-height: calc(100vh - var(--nav-h)); overflow-y: auto; padding-block: 28px; scrollbar-width: thin; }
.side-box > summary { list-style: none; cursor: default; display: grid; gap: 4px; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.side-box > summary::-webkit-details-marker { display: none; }
.side-title { font-family: var(--font-display); font-weight: 700; font-size: 1rem; line-height: 1.25; }
.side-list { list-style: none; margin: 0; padding: 8px 0; display: grid; }
.side-list a { display: grid; grid-template-columns: 2.4ch minmax(0, 1fr); gap: 10px; padding: 6px 8px; margin-inline: -8px; border-radius: var(--radius); text-decoration: none; font-family: var(--font-display); font-size: 0.86rem; line-height: 1.3; color: var(--ink-2); }
.side-list a:hover { color: var(--ink); background: var(--paper-2); }
.side-list a[aria-current="page"] { color: var(--ink); background: var(--blue-soft); font-weight: 600; box-shadow: inset 2px 0 0 var(--orange); }
.side-list .n { font-family: var(--font-mono); font-size: 0.75rem; color: var(--blue); padding-top: 1px; }
.side-phase { display: block; font-family: var(--font-display); font-size: 0.85rem; padding-top: 10px; border-top: 1px solid var(--rule); text-decoration: none; color: var(--blue); }
@media (max-width: 920px) {
  .side { position: static; max-height: none; overflow: visible; padding-block: 16px 0; }
  .side-box { border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper-2); padding: 12px 14px; }
  .side-box > summary { cursor: pointer; border-bottom: 0; padding-bottom: 0; position: relative; padding-right: 28px; }
  .side-box > summary::after { content: "▾"; position: absolute; right: 0; top: 50%; transform: translateY(-50%); color: var(--ink-2); }
  .side-box[open] > summary { border-bottom: 1px solid var(--rule); padding-bottom: 10px; }
  .side-box[open] > summary::after { content: "▴"; }
}

.toc { position: sticky; top: var(--nav-h); padding-block: 28px; max-height: calc(100vh - var(--nav-h)); overflow-y: auto; scrollbar-width: thin; }
.toc ol { list-style: none; margin: 10px 0 0; padding: 0; border-left: 1px solid var(--rule); }
.toc a { display: block; padding: 4px 0 4px 12px; margin-left: -1px; border-left: 2px solid transparent; font-family: var(--font-display); font-size: 0.83rem; line-height: 1.3; color: var(--ink-2); text-decoration: none; }
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--ink); border-left-color: var(--orange); }

.crumbs ol { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 8px; font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-2); }
.crumbs li + li::before { content: "/"; margin-right: 8px; color: var(--rule); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--ink); }

/* Lesson header */
.lesson-head { display: grid; gap: 14px; padding-bottom: 22px; }
.lesson-head h1 { margin: 0; font-size: clamp(2rem, 4.4vw, 3rem); font-weight: 800; letter-spacing: -0.025em; line-height: 1.04; }
.tagline { border-left: 3px solid var(--orange); padding: 2px 0 2px 16px; font-size: 1.2rem; line-height: 1.5; }
.tagline p { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .mode { font-family: var(--font-mono); font-size: 0.74rem; line-height: 1.4; padding: 4px 8px; border-radius: var(--radius); border: 1px solid var(--rule); color: var(--ink-2); }
.chip b { font-weight: 500; color: var(--ink); margin-right: 4px; }
.mode { border-color: transparent; background: var(--blue-soft); color: var(--blue); }
.buildit { margin: 0; font-size: 1rem; line-height: 1.5; color: var(--ink-2); }
.buildit .k { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--orange); margin-right: 6px; }
.mode-lab { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange); }
.mode-data { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }

/* Spec (the metadata table) */
.spec { display: grid; gap: 14px; margin-bottom: 36px; }
.spec dl { margin: 0; display: grid; }
.spec-main { border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper-2); }
.spec-row { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 6px 20px; padding: 14px 18px; border-top: 1px solid var(--rule); }
.spec-row:first-child { border-top: 0; }
.spec dt { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); padding-top: 4px; }
.spec dd { margin: 0; font-size: 0.98rem; line-height: 1.55; min-width: 0; overflow-wrap: anywhere; }
.spec dd p { margin: 0; }
.spec dd ol { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.spec-engineering dd { font-weight: 600; }
@media (max-width: 600px) { .spec-row { grid-template-columns: minmax(0, 1fr); padding: 12px 14px; } }
.spec-more { border: 1px solid var(--rule); border-radius: var(--radius); }
.spec-more > summary { cursor: pointer; padding: 12px 18px; font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; }
.spec-more[open] > summary { border-bottom: 1px solid var(--rule); }

.callout { border: 1px solid var(--rule); border-left: 3px solid var(--blue); border-radius: var(--radius); padding: 12px 16px; background: var(--paper-2); margin: 24px 0; }
.callout p { margin: 0; }
.callout-k { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--blue); margin-bottom: 4px !important; }
.callout-safety { border-left-color: var(--orange); margin: 0; }
.callout-safety .callout-k { color: var(--orange); }

/* Prose: rendered Markdown */
.prose { overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: clamp(1.5rem, 2.6vw, 1.9rem); margin: 2.4em 0 0.6em; padding-top: 0.8em; border-top: 1px solid var(--rule); }
.prose h3 { font-size: 1.25rem; margin: 1.9em 0 0.5em; }
.prose h4 { font-size: 1.05rem; margin: 1.6em 0 0.4em; }
.prose h2, .prose h3, .prose h4 { position: relative; }
.anchor { position: absolute; left: -1.1em; width: 1em; text-decoration: none; color: var(--rule); opacity: 0; font-weight: 500; }
.prose h2 .anchor { top: 0.8em; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus { opacity: 1; }
@media (max-width: 920px) { .anchor { display: none; } }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose .table-wrap, .prose pre, .prose .math-display { margin: 0 0 1.1em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: 0.3em 0; }
.prose li > p { margin: 0 0 0.5em; }
.prose blockquote { border-left: 3px solid var(--rule); padding-left: 16px; color: var(--ink-2); margin-left: 0; }
.prose strong { font-weight: 600; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }
.prose img { display: block; margin: 1.2em auto; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; }
.prose img[src$=".svg"] { border: 0; border-radius: 0; background: none; height: auto; }
.prose figure { margin: 1.6em 0; }
.prose figure img { margin: 0 auto; }
.prose figcaption { margin-top: 0.6em; font-size: 0.92rem; line-height: 1.45; color: var(--ink-2); }
.prose figcaption em { font-style: normal; }

code { font-family: var(--font-mono); font-size: 0.86em; background: var(--code-bg); border: 1px solid var(--rule); border-radius: 3px; padding: 0.05em 0.3em; overflow-wrap: anywhere; }
a.lref, a.pref { text-decoration: none; }
a.lref code { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 35%, transparent); }
a.lref:hover code, a.pref:hover code { border-color: var(--orange); }
code.cite { color: var(--ink-2); background: none; border: 0; padding: 0; }
pre.code { position: relative; background: var(--code-bg); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; line-height: 1.5; font-size: 0.86rem; tab-size: 4; }
pre.code code { background: none; border: 0; padding: 0; font-size: inherit; overflow-wrap: normal; white-space: pre; }
pre.code[data-lang]::before { content: attr(data-lang); position: absolute; top: 6px; right: 10px; font-family: var(--font-mono); font-size: 0.68rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; }
pre.code .copy { position: absolute; top: 6px; right: 6px; font-family: var(--font-mono); font-size: 0.7rem; padding: 3px 8px; border-radius: 3px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink-2); cursor: pointer; opacity: 0; transition: opacity 120ms; }
pre.code:hover .copy, pre.code .copy:focus { opacity: 1; }
pre.code[data-lang]:hover::before { opacity: 0; }
@media (hover: none) { pre.code .copy { opacity: 1; } pre.code[data-lang]::before { display: none; } }
.hljs-keyword, .hljs-built_in, .hljs-literal, .hljs-meta .hljs-keyword { color: var(--hl-kw); }
.hljs-string, .hljs-meta .hljs-string { color: var(--hl-str); }
.hljs-number { color: var(--hl-num); }
.hljs-comment, .hljs-quote { color: var(--hl-com); font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-title.class_ { color: var(--hl-fn); }
.hljs-params { color: inherit; }
.hljs-meta { color: var(--hl-com); }

.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius); }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.92rem; line-height: 1.45; }
.prose th, .prose td { padding: 8px 12px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.prose th { font-family: var(--font-display); font-weight: 600; background: var(--paper-2); }
.prose tr:last-child td { border-bottom: 0; }
.prose td code { overflow-wrap: normal; white-space: nowrap; }

.math-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.katex { font-size: 1.06em; }
.katex-display { margin: 0; }

/* Problems, code box, pager */
.problems { margin-top: 1em; }
.problems h3 { font-size: 1.12rem; }
.codebox { margin-top: 48px; border: 1px solid var(--rule); border-radius: var(--radius); padding: 22px clamp(16px, 3vw, 26px); background: var(--paper-2); display: grid; gap: 12px; }
.codebox h2 { margin: 0; font-size: 1.4rem; }
.codebox p, .codebox pre { margin: 0; }
.codebox pre.code { background: var(--paper); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 32px; }
.pager a { display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--rule); border-radius: var(--radius); text-decoration: none; min-width: 0; }
.pager a:hover { border-color: var(--ink); }
.pager .next { text-align: right; }
.pager .k { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.pager .t { font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; line-height: 1.3; }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager .next { text-align: left; } }

/* Phase page and curriculum index */
.wide { max-width: 1180px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 48px) 72px; }
.phase-head { display: grid; gap: 16px; padding-bottom: 36px; max-width: 62rem; }
.phase-head h1 { margin: 0; font-size: clamp(2.2rem, 5vw, 3.6rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.lede { margin: 0; font-size: 1.15rem; line-height: 1.55; max-width: 68ch; }
.section-h { font-size: 1.5rem; margin: 0 0 16px; }
.cards, .phase-cards { list-style: none; margin: 0 0 48px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.card { height: 100%; display: grid; align-content: start; gap: 8px; padding: 16px 18px; border: 1px solid var(--rule); border-radius: var(--radius); text-decoration: none; background: var(--paper); transition: border-color 120ms; }
.card:hover { border-color: var(--ink); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--blue); }
.card-t { font-family: var(--font-display); font-weight: 700; font-size: 1.08rem; line-height: 1.25; }
.card-b { font-size: 0.92rem; line-height: 1.45; color: var(--ink-2); }
.card-b b { font-weight: 600; color: var(--ink); }
.phase-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.prose-wide { max-width: 820px; }

.foot { border-top: 1px solid var(--rule); }
.foot-in { max-width: 1440px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 32px); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-2); }

@media print {
  .nav, .side, .toc, .pager, .foot, .copy { display: none !important; }
  .shell { display: block; }
  .spec-more { display: block; }
}
