/* Layout concept: a lab notebook seen through the eyepiece — round "fields of view"
   hold every simulation; stain colours (methylene blue / eosin) carry the frise's colour code. */
:root {
  --bg: #eef1ee;
  --paper: #fafbf9;
  --ink: #142029;
  --muted: #56636b;
  --rule: #cdd5d1;
  --blue: #2b57b5;      /* bleu de méthylène : innovation technique */
  --pink: #b8326a;      /* éosine : découverte scientifique */
  --brass: #9a6f22;     /* laiton des instruments */
  --lens: #0e171c;      /* fond du champ de vision */
  --lens-ink: #dfe8e4;
  --blue-soft: color-mix(in srgb, var(--blue) 12%, transparent);
  --pink-soft: color-mix(in srgb, var(--pink) 12%, transparent);

  --font-display: "Young Serif", "Iowan Old Style", Georgia, serif;
  --font-body: "Lexend", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --step--1: clamp(0.8rem, 0.76rem + 0.12vw, 0.92rem);
  --step-0: clamp(1rem, 0.94rem + 0.22vw, 1.2rem);
  --step-1: clamp(1.2rem, 1.08rem + 0.5vw, 1.6rem);
  --step-2: clamp(1.5rem, 1.28rem + 1vw, 2.4rem);
  --step-3: clamp(2rem, 1.5rem + 2.4vw, 3.9rem);
  --step-4: clamp(2.6rem, 1.6rem + 4.6vw, 6.4rem);

  --gutter: clamp(16px, 4.5vw, 104px); /* the page always spans the full window */
  --section: clamp(3.5rem, 2.5rem + 5vw, 7rem);
  --radius: 14px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1216; --paper: #121c22; --ink: #e4ebe8; --muted: #93a1a8; --rule: #25333b;
    --blue: #88a9f2; --pink: #f182ad; --brass: #d7ae62; --lens: #060b0e; --lens-ink: #dfe8e4;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1216; --paper: #121c22; --ink: #e4ebe8; --muted: #93a1a8; --rule: #25333b;
  --blue: #88a9f2; --pink: #f182ad; --brass: #d7ae62; --lens: #060b0e; --lens-ink: #dfe8e4;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
html { -webkit-text-size-adjust: 100%; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.08; text-wrap: balance; margin: 0; }
p, figure { margin: 0; }
a { color: inherit; }
img { max-width: 100%; height: auto; display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 3px; border-radius: 4px; }

.wrap { margin-inline: auto; padding-inline: var(--gutter); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.eyebrow {
  font-family: var(--font-mono); font-size: var(--step--1); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; z-index: 50; background: var(--paper); padding: 8px 12px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.topbar .wrap { display: flex; align-items: center; gap: 1rem; min-height: 58px; }
.brand { white-space: nowrap; display: flex; align-items: center; gap: 0.6rem; text-decoration: none; font-family: var(--font-display); font-size: 1.05rem; }
.brand-mark { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--pink), var(--blue)); }
.topnav { margin-left: auto; display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; }
.topnav a {
  text-decoration: none; font-size: var(--step--1); padding: 0.4rem 0.7rem; border-radius: 999px;
  white-space: nowrap; color: var(--muted); transition: background var(--dur, 150ms), color 150ms;
}
.topnav a:hover { background: var(--paper); color: var(--ink); }
.topnav .short { display: none; }
@media (max-width: 760px) { .brand span { display: none; } }
@media (max-width: 560px) {
  .topnav .long { display: none; }
  .topnav .short { display: inline; }
  .topnav { gap: 0; }
  .topnav a { padding: 0.4rem 0.5rem; font-size: 0.8rem; }
}
@media (max-width: 360px) { .topbar .wrap { gap: 0.4rem; } .topnav a { padding-inline: 0.3rem; font-size: 0.74rem; } }

/* ---------- Hero ---------- */
.hero { padding-block: clamp(2.5rem, 6vw, 5.5rem) clamp(2rem, 4vw, 3.5rem); }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: clamp(2rem, 5vw, 5rem); align-items: center; }
.hero h1 { font-size: var(--step-4); letter-spacing: -0.02em; margin-block: 0.9rem 1.4rem; }
.hero h1 em { font-style: normal; color: var(--pink); }
.hero .lead { font-size: var(--step-1); line-height: 1.45; max-width: 34ch; color: var(--ink); }
.hero .disciplines { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.8rem; }
.tag {
  display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--font-mono); font-size: 0.75rem;
  letter-spacing: 0.04em; padding: 0.3rem 0.65rem; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper);
}
.eyepiece { position: relative; justify-self: center; width: min(100%, 440px); }
.eyepiece canvas { width: 100%; aspect-ratio: 1; display: block; }
.eyepiece figcaption { margin-top: 1rem; text-align: center; font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted); min-height: 1.6em; }
@media (max-width: 820px) { .hero .wrap { grid-template-columns: 1fr; } .eyepiece { width: min(100%, 340px); } }

