/* =====================================================================================================================
   Isabel Lasierra · case study · visual system (w09; green frame and light-only from the 22-nov plan, D13)
   A green frame (masthead, chapter bands, footer) with line drawings of energy sources; text and charts sit on a
   warm-grey plane and white cards, with one blue accent, big tabular numbers and quiet charts. Light theme only (P7).
   Evolved from version 1 (src/template.html): every v1 class keeps its name and meaning, so v1 chart code still works.
   Documentation (in Spanish): work/w09/sistema.md
   ===================================================================================================================== */

/* ---------------------------------------------------------------------------------------------------------------------
   1. Tokens
   --------------------------------------------------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* surfaces and ink */
  --plane: #f9f9f7;            /* page background */
  --surface: #fcfcfb;          /* chart / card surface */
  --sunken: #f1f0eb;           /* code, caveat, table header */
  --ink: #0b0b0b;              /* primary text            17.9:1 on plane */
  --ink-2: #52514e;            /* secondary text           7.5:1 */
  --muted: #6b6963;            /* tertiary text, ticks     5.2:1 (4.8 on sunken) */
  --grid: #e1e0d9;             /* gridlines, hairline borders */
  --axis: #c3c2b7;             /* baselines, control borders (non-text) */
  --hair: rgba(11, 11, 11, 0.10);
  --band: rgba(11, 11, 11, 0.05);
  --code: #f1f0eb;             /* alias of --sunken, kept for v1 code */
  --control: #85837c;          /* borders of inputs, buttons, segmented controls: >= 3:1 (R44) */
  --shadow: 0 8px 28px rgba(11, 11, 11, 0.12);

  /* accent: --accent for marks, focus rings and rules (non-text, >=3:1); --link for any blue TEXT (AA 4.5:1).
     v1 used #2a78d6 for link text = 4.2:1 on the plane, below AA. */
  --accent: #2a78d6;
  --link: #1f63b8;             /* 5.6:1 on plane */

  /* categorical series (D10, own palette): blue, orange, teal, magenta + neutral. Order fixed, never cycled.
     Validated all-pairs in both modes, every hue >= 3:1 on plane and surface: see work/w09/sistema.md §2.
     --sn (neutral) is ALWAYS dashed or dotted as second encoding. --on-sN = text on that colour, >= 4.5:1. */
  --s1: #0a7bda; --s2: #d4552b; --s3: #2fa284; --s4: #a644a0; --sn: #5f5e59;
  --on-s1: #0b0b0b; --on-s2: #0b0b0b; --on-s3: #0b0b0b; --on-s4: #ffffff; --on-sn: #ffffff;

  /* sequential blue, light = low (heatmap of price) */
  --q0: #cde2fb; --q1: #9ec5f4; --q2: #6da7ec; --q3: #3987e5; --q4: #256abf; --q5: #184f95; --q6: #0d366b;

  /* diverging (D10, own): blue = better / cheaper than the reference, orange-red = worse / dearer, grey = no
     difference. Same hues as --s1/--s2; arms lightness-matched in OKLCH (L 0.85 / 0.68 / 0.50).
     --on-dN = text colour for a label inside that cell, >= 4.5:1 (R35). */
  --d-3: #1364b0; --d-2: #589ce6; --d-1: #add1fb; --d0: #e6e5e0; --d1: #f7bfad; --d2: #db795b; --d3: #a33f1e;
  --on-d-3: #ffffff; --on-d-2: #0b0b0b; --on-d-1: #0b0b0b; --on-d0: #0b0b0b; --on-d1: #0b0b0b; --on-d2: #0b0b0b; --on-d3: #ffffff;

  /* marks that sit on top of colour: one hatch colour for "at or below 0 €/MWh" and for illustrative fills */
  --hatch: rgba(11, 11, 11, 0.55);

  /* green frame (P5): masthead, chapter bands, footer, primary buttons. Text on it is ALWAYS --on-field (6.1:1, P5b);
     white on --field is 2.19:1 and is not used for text. Drawings are white at --line-a. */
  --field: #14c967;
  --on-field: #06371c;
  --line-a: 0.7;
  --band-h: clamp(360px, 60vh, 640px);   /* chapter band: about 3/5 of the screen */

  /* dark side panel of a detail sheet (light theme only; it is part of the light design) */
  --panel: #2b2b2a;            /* background */
  --panel-ink: #eeeeec;        /* text            12.2:1 */
  --panel-2: #b8b6b0;          /* secondary text   6.99:1 */
  --panel-link: #7fb0ee;       /* links            6.31:1 (--link is 2.39:1 here) */
  --panel-zero: #8a8984;       /* zero line        4.04:1 (non-text) */
  --panel-grid: #555555;       /* other gridlines (decorative) */

  /* year colours (D17): one categorical colour per year, never interpolated. Ochre, rust, violet, petrol, green, pink.
     Validated all pairs: normal vision >= 16.7, protan/deutan >= 10.3, tritan >= 12.9 (OKLab dE x100); every colour
     >= 3.3:1 on --plane and --surface. The year is still written (legend with numbers, live text, table). On --panel
     2022-2024 are below 3:1, so there they are used only as dots with a --panel-ink ring. */
  --yr-2021: #a97015; --yr-2022: #8f2d01; --yr-2023: #7f1bcc; --yr-2024: #035787; --yr-2025: #2b9171; --yr-2026: #ec3eba;

  /* type */
  --font-text: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-hero: clamp(2.3rem, 6vw, 3.6rem);
  --fs-h2: clamp(1.5rem, 3.2vw, 1.95rem);
  --fs-h3: 1.0625rem;
  --fs-lede: clamp(1.2rem, 2.4vw, 1.45rem);   /* large and light (Plex 300) */
  --fs-name: clamp(1.75rem, 7.6vw, 4.5rem);   /* the site name in the masthead (D16): one line from 360 px */
  --fs-band: clamp(1.9rem, 4vw, 2.75rem);     /* chapter band titles, weight 400 */
  --fs-caption: clamp(1.15rem, 2vw, 1.4rem);  /* pinned row captions, weight 300 */
  --fs-body: 1rem;
  --fs-small: 0.875rem;
  --fs-micro: 0.75rem;
  --fs-stat: clamp(2.5rem, 6vw, 3.25rem);
  /* chart text scale (px, SVG): title 1.75x / subtitle 1.125x / axis 1x / source 0.875x of 12px base */
  --chart-fs: 12px;
  --chart-fs-label: 13px;

  /* spacing scale (4px base) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 72px; --sp-9: 96px;

  /* grid */
  --measure: 680px;            /* reading column */
  --wide: 1040px;              /* figures, scrolly, page max */
  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --nav-h: 52px;               /* fixed top bar; sections use it for scroll-margin-top */
  --radius: 12px;
  --radius-s: 6px;

  /* motion: only to explain a change of state; zeroed under prefers-reduced-motion */
  --dur-fast: 150ms;           /* hover, pressed */
  --dur: 280ms;                /* nav show/hide, disclosure */
  --dur-chart: 400ms;          /* chart state transitions (JS reads this token) */
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ---------------------------------------------------------------------------------------------------------------------
   2. Base
   --------------------------------------------------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + var(--sp-4)); -webkit-text-size-adjust: 100%;
  overflow-x: clip; }   /* clip, not hidden: it does not create a scroll container, so position:sticky keeps working */
