/* Alt Earth — Geology from First Principles
   Brand fonts (Graphik / Flecha M) are used if self-hosted on the domain;
   Inter / Newsreader from Google Fonts are the fallbacks.
   See AUTHORING.md for the component reference. */

:root {
  /* neutrals + accent follow the Alt Carbon brand tokens (altcarbon.com/climatestudio):
     cream #f2efde, grid #dcd8c7, ink #111, iris #3919a2 */
  --bg: #f2efde;
  --surface: #ffffff;
  --ink: #111111;
  --ink-soft: #3b3a34;
  --muted: #6b6a62;
  --line: #dcd8c7;
  --accent: #3919a2;
  --accent-soft: #e5dbf0;
  --ok: #2f6b3a;
  --ok-soft: #e1eee2;
  --bad: #9c2b1f;
  --bad-soft: #f6e0dc;
  --header: #111111;
  --header-ink: #f2efde;
  --plot: #2d6a8f;

  /* lithology palette — same in both themes so diagrams stay "true" */
  --sand: #e4c88f;
  --shale: #9b9384;
  --lime: #cfd0bf;
  --silt: #c7a77a;
  --basalt: #3f3c3b;
  --granite: #e2b0a3;
  --magma: #c9482a;
  --mantle: #d98a4a;
  --outer-core: #e8b04a;
  --inner-core: #f4dc86;
  --crust: #6e4b33;
  --water: #9cc3d8;
  --soil: #5a3d2b;
  --ore: #b8892b;
  --sulphide: #8a8f3a;
  --fluid: #4f8fb8;
  --outline: rgba(17,17,17,.35);   /* edge for dark lithology bodies (basalt etc.) so they never melt into the page */

  --font-sans: "Graphik", "Inter", system-ui, -apple-system, sans-serif;
  --font-serif: "Flecha M", "Newsreader", Georgia, serif;
  --radius: 10px;
  --max: 1440px;
  --gutter: clamp(16px, 4vw, 48px);
  --read: 680px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111111; --surface: #1c1b18; --ink: #f2efde; --ink-soft: #d6d2c2; --muted: #9d9a8e;
    --line: #34322c; --accent: #a898f2; --accent-soft: #2a2140; --ok: #8cc896; --ok-soft: #1f3322;
    --bad: #ec8b7c; --bad-soft: #3d1f1a; --header: #0a0a0a; --plot: #7fb8db;
    --outline: rgba(242,239,222,.45);
  }
}
:root[data-theme="dark"] {
  --outline: rgba(242,239,222,.45);
  --bg: #111111; --surface: #1c1b18; --ink: #f2efde; --ink-soft: #d6d2c2; --muted: #9d9a8e;
  --line: #34322c; --accent: #a898f2; --accent-soft: #2a2140; --ok: #8cc896; --ok-soft: #1f3322;
  --bad: #ec8b7c; --bad-soft: #3d1f1a; --header: #0a0a0a; --plot: #7fb8db;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-sans); font-size: 17px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
.prose a, .card a, .note a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-serif); font-weight: 400; line-height: 1.15; margin: 0; }
p { margin: 0 0 1em; }
sub, sup { font-size: .7em; }
ul.prose, ol.prose { padding-left: 1.2em; }
ul.prose li, ol.prose li { margin-bottom: .4em; }

/* ---------- header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--header); color: var(--header-ink); min-height: 58px; }
.site-header .inner { margin: 0 auto; padding: 14px var(--gutter); display: flex; align-items: center; gap: 20px; }
.site-header img { height: 30px; width: auto; filter: invert(1); }   /* dark logo → light on the dark bar */
.site-header .course-name {
  font-size: 13px; letter-spacing: .12em; text-transform: uppercase; opacity: .75; text-decoration: none;
  border-left: 1px solid rgba(255,255,255,.25); padding-left: 20px;
}

/* ---------- hero (home) ---------- */
/* header + home page run full width; module pages sit in --max.
   The hero fills the first screen (minus header and strata band) with an animated cross-section behind the text. */
