:root {
  color-scheme: light;
  --bg: #f2f3f1;
  --bg-2: #ffffff;
  --bg-3: #e7e9e5;
  --ink: #15191e;
  --ink-2: #4a525c;
  --ink-3: #747d87;
  --rule: #d8dbd6;
  --amber: #b86d00;
  --amber-wash: rgba(184, 109, 0, 0.12);
  --blue: #2f6db5;
  --blue-wash: rgba(47, 109, 181, 0.12);
  --magenta: #a03a8c;
  --red: #b3261e;
  --focus: #1f4e8c;
  --sans: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --measure: 66ch;
  --rail: 220px;
  --content: 1120px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
@media (max-width: 720px) { body { font-size: 17px; } }

a { color: inherit; text-decoration-color: var(--ink-3); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

/* ---------- page frame ---------- */
.page {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  max-width: calc(var(--content) + var(--rail) + 64px);
  margin: 0 auto;
  padding: 0 32px;
  gap: 48px;
}
@media (max-width: 1100px) {
  .page { grid-template-columns: minmax(0, 1fr); padding: 0 20px; gap: 0; }
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 40px 0;
  font-size: 15px;
  line-height: 1.4;
  overflow: auto;
}
.rail .brand { font-weight: 700; letter-spacing: -0.01em; margin-bottom: 28px; display: block; text-decoration: none; }
.rail ol { list-style: none; margin: 0; padding: 0; counter-reset: ch; }
.rail li { margin: 0 0 10px; }
.rail li a { display: block; color: var(--ink-2); text-decoration: none; padding: 2px 0 2px 14px; border-left: 2px solid transparent; }
.rail li a:hover { color: var(--ink); }
.rail li a[aria-current="true"] { color: var(--ink); border-left-color: var(--ink); }
.rail .meta { margin-top: 32px; color: var(--ink-3); font-size: 13px; }
@media (max-width: 1100px) { .rail { display: none; } }

main { min-width: 0; padding-bottom: 120px; }

/* ---------- type ---------- */
h1, h2, h3, h4 { font-weight: 400; letter-spacing: -0.015em; line-height: 1.12; margin: 0; }
h1 { font-size: clamp(2.6rem, 6.2vw, 4.6rem); font-weight: 300; letter-spacing: -0.03em; max-width: 16ch; }
h2 { font-size: clamp(1.8rem, 3.4vw, 2.5rem); margin: 0 0 20px; max-width: 24ch; }
h3 { font-size: 1.3rem; font-weight: 600; margin: 40px 0 10px; }
h4 { font-size: 1.05rem; font-weight: 700; margin: 24px 0 6px; }
p, ul, ol, table { margin: 0 0 1.1em; }
p, li { max-width: var(--measure); }
.lede { font-size: 1.25rem; line-height: 1.45; color: var(--ink-2); max-width: 52ch; }
.small { font-size: 15px; color: var(--ink-2); }
.muted { color: var(--ink-3); }
strong { font-weight: 700; }
ul, ol { padding-left: 1.2em; }
li { margin-bottom: 0.35em; }
code, .num { font-family: var(--mono); font-size: 0.92em; }
.num { font-variant-numeric: tabular-nums; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 0; }

section { padding: 96px 0 24px; scroll-margin-top: 24px; }
section + section { border-top: 1px solid var(--rule); }
@media (max-width: 720px) { section { padding: 64px 0 16px; } }
.chapter { color: var(--ink-3); font-size: 15px; margin-bottom: 14px; }

/* ---------- hero ---------- */
.hero { padding-top: 56px; }
.hero h1 { margin-bottom: 20px; }
.hero .lede { margin-bottom: 36px; }

/* ---------- the stage (one pass, every step) ---------- */
.stage { background: var(--ink); border-radius: 6px; overflow: hidden; color: #e9ebee; }
.stage-view { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0e1114; }
.stage-view video, .stage-view img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 120ms linear; }
.stage-view video.active, .stage-view img.active { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .stage-view video, .stage-view img { transition: none; } }
.stage-view .badge { position: absolute; left: 14px; top: 12px; font-size: 13px; background: rgba(0,0,0,.55); padding: 4px 9px; border-radius: 3px; }
.stage-steps { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; padding: 2px; background: #0e1114; }
.stage-steps button {
  appearance: none; border: 0; cursor: pointer; font: inherit; color: #c7ccd2;
  background: #1c2127; padding: 12px 8px 10px; text-align: left; font-size: 14px; line-height: 1.25;
  display: flex; flex-direction: column; gap: 4px; min-height: 64px;
}
.stage-steps button .n { font-family: var(--mono); font-size: 12px; color: #8a929b; }
.stage-steps button:hover { background: #252b32; color: #fff; }
.stage-steps button[aria-pressed="true"] { background: #f2f3f1; color: var(--ink); }
.stage-steps button[aria-pressed="true"] .n { color: var(--ink-2); }
.stage-steps button:focus-visible { outline-offset: -3px; }
@media (max-width: 820px) {
  .stage-steps { grid-template-columns: repeat(4, 1fr); }
  .stage-steps button { min-height: 56px; font-size: 13px; }
}
.stage-caption { padding: 18px 20px 20px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: start; background: var(--bg-2); color: var(--ink); border-top: 1px solid var(--rule); }
.stage-caption p { margin: 0; max-width: 60ch; }
.readout { display: flex; gap: 28px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.readout div { display: flex; flex-direction: column; gap: 2px; }
.readout .k { font-size: 13px; color: var(--ink-2); }
.readout .v { font-size: 1.6rem; line-height: 1.1; font-weight: 600; display: flex; align-items: baseline; gap: 6px; }
.readout .v small { font-size: 0.9rem; font-weight: 400; color: var(--ink-2); }
.readout .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.swatch.blue { background: var(--blue); }
.swatch.amber { background: var(--amber); }
.swatch.magenta { background: var(--magenta); }
.swatch.white { background: #fff; border: 1px solid var(--rule); }
@media (max-width: 820px) { .stage-caption { grid-template-columns: 1fr; } .readout { gap: 18px; flex-wrap: wrap; } }

.clip-picker { display: flex; gap: 8px; overflow-x: auto; padding: 14px 2px 6px; scrollbar-width: thin; }
.clip-picker button { appearance: none; border: 2px solid transparent; padding: 0; background: none; cursor: pointer; border-radius: 4px; flex: 0 0 auto; width: 132px; text-align: left; font: inherit; color: var(--ink-2); font-size: 13px; }
.clip-picker button img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 3px; background: var(--bg-3); }
.clip-picker button span { display: block; padding: 5px 4px 4px; line-height: 1.25; }
.clip-picker button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); }
.clip-picker button:hover img { filter: brightness(1.05); }

/* ---------- media ---------- */
figure { margin: 28px 0 36px; }
figure.wide { margin-left: 0; }
figure img, figure video { display: block; width: 100%; height: auto; border-radius: 4px; background: var(--bg-3); }
figcaption { font-size: 15px; color: var(--ink-2); margin-top: 10px; max-width: 70ch; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px 24px; margin: 28px 0 36px; }
.media-grid figure { margin: 0; }
.step-media { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 32px; align-items: start; margin: 20px 0 48px; }
.step-media figure { margin: 0; }
.step-media .text p:last-child { margin-bottom: 0; }
@media (max-width: 900px) { .step-media { grid-template-columns: 1fr; gap: 16px; } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--ink-2); margin: 10px 0 0; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 7px; margin: 0; }

/* ---------- key numbers ---------- */
.hero-figure { display: flex; align-items: baseline; gap: 14px; margin: 24px 0 8px; }
.hero-figure .big { font-size: clamp(3.2rem, 8vw, 5.6rem); font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
.hero-figure .unit { font-size: 1.4rem; color: var(--ink-2); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 18px 28px; margin: 28px 0 36px; max-width: 900px; }
.stats div { border-top: 2px solid var(--ink); padding-top: 10px; }
.stats .v { font-size: 1.7rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.stats .k { font-size: 14px; color: var(--ink-2); margin-top: 2px; }

/* ---------- charts ---------- */
.chart { margin: 28px 0 10px; }
.chart svg { display: block; width: 100%; height: auto; font-family: var(--sans); font-size: 13px; }
.chart .axis text { fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.chart .grid line { stroke: var(--rule); stroke-width: 1; }
.chart .axis line, .chart .axis path { stroke: var(--rule); }
.chart .label { fill: var(--ink-2); }
.chart .label.strong { fill: var(--ink); font-weight: 600; }
.chart-title { font-weight: 600; margin: 0 0 2px; }
.chart-sub { font-size: 15px; color: var(--ink-2); margin: 0 0 8px; }
.tooltip { position: fixed; pointer-events: none; background: var(--ink); color: #fff; font-size: 13px; padding: 6px 9px; border-radius: 3px; transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap; opacity: 0; transition: opacity 80ms; z-index: 10; font-variant-numeric: tabular-nums; }
.tooltip.show { opacity: 1; }
details.table { margin: 6px 0 28px; font-size: 15px; }
details.table summary { cursor: pointer; color: var(--ink-2); }
details.table table { margin-top: 10px; }

table { border-collapse: collapse; width: 100%; max-width: 900px; font-size: 15.5px; }
th, td { text-align: left; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 700; color: var(--ink); }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; padding-right: 18px; }
tbody tr:last-child td { border-bottom-color: var(--ink); }

/* ---------- callouts / asides ---------- */
.note { border-left: 3px solid var(--amber); padding: 4px 0 4px 18px; margin: 24px 0 32px; max-width: calc(var(--measure) + 21px); }
.note.blue { border-left-color: var(--blue); }
.note p:last-child { margin-bottom: 0; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px 40px; max-width: 980px; }
.two-col > div p { max-width: 48ch; }

/* ---------- diagrams ---------- */
.diagram svg { display: block; width: 100%; height: auto; font-family: var(--sans); }
.diagram { margin: 28px 0 36px; }
.diagram text { fill: var(--ink); font-size: 14px; }
.diagram .dim { fill: var(--ink-2); font-size: 13px; }
.diagram .box { fill: var(--bg-2); stroke: var(--ink); stroke-width: 1.25; }
.diagram .box.soft { stroke: var(--ink-3); }
.diagram .arrow { stroke: var(--ink); stroke-width: 1.5; fill: none; marker-end: url(#ah); }
.diagram .road { fill: #3b4046; }
.diagram .paint { stroke: #e9ebee; stroke-width: 3; }

/* ---------- glossary / faq ---------- */
dl { max-width: var(--measure); }
dt { font-weight: 700; margin-top: 16px; }
dd { margin: 2px 0 0; color: var(--ink-2); }
details.faq { border-top: 1px solid var(--rule); padding: 14px 0; max-width: var(--measure); }
details.faq:last-of-type { border-bottom: 1px solid var(--rule); }
details.faq summary { cursor: pointer; font-weight: 600; }
details.faq p { margin: 10px 0 0; }

/* ---------- downloads ---------- */
.dl a { font-family: var(--mono); font-size: 14px; }

footer { padding: 40px 0 0; color: var(--ink-2); font-size: 15px; border-top: 1px solid var(--rule); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