body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
p, li, dd, figcaption, .caveat, .fig-source, .stat-note, td:not(.num) { overflow-wrap: anywhere; }  /* long paths, URLs (R41) */
img, svg, canvas { max-width: 100%; }
a { color: var(--link); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { text-wrap: balance; margin: 0; }
h1 { font-size: var(--fs-hero); line-height: 1.05; font-weight: 600; letter-spacing: -0.025em; }
h2 { font-size: var(--fs-h2); line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; }
h3 { font-size: var(--fs-h3); line-height: 1.35; font-weight: 600; }
p { margin: 0; }
strong { font-weight: 600; }
.num, .tnum { font-variant-numeric: tabular-nums lining-nums; }
.mono { font-family: var(--font-data); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--sp-4); top: -100px; z-index: 100;
  padding: var(--sp-2) var(--sp-4); border-radius: var(--radius-s);
  background: var(--ink); color: var(--plane); font-weight: 500; text-decoration: none;
}
.skip-link:focus { top: var(--sp-2); }

/* ---------------------------------------------------------------------------------------------------------------------
   3. Layout grid
   One centred column of --wide; prose inside it keeps --measure. Sections are separated by --sp-9 (72 on phones).
   --------------------------------------------------------------------------------------------------------------------- */
.page {
  padding-left: var(--gutter);
  padding-right: var(--gutter-r);
  padding-block: var(--sp-7) var(--sp-8);
}
.wrap { display: flex; flex-direction: column; gap: var(--sp-9); }
.wrap > * { width: 100%; max-width: var(--wide); margin-inline: auto; }
.prose { max-width: var(--measure); display: flex; flex-direction: column; gap: 14px; }
.prose p { margin: 0; }
.prose ul, .prose ol { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 20px; }
.pair > * { min-width: 0; }

/* ---------------------------------------------------------------------------------------------------------------------
   4. Top bar with table of contents
   <header class="topbar" data-hidden="true|false"> … <nav class="toc" aria-label="Chapters"> <button class="toc-toggle"
   aria-expanded aria-controls="toc-list"> <ol id="toc-list" class="toc-list"> <a aria-current="true"> …
   JS: set data-hidden="false" once the hero is passed; keep it visible while anything inside has focus.
   --------------------------------------------------------------------------------------------------------------------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  height: var(--nav-h);
  padding-inline: var(--gutter) max(16px, env(safe-area-inset-right, 0px));
  background: var(--plane);
  border-bottom: 1px solid var(--grid);
  transition: transform var(--dur) var(--ease);
}
@supports (backdrop-filter: blur(8px)) and (background: color-mix(in srgb, red 50%, transparent)) {
  .topbar { background: color-mix(in srgb, var(--plane) 82%, transparent); backdrop-filter: blur(8px); }
}
/* Hidden = moved up only (no visibility:hidden), so Tab still reaches it and :focus-within brings it back (R40).
   Ship data-hidden="false" in the HTML so it works without JS. */
.topbar[data-hidden="true"]:not(:focus-within) { transform: translateY(-100%); }
.topbar-inner {
  max-width: var(--wide); height: 100%; margin-inline: auto;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
}
.topbar-name { font-weight: 600; font-size: 0.95rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.topbar-tools { display: flex; align-items: center; gap: var(--sp-2); }
.toc { position: relative; }
.toc-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; }
.toc-list a {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 10px; border-radius: 999px;
  font-size: var(--fs-small); color: var(--ink-2); text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.toc-list a:hover { color: var(--ink); background: var(--band); }
.toc-list a[aria-current="true"] { color: var(--ink); background: var(--band); box-shadow: inset 0 -2px 0 var(--accent); }

/* menu button of the top bar on phones */
.toc-toggle {
  font: 500 var(--fs-small)/1 var(--font-text); color: var(--ink);
  background: transparent; border: 1px solid var(--control); border-radius: 999px;
  min-height: 32px; min-width: 32px; padding: 0 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.toc-toggle:hover { background: var(--band); }
.toc-toggle { display: none; }

@media (max-width: 719.98px) {
  .toc-toggle { display: inline-flex; }
  .toc-list {
    display: none;
    position: absolute; right: 0; top: calc(100% + 8px);
    flex-direction: column; gap: 0; min-width: 220px; padding: var(--sp-2);
    background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius-s); box-shadow: var(--shadow);
  }
  .toc-toggle[aria-expanded="true"] + .toc-list { display: flex; }
  .toc-list a { display: flex; min-height: 44px; border-radius: 4px; padding: 0 12px; }
  .toc-list a[aria-current="true"] { box-shadow: inset 2px 0 0 var(--accent); }
}

/* sections leave room for the fixed bar (WCAG 2.4.11) */
.section, [id] { scroll-margin-top: calc(var(--nav-h) + var(--sp-4)); }

/* ---------------------------------------------------------------------------------------------------------------------
   4b. Green frame: masthead, scenes of line drawings, chapter bands (P5, P6, P15)
   <header class="masthead" id="top">
     <div class="scene scene-gen" aria-hidden="true"></div>
     <div class="masthead-inner">
       <div class="masthead-title"><p class="masthead-byline"><a href="#sources">A data story by …</a></p><h1>…</h1></div>
       <nav class="jump" aria-label="Chapters"><h2 class="jump-title">Jump to</h2><ol><li><a href="#market">…</a></li>…</ol></nav>
     </div>
   </header>
   <section class="chapter-band" id="market" aria-labelledby="t-market">       (inside .wrap, sibling of the sections)
     <div class="scene scene-gen" aria-hidden="true"></div>
     <div class="band-inner"><h2 class="band-title" id="t-market"><span class="band-eyebrow">01 · Market</span>
       <span class="band-text">…</span></h2></div>
   </section>
   Every text on the green sits on a solid --field block: no drawing passes behind any letter (D13, item 2).
   --------------------------------------------------------------------------------------------------------------------- */
/* a scene = the green plus one tile of drawings; scene-gen = generation set, scene-red = grid and flexibility set */
.scene { position: absolute; inset: 0; z-index: -1; background-color: var(--field); pointer-events: none; }
.scene::after { content: ""; position: absolute; inset: 0; background: center / 560px repeat; opacity: var(--line-a); }
.scene-gen::after { background-image: url("img/motivos-generacion.svg"); }
.scene-red::after { background-image: url("img/motivos-red.svg"); }
.on-field-block { background: var(--field); color: var(--on-field); }

/* masthead: title block bottom-left, "Jump to" bottom-right */
.masthead { position: relative; isolation: isolate; min-height: clamp(400px, 52vh, 580px); display: flex; align-items: flex-end;
  padding: var(--sp-8) var(--gutter-r) var(--sp-6) var(--gutter); }
.masthead-inner { width: 100%; max-width: var(--wide); margin-inline: auto;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-5) var(--sp-6); align-items: end; }
.masthead-title, .jump { background: var(--field); color: var(--on-field); }
.masthead-title { width: fit-content; max-width: 100%; padding: var(--sp-4) var(--sp-5) var(--sp-5); margin-left: calc(-1 * var(--sp-5));
  display: flex; flex-direction: column; gap: var(--sp-2); }