.hero { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-start;
  min-height: max(560px, calc(100svh - 58px - 56px)); padding: 44px var(--gutter) 120px;
  /* the brand's ruled survey grid behind the block */
  background-image: linear-gradient(to right, color-mix(in srgb, var(--line) 55%, transparent) 1px, transparent 1px),
                    linear-gradient(to bottom, color-mix(in srgb, var(--line) 55%, transparent) 1px, transparent 1px);
  background-size: 72px 72px; background-position: center top; }
.hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-cap { position: absolute; top: 24px; right: var(--gutter); width: min(340px, 34vw); text-align: right; pointer-events: none; }
.hero-cap.empty .hero-phase::before { display: none; }
.hero-sub { margin: 6px 0 0; font-size: 13.5px; line-height: 1.45; color: var(--ink-soft); text-shadow: 0 0 8px var(--bg), 0 0 3px var(--bg); min-height: 3em; }
.hero-phase { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.hero-phase::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: 1px; }
/* phones: the caption, chapters and breadcrumbs sit under the block, in space reserved for them (--cap-h) */
@media (max-width: 799px) {
  .hero.stage { --cap-h: 300px; }
  .hero:not(.stage) .hero-cap { display: none; }
  .hero.stage .hero-cap { top: auto; bottom: 18px; left: var(--gutter); right: var(--gutter); width: auto; height: calc(var(--cap-h) - 24px); text-align: left; }
  .hero .hero-crumbs, .hero .hero-chapters { justify-content: flex-start; }
  .hero-sub { font-size: 13px; min-height: 0; }
  .hero-hint { display: none; }
  .hero-replay { margin-top: 8px; padding: 6px 13px; font-size: 12.5px; }
}
.hero-inner { position: relative; will-change: transform; pointer-events: none; }   /* let drags reach the 3D block… */
.hero-inner > * { pointer-events: auto; width: fit-content; }                        /* …but keep the text and buttons usable */
.hero-canvas { touch-action: pan-y; }
.hero-hint { margin-top: 6px; font-size: 12px; color: var(--muted); opacity: .8; transition: opacity .6s; pointer-events: none; }
.hero-dragged .hero-hint { opacity: 0; }
.hero-scale { margin-top: 4px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hero-replay { pointer-events: auto; margin-top: 12px; font: inherit; font-size: 13px; cursor: pointer; border-radius: 999px; padding: 7px 16px;
  border: 1px solid var(--ink); background: var(--bg); color: var(--ink); }
.hero-replay:hover { background: var(--ink); color: var(--bg); }
.hero-replay[hidden] { display: none; }
/* home hero: a link from the stylised loop to the Himalaya page */
.hero-link { pointer-events: auto; display: inline-block; margin-top: 10px; font-size: 13.5px; font-weight: 500; color: var(--accent); text-decoration: none; text-shadow: 0 0 8px var(--bg); }
.hero-link:hover { text-decoration: underline; text-underline-offset: 3px; }
/* home hero: a live seismometer trace under the caption */
.hero-seis { display: block; width: 100%; height: 46px; margin: 10px 0 0; }
.hero-seis-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hero-cap .hero-phase { transition: color .3s; }
/* the Himalaya page */
.stage-kicker { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
.stage-notes { max-width: var(--read); margin: 64px auto 88px; padding: 0 var(--gutter); }
.stage-notes h3:first-child { margin-top: 0; }
/* block 2's chapters: small pill buttons under the caption */
.hero-chapters { pointer-events: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 12px; }
.hero-chapters[hidden] { display: none; }
.hero-chapters button { font: inherit; font-size: 12.5px; cursor: pointer; border-radius: 999px; padding: 6px 13px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-soft); transition: background .2s, color .2s, border-color .2s; }
.hero-chapters button:hover { border-color: var(--ink); color: var(--ink); }
.hero-chapters button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
/* where you are on the scale ladder: Collision › The Himalaya › close-up */
.hero-crumbs { pointer-events: auto; display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 4px 6px; margin-bottom: 10px; font-size: 12.5px; color: var(--muted); }
.hero-crumbs[hidden] { display: none; }
.hero-crumbs button { font: inherit; color: var(--ink-soft); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.hero-crumbs button:hover { color: var(--ink); text-decoration-color: currentColor; }
.hero-crumbs [aria-current] { color: var(--ink); font-weight: 500; }
.hero-crumbs .sep { color: var(--muted); }
/* scale bar, pinned under the front edge of the 3D block */
.hero-scalebar { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; will-change: transform, opacity; }
.hero-scalebar i { display: block; height: 6px; border: 1.5px solid var(--ink-soft); border-top: 0; }
.hero-scalebar span { display: block; margin-top: 3px; font-size: 11px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
/* labels pinned to points in the 3D block: a dot at the point, text beside it */
.hero-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.hero-label { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 6px; white-space: nowrap; will-change: transform, opacity; }
.hero-label i { width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px var(--bg); flex: none; }
.hero-label span { font-size: 12px; line-height: 1; padding: 4px 8px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 88%, transparent); color: var(--ink); transform: translateY(-1px); }
.hero-label.fault span { font-size: 11px; color: var(--ink-soft); }
.hero-label.deposit i { background: var(--accent); }
.hero-label.deposit span { font-weight: 500; color: var(--accent); }
@media (max-width: 799px) { .hero-label span { font-size: 10.5px; padding: 3px 6px; } .hero-label.fault { display: none; } }
.hero .btn:not(.primary) { background: var(--bg); }
.hero-meta, .hero .lede { text-shadow: 0 0 12px var(--bg), 0 0 4px var(--bg); }
.hero h1 { font-size: clamp(44px, 6vw, 112px); letter-spacing: -.02em; max-width: 14ch; }
.hero h1 .hw, .hero h1 .hc { display: inline-block; }   /* words and loose letters the earthquake moves (hero.js) */
.hero .lede { font-size: clamp(18px, 2.2vw, 22px); color: var(--ink-soft); max-width: 44ch; margin-top: 28px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 20px 28px; max-width: 720px; margin-top: 40px; font-size: 14px; color: var(--muted); }
.hero-meta b { display: block; color: var(--ink); font-weight: 500; font-size: 15px; }
.hero-actions { margin-top: 36px; display: flex; gap: 12px; flex-wrap: wrap; }
.btn { display: inline-block; font: inherit; font-size: 15px; text-decoration: none; cursor: pointer; border-radius: 999px; padding: 11px 22px; border: 1px solid var(--ink); background: transparent; color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--bg); }

.strata-band { height: 56px; display: flex; flex-direction: column; }
.strata-band span { flex: 1; }

/* ---------- home: parts ---------- */
.parts { margin: 0 auto; padding: 24px var(--gutter) 40px; }
.part { padding: 48px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 40px; }
.part:first-child { border-top: 0; }
.part-head .part-num { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.part-head h2 { font-size: 34px; margin-top: 6px; }
.part-head p { color: var(--ink-soft); font-size: 15px; margin-top: 12px; }
.mod-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (min-width: 1800px) { .mod-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 2400px) { .mod-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.mod-card {
  display: block; text-decoration: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; transition: border-color .15s, transform .15s;
}
.mod-card:hover { border-color: var(--ink); transform: translateY(-1px); }
.mod-card .meta { display: flex; justify-content: space-between; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.mod-card h3 { font-size: 22px; margin: 8px 0 6px; }
.mod-card p { font-size: 14px; color: var(--ink-soft); margin: 0; }

/* ---------- module layout ---------- */
.layout { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 56px; }
.toc { position: sticky; top: 74px; align-self: start; padding: 40px 0; font-size: 14px; max-height: calc(100vh - 74px); overflow-y: auto; }
.toc-toggle { display: none; }
.toc .toc-part { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 18px 0 4px; }
.toc .toc-part:first-child { margin-top: 0; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li a {
  display: flex; gap: 10px; padding: 5px 0 5px 12px; margin-left: -14px; text-decoration: none; color: var(--muted);
  border-left: 2px solid transparent; line-height: 1.35;
}
.toc li a .n { font-variant-numeric: tabular-nums; width: 1.6em; flex: none; }
.toc li a:hover { color: var(--ink); }
.toc li a.active { color: var(--ink); border-left-color: var(--accent); }
.toc .toc-extra { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }

main { min-width: 0; }
.module { padding: 56px 0 24px; }
.module-head { margin-bottom: 32px; }
.module-num { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); min-height: 1.2em; }
.module h2 { font-size: clamp(36px, 5.5vw, 60px); letter-spacing: -.01em; margin-top: 8px; }
.module .summary { font-size: 21px; color: var(--ink-soft); max-width: var(--read); margin-top: 16px; font-family: var(--font-serif); line-height: 1.45; }
.module h3 { font-size: 28px; margin: 48px 0 14px; }
.prose { max-width: var(--read); }

.objectives { max-width: var(--read); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; margin: 0 0 32px; font-size: 15px; }
.objectives .label, .note .label, .why .label { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 8px; }
.objectives .label { color: var(--muted); }
.objectives ul { margin: 0; padding-left: 1.1em; }
.objectives li { margin: 3px 0; }

.big-idea {
  max-width: var(--read); border-left: 3px solid var(--accent); padding: 4px 0 4px 20px; margin: 32px 0;
  font-family: var(--font-serif); font-size: 22px; line-height: 1.4;
}
.why { background: var(--header); color: var(--header-ink); border-radius: var(--radius); padding: 24px 26px; margin: 36px 0; max-width: var(--read); }
.why .label { opacity: .65; }
.why p:last-child { margin-bottom: 0; }
.note { border: 1px solid var(--line); border-left: 3px solid var(--plot); border-radius: var(--radius); padding: 16px 20px; margin: 28px 0; max-width: var(--read); font-size: 15px; background: var(--surface); }
.note .label { color: var(--plot); }
.note p:last-child { margin-bottom: 0; }

figure { margin: 32px 0; }
figure svg { width: 100%; height: auto; display: block; }
figcaption { font-size: 14px; color: var(--muted); margin-top: 10px; max-width: var(--read); }
.diagram { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 24px 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 24px 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h4 { margin: 10px 0 4px; font-size: 16px; font-weight: 600; }
.card h4:first-child { margin-top: 0; }
.card p { font-size: 15px; color: var(--ink-soft); margin: 0 0 .6em; }
.card p:last-child { margin-bottom: 0; }
.card svg { width: 100%; height: auto; display: block; }
.card .kicker { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tags span { font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; color: var(--muted); }

/* stats row */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin: 28px 0; }
.stats > div { border-top: 2px solid var(--ink); padding-top: 12px; }
.stats b { display: block; font-family: var(--font-serif); font-weight: 400; font-size: 40px; line-height: 1.1; }
.stats span { font-size: 14px; color: var(--muted); }

/* pipeline of steps */
.pipeline { list-style: none; margin: 28px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; counter-reset: step; }
.pipeline li { counter-increment: step; position: relative; padding: 16px 16px 16px 0; border-top: 2px solid var(--ink); font-size: 14px; color: var(--ink-soft); }
.pipeline li::before { content: counter(step, decimal-leading-zero); display: block; font-size: 12px; letter-spacing: .1em; color: var(--accent); margin-bottom: 4px; }
.pipeline li b { display: block; color: var(--ink); font-size: 15px; font-weight: 600; margin-bottom: 4px; }

/* svg text */
svg text { font-family: var(--font-sans); fill: var(--ink); }
svg .lbl { font-size: 13px; font-weight: 500; }
svg .sm { font-size: 11px; fill: var(--muted); }
svg .on-dark { fill: #fff; }
svg .on-fill { fill: #111111; }
svg .stroke { stroke: var(--ink); fill: none; }
svg .lead { stroke: var(--muted); stroke-width: 1; fill: none; }
svg .axis { stroke: var(--muted); stroke-width: 1; fill: none; }
svg .grid-line { stroke: var(--line); stroke-width: 1; }
svg .plot-line { stroke: var(--plot); stroke-width: 2.5; fill: none; }


/* ---------- tables ---------- */
.compare { width: 100%; border-collapse: collapse; font-size: 15px; margin: 24px 0; }
.compare th, .compare td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.compare thead th { font-weight: 600; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.compare td:first-child { color: var(--muted); width: 26%; }
.compare.plain td:first-child { color: var(--ink); font-weight: 500; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; border: 1px solid rgba(0,0,0,.15); }
.table-wrap { overflow-x: auto; }

/* ---------- weathering ladder ---------- */

/* ---------- equation ---------- */
.equation {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; overflow-x: auto; white-space: nowrap; max-width: var(--read); margin: 16px 0;
}
.equation .arrow { color: var(--accent); padding: 0 8px; }

/* ---------- soil profile ---------- */
.soil { display: grid; grid-template-columns: 140px 1fr; max-width: var(--read); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.soil .col > div { display: flex; align-items: center; justify-content: center; font-weight: 600; color: #fff; font-size: 18px; }
.soil .desc > div { display: flex; flex-direction: column; justify-content: center; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 14px; }
.soil .desc > div:last-child { border-bottom: 0; }
.soil .desc b { font-size: 15px; }
.soil .desc span { color: var(--muted); }
.h-o { background: #2e1f16; height: 54px; } .h-a { background: #4a3324; height: 80px; } .h-e { background: #a48a6e; height: 54px; }
.h-b { background: #8a5a36; height: 80px; }
.h-c { background: #a99a85; height: 70px; background-image: radial-gradient(circle at 30% 40%, #7d7365 6px, transparent 7px), radial-gradient(circle at 70% 70%, #7d7365 8px, transparent 9px); }
.h-r { background: var(--basalt); height: 60px; }
.soil .desc .d-o { height: 54px; } .soil .desc .d-a { height: 80px; } .soil .desc .d-e { height: 54px; }
.soil .desc .d-b { height: 80px; } .soil .desc .d-c { height: 70px; } .soil .desc .d-r { height: 60px; }

/* ---------- interactive demo panel ---------- */
.demo { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin: 32px 0; }
.demo-title { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.demo-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.controls { display: grid; gap: 14px; }
.controls label { display: grid; gap: 4px; font-size: 14px; }
.controls label span { display: flex; justify-content: space-between; }
.controls output { font-variant-numeric: tabular-nums; color: var(--muted); }
.controls input[type="range"] { width: 100%; accent-color: var(--accent); }
.readout { font-size: 14px; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: 12px; }
.readout b { font-variant-numeric: tabular-nums; }
.demo .ex-actions { flex-wrap: wrap; }
.demo button { font: inherit; font-size: 14px; cursor: pointer; border-radius: 999px; padding: 9px 18px; border: 1px solid var(--ink); background: transparent; color: var(--ink); }
.demo button.primary { background: var(--ink); color: var(--bg); }

/* ---------- plunging fold demo (deformation) ---------- */
.pf-stage { display: flex; gap: 10px; align-items: stretch; }
.pf-stage svg { flex: 1; min-width: 0; }
.pf-vlabel { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 56px; flex: none; text-align: center; line-height: 1.25; font-size: 12px; color: var(--muted); padding: 30px 0 8px; }
.pf-vslider { writing-mode: vertical-lr; direction: rtl; flex: 1; width: 28px; min-height: 160px; margin: 0; accent-color: var(--accent); }
.pf-slice { margin-top: 10px; }
.pf-legend { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.pf-legend div { display: flex; align-items: center; gap: 8px; min-height: 18px; }
.pf-legend i { width: 28px; height: 14px; border-radius: 3px; display: inline-block; }

/* ---------- simulator extras (pickers, meters, hints, fact strips) ---------- */
.demo-lede { font-size: 15px; color: var(--ink-soft); max-width: var(--read); margin: 0 0 16px; }
.demo-note { font-size: 15px; color: var(--ink-soft); max-width: var(--read); margin: 18px 0 0; }
.controls .hint { font-size: 13px; color: var(--muted); margin: -8px 0 0; line-height: 1.4; }
.demo button:disabled { cursor: default; }
.demo svg .halo { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.pickers { display: flex; flex-wrap: wrap; gap: 12px 20px; margin-bottom: 20px; }
.pickers label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.demo select { font: inherit; font-size: 15px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 260px; max-width: 100%; }
.meters { display: grid; gap: 14px; }
.meter { display: grid; grid-template-columns: 160px minmax(0, 1fr) 200px; gap: 14px; align-items: center; font-size: 14px; }
.meter b { display: block; font-weight: 600; }
.meter .m-name span, .meter .m-val span { display: block; font-size: 12px; color: var(--muted); line-height: 1.35; }
.meter .bar { height: 12px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.meter .bar span { display: block; height: 100%; width: 0; border-radius: 6px; background: var(--muted); transition: width .5s ease, background-color .3s; }
.meter[data-level="0"] .bar span { background: var(--line); }
.meter[data-level="2"] .bar span { background: var(--plot); }
.meter[data-level="3"] .bar span { background: var(--accent); }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 20px 0 24px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.facts > div { background: var(--surface); padding: 12px 16px; }
.facts dt { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 3px 0 0; font-size: 14px; line-height: 1.45; }
.tp-opts { display: flex; flex-wrap: wrap; gap: 8px; }
#tp .q { background: var(--bg); }
.tp-foot { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 15px; }

/* ---------- method cards with looping icons ---------- */
.methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 24px 0; }
.method { display: block; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 16px; transition: border-color .15s, transform .15s; }
.method:hover { border-color: var(--ink); transform: translateY(-1px); }
.method svg { width: 100%; height: auto; display: block; margin-bottom: 10px; border-radius: 6px; background: var(--bg); }
.method .kicker { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.method h4 { margin: 2px 0 4px; font-size: 16px; font-weight: 600; }
.method p { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink-soft); }

/* ---------- animation utilities (all switched off for reduced motion, below) ---------- */
.anim-slide { animation: anim-slide 4s linear infinite; }
.anim-draw { stroke-dasharray: 100; animation: anim-draw 4s linear infinite; }
.anim-flash { animation: anim-flash 2.6s ease-out infinite; }
.anim-ring { transform-box: fill-box; transform-origin: center; animation: anim-ring 2.4s ease-out infinite; }
.anim-ring.d2 { animation-delay: 1.2s; }
.anim-grow { transform-box: fill-box; transform-origin: center; animation: anim-grow 2.4s linear infinite; }
.anim-pulse { animation: anim-pulse 2.4s ease-in-out infinite; }
.anim-flow, svg .flow { animation: anim-flow 1.2s linear infinite; }
.loop-dash { stroke-dasharray: 5 20; animation: loop-dash 8s linear infinite; }
@keyframes anim-slide { from { transform: translateX(0); } to { transform: translateX(100px); } }
@keyframes anim-draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes anim-flash { 0%, 58%, 100% { opacity: .2; } 62%, 70% { opacity: 1; } 66% { opacity: .45; } }
@keyframes anim-ring { from { transform: translateY(0) scale(.6); opacity: .9; } to { transform: translateY(26px) scale(2.2); opacity: 0; } }
@keyframes anim-grow { from { transform: scale(.05); opacity: 1; } to { transform: scale(1); opacity: 0; } }
@keyframes anim-pulse { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }
@keyframes anim-flow { to { stroke-dashoffset: -14; } }
@keyframes loop-dash { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
/* ---------- figure keys & legends (keep long text out of SVGs so it stays readable on phones) ---------- */
.fig-key { list-style: none; counter-reset: k; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 6px 20px; font-size: 14px; line-height: 1.45; color: var(--ink-soft); }
.fig-key li { counter-increment: k; position: relative; padding-left: 30px; }
.fig-key li::before { content: counter(k); position: absolute; left: 0; top: 0; width: 21px; height: 21px; border-radius: 50%; background: var(--ink); color: var(--surface); font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.fig-key li b { color: var(--ink); font-weight: 600; }
svg .badge circle { fill: var(--ink); }
svg .badge text { fill: var(--surface); font-size: 12px; font-weight: 600; text-anchor: middle; dominant-baseline: central; }
.fig-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 0; font-size: 13.5px; color: var(--ink-soft); }
.fig-legend span { display: inline-flex; align-items: center; gap: 7px; }
.fig-legend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; box-shadow: inset 0 0 0 1px var(--outline); }
.fig-legend i.line { height: 3px; border-radius: 2px; box-shadow: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
  .anim-slide, .anim-draw, .anim-flash, .anim-ring, .anim-grow, .anim-pulse, .anim-flow, svg .flow, .loop-dash { animation: none !important; }
}

/* ---------- quiz ---------- */
.quiz { max-width: var(--read); margin-top: 48px; }
.quiz.inline { margin-top: 28px; }
.q button.opt.ok { background: var(--accent-soft); border-color: var(--accent); }
.quiz-title { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 14px; }
.q p.stem { font-weight: 500; margin-bottom: 14px; }
.q .opts { display: grid; gap: 8px; }
.q button.opt { font: inherit; font-size: 15px; text-align: left; cursor: pointer; background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.q button.opt:hover:not(:disabled) { border-color: var(--ink); }
.q button.opt:disabled { cursor: default; }
.q button.opt.right { background: var(--ok-soft); border-color: var(--ok); }
.q button.opt.wrong { background: var(--bad-soft); border-color: var(--bad); }
.q .explain { margin-top: 12px; font-size: 15px; color: var(--ink-soft); display: none; }
.q.answered .explain { display: block; }

/* ---------- module footer ---------- */
.module-footer { border-top: 1px solid var(--line); margin-top: 56px; padding: 32px 0 72px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pager a { display: block; text-decoration: none; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; background: var(--surface); }
.pager a:hover { border-color: var(--ink); }
.pager a.next { text-align: right; grid-column: 2; }
.pager small { display: block; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.pager span { font-family: var(--font-serif); font-size: 20px; }

/* ---------- field exercise ---------- */
.exercise { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; align-items: start; margin-top: 24px; }
.event-pool, .event-order { display: flex; flex-direction: column; gap: 8px; }
.event-order { min-height: 60px; counter-reset: ev; }
.event-pool button, .event-order button { font: inherit; font-size: 15px; text-align: left; cursor: pointer; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.event-order button { counter-increment: ev; border-color: var(--ink); }
.event-order button::before { content: counter(ev) ". "; color: var(--muted); font-variant-numeric: tabular-nums; }
.event-order button.right { background: var(--ok-soft); border-color: var(--ok); }
.event-order button.wrong { background: var(--bad-soft); border-color: var(--bad); }
.ex-label { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.ex-actions { display: flex; gap: 10px; margin-top: 14px; }
.ex-actions button { font: inherit; font-size: 14px; cursor: pointer; border-radius: 999px; padding: 9px 18px; border: 1px solid var(--ink); background: transparent; color: var(--ink); }
.ex-actions button.primary { background: var(--ink); color: var(--bg); }
.ex-feedback { margin-top: 14px; font-size: 15px; }

/* ---------- glossary ---------- */
.glossary-filter { font: inherit; width: 100%; max-width: 420px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); margin-bottom: 8px; }
.glossary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 40px; }
.glossary dt { font-weight: 600; margin-top: 16px; }
.glossary dd { margin: 2px 0 0; color: var(--ink-soft); font-size: 15px; }
.glossary dd a { color: var(--muted); font-size: 13px; }

/* ---------- footer ---------- */
.site-footer { background: var(--header); color: var(--header-ink); }
.site-footer .inner { margin: 0 auto; padding: 48px var(--gutter); display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; align-items: center; font-size: 14px; }
.site-footer img { height: 28px; width: auto; filter: invert(1); }
.site-footer span { opacity: .7; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc { position: static; padding: 16px 0 0; max-height: none; overflow: visible; }
  .toc-toggle { display: flex; justify-content: space-between; width: 100%; font: inherit; font-size: 14px; cursor: pointer; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
  .toc .toc-list { display: none; padding: 12px 4px 0 16px; }
  .toc.open .toc-list { display: block; }
  .exercise, .demo-grid { grid-template-columns: minmax(0, 1fr); }
  .part { grid-template-columns: minmax(0, 1fr); gap: 20px; }
}
@media (max-width: 680px) {
  body { font-size: 16px; }
  .grid-3, .grid-2, .glossary, .mod-grid, .pager { grid-template-columns: minmax(0, 1fr); }
  .pager a.next { grid-column: 1; }
  .site-header .course-name { display: none; }
  .hero { padding: 32px var(--gutter) 150px; min-height: 0; }
  .diagram { padding: 12px; }
  .soil { grid-template-columns: 70px 1fr; }
  .demo svg .sm { font-size: 14px; }
  .demo svg .lbl { font-size: 15px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meter { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .meter .bar { grid-column: 1 / -1; grid-row: 2; }
  .meter .m-val { text-align: right; }
  .demo select { min-width: 0; width: 100%; }
  .pickers label { flex: 1 1 100%; }
}

/* phones: the 3D block sits under the hero text */
@media (max-width: 799px) { .hero { padding-bottom: calc(62vw + 48px + var(--cap-h, 0px)); } }