/* ---------- Legend / colour code ---------- */
.legend { border-block: 1px solid var(--rule); background: var(--paper); }
.legend .wrap { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem 2.5rem; padding-block: 1.6rem; }
.legend-item { display: flex; gap: 0.9rem; align-items: flex-start; }
.legend-item p { font-size: var(--step--1); color: var(--muted); }
.legend-item strong { display: block; color: var(--ink); font-size: var(--step-0); }
.swatch { width: 18px; height: 18px; border-radius: 50%; flex: none; margin-top: 4px; }
.swatch.tech { background: var(--blue); }
.swatch.sci { background: var(--pink); }
.swatch.qr { background: none; border: 2px dashed var(--muted); border-radius: 4px; }
@media (max-width: 760px) { .legend .wrap { grid-template-columns: 1fr; } }

/* ---------- Section heads ---------- */
.section { padding-block: var(--section) 0; }
.section-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem 3rem; align-items: end; margin-bottom: 2rem; }
.section-head h2 { font-size: var(--step-3); }
.section-head p { color: var(--muted); max-width: 52ch; }
@media (max-width: 760px) { .section-head { grid-template-columns: 1fr; } }

/* ---------- Timeline navigator ---------- */
.timeline-scroll { overflow-x: auto; padding-bottom: 0.5rem; scrollbar-width: thin; }
.timeline { position: relative; isolation: isolate; } /* keeps label layering below the sticky menu */
.timeline .axis { position: absolute; left: 0; right: 0; height: 2px; background: var(--ink); }
.timeline .break {
  position: absolute; width: 14px; height: 26px; background: var(--bg);
  border-inline: 2px solid var(--ink); transform: skewX(-18deg);
}
.tick { position: absolute; font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); transform: translateX(-50%); }
.tick::before { content: ""; position: absolute; left: 50%; top: -8px; width: 1px; height: 6px; background: var(--muted); }
.event {
  position: absolute; width: 124px; transform: translateX(-8px); text-decoration: none;
  font-size: 0.76rem; line-height: 1.3; padding-left: 10px; border-left: 2px solid var(--c, var(--muted));
}
.event .yr { font-family: var(--font-mono); font-weight: 700; color: var(--c, var(--ink)); display: block; }
.event .who { color: var(--muted); display: block; }
.event .what { display: block; }
/* Labels sit above the connector lines of farther rows, so those lines pass behind the text. */
.event .yr, .event .what, .event .who { position: relative; z-index: 1; background: var(--bg); padding-right: 4px; }
.event .dot { z-index: 2; }
.event.tech { --c: var(--blue); }
.event.sci { --c: var(--pink); }
.event.origin { --c: var(--brass); }
.event[href] .what { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.event[href]:hover .what { color: var(--c); }
.event .dot { position: absolute; left: -7px; width: 12px; height: 12px; border-radius: 50%; background: var(--c); border: 2px solid var(--bg); }
.event.up .dot { bottom: -8px; }
.event.down .dot { top: -6px; }

/* Vertical timeline (phones, tablets) */
.timeline.vertical { padding-block: 0.25rem 0.5rem; }
.timeline.vertical .axis { left: 86px; right: auto; top: 6px; bottom: 6px; width: 2px; height: auto; }
.timeline.vertical .event {
  position: relative; width: auto; transform: none; border-left: 0; padding: 0;
  display: grid; grid-template-columns: 74px minmax(0, 1fr); column-gap: 30px; font-size: 0.9rem;
}
.timeline.vertical .event .yr { grid-row: 1 / span 2; text-align: right; font-size: 0.82rem; padding-top: 1px; }
.timeline.vertical .event .what, .timeline.vertical .event .who { grid-column: 2; }
.timeline.vertical .event .dot { left: 81px; top: 4px; }
.timeline.vertical .event.origin .yr { font-size: 0.72rem; line-height: 1.25; }
.v-break {
  margin: 0.9rem 0 1rem 104px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted);
  position: relative; background: var(--bg); padding-block: 4px;
}
.v-break::before { content: "//"; position: absolute; left: -26px; color: var(--ink); font-weight: 700; }