.masthead-byline { margin: 0; font-size: 1.05rem; line-height: 1.4; }
.masthead-byline a { color: inherit; text-decoration: none; }
.masthead-byline a:hover { text-decoration: underline; text-underline-offset: 3px; }
.masthead h1 { font-size: var(--fs-hero); line-height: 1.12; font-weight: 400; letter-spacing: 0; max-width: 18ch; color: var(--on-field); }
/* site name (D16) as the big title, the question under it as a subtitle; both on the solid title block */
.masthead .masthead-name { font-size: var(--fs-name); line-height: 1.02; letter-spacing: 0.005em; max-width: none; text-wrap: balance; }
@media (min-width: 760px) {   /* two columns: the name shares the row with "Jump to", so size it to the room left (~9.6 em wide) */
  .masthead .masthead-name { font-size: clamp(2.5rem, calc((100vw - 340px) / 9.4), 4.5rem); }
}
.masthead-question { margin: var(--sp-1) 0 0; font-size: clamp(1.1rem, 2.4vw, 1.6rem); line-height: 1.3; font-weight: 400;
  max-width: 28ch; color: var(--on-field); text-wrap: balance; }
.jump { padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4); margin-right: calc(-1 * var(--sp-3)); text-align: right; }
.jump-title { font: 500 0.9rem/1.6 var(--font-text); letter-spacing: 0.08em; text-transform: uppercase; color: var(--on-field); padding-right: 0.6em; }
.jump ol { list-style: none; margin: 0; padding: 0; }
.jump a { display: inline-block; padding: 2px 0.6em; font-size: 0.95rem; line-height: 1.6; color: var(--on-field); text-decoration: none; border-radius: 3px; }
.jump a:hover, .jump a:focus-visible { background: var(--on-field); color: var(--field); }   /* inverted, 6.1:1 */
.masthead :focus-visible, .chapter-band :focus-visible, .foot-band :focus-visible { outline-color: var(--on-field); }

/* chapter band: a window onto a still scene.
   clip-path makes the band clip everything inside it, also the position:fixed scene, so the drawings stay still while
   the band slides over them (works on iOS, unlike background-attachment:fixed; Safari check is Isabel's, D13 item 3).
   The title is sticky inside .band-inner, which is twice as tall as the band: it rides down with the band, pins under
   the top bar and is cut by the band's lower edge as the next section comes up. No JavaScript. */
.wrap > .chapter-band { max-width: none; width: auto; margin-inline: calc(-1 * var(--gutter)) calc(-1 * var(--gutter-r)); }
.wrap > .chapter-band + * { margin-top: calc(var(--sp-7) - var(--sp-9)); }
.chapter-band { position: relative; isolation: isolate; height: var(--band-h); clip-path: inset(0); }
.chapter-band .scene { position: fixed; }
.band-inner { height: calc(var(--band-h) * 2); max-width: var(--wide); margin-inline: auto; padding: var(--sp-6) var(--gutter-r) 0 var(--gutter); }
.band-title { position: sticky; top: calc(var(--nav-h) + var(--sp-5));
  width: fit-content; max-width: min(100%, 26ch); margin-left: calc(-1 * var(--sp-5)); padding: var(--sp-3) var(--sp-5) var(--sp-4);
  background: var(--field); color: var(--on-field);
  display: flex; flex-direction: column; gap: var(--sp-2); font-size: var(--fs-band); line-height: 1.18; font-weight: 400; letter-spacing: 0; }
.band-eyebrow { font: 600 var(--fs-micro)/1.4 var(--font-data); letter-spacing: 0.1em; text-transform: uppercase; }
.band-text { text-wrap: balance; }

/* ---------------------------------------------------------------------------------------------------------------------
   5. Hero (now under the masthead, on the plane): lede, three stat cards (each a link to its chapter), chapter index
   --------------------------------------------------------------------------------------------------------------------- */
.hero { display: flex; flex-direction: column; gap: var(--sp-6); }
.lede { font-size: var(--fs-lede); line-height: 1.5; font-weight: 300; max-width: 40ch; margin: 0; color: var(--ink-2); }

.stats { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4) 28px; margin-top: var(--sp-2); }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }   /* never 2 + 1 orphan */
.stat { display: flex; flex-direction: column; gap: var(--sp-2); border-top: 1px solid var(--axis); padding-top: var(--sp-4); min-width: 0; }
.stat-value { font-size: var(--fs-stat); line-height: 1; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums lining-nums; }
.stat-label { margin: 0; font-size: 1rem; line-height: 1.4; }
.stat-note { margin: 0; font-size: 0.85rem; color: var(--muted); line-height: 1.45; }

/* <a class="stat stat-card" href="#value"> value / label / note / <span class="stat-go">Value →</span> </a> */
.stat-card {
  color: inherit; text-decoration: none;
  border-top: 2px solid var(--axis); padding-top: 15px;
  transition: border-color var(--dur-fast) var(--ease);
}
.stat-card:hover { border-top-color: var(--accent); }
.stat-card:hover .stat-label { text-decoration: underline; text-underline-offset: 3px; }
.stat-card:focus-visible { outline-offset: 4px; border-top-color: var(--accent); }
.stat-go { margin-top: auto; padding-top: var(--sp-1); font: 500 var(--fs-micro)/1.4 var(--font-data); letter-spacing: 0.06em; text-transform: uppercase; color: var(--link); }

