/* ---------- 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; }

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 ---------- */
section[data-theme="paper"] { background: var(--paper); color: var(--text-on-paper); --accent: var(--pink); --accent-2: var(--blue); --surface-2: var(--paper-2); --text-2: var(--text-on-paper-2); }
section[data-theme="ink"]   { background: var(--ink);   color: var(--text-on-ink);   --accent: var(--pink-dark); --accent-2: var(--blue-dark); --surface-2: var(--ink-2); --text-2: var(--text-on-ink-2); }

/* ---------- 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--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(--pink-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(--pink-dark); }
.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); } }

.facades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.facade { position: relative; margin: 0; cursor: pointer; overflow: hidden; border-radius: 6px; background: var(--ink-2); outline: none; }
.facade img { aspect-ratio: 4 / 3; width: 100%; object-fit: cover; transition: transform 0.6s var(--ease), filter 0.6s var(--ease); filter: saturate(0.85); }
.facade:hover img, .facade:focus-visible img { transform: scale(1.03); filter: saturate(1); }
.facade:focus-visible { box-shadow: 0 0 0 3px var(--pink-dark); }
.facade figcaption { position: absolute; left: 10px; bottom: 10px; font-family: var(--serif); font-size: 1.25rem; line-height: 1; color: #fff; background: rgba(13,15,20,0.72); padding: 0.45rem 0.8rem; border-radius: 999px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); min-width: 2.4rem; text-align: center; }
.facade:not(.is-revealed) figcaption { background: var(--pink-dark); }
.facade__year { display: none; }
.facade.is-revealed .facade__q { display: none; }
.facade.is-revealed .facade__year { display: inline; animation: pop 0.5s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) { .facades { grid-template-columns: repeat(2, 1fr); } }

/* ---------- 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; } }

/* ---------- timeline ---------- */
.timeline { margin-top: 3rem; }
.timeline__head h3 { margin-top: 0; }
.timeline__ribbon { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; margin-top: 1.2rem; }
.epoch { padding: 0.7rem 0.4rem 0.6rem; border-radius: 4px; cursor: pointer; border: none; font: inherit; text-align: left; transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease); min-width: 0; }
.epoch:hover, .epoch:focus-visible, .epoch.is-active { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.35); outline: none; }
.epoch__years { display: block; font-family: var(--serif); font-size: clamp(0.72rem, 1.3vw, 1rem); line-height: 1.15; }
.epoch__name { display: block; font-size: 0.68rem; opacity: 0.85; margin-top: 0.25rem; line-height: 1.25; }
.timeline__scale { display: flex; height: 8px; gap: 2px; margin-top: 6px; border-radius: 3px; overflow: hidden; }
.timeline__scale i { display: block; height: 100%; }
.timeline__detail { margin-top: 1rem; min-height: 3.2rem; font-size: 1rem; color: var(--text-on-ink); }
.timeline__detail b { font-family: var(--serif); font-weight: 500; font-size: 1.15rem; margin-right: 0.5rem; }
@media (max-width: 720px) {
  .timeline__ribbon { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .epoch__name { font-size: 0.72rem; }
}

/* ---------- 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; }
.graphic img { max-height: 72vh; width: 100%; object-fit: contain; border-radius: 6px; background: #fff; }
.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__title { font-family: var(--serif); font-size: 1.3rem; margin-bottom: 0.8rem; }
.card ol { padding-left: 1.3rem; margin-bottom: 1rem; }
.card li { margin-bottom: 0.5rem; font-size: 1.05rem; }
.card .muted { margin: 0; }
.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.8rem, 3vw, 2.6rem); 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; }
  .graphic img { max-height: 42vh; }
  .card { padding: 1.1rem 1.2rem; max-height: 42vh; overflow: auto; }
  .card__title { font-size: 1.1rem; }
  .card li { font-size: 0.92rem; }
  .card--numbers { gap: 0.6rem; }
  .scrolly__steps { padding: 2rem 0 4rem; }
  .step { margin-bottom: 30vh; padding: 1rem 1.1rem; }
}

/* ---------- 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: 480px; color: var(--text-2); }

/* ---------- matrix ---------- */
.matrix-block { margin: 2.5rem 0; }
.matrix-block__head h3 { margin-top: 0; }
.matrix { overflow-x: auto; margin-top: 1rem; -webkit-overflow-scrolling: touch; }
.matrix table { border-collapse: separate; border-spacing: 2px; font-size: 0.82rem; min-width: 560px; width: 100%; }
.matrix th { font-weight: 500; color: var(--text-2); padding: 0.3rem 0.4rem; text-align: center; white-space: nowrap; font-size: 0.78rem; }
.matrix th[scope="row"] { text-align: right; }
.matrix th.axis { font-family: var(--serif); font-style: italic; font-weight: 400; text-align: left; }
.matrix td { text-align: center; padding: 0; height: 2.4rem; border-radius: 3px; position: relative; transition: outline-color 0.15s; outline: 2px solid transparent; outline-offset: -2px; }
.matrix td span { display: block; line-height: 2.4rem; 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(255,255,255,0.35); }
.matrix td.zero span { opacity: 0.45; }
.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; }

