/* ---------- tokens ---------- */
:root {
  --paper: #f6f1e8;
  --paper-2: #ebe4d7;
  --ink: #14161c;
  --ink-2: #1d2029;
  --ink-3: #272b36;

  --text-on-paper: #1d1a16;
  --text-on-paper-2: #5c564d;
  --text-on-ink: #f3efe7;
  --text-on-ink-2: #a9a59b;

  --pink: #d6186f;
  --blue: #2457b8;
  --pink-dark: #ec4a93;   /* on ink */
  --blue-dark: #5f93f0;   /* on ink */

  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --gutter: 16px;
  --max: 1120px;
  --narrow: 720px;
  --ease: cubic-bezier(.2,.7,.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-weight: 300;
  background: var(--ink);
  color: var(--text-on-ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
strong { font-weight: 600; }
sub { font-size: 0.7em; }

h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.1; letter-spacing: -0.01em; }
h2 { font-size: clamp(1.9rem, 4vw, 3rem); margin: 0 0 1.2rem; }
h3 { font-size: clamp(1.3rem, 2.4vw, 1.7rem); margin: 2.4rem 0 1rem; }
p { font-size: clamp(1.02rem, 1.2vw, 1.15rem); margin-bottom: 1.2rem; max-width: var(--narrow); }
.muted { font-size: 0.92rem; opacity: 0.75; }

/* ---------- themes ---------- */
/* This page leads with blue; pink is the secondary accent (the reverse of the building-age story). */
section[data-theme="paper"] { background: var(--paper); color: var(--text-on-paper); --accent: var(--blue); --accent-2: var(--pink); --surface-2: var(--paper-2); --surface-3: #ddd5c5; --text-2: var(--text-on-paper-2); --line: rgba(0,0,0,0.12); }
section[data-theme="ink"]   { background: var(--ink);   color: var(--text-on-ink);   --accent: var(--blue-dark); --accent-2: var(--pink-dark); --surface-2: var(--ink-2); --surface-3: var(--ink-3); --text-2: var(--text-on-ink-2); --line: rgba(255,255,255,0.14); }

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.wrap--narrow { max-width: calc(var(--narrow) + 2 * var(--gutter)); }
.chapter { padding: clamp(4rem, 9vw, 8rem) 0; position: relative; }
.chapter__num { font-family: var(--serif); font-style: italic; font-size: 1rem; color: var(--accent); letter-spacing: 0.08em; margin-bottom: 0.4rem; }
.eyebrow { font-size: 0.82rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-on-ink-2); margin-bottom: 1.6rem; }
.eyebrow em { font-style: italic; text-transform: none; letter-spacing: 0; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(1.5rem, 4vw, 4rem); align-items: center; margin: 1.5rem 0 2.5rem; }
.split--wide { grid-template-columns: 0.9fr 1.1fr; align-items: start; }
.split--reverse .split__text { order: 2; }
.split--reverse .split__fig { order: 1; }
.split__fig { margin: 0; }

/* ---------- progress + topbar ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 3px; background: transparent; z-index: 60; }
.progress__bar { height: 100%; width: 0; background: var(--blue-dark); transition: width 0.08s linear; }
.topbar {
  position: fixed; top: 3px; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.6rem var(--gutter);
  font-size: 0.85rem; letter-spacing: 0.02em;
  color: var(--text-on-ink); mix-blend-mode: difference;
}
.topbar a { text-decoration: none; opacity: 0.85; }
.topbar a:hover { opacity: 1; }
.topbar__brand { font-family: var(--serif); font-size: 1.05rem; }
.topbar__nav { display: flex; gap: 1.1rem; }
.topbar__nav a.is-current { text-decoration: underline; text-underline-offset: 4px; }
@media (max-width: 820px) { .topbar__nav { display: none; } }

/* ---------- hero ---------- */
.hero { min-height: 100vh; padding: 7rem 0 4rem; display: flex; flex-direction: column; justify-content: center; gap: 2.2rem; background: var(--ink); color: var(--text-on-ink); --accent: var(--blue-dark); --accent-2: var(--pink-dark); --text-2: var(--text-on-ink-2); }
.hero__title { font-size: clamp(2.6rem, 7vw, 5.4rem); font-weight: 300; line-height: 0.98; margin-bottom: 1.4rem; }
.lede { font-size: clamp(1.1rem, 1.6vw, 1.35rem); max-width: 760px; color: var(--text-on-ink); }
.hint { font-size: 0.9rem; color: var(--text-on-ink-2); }
.byline { font-family: var(--serif); font-style: italic; color: var(--text-on-ink-2); margin-top: 0.5rem; }
.scrollcue { display: inline-block; text-decoration: none; font-size: 1.4rem; color: var(--text-on-ink-2); animation: bob 2s infinite var(--ease); }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

/* EPC ruler */
.ruler { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; }
.band { position: relative; border: none; background: transparent; font: inherit; color: inherit; cursor: pointer; padding: 0; text-align: left; outline: none; min-width: 0; }
.band__bar { display: block; width: 100%; border-radius: 4px 4px 0 0; transition: transform 0.3s var(--ease), filter 0.3s var(--ease); transform-origin: bottom; }
.band__cap { display: flex; justify-content: space-between; align-items: baseline; padding: 0.45rem 0.6rem; border-radius: 0 0 4px 4px; }
.band__letter { font-family: var(--serif); font-size: clamp(1.3rem, 3vw, 2.2rem); line-height: 1; }
.band__share { font-size: 0.78rem; opacity: 0.85; font-variant-numeric: tabular-nums; }
.band:hover .band__bar, .band:focus-visible .band__bar, .band.is-active .band__bar { transform: scaleY(1.06); filter: brightness(1.12); }
.band:focus-visible .band__cap, .band.is-active .band__cap { box-shadow: 0 0 0 2px var(--text-on-ink); }
.ruler__detail { margin-top: 1rem; min-height: 3rem; font-size: 1rem; color: var(--text-on-ink); max-width: none; }
.ruler__detail b { font-family: var(--serif); font-weight: 500; font-size: 1.2rem; margin-right: 0.4rem; }
@media (max-width: 640px) {
  .ruler { gap: 3px; }
  .band__cap { padding: 0.35rem 0.3rem; flex-direction: column; align-items: flex-start; gap: 0.1rem; }
  .band__share { font-size: 0.68rem; }
}

/* ---------- figures ---------- */
.figure { margin: 2rem 0; }
.figure img { width: 100%; border-radius: 6px; }
section[data-theme="ink"] .figure img { background: #fff; }
.figure figcaption { font-size: 0.88rem; color: var(--text-2); margin-top: 0.7rem; line-height: 1.5; }
.figure--bleed { margin: 2rem calc(-1 * var(--gutter)); }
.figure--bleed img { border-radius: 0; }
.figure--bleed figcaption { padding: 0 var(--gutter); }
.key { display: inline-flex; align-items: center; gap: 6px; margin-left: 0.9rem; white-space: nowrap; }
.key i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }

.pull { border-left: 3px solid var(--accent); padding: 0.4rem 0 0.4rem 1.4rem; margin: 2.2rem 0; }
.pull p { font-family: var(--serif); font-size: clamp(1.25rem, 2vw, 1.6rem); line-height: 1.4; font-weight: 300; margin: 0; }

/* ---------- stats ---------- */
.stats { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 1.6rem 0 1.8rem; }
.stats__n { display: block; font-family: var(--serif); font-size: clamp(1.4rem, 2.6vw, 2rem); color: var(--accent); line-height: 1.1; }
.stats__l { display: block; font-size: 0.85rem; color: var(--text-2); margin-top: 0.25rem; }
@media (max-width: 640px) { .stats { grid-template-columns: 1fr; gap: 0.8rem; } }

/* ---------- funnel ---------- */
.funnel { margin-top: 3rem; }
.funnel h3 { margin-top: 0; }
.funnel__rows { display: grid; gap: 10px; margin-top: 1.2rem; }
.frow { display: grid; grid-template-columns: minmax(150px, 260px) 1fr; gap: 1rem; align-items: center; cursor: default; }
.frow__lab { font-size: 0.9rem; color: var(--text-2); line-height: 1.3; }
.frow__track { position: relative; height: 30px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.frow__bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 4px; transition: width 1.1s var(--ease); }
.frow--images .frow__bar { background: var(--accent-2); }
.frow__n { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-family: var(--serif); font-size: 1rem; color: #fff; font-variant-numeric: tabular-nums; white-space: nowrap; }
.frow:hover .frow__track, .frow:focus-within .frow__track { box-shadow: 0 0 0 2px var(--line); }
@media (max-width: 640px) { .frow { grid-template-columns: 1fr; gap: 0.3rem; } }

/* ---------- specs ---------- */
.specs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 1.2rem 0 1.4rem; }
.spec { background: var(--surface-2); border-radius: 8px; padding: 1.1rem 1.2rem; }
.spec__n { display: block; font-family: var(--serif); font-size: clamp(1.4rem, 2.4vw, 1.9rem); color: var(--accent); line-height: 1.1; }
.spec__l { display: block; font-size: 0.85rem; color: var(--text-2); margin-top: 0.3rem; }
@media (max-width: 820px) { .specs { grid-template-columns: repeat(2, 1fr); } }

/* ---------- scrollytelling ---------- */
.scrolly { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: clamp(1.5rem, 4vw, 4rem); margin-top: 2.5rem; }
.scrolly__graphic { position: sticky; top: 14vh; height: 72vh; display: flex; align-items: center; justify-content: center; }
.graphic { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; transform: translateY(14px); transition: opacity 0.5s var(--ease), transform 0.5s var(--ease); pointer-events: none; }
.graphic.is-active { opacity: 1; transform: none; pointer-events: auto; }
.cam-fig { position: relative; width: 100%; }
.cam-fig img { max-height: 72vh; width: 100%; object-fit: contain; border-radius: 6px; background: #fff; }
.cam-fig__badge { position: absolute; left: 12px; top: 12px; background: var(--accent); color: #fff; border-radius: 999px; padding: 0.35rem 0.9rem 0.35rem 0.7rem; font-size: 0.9rem; display: inline-flex; gap: 0.5rem; align-items: baseline; }
.cam-fig__badge b { font-family: var(--serif); font-size: 1.3rem; font-weight: 500; }
.scrolly__steps { padding: 20vh 0 30vh; }
.step { padding: 1.4rem 1.5rem; margin-bottom: 55vh; border-left: 2px solid transparent; opacity: 0.35; transition: opacity 0.4s var(--ease), border-color 0.4s var(--ease); }
.step:last-child { margin-bottom: 0; }
.step.is-active { opacity: 1; border-color: var(--accent); }
.step h3 { margin-top: 0; font-size: 1.25rem; }
.step p { margin: 0; }

.card { background: var(--surface-2); border-radius: 10px; padding: 1.8rem; width: 100%; max-width: 520px; }
.card--numbers { display: grid; gap: 1.2rem; }
.card--numbers div { display: grid; gap: 0.15rem; }
.card--numbers .big { font-family: var(--serif); font-size: clamp(1.6rem, 2.6vw, 2.3rem); color: var(--accent); line-height: 1; }
.card--numbers span:last-child { font-size: 0.9rem; color: var(--text-2); }

@media (max-width: 820px) {
  .scrolly { display: block; }
  .scrolly__graphic { position: sticky; top: 0; height: 44vh; background: inherit; z-index: 2; padding: 0.6rem 0; }
  .cam-fig img { max-height: 42vh; }
  .scrolly__steps { padding: 2rem 0 4rem; }
  .step { margin-bottom: 30vh; padding: 1rem 1.1rem; }
  .card { max-width: none; }
}

/* ---------- hero number ---------- */
.hero-number { display: grid; gap: 0.3rem; margin: 3.5rem 0 3rem; padding: 0 0 0 1.4rem; border-left: 3px solid var(--accent); }
.hero-number__n { font-family: var(--serif); font-size: clamp(3rem, 8vw, 6rem); line-height: 1; font-weight: 300; }
.hero-number__l { max-width: 520px; color: var(--text-2); }

/* ---------- per-band performance ---------- */
.perf { margin: 2.5rem 0 1.5rem; }
.perf__rows { display: grid; gap: 8px; margin-top: 1rem; }
.prow { display: grid; grid-template-columns: 2.4rem 1fr 1fr 1fr; gap: 10px; align-items: center; }
.prow--head { font-size: 0.75rem; color: var(--text-2); letter-spacing: 0.04em; text-transform: uppercase; }
.prow__band { font-family: var(--serif); font-size: 1.3rem; }
.pbar { position: relative; height: 22px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.pbar i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.9s var(--ease); }
.pbar span { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 0.78rem; font-variant-numeric: tabular-nums; color: var(--text-on-ink); }
.prow__n { font-size: 0.72rem; color: var(--text-2); }
@media (max-width: 640px) {
  .prow { grid-template-columns: 2.4rem 1fr 1fr; gap: 8px; }
  .pbar--f1, .prow--head span:nth-child(4) { display: none; }
}

/* ---------- matrix ---------- */
.matrix-block { margin: 2.5rem 0; }
.matrix-block__head h3 { margin-top: 0; }
.toggle { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 0.4rem; }
.toggle__btn { font: inherit; font-size: 0.85rem; padding: 0.45rem 0.9rem; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: inherit; cursor: pointer; transition: background 0.2s, color 0.2s, border-color 0.2s; }
.toggle__btn:hover { border-color: var(--accent); }
.toggle__btn.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.toggle__btn small { opacity: 0.75; margin-left: 0.35rem; }
.matrix { overflow-x: auto; margin-top: 1rem; -webkit-overflow-scrolling: touch; }
.matrix table { border-collapse: separate; border-spacing: 3px; font-size: 0.88rem; min-width: 420px; width: 100%; max-width: 720px; }
.matrix th { font-weight: 500; color: var(--text-2); padding: 0.3rem 0.4rem; text-align: center; white-space: nowrap; font-size: 0.82rem; font-family: var(--serif); }
.matrix th[scope="row"] { text-align: right; font-size: 1rem; }
.matrix th.axis { font-style: italic; font-weight: 400; text-align: left; font-family: var(--serif); }
.matrix td { text-align: center; padding: 0; height: 2.6rem; border-radius: 4px; position: relative; transition: outline-color 0.15s, background 0.5s var(--ease), color 0.5s var(--ease); outline: 2px solid transparent; outline-offset: -2px; }
.matrix td span { display: block; line-height: 2.6rem; font-variant-numeric: tabular-nums; }
.matrix td:hover, .matrix td:focus-visible { outline-color: var(--accent-2); z-index: 1; }
.matrix td.diag { box-shadow: inset 0 0 0 1.5px rgba(0,0,0,0.18); }
.matrix td.zero span { opacity: 0.4; }
.tip { position: fixed; z-index: 70; pointer-events: none; background: #0d0f14; color: #f3efe7; padding: 0.5rem 0.7rem; border-radius: 6px; font-size: 0.82rem; line-height: 1.4; box-shadow: 0 6px 24px rgba(0,0,0,0.4); opacity: 0; transition: opacity 0.12s; max-width: 240px; }
.tip.is-on { opacity: 1; }
.tip b { font-weight: 600; }

/* ---------- callouts ---------- */
.callout { background: var(--surface-2); border-radius: 10px; padding: 1.5rem; }
.callout__n { font-family: var(--serif); font-size: clamp(2.4rem, 5vw, 4rem); color: var(--accent); display: block; line-height: 1; margin-bottom: 0.6rem; }
.callout p { margin: 0; font-size: 0.98rem; }

/* ---------- chart ---------- */
.chart-block { margin: 1.5rem 0 2rem; }
.chart svg { width: 100%; height: auto; display: block; font-family: var(--sans); }
.chart .grid line { stroke: var(--line); }
.chart text { fill: var(--text-2); font-size: 11px; }
.chart .label { fill: currentColor; font-size: 12px; font-weight: 500; }
.chart .bar { transition: opacity 0.15s; }
.chart .bar.is-dim { opacity: 0.35; }
.chart .val { font-size: 11px; font-weight: 500; fill: currentColor; }
.chart .legend text { fill: currentColor; font-size: 12px; }
.chart__caption { margin-top: 0.6rem; }
@media (max-width: 720px) {
  .chart text, .chart .val { font-size: 15px; }
  .chart .label, .chart .legend text { font-size: 16px; }
}

/* ---------- SHAP list ---------- */
.shaplist { display: grid; gap: 4px; margin-top: 0.4rem; }
.srow { display: grid; grid-template-columns: 1.6rem 1fr; gap: 0.6rem; align-items: center; padding: 0.35rem 0.5rem; border-radius: 6px; font-size: 0.9rem; line-height: 1.3; cursor: default; transition: background 0.15s; }
.srow:hover, .srow:focus-visible { background: var(--surface-2); outline: none; }
.srow__rank { font-family: var(--serif); color: var(--text-2); font-size: 0.85rem; text-align: right; }
.srow__name b { font-weight: 500; }
.srow__tag { display: inline-block; margin-left: 0.5rem; font-size: 0.72rem; padding: 0.08rem 0.5rem; border-radius: 999px; vertical-align: middle; white-space: nowrap; }
.srow__tag--worse { background: var(--pink); color: #fff; }
.srow__tag--better { background: var(--blue); color: #fff; }
.srow__note { grid-column: 2; font-size: 0.82rem; color: var(--text-2); margin-top: 0.15rem; }

/* ---------- picker ---------- */
.picker { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.5rem; align-items: start; margin: 1.5rem 0 1rem; }
.picker__stage { margin: 0; }
.picker__stage img { width: 100%; border-radius: 8px; background: #fff; aspect-ratio: 1; object-fit: cover; }
.picker__stage figcaption { margin-top: 0.6rem; }
.picker__thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb { padding: 0; border: 2px solid transparent; border-radius: 6px; overflow: hidden; background: transparent; cursor: pointer; transition: border-color 0.2s, transform 0.2s var(--ease); }
.thumb img { aspect-ratio: 1; object-fit: cover; width: 100%; }
.thumb:hover { transform: translateY(-2px); }
.thumb.is-active, .thumb:focus-visible { border-color: var(--accent); outline: none; }
@media (max-width: 720px) { .picker { grid-template-columns: 1fr; } }

/* ---------- outro ---------- */
.takeaways { list-style: none; display: grid; gap: 1rem; margin: 1.5rem 0 1rem; }
.takeaways li { padding: 1.1rem 1.3rem; background: var(--surface-2); border-radius: 8px; font-size: 1.02rem; }
.cite { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--line); }
.cite__ref { font-size: 0.98rem; }
.cite__links { display: flex; flex-wrap: wrap; gap: 1.4rem; font-size: 0.95rem; }
.cite__links a { color: var(--accent); text-decoration: none; border-bottom: 1px solid currentColor; }
.cite__note { font-size: 0.82rem; margin-top: 1rem; }

/* ---------- reveal ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.8s var(--ease), transform 0.8s var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .scrollcue { animation: none; }
  .frow__bar, .pbar i { transition: none; }
  html { scroll-behavior: auto; }
}

@media (max-width: 820px) {
  .split, .split--reverse, .split--wide { grid-template-columns: 1fr; }
  .split--reverse .split__text { order: 1; }
  .split--reverse .split__fig { order: 2; }
}