@media (max-width: 519.98px) {
  .page { padding-top: var(--sp-6); }
  .hero { gap: var(--sp-5); }
  .hero .lede { font-size: 1.15rem; line-height: 1.45; }
  .stats { gap: var(--sp-3); margin-top: 0; }
  .stat-card { display: grid; grid-template-columns: 4.4rem minmax(0, 1fr); column-gap: var(--sp-3); row-gap: 2px; padding-top: var(--sp-3); }
  .stat-card .stat-value { grid-row: span 3; font-size: 1.75rem; }
  .stat-card .stat-label { font-size: 0.9375rem; line-height: 1.35; }
  .stat-card .stat-note { font-size: 0.8rem; }
  .stat-card .stat-go { display: none; }       /* the whole card is the link; the label says where it goes */
}

/* numbered index as used by the template (his-web, w13): plain <nav class="hero-toc"><ol><li><a>headline</a></li>…</ol>
   Numbers come from a CSS counter (01–07, mono, muted); links in --link; quiet so it does not compete with the figures.
   Two columns from 720 px, one below. */
.hero-toc ol { list-style: none; margin: 0; padding: var(--sp-3) 0 0; border-top: 1px solid var(--grid); counter-reset: htoc;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px var(--sp-6); }
.hero-toc li { counter-increment: htoc; display: grid; grid-template-columns: 2rem minmax(0, 1fr); align-items: baseline; }
.hero-toc li::before { content: counter(htoc, decimal-leading-zero); font: 500 var(--fs-micro)/1.6 var(--font-data); color: var(--muted); }
.hero-toc a { display: inline-block; padding: 3px 0; font-size: var(--fs-small); line-height: 1.4; color: var(--link);
  text-decoration: none; }
.hero-toc a:hover { text-decoration: underline; text-underline-offset: 3px; }
@media (min-width: 720px) { .hero-toc ol { display: block; columns: 2; column-gap: var(--sp-6); } .hero-toc li { break-inside: avoid; } }  /* reads down: 01–04, 05–07 */
@media (max-width: 519.98px) { .hero-toc a { font-size: 0.8125rem; padding: 2px 0; } }

/* ---------------------------------------------------------------------------------------------------------------------
   6. Chapter head: eyebrow (dataset · period), conclusion headline, prose; "Next" link at the end
   --------------------------------------------------------------------------------------------------------------------- */
.section { display: flex; flex-direction: column; gap: 22px; }
.section-head { display: flex; flex-direction: column; gap: 10px; max-width: var(--measure); }
.eyebrow {
  margin: 0;
  font-family: var(--font-data);
  font-size: var(--fs-micro);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow .chap { color: var(--ink); }            /* optional "02" chapter number inside the eyebrow */
.section-head h2 { max-width: 22ch; }            /* conclusion headlines read as one claim */
.section h3 { margin-top: var(--sp-3); }

/* <a class="next-link" href="#forecast"><span>Next</span> Beyond tomorrow, weather data pays off…</a> */
.next-link {
  align-self: flex-start; max-width: var(--measure);
  display: inline-flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap;
  padding-top: var(--sp-3); border-top: 1px solid var(--grid);
  color: var(--ink-2); text-decoration: none; font-size: var(--fs-small);
}
.next-link span { font: 500 var(--fs-micro)/1 var(--font-data); letter-spacing: 0.06em; text-transform: uppercase; color: var(--link); }
.next-link span::after { content: " →"; }
.next-link:hover { color: var(--ink); }

/* ---------------------------------------------------------------------------------------------------------------------
   7. Caveat: visible, its own style, never tiny grey text
   <aside class="caveat"><p class="caveat-tag">Caveat</p><p>Savings are simulated on past data…</p></aside>
   Inline variant next to a number: <span class="caveat-inline">Exploratory</span>
   --------------------------------------------------------------------------------------------------------------------- */
.caveat {
  max-width: var(--measure);
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-1) var(--sp-3); align-items: baseline;
  padding: var(--sp-3) var(--sp-4);
  background: var(--sunken); border-left: 3px solid var(--ink-2); border-radius: 0 var(--radius-s) var(--radius-s) 0;
  font-size: 0.92rem; line-height: 1.5; color: var(--ink);
}
.caveat p { margin: 0; }
.caveat-tag, .caveat > p:first-child.caveat-tag {
  font: 500 var(--fs-micro)/1.6 var(--font-data); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2);
}
@media (max-width: 479.98px) { .caveat { grid-template-columns: 1fr; } }
.caveat-inline {
  display: inline-block; vertical-align: 0.1em;
  font: 500 0.68rem/1 var(--font-data); letter-spacing: 0.05em; text-transform: uppercase;
  padding: 3px 6px; border-radius: 4px; border: 1px solid var(--ink-2); color: var(--ink-2);
}

/* ---------------------------------------------------------------------------------------------------------------------
   8. Illustrative box (battery module): dashed frame + tag, so it never competes with thesis results
   <section class="illustrative" aria-labelledby="…"><p class="tag tag-illustrative">Illustrative</p> …</section>
   --------------------------------------------------------------------------------------------------------------------- */
.illustrative {
  display: flex; flex-direction: column; gap: var(--sp-3);
  padding: var(--sp-5) clamp(var(--sp-3), 3vw, var(--sp-5));
  border: 1.5px dashed var(--axis); border-radius: var(--radius);
  background: transparent;
}
.illustrative .caveat { background: transparent; padding-left: var(--sp-3); }
.tag {
  align-self: flex-start; font: 500 0.72rem/1 var(--font-data); letter-spacing: 0.04em; text-transform: uppercase;
  padding: 4px 7px; border-radius: 4px; background: var(--band); color: var(--ink);
}
.tag-illustrative { background: transparent; border: 1px dashed var(--ink-2); color: var(--ink-2); }

/* ---------------------------------------------------------------------------------------------------------------------
   9. Figure frame (every chart): head (title, subtitle, controls), chart, legend, caption/source, data table
   --------------------------------------------------------------------------------------------------------------------- */
.figure {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 20px clamp(12px, 3vw, 24px) 16px;
  display: flex; flex-direction: column; gap: 14px;
  min-width: 0;
}
.fig-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px 20px; }
.fig-head > div:first-child { min-width: 0; flex: 1 1 320px; display: flex; flex-direction: column; gap: 4px; }
.fig-title { font-size: var(--fs-h3); font-weight: 600; line-height: 1.35; }
.fig-sub { margin: 0; font-size: var(--fs-small); color: var(--ink-2); line-height: 1.45; }
figcaption, .fig-source { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }
.fig-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: var(--sp-2) var(--sp-4); }
.chart { width: 100%; min-width: 0; position: relative; }
.chart svg, .chart canvas { display: block; }
.chart svg { overflow: visible; }
.chart-scroll { overflow-x: auto; overflow-y: hidden; }
.chart-scroll > .chart { min-width: 640px; }
.live { min-height: 1.5em; font-size: var(--fs-small); color: var(--ink-2); }   /* aria-live status line */