.recall { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; margin-top: 1.2rem; }
.recall__item { font-size: 0.72rem; color: var(--text-2); }
.recall__bar { height: 6px; background: var(--ink-3); border-radius: 3px; overflow: hidden; margin: 0.25rem 0 0.2rem; }
.recall__bar i { display: block; height: 100%; background: var(--accent-2); border-radius: 3px; }
.recall__lab { white-space: nowrap; }
@media (max-width: 720px) { .recall { grid-template-columns: repeat(3, 1fr); } }

/* ---------- CAM ---------- */
.cam { margin: 2.5rem 0; }
.cam__controls { display: flex; flex-wrap: wrap; gap: 6px; }
.cam__btn { font: inherit; font-size: 0.82rem; padding: 0.45rem 0.8rem; border-radius: 999px; border: 1px solid rgba(255,255,255,0.18); background: transparent; color: var(--text-on-ink); cursor: pointer; transition: background 0.2s, color 0.2s, border-color 0.2s; }
.cam__btn:hover { border-color: rgba(255,255,255,0.5); }
.cam__btn.is-active { background: var(--text-on-ink); color: var(--ink); border-color: var(--text-on-ink); }
.cam__stage { margin-top: 1rem; background: #fff; border-radius: 8px; padding: 10px; }
.cam__stage img { width: 100%; }
.cam__legend { display: flex; gap: 2rem; flex-wrap: wrap; font-size: 0.85rem; color: var(--text-2); margin-top: 0.8rem; }
.cam__note { margin-top: 0.8rem; font-size: 1rem; }
.cam__note b { font-family: var(--serif); font-weight: 500; font-size: 1.15rem; margin-right: 0.4rem; }

/* ---------- callouts ---------- */
.callouts { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; margin: 2.5rem 0; }
.callout { background: var(--surface-2); border-radius: 10px; padding: 1.5rem; }
.callout__n { font-family: var(--serif); font-size: clamp(2rem, 4vw, 3rem); color: var(--accent); display: block; line-height: 1; margin-bottom: 0.6rem; }
.callout p { margin: 0; font-size: 0.98rem; }
@media (max-width: 720px) { .callouts { grid-template-columns: 1fr; } }

/* ---------- chart ---------- */
.chart-block { margin: 1.5rem 0 2rem; }
.chart svg { width: 100%; height: auto; display: block; font-family: var(--sans); }
.chart .axis line, .chart .axis path { stroke: rgba(255,255,255,0.15); }
.chart .grid line { stroke: rgba(255,255,255,0.08); }
.chart text { fill: var(--text-on-ink-2); font-size: 11px; }
.chart .series { fill: none; stroke: var(--blue-dark); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--blue-dark); stroke: var(--ink); stroke-width: 2; }
.chart .dot--key { r: 5.5; }
.chart .label { fill: var(--text-on-ink); font-size: 12px; font-weight: 500; }
.chart .crosshair { stroke: rgba(255,255,255,0.3); stroke-dasharray: 3 3; opacity: 0; }
.chart .hit { fill: transparent; }
.chart__caption { margin-top: 0.6rem; }
@media (max-width: 720px) {
  .chart text { font-size: 16px; }
  .chart .label { font-size: 17px; }
  .chart .series { stroke-width: 2.5; }
}

/* ---------- 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 rgba(0,0,0,0.12); }
.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; }
  html { scroll-behavior: auto; }
}

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