/* ---------- Scale explorer ---------- */
.scale { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: clamp(1.5rem, 4vw, 4rem); align-items: center; }
.lens { position: relative; width: min(100%, 420px); justify-self: center; }
.lens canvas { width: 100%; aspect-ratio: 1; display: block; }
.scale-panel { min-width: 0; display: grid; gap: 1.25rem; }
.scale-readout { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.scale-readout .obj { font-family: var(--font-display); font-size: var(--step-2); }
.scale-readout .size { font-family: var(--font-mono); font-size: var(--step-1); color: var(--brass); }
.scale-note { color: var(--muted); max-width: 52ch; min-height: 3.2em; }
.slider-row { display: grid; gap: 0.35rem; }
.slider-row label { font-size: var(--step--1); color: var(--muted); display: flex; justify-content: space-between; gap: 1rem; }
input[type="range"] { width: 100%; accent-color: var(--brass); height: 28px; }
.instruments { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.instruments li {
  display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) auto; gap: 0.6rem; align-items: center;
  padding: 0.55rem 0.8rem; border-radius: 10px; background: var(--paper); border: 1px solid var(--rule);
  transition: opacity 200ms, border-color 200ms;
}
.instruments li .lim { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }
.instruments li .state { font-weight: 700; text-align: center; }
.instruments li.yes { border-color: color-mix(in srgb, var(--blue) 55%, var(--rule)); }
.instruments li.yes .state { color: var(--blue); }
.instruments li.no { opacity: 0.55; }
@media (max-width: 820px) { .scale { grid-template-columns: 1fr; } }

/* ---------- Chapters ---------- */
.chapter { padding-block: var(--section) 0; }
.chapter-head {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.5rem 2rem; align-items: end;
  padding-bottom: 1.5rem; border-bottom: 1px solid var(--rule); margin-bottom: 2rem;
}
.chapter-num { font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted); grid-column: 1 / -1; display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.chapter-year { font-family: var(--font-display); font-size: var(--step-4); line-height: 0.9; color: var(--c); letter-spacing: -0.03em; }
.chapter.tech { --c: var(--blue); --c-soft: var(--blue-soft); }
.chapter.sci { --c: var(--pink); --c-soft: var(--pink-soft); }
.chapter-title h2 { font-size: var(--step-3); }
.chapter-title .who { color: var(--muted); margin-top: 0.5rem; }
.kind { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--c); }
.kind::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
@media (max-width: 700px) { .chapter-head { grid-template-columns: 1fr; } }

.chapter-body { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: clamp(1.5rem, 4vw, 4rem); }
.prose { display: grid; gap: 1.6rem; align-content: start; }
.prose h3 { font-size: var(--step-1); margin-bottom: 0.5rem; display: flex; gap: 0.6rem; align-items: baseline; }
.prose h3 .mono { font-size: 0.75rem; color: var(--c); letter-spacing: 0.06em; text-transform: uppercase; }
.prose p + p { margin-top: 0.75rem; }
.prose p, .prose li { max-width: 62ch; }
.prose ul { margin: 0.5rem 0 0; padding-left: 1.1rem; }
.prose li + li { margin-top: 0.3rem; }
.keyfact {
  border-left: 3px solid var(--c); background: var(--c-soft); padding: 0.9rem 1.1rem; border-radius: 0 10px 10px 0;
  font-family: var(--font-display); font-size: var(--step-1); line-height: 1.3;
}
.keyfact small { display: block; font-family: var(--font-body); font-size: var(--step--1); color: var(--muted); margin-top: 0.35rem; }
.experiment { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.2rem 1.3rem; }
.experiment ol { margin: 0.6rem 0 0; padding-left: 1.2rem; }
.experiment li + li { margin-top: 0.35rem; }

.figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-content: start; }
.figures figure { margin: 0; }
.figures figure.wide { grid-column: 1 / -1; }
.figures figure.single { max-width: 340px; }
.figures img { width: 100%; object-fit: cover; border-radius: 10px; background: var(--paper); border: 1px solid var(--rule); }
.figures .portrait img { aspect-ratio: 4 / 5; object-position: top; }
.figures .doc img { aspect-ratio: auto; object-fit: contain; background: #f4f1ea; }
figcaption { font-size: var(--step--1); color: var(--muted); margin-top: 0.45rem; line-height: 1.4; }
figcaption b { color: var(--ink); font-weight: 700; }
@media (max-width: 860px) { .chapter-body { grid-template-columns: 1fr; } }

/* ---------- Lab bench (simulation block) ---------- */
.bench {
  margin-top: 2.5rem; display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: clamp(1.25rem, 3vw, 3rem);
  align-items: center; padding: clamp(1.2rem, 3vw, 2.2rem); border-radius: calc(var(--radius) + 6px);
  background: var(--paper); border: 1px solid var(--rule); position: relative; overflow: hidden;
}
.bench::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c);
}
.bench.reverse { grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr); }
.bench.reverse .bench-view { order: 2; }
.bench-view { min-width: 0; justify-self: center; width: 100%; max-width: 420px; }
.bench-view.wide { max-width: 640px; }
.bench-view canvas { width: 100%; display: block; border-radius: 12px; }
.bench-view canvas.round { aspect-ratio: 1; border-radius: 50%; }
.bench-text { min-width: 0; display: grid; gap: 0.9rem; align-content: center; }
.bench-text h3 { font-size: var(--step-2); }
.bench-text .eyebrow { color: var(--c); }
.bench-text p { color: var(--muted); max-width: 54ch; }
.controls { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.readout { font-family: var(--font-mono); font-size: 0.85rem; color: var(--ink); background: var(--bg); border-radius: 8px; padding: 0.5rem 0.75rem; }
.readout b { color: var(--c); }
.btn {
  font: inherit; font-size: var(--step--1); font-weight: 700; cursor: pointer; border-radius: 999px;
  padding: 0.55rem 1.1rem; border: 1.5px solid var(--ink); background: var(--ink); color: var(--bg);
  transition: transform 150ms var(--ease), background 150ms, color 150ms;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--bg); }
.btn[aria-pressed="true"] { background: var(--c, var(--brass)); border-color: var(--c, var(--brass)); color: var(--paper); }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 999px; padding: 2px; }
.seg .btn { border: 0; background: transparent; color: var(--ink); padding: 0.45rem 0.9rem; }
.seg .btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; counter-reset: s; }
.steps li { counter-increment: s; font-size: var(--step--1); color: var(--muted); padding: 0.35rem 0.6rem; border-radius: 8px; transition: background 200ms, color 200ms; }
.steps li::before { content: counter(s) " · "; font-family: var(--font-mono); }
.steps li.on { background: var(--c-soft); color: var(--ink); font-weight: 700; }
@media (max-width: 820px) {
  .bench, .bench.reverse { grid-template-columns: 1fr; }
  .bench.reverse .bench-view { order: 0; }
}