/* controls */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.controls-label { font-size: var(--fs-small); color: var(--ink-2); }
.controls-note { font-size: 0.8rem; color: var(--muted); font-family: var(--font-data); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border: 1px solid var(--control); border-radius: 999px; background: var(--plane); }
.seg button {
  font: 500 0.85rem/1 var(--font-text);
  color: var(--ink-2);
  background: transparent;
  border: 0; border-radius: 999px;
  min-height: 32px; padding: 0 14px;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.seg button:hover { color: var(--ink); background: var(--band); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--ink); color: var(--surface); }

/* plain button and select, same family */
.btn {
  font: 500 0.85rem/1 var(--font-text); color: var(--ink);
  background: var(--surface); border: 1px solid var(--control); border-radius: var(--radius-s);
  min-height: 32px; padding: 0 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background-color var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--band); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--plane); border-color: var(--ink); }
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.select {
  font: 500 0.85rem/1 var(--font-text); color: var(--ink);
  background: var(--surface); border: 1px solid var(--control); border-radius: var(--radius-s);
  min-height: 32px; padding: 0 28px 0 10px; max-width: 100%;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}

/* legends and keys */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; font-size: 0.85rem; color: var(--ink-2); }
.legend-title { color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
button.legend-item { font: inherit; color: inherit; background: none; border: 0; padding: 4px 2px; cursor: pointer; border-radius: 4px; }
button.legend-item[aria-pressed="true"] { color: var(--ink); font-weight: 500; box-shadow: inset 0 -2px 0 var(--ink); border-radius: 0; }
.key-line { width: 18px; height: 2px; border-radius: 1px; flex: none; }
.key-line.dashed { height: 0; border-top: 2px dashed currentColor; background: none; }   /* set color with .kc-N */
.key-line.bg-n { background: repeating-linear-gradient(90deg, var(--sn) 0 4px, transparent 4px 7px); }  /* neutral is always dashed */
.kc-1 { color: var(--s1); } .kc-2 { color: var(--s2); } .kc-3 { color: var(--s3); } .kc-4 { color: var(--s4); } .kc-n { color: var(--sn); }
.key-box { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.key-hatch { width: 12px; height: 12px; border-radius: 3px; flex: none; border: 1px solid var(--axis);
  background: repeating-linear-gradient(135deg, var(--hatch) 0 1.5px, transparent 1.5px 4px); }
/* key for a small dot mark drawn on top of colour (e.g. heatmap cells with a price <= 0, where hatching is too fine) */
.key-dot { width: 12px; height: 12px; border-radius: 3px; flex: none; background: radial-gradient(circle, var(--hatch) 0 2px, transparent 2.5px), var(--q3); }
.key-ramp { display: inline-flex; height: 10px; border-radius: 2px; overflow: hidden; }
.key-ramp > span { width: 18px; }
.bg-1 { background: var(--s1); } .bg-2 { background: var(--s2); } .bg-3 { background: var(--s3); }
.bg-4 { background: var(--s4); } .bg-n { background: var(--sn); }
.bgq0 { background: var(--q0); } .bgq1 { background: var(--q1); } .bgq2 { background: var(--q2); } .bgq3 { background: var(--q3); }
.bgq4 { background: var(--q4); } .bgq5 { background: var(--q5); } .bgq6 { background: var(--q6); }
.bgd-3 { background: var(--d-3); } .bgd-2 { background: var(--d-2); } .bgd-1 { background: var(--d-1); } .bgd0 { background: var(--d0); }
.bgd1 { background: var(--d1); } .bgd2 { background: var(--d2); } .bgd3 { background: var(--d3); }
/* text on colour: ONLY these tokens (R34, R35). Labels that do not fit inside go outside the mark, in --ink. */
.on-1 { color: var(--on-s1); } .on-2 { color: var(--on-s2); } .on-3 { color: var(--on-s3); } .on-4 { color: var(--on-s4); } .on-n { color: var(--on-sn); }
.ond-3 { color: var(--on-d-3); } .ond-2 { color: var(--on-d-2); } .ond-1 { color: var(--on-d-1); } .ond0 { color: var(--on-d0); }
.ond1 { color: var(--on-d1); } .ond2 { color: var(--on-d2); } .ond3 { color: var(--on-d3); }
/* significance inside coloured cells: weight + a written mark, never --muted on colour (R35) */
.is-sig { font-weight: 600; }
.is-ns { font-weight: 400; }
.is-ns::after { content: " ns"; font: 400 0.7em/1 var(--font-data); letter-spacing: 0.02em; }

/* ---------------------------------------------------------------------------------------------------------------------
   10. SVG marks. Every colour comes from a token, so both themes follow without re-rendering.
   Rule: text in charts wears --ink / --ink-2 / --muted, never the series colour.
   --------------------------------------------------------------------------------------------------------------------- */
.gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.tick { fill: var(--muted); font-size: var(--chart-fs); font-family: var(--font-text); font-variant-numeric: tabular-nums; }
.axis-title { fill: var(--muted); font-size: var(--chart-fs); font-family: var(--font-text); }
.ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ln-dash { stroke-dasharray: 5 4; }
.ln-1 { stroke: var(--s1); } .ln-2 { stroke: var(--s2); } .ln-3 { stroke: var(--s3); } .ln-4 { stroke: var(--s4); }
.ln-n { stroke: var(--sn); stroke-dasharray: 4 3; }          /* neutral always dashed: second encoding (R37) */
.fl-1 { fill: var(--s1); } .fl-2 { fill: var(--s2); } .fl-3 { fill: var(--s3); } .fl-4 { fill: var(--s4); } .fl-n { fill: var(--sn); }
.area { opacity: 0.16; }
.dot { stroke: var(--surface); stroke-width: 2; }
.q0 { fill: var(--q0); } .q1 { fill: var(--q1); } .q2 { fill: var(--q2); } .q3 { fill: var(--q3); }
.q4 { fill: var(--q4); } .q5 { fill: var(--q5); } .q6 { fill: var(--q6); }
.d-3 { fill: var(--d-3); } .d-2 { fill: var(--d-2); } .d-1 { fill: var(--d-1); } .d0 { fill: var(--d0); }
.d1 { fill: var(--d1); } .d2 { fill: var(--d2); } .d3 { fill: var(--d3); }
.is-dim { opacity: 0.25; transition: opacity var(--dur-fast) var(--ease); }   /* de-emphasis on legend hover */
.hl { fill: none; stroke: var(--ink); stroke-width: 1.5; pointer-events: none; }
.crosshair { stroke: var(--ink-2); stroke-width: 1; pointer-events: none; }
.band { fill: var(--band); }
.band-label, .ann-label { fill: var(--ink-2); font-size: var(--chart-fs); font-family: var(--font-text); }
.ann-line { stroke: var(--ink-2); stroke-width: 1; fill: none; }
.ref-line { stroke: var(--ink-2); stroke-width: 1; shape-rendering: crispEdges; }
.zero-line { stroke: var(--ink-2); stroke-width: 1; shape-rendering: crispEdges; }
.val-label { fill: var(--ink); font-size: var(--chart-fs); font-weight: 600; font-family: var(--font-text); font-variant-numeric: tabular-nums; }
/* halo: any label that sits on top of colour (heatmap, bars) */
text.halo, .row-label { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
:not(text).halo { text-shadow: 0 0 2px var(--surface), 0 0 4px var(--surface), 0 0 6px var(--surface); }  /* HTML has no paint-order stroke (R35) */
.row-label { fill: var(--ink); font-size: var(--chart-fs-label); font-family: var(--font-text); stroke-width: 5px; }
.end-label { fill: var(--ink-2); font-size: var(--chart-fs); font-family: var(--font-text); }
.ci { stroke: var(--ink-2); stroke-width: 1.5; }
.seg-label { font-size: var(--chart-fs); font-weight: 600; font-family: var(--font-text); pointer-events: none; }
.lab-on-1 { fill: var(--on-s1); } .lab-on-2 { fill: var(--on-s2); } .lab-on-3 { fill: var(--on-s3); }
.lab-on-4 { fill: var(--on-s4); } .lab-on-n { fill: var(--on-sn); }
.lab-ond-3 { fill: var(--on-d-3); } .lab-ond-2 { fill: var(--on-d-2); } .lab-ond-1 { fill: var(--on-d-1); } .lab-ond0 { fill: var(--on-d0); }
.lab-ond1 { fill: var(--on-d1); } .lab-ond2 { fill: var(--on-d2); } .lab-ond3 { fill: var(--on-d3); }
.hit { fill: transparent; cursor: crosshair; }
.bar, .segment { cursor: default; }
.bar:focus, .segment:focus { outline: none; }
.bar:focus-visible, .segment:focus-visible, .bar:hover, .segment:hover { stroke: var(--ink); stroke-width: 1.5; }
svg[tabindex]:focus-visible, canvas[tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
/* chart transitions: JS may use CSS transitions on these, or read --dur-chart; both vanish with reduced motion */
.tr { transition: transform var(--dur-chart) var(--ease), opacity var(--dur-chart) var(--ease), fill var(--dur-chart) var(--ease); }

/* tooltip */
.tip {
  position: fixed; z-index: 50; pointer-events: none;
  min-width: 170px; max-width: min(300px, calc(100vw - 32px));
  padding: 9px 11px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--hair); border-radius: 8px; box-shadow: var(--shadow);
  font: 13px/1.35 var(--font-text);
  display: flex; flex-direction: column; gap: 5px;
}
.tip[hidden] { display: none; }
.tip-title { color: var(--ink-2); font-size: 12px; }
.tip-row { display: grid; grid-template-columns: 14px auto 1fr; align-items: baseline; column-gap: 8px; }
.tip-key { align-self: center; }
.tip-key.line { width: 14px; height: 2px; border-radius: 1px; }
.tip-key.box { width: 10px; height: 10px; border-radius: 2px; }
.tip-value { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tip-label { color: var(--ink-2); }

/* ---------------------------------------------------------------------------------------------------------------------
   11. Scrolly block: sticky graphic + steps (value ladder in ch. 2, leak timeline in ch. 4)
   <div class="scrolly">
     <div class="scrolly-graphic"> <figure class="figure">…</figure> </div>
     <ol class="scrolly-steps">
       <li class="scrolly-step" data-step="1" aria-current="step"> <p>…</p>
         <button class="step-btn" type="button">Show this step</button> </li> …
     </ol>
     <div class="step-nav"><button class="btn">← Previous step</button><button class="btn">Next step →</button></div>  (optional, D6)
   </div>
   The graphic comes first in the DOM and on screen (left on desktop, top on phones): focus order = visual order.
   ≥ 720 px wide AND ≥ 600 px tall: graphic sticky on the left, steps ~70vh on the right, active step at full ink.
   Otherwise (phones, landscape phones): nothing sticky, no vh; steps as a compact list with visible buttons (R42).
   --------------------------------------------------------------------------------------------------------------------- */
.scrolly { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }
.scrolly-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); counter-reset: sstep; }
.scrolly-step {
  counter-increment: sstep; position: relative;
  display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--sp-1) var(--sp-3); align-items: baseline;
  padding: var(--sp-3) 0; border-top: 1px solid var(--grid);
  color: var(--ink-2);
  transition: color var(--dur) var(--ease);
}
.scrolly-step::before { content: counter(sstep); grid-row: span 2; font: 500 0.85rem/1.6 var(--font-data); color: var(--muted); }
.scrolly-step > * { grid-column: 2; }
.scrolly-step[aria-current="step"], .scrolly-step.is-active { color: var(--ink); }
.scrolly-step[aria-current="step"]::before, .scrolly-step.is-active::before { color: var(--link); }
.step-btn {
  justify-self: start; margin-top: var(--sp-1);
  font: 500 var(--fs-micro)/1 var(--font-data); letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--link); background: none; border: 1px solid var(--control); border-radius: 999px;
  min-height: 28px; padding: 0 10px; cursor: pointer;
}
.step-btn:hover { background: var(--band); }
.scrolly-step[aria-current="step"] .step-btn { color: var(--ink-2); }
.step-nav { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

@media (min-width: 720px) and (min-height: 600px) {
  .scrolly { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--sp-6); align-items: start; }
  .scrolly-graphic { position: sticky; top: calc(var(--nav-h) + var(--sp-4)); }
  .scrolly-steps { gap: 0; padding-bottom: 30vh; }
  .scrolly-step { min-height: 70vh; align-content: center; border-top: 0; padding: var(--sp-5) 0; }
  .scrolly-step:first-child { min-height: 40vh; align-content: start; }
  /* scroll drives the graphic; the button stays in the tab order but is only drawn when focused (not a hidden hit area) */
  .scrolly-step .step-btn:not(:focus-visible) {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: 0; overflow: hidden; clip-path: inset(50%); border: 0;
  }
  .scrolly-graphic .figure { max-height: calc(100svh - var(--nav-h) - var(--sp-6)); }
  .step-nav { grid-column: 1; }
}