/* Wide simulations take the full width; their text and controls sit underneath. */
.bench.wide { grid-template-columns: minmax(0, 1fr); }
.bench.wide .bench-view { max-width: min(960px, calc((100svh - 250px) * 1.7)); }
.bench.wide .bench-text {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); column-gap: clamp(1.5rem, 4vw, 3.5rem);
  grid-template-areas: "eyebrow eyebrow" "title title" "text controls" "text readout"; align-items: start;
}
.bench.wide .bench-text > .eyebrow { grid-area: eyebrow; }
.bench.wide .bench-text > h3 { grid-area: title; }
.bench.wide .bench-text > p:not(.eyebrow):not(.readout) { grid-area: text; }
.bench.wide .bench-text > .controls { grid-area: controls; }
.bench.wide .bench-text > .readout { grid-area: readout; }
@media (max-width: 820px) {
  .bench.wide .bench-text { grid-template-columns: minmax(0, 1fr); grid-template-areas: "eyebrow" "title" "text" "controls" "readout"; }
}
@media (max-width: 600px) {
  .bench { padding: 1.1rem 0.8rem 1.3rem; border-radius: var(--radius); }
  .bench-view canvas { border-radius: 8px; }
}

/* ---------- Diagrams ---------- */
.diagram { margin-top: 2.5rem; }
.diagram-scroll { overflow-x: auto; }
.diagram svg { width: 100%; min-width: 560px; height: auto; display: block; }
.diagram svg text { font-family: var(--font-body); fill: var(--ink); font-size: 13px; }
.diagram svg .sub { fill: var(--muted); font-size: 11.5px; }
.diagram svg .lbl-title { font-family: var(--font-display); font-size: 18px; }
.diagram figcaption { max-width: 70ch; }
.diagram svg.dg-v { display: none; }
.diagram-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 2rem; }
.diagram-pair svg { min-width: 0; }
@media (max-width: 700px) { .diagram-pair { grid-template-columns: minmax(0, 1fr); } .diagram-pair svg { max-width: 460px; } }
@media (max-width: 600px) {
  .diagram svg.dg-h { display: none; }
  .diagram svg.dg-v { display: block; min-width: 0; max-width: 400px; margin-inline: auto; }
  .diagram svg.dg-v text { font-size: 15.5px; }
  .diagram svg.dg-v .sub { font-size: 13.5px; }
}

/* ---------- Videos ---------- */
.videos { margin-top: 2.5rem; }
.videos h3 { font-size: var(--step-1); margin-bottom: 1rem; }
.video-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 1rem; }
.video {
  display: grid; grid-template-rows: auto 1fr; text-decoration: none; border-radius: 12px; overflow: hidden;
  background: var(--paper); border: 1px solid var(--rule); transition: transform 200ms var(--ease), border-color 200ms;
}
.video:hover { transform: translateY(-3px); border-color: var(--c, var(--ink)); }
.video .thumb { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--lens); }
.video .thumb img { width: 100%; height: 100%; object-fit: cover; }
.video .thumb::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: rgb(0 0 0 / 0.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 7l9 5-9 5z' fill='white'/%3E%3C/svg%3E") center / 26px no-repeat;
  transition: transform 200ms var(--ease);
}
.video:hover .thumb::after { transform: scale(1.1); }
.video .meta { padding: 0.75rem 0.9rem 0.9rem; display: grid; gap: 0.2rem; align-content: start; }
.video .meta strong { font-size: 0.92rem; line-height: 1.3; }
.video .meta span { font-size: 0.78rem; color: var(--muted); }
.lang { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.05em; color: var(--c, var(--muted)); }

/* ---------- Sources ---------- */
details.sources { margin-top: 2rem; border-top: 1px solid var(--rule); padding-top: 1rem; }
details.sources summary { cursor: pointer; font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted); letter-spacing: 0.04em; }
details.sources summary:hover { color: var(--ink); }
details.sources ul { margin: 0.8rem 0 0; padding-left: 1.1rem; font-size: var(--step--1); color: var(--muted); display: grid; gap: 0.35rem; }
details.sources a { overflow-wrap: anywhere; }