/* ---------------------------------------------------------------------------------------------------------------------
   12. "Plan a week" demo frame
   --------------------------------------------------------------------------------------------------------------------- */
.demo { display: flex; flex-direction: column; gap: var(--sp-4); }
.demo-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-5); }
.week-picker { display: inline-flex; align-items: center; gap: var(--sp-1); }
.week-picker .btn { padding: 0 10px; }
.demo-costs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: var(--sp-3); }
.cost { display: flex; flex-direction: column; gap: 2px; padding-top: var(--sp-2); border-top: 2px solid var(--sn); min-width: 0; }
.cost.c-1 { border-top-color: var(--s1); } .cost.c-2 { border-top-color: var(--s2); }
.cost.c-3 { border-top-color: var(--s3); } .cost.c-4 { border-top-color: var(--s4); }
.cost-name { font-size: var(--fs-small); color: var(--ink-2); }
.cost-value { font-size: 1.5rem; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums lining-nums; }
.cost-delta { font: 500 0.8rem/1.4 var(--font-data); color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------------------------------------------------------
   13. Pinned row captions (P15) and the detail sheet with a dark panel
   <div class="caption-row"><div class="row-sentinel" aria-hidden="true"></div><p class="row-caption">…</p> figures… </div>
   The caption sticks under the top bar while its row passes; the end of the row pushes it out. Shadow only while
   pinned: page.js toggles .is-stuck when the sentinel has scrolled above the top bar (IntersectionObserver).
   <div class="sheet"><figure class="sheet-chart" data-chart="clock24">…</figure>
     <aside class="sheet-panel"><p class="sheet-kicker">…</p><p class="sheet-head">…</p><hr><h3>…</h3><p>…</p><div data-yoy></div></aside></div>
   --------------------------------------------------------------------------------------------------------------------- */
.caption-row { display: flex; flex-direction: column; gap: var(--sp-4); }
.row-sentinel { height: 1px; margin-bottom: -1px; }
.row-caption { position: sticky; top: var(--nav-h); z-index: 5;            /* tooltips (.tip) sit above at 50, top bar at 40 */
  margin: 0 calc(-1 * var(--sp-4)); padding: var(--sp-3) var(--sp-4);
  background: var(--plane); color: var(--ink-2);
  font-size: var(--fs-caption); line-height: 1.45; font-weight: 300; max-width: none;
  transition: box-shadow var(--dur-fast) var(--ease); }
.row-caption.is-stuck { box-shadow: 0 8px 10px -8px rgba(11, 11, 11, 0.3); }
/* a caption only pins over a real row (a sheet or several figures); over a single card it would just hide its title */
.caption-row:not(:has(> .sheet, > .figure ~ .figure)) > .row-caption { position: static; box-shadow: none; }

.sheet { display: grid; grid-template-columns: minmax(0, 616fr) minmax(0, 348fr); box-shadow: 0 0 25px rgba(11, 11, 11, 0.18); border-radius: var(--radius); }
.sheet-chart { margin: 0; min-width: 0; background: var(--surface); border-radius: var(--radius) 0 0 var(--radius);
  padding: 20px clamp(12px, 3vw, 24px) 16px; display: flex; flex-direction: column; gap: 14px; position: relative; }
.sheet-panel { background: var(--panel); color: var(--panel-ink); border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.sheet-kicker { margin: 0; font-size: 0.95rem; font-weight: 300; color: var(--panel-2); }
.sheet-head { margin: 0; font-size: 1.25rem; line-height: 1.3; font-weight: 500; color: var(--field); }      /* 6.47:1 on --panel */
.sheet-panel hr { border: 0; border-top: 1px solid #5a5957; margin: var(--sp-1) 0; }
.sheet-panel h3 { margin: 0; font-size: 1rem; font-weight: 500; color: var(--panel-ink); }
.sheet-panel p { margin: 0; font-size: var(--fs-small); line-height: 1.55; color: var(--panel-2); }
.sheet-panel a { color: var(--panel-link); }
.sheet-panel :focus-visible { outline-color: var(--panel-ink); }
.sheet-panel [data-yoy] { margin-top: var(--sp-2); }
.sheet-panel .tick { fill: var(--panel-2); font-size: 11px; }
.sheet-panel .gridline { stroke: var(--panel-grid); }
.sheet-panel .zero-line { stroke: var(--panel-zero); }
/* primary action on a chart (Play): the green with --on-field text, inverted on hover (6.1:1 both ways) */
.btn-go { font: 600 0.9rem/1 var(--font-text); color: var(--on-field); background: var(--field); border: 0; border-radius: 999px;
  min-height: 36px; padding: 0 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.btn-go:hover { background: var(--on-field); color: var(--field); }
.btn-go:focus-visible { outline: 2px solid var(--on-field); outline-offset: 2px; }

/* ---------------------------------------------------------------------------------------------------------------------
   14. Tables (every chart has one, in a <details class="data">)
   --------------------------------------------------------------------------------------------------------------------- */
details.data { border-top: 1px solid var(--grid); padding-top: 10px; }
details.data summary { cursor: pointer; font-size: 0.85rem; color: var(--ink-2); width: fit-content; min-height: 28px; display: flex; align-items: center; gap: 6px; }
details.data summary:hover { color: var(--ink); }
details.data summary::-webkit-details-marker { display: none; }
details.data summary::before {                                      /* display:flex drops the native marker; this puts it back */
  content: ""; width: 0.45em; height: 0.45em; border: solid currentColor; border-width: 0 1.5px 1.5px 0;
  transform: rotate(-45deg); transition: transform var(--dur-fast) var(--ease); margin-right: 2px;
}
details.data[open] summary::before { transform: rotate(45deg); }
.table-wrap { overflow-x: auto; margin-top: 10px; }
/* scroll shadow: the edge darkens only while there is more table to scroll to (covers move with the content) */
@supports (background: color-mix(in srgb, red 50%, transparent)) {
  .figure .table-wrap {
    background:
      linear-gradient(to right, var(--surface) 40%, transparent) left / 32px 100% no-repeat local,
      linear-gradient(to left, var(--surface) 40%, transparent) right / 32px 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%, color-mix(in srgb, var(--ink) 22%, transparent), transparent) left / 12px 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%, color-mix(in srgb, var(--ink) 22%, transparent), transparent) right / 12px 100% no-repeat scroll;
  }
}
table { border-collapse: collapse; width: 100%; font-size: 0.82rem; }
caption { text-align: left; font-size: 0.8rem; color: var(--muted); padding-bottom: 6px; }
th, td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--grid); vertical-align: top; }
thead th { color: var(--muted); font-weight: 500; white-space: nowrap; }
tbody th { font-weight: 500; }
tbody tr:hover { background: var(--band); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.is-ref th, tr.is-ref td { color: var(--ink-2); }
tr.is-key th, tr.is-key td { font-weight: 600; }
td.na { color: var(--muted); text-align: center; }                  /* visible gap, e.g. S2 only at 0.30 */
@media (max-width: 639px) {                                           /* long headers wrap instead of pushing numbers out of view */
  thead th, thead th.num { white-space: normal; }
  th, td { padding: 6px; }
  tr > :first-child { padding-left: 0; }
}

/* ---------------------------------------------------------------------------------------------------------------------
   15. Platform chapter: idea cards (four since the 22-nov plan)
   --------------------------------------------------------------------------------------------------------------------- */
.ideas { list-style: none; counter-reset: idea; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: var(--sp-5) var(--sp-6); }
.ideas li { counter-increment: idea; display: flex; flex-direction: column; gap: 6px; padding-top: var(--sp-3); border-top: 1px solid var(--grid); }
.ideas li::before { content: counter(idea, decimal-leading-zero); font: 500 0.8rem/1 var(--font-data); color: var(--link); }
.ideas h3 { margin: 0; }
.ideas p { font-size: 0.95rem; color: var(--ink-2); line-height: 1.55; }
.ideas .go { font: 500 var(--fs-micro)/1.4 var(--font-data); letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none; }
.ideas .go::before { content: "→ "; }

/* ---------------------------------------------------------------------------------------------------------------------
   16. Credits (chapter 07, after the band #sources) and the short green footer
   <section class="credits" aria-labelledby="t-sources"><div class="credits-about"><p>…</p></div>
     <div><h3>Data</h3><p>…</p></div><div><h3>Made by</h3><dl><dt>…</dt><dd>…</dd>…</dl></div></section>
   <footer class="foot-band"><div class="scene scene-gen" aria-hidden="true"></div>
     <div class="foot-inner"><a class="foot-link" href="#top">Back to the top</a></div></footer>
   --------------------------------------------------------------------------------------------------------------------- */
.credits { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-6) var(--sp-7); }
.credits > * { min-width: 0; }
.credits .credits-about p { margin: 0 0 var(--sp-3); font-size: clamp(1.1rem, 1.8vw, 1.3rem); line-height: 1.5; font-weight: 300; color: var(--ink-2); }
.credits h3 { margin: 0 0 var(--sp-2); font: 500 0.85rem/1.4 var(--font-text); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.credits p, .credits dl { margin: 0 0 var(--sp-3); font-size: var(--fs-small); line-height: 1.55; color: var(--ink-2); }
.credits dt { color: var(--muted); }
.credits dd { margin: 0 0 var(--sp-3); color: var(--ink); }
.note { font-size: 0.85rem; color: var(--muted); margin: 0; }

/* tall enough that the last chapter band can scroll fully away before the page ends (no half-cut title at the bottom) */
.foot-band { position: relative; isolation: isolate; min-height: clamp(320px, 55vh, 560px); display: flex; align-items: center;
  padding: var(--sp-8) var(--gutter-r) var(--sp-8) var(--gutter); }
.foot-inner { width: 100%; }
.foot-inner { max-width: var(--wide); margin-inline: auto; }
.foot-link { display: inline-block; background: var(--field); color: var(--on-field); padding: var(--sp-2) var(--sp-4);
  margin-left: calc(-1 * var(--sp-4)); font-size: 1.05rem; font-weight: 500; text-decoration: none; }
.foot-link:hover { background: var(--on-field); color: var(--field); }

/* ---------------------------------------------------------------------------------------------------------------------
   17. Responsive, motion, forced colours, print
   --------------------------------------------------------------------------------------------------------------------- */
@media (max-width: 759.98px) {
  :root { --band-h: clamp(260px, 45vh, 420px); }
  .masthead { min-height: 0; padding-top: var(--sp-7); padding-bottom: var(--sp-5); }
  .masthead-inner { grid-template-columns: minmax(0, 1fr); }
  .masthead-title { margin-left: calc(-1 * var(--sp-4)); padding: var(--sp-3) var(--sp-4) var(--sp-4); }
  .jump { text-align: left; margin: 0 0 0 calc(-1 * var(--sp-4)); padding: var(--sp-3) var(--sp-4); width: fit-content; max-width: calc(100% + var(--sp-4)); }
  .jump-title { padding: 0 0.6em 2px; }
  .jump ol { display: grid; grid-template-columns: repeat(2, minmax(0, max-content)); column-gap: var(--sp-4); }
  .jump a { padding: 6px 0.6em; }
  .scene::after { background-size: 420px; }
  .band-title { margin-left: calc(-1 * var(--sp-4)); padding: var(--sp-3) var(--sp-4); }
  .sheet { grid-template-columns: minmax(0, 1fr); }
  .sheet-chart { border-radius: var(--radius) var(--radius) 0 0; }
  .sheet-panel { border-radius: 0 0 var(--radius) var(--radius); }
  .credits { grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }
  .foot-link { margin-left: calc(-1 * var(--sp-4)); }
}
@media (max-width: 519.98px) {
  .wrap { gap: var(--sp-8); }
  .wrap > .chapter-band + * { margin-top: calc(var(--sp-6) - var(--sp-8)); }
  .figure { border-radius: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 0ms; --dur: 0ms; --dur-chart: 0ms; }
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .seg button[aria-pressed="true"], .seg button[aria-selected="true"] { outline: 2px solid CanvasText; }
  .toc-list a[aria-current="true"] { outline: 1px solid CanvasText; }
  .caveat, .illustrative, .figure, .sheet-panel { border: 1px solid CanvasText; }
  .scene { display: none; }
  .masthead, .chapter-band, .foot-band { border-block: 1px solid CanvasText; }
  .key-line, .key-box, .key-hatch, .key-dot, .key-ramp, .bg-1, .bg-2, .bg-3, .bg-4, .bg-n, .segbar-part, .cost, svg { forced-color-adjust: none; }
}
@media print {
  .topbar, .skip-link, .controls, .step-btn, .scene, .btn-go { display: none !important; }
  .chapter-band { height: auto; clip-path: none; }
  .band-inner { height: auto; padding-bottom: var(--sp-4); }
  .band-title { position: static; }
  .row-caption { position: static; box-shadow: none; }
  body { background: #fff; color: #000; }
  .figure { break-inside: avoid; box-shadow: none; }
  .scrolly-graphic { position: static; }
  .scrolly-step { min-height: 0; }
  details.data::details-content { content-visibility: visible; display: block; }   /* Chrome 131+; JS may also open them on beforeprint */
  .scrolly-step .step-btn { display: none; }
}