/* ---------- Quiz ---------- */
.quiz { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 1.25rem; }
.q { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.2rem 1.3rem; display: grid; gap: 0.8rem; align-content: start; }
.q legend { font-weight: 700; padding: 0; margin-bottom: 0.2rem; }
.q .qn { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); display: block; font-weight: 400; margin-bottom: 0.2rem; }
.q fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 0.45rem; min-width: 0; }
.choice {
  text-align: left; font: inherit; font-size: 0.95rem; cursor: pointer; padding: 0.6rem 0.85rem; border-radius: 10px;
  border: 1.5px solid var(--rule); background: var(--bg); color: var(--ink); transition: border-color 150ms, background 150ms;
}
.choice:hover:not(:disabled) { border-color: var(--ink); }
.choice:disabled { cursor: default; }
.choice.right { border-color: var(--blue); background: var(--blue-soft); font-weight: 700; }
.choice.wrong { border-color: var(--pink); background: var(--pink-soft); text-decoration: line-through; }
.q .why { font-size: var(--step--1); color: var(--muted); }
.score { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; padding: 1.1rem 1.3rem; border-radius: var(--radius); background: var(--ink); color: var(--bg); }
.score .mono { font-size: var(--step-2); }
.score .btn { background: var(--bg); color: var(--ink); border-color: var(--bg); }
@media (max-width: 760px) { .quiz { grid-template-columns: 1fr; } }

/* ---------- Footer ---------- */
.credits { margin-top: var(--section); border-top: 1px solid var(--rule); background: var(--paper); padding-block: 3rem 4rem; }
.credits .wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem 4rem; }
.credits h2 { font-size: var(--step-2); margin-bottom: 1rem; }
.credits ul { margin: 0; padding-left: 1.1rem; font-size: var(--step--1); color: var(--muted); display: grid; gap: 0.3rem; }
.credits .made { grid-column: 1 / -1; border-top: 1px solid var(--rule); padding-top: 1.5rem; font-size: var(--step--1); color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; justify-content: space-between; }
@media (max-width: 760px) { .credits .wrap { grid-template-columns: 1fr; } }

/* ---------- Large screens: fill the width with more columns, not longer lines ---------- */
@media (min-width: 1200px) {
  /* videos and sources side by side at the end of each chapter */
  .chapter-foot { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 2.5rem; align-items: start; margin-top: 2.5rem; }
  .chapter-foot:has(> :only-child) { grid-template-columns: minmax(0, 1fr); }
  .chapter-foot .videos, .chapter-foot details.sources { margin-top: 0; }
  .chapter-foot details.sources { border-top: 0; border-left: 1px solid var(--rule); padding: 0 0 0 2rem; }
  .chapter-foot .video-row { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .chapter-foot .video { max-width: 520px; }
  /* wide simulations: big canvas on the left, explanation and controls on the right */
  .bench.wide { grid-template-columns: minmax(0, 2.3fr) minmax(0, 1fr); align-items: center; }
  .bench.wide .bench-view { max-width: none; }
  .bench.wide .bench-text { grid-template-columns: minmax(0, 1fr); grid-template-areas: "eyebrow" "title" "text" "controls" "readout"; }
  /* diagrams sit beside their caption */
  .diagram { display: grid; grid-template-columns: minmax(0, 2.6fr) minmax(0, 1fr); gap: 2.5rem; align-items: center; }
  .diagram figcaption { margin-top: 0; font-size: var(--step-0); }
}
@media (min-width: 1400px) {
  .eyepiece { width: min(100%, 560px); }
  .lens { width: min(100%, 540px); }
  .bench-view { max-width: 520px; }
  .bench-text p { max-width: 64ch; }
  /* chapter text flows in two columns next to the pictures */
  .chapter-body { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
  .chapter-body:has(.figures > figure:only-child) { grid-template-columns: minmax(0, 2.4fr) minmax(0, 0.8fr); }
  .prose { display: block; columns: 2; column-gap: clamp(2rem, 3vw, 3.5rem); }
  .prose > * { break-inside: avoid; margin-bottom: 1.6rem; }
  .figures figure.single { max-width: none; }
  .legend .wrap { gap: 1.5rem 4rem; }
}
@media (min-width: 1800px) {
  .eyepiece { width: min(100%, 680px); }
  .hero .lead { max-width: 40ch; }
  .lens { width: min(100%, 620px); }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
  .chapter-body { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
}

/* ---------- Reveal ---------- */
@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: rise 700ms var(--ease) both; }
  .reveal.d1 { animation-delay: 80ms; } .reveal.d2 { animation-delay: 160ms; } .reveal.d3 { animation-delay: 240ms; }
  @keyframes rise { from { transform: translateY(14px); } to { transform: none; } }
}
