@font-face { font-family: "Newsreader"; src: url(fonts/newsreader.woff2) format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url(fonts/newsreader-italic.woff2) format("woff2"); font-weight: 200 800; font-style: italic; font-display: swap; }
@font-face { font-family: "Libre Franklin"; src: url(fonts/libre-franklin.woff2) format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  --ink: #121212;
  --ink-2: #4d5257;
  --ink-3: #7b8187;
  --rule: #dfe1e3;
  --paper: #ffffff;
  --land: #f1f2f2;
  --orange: #d9562b;
  --peach: #f3b79c;
  --blue: #1f6fb5;
  --violet: #6250d6;
  --aqua: #1baf7a;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Libre Franklin", "Helvetica Neue", Arial, sans-serif;
  --col: 372px;
  --gutter: max(6vw, 32px);
  --vh: 100vh;
}
@supports (height: 100lvh) { :root { --vh: 100lvh; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--serif); font-optical-sizing: auto; -webkit-font-smoothing: antialiased; }
h1, h2, p, dl, dd, figure, ul { margin: 0; }

/* ---------- Stage ---------- */
.scrolly { position: relative; }
.stage { position: sticky; top: 0; height: var(--vh); overflow: hidden; background: var(--land); z-index: 0; }
#map { position: absolute; inset: 0; }
#map canvas { outline: none; }
.stage::before {
  content: ""; position: absolute; inset: 0 0 46% 0; z-index: 1; pointer-events: none; opacity: 0;
  background: linear-gradient(to bottom, #fff 0, rgba(255,255,255,.94) 62%, rgba(255,255,255,0) 100%);
  transition: opacity .6s ease;
}
.stage[data-step="hero"]::before { opacity: 1; }

/* ---------- Steps ---------- */
.steps { position: relative; z-index: 2; margin-top: calc(-1 * var(--vh)); pointer-events: none; }
.step { min-height: 105vh; display: flex; align-items: center; padding: 0 14px; }
.step.hero { min-height: 100vh; min-height: 100svh; align-items: flex-start; padding: 0 22px; }
.step.explore-step { min-height: 135vh; }

.hero-inner { padding-top: 9vh; max-width: 30rem; }
h1 { font-weight: 600; font-size: clamp(2.5rem, 11.2vw, 3rem); line-height: 1; letter-spacing: -.02em; text-wrap: balance; }
.dek { margin-top: 16px; font-size: 1.1875rem; line-height: 1.34; color: #2b2f33; text-wrap: pretty; }
.meta { margin-top: 14px; font: 400 .8125rem/1.45 var(--sans); color: var(--ink-3); }

.card {
  pointer-events: auto; width: 100%; max-width: 26rem; margin: 0 auto; padding: 18px 20px 20px;
  background: rgba(255,255,255,.97); border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(18,18,18,.06), 0 10px 30px -8px rgba(18,18,18,.22);
}
.card h2 { font-weight: 600; font-size: 1.4375rem; line-height: 1.14; letter-spacing: -.01em; text-wrap: balance; }
.card p { margin-top: 9px; font-size: 1.125rem; line-height: 1.42; text-wrap: pretty; }
.card p.small { margin-top: 12px; font: 400 .8125rem/1.45 var(--sans); color: var(--ink-3); }

mark { padding: .06em .32em .1em; border-radius: 2px; font-weight: 600; color: #fff; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
mark.orange { background: var(--orange); }
mark.blue { background: var(--blue); }
mark.violet { background: var(--violet); }
mark.aqua { background: #128a5f; }
mark.peach { background: var(--peach); color: var(--ink); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; flex: none; }
.dot.blue { background: var(--blue); }
.dot.orange { background: var(--orange); }

.pair { margin-top: 12px; border-top: 1px solid var(--rule); }
.pair > div { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.pair dt { font: 400 .875rem/1.35 var(--sans); color: var(--ink-2); }
.pair dt .dot { transform: translateY(-1px); }
.pair dd { font: 600 1.375rem/1 var(--sans); letter-spacing: -.01em; white-space: nowrap; }
.causes dt { line-height: 1.5; }
.causes dd { font-size: 1.125rem; }

/* ---------- Charts ---------- */
.plots { position: absolute; inset: 0; z-index: 1; background: var(--paper); opacity: 0; visibility: hidden; transition: opacity .5s ease, visibility 0s linear .5s; }
.stage[data-view="chart"] .plots { opacity: 1; visibility: visible; transition: opacity .5s ease; }
.plot { position: absolute; inset: 56px 14px 37% 12px; display: flex; flex-direction: column; opacity: 0; visibility: hidden; transition: opacity .45s ease, visibility 0s linear .45s; }
.plot.on { opacity: 1; visibility: visible; transition: opacity .45s ease .1s; }
.plot figcaption { font: 400 .75rem/1.4 var(--sans); color: var(--ink-2); padding-left: 2px; }
.plot figcaption strong { display: block; font-weight: 650; font-size: .875rem; color: var(--ink); }
.keys { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 5px; }
.key { display: inline-flex; align-items: center; }
.key .dot { width: 8px; height: 8px; margin-right: 6px; }
.key .bar { display: inline-block; width: 14px; height: 2px; background: var(--ink); margin-right: 6px; }
.rate-keys { transition: opacity .5s ease; }
#plot-rate[data-state="0"] .rate-keys { opacity: 0; }
.plot-body { position: relative; flex: 1; min-height: 0; margin-top: 8px; }
.plot-body svg, .plot-body canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.plot-body svg { overflow: visible; }
.plot-note { font: 400 .6875rem/1.4 var(--sans); color: var(--ink-3); margin-top: 4px; padding-left: 2px; }
.plot text { font: 400 11px var(--sans); fill: var(--ink-3); }
.plot text.axis-title { fill: var(--ink-2); }
.plot text.callout { font-weight: 650; font-size: 13px; fill: var(--ink); paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; }
.plot .grid { stroke: #e6e8ea; stroke-width: 1; shape-rendering: crispEdges; }
.plot .base { stroke: #b9bec3; stroke-width: 1; shape-rendering: crispEdges; }
.medians { transition: opacity .6s ease .7s; }
#plot-rate[data-state="0"] .medians { opacity: 0; transition-delay: 0s; }


/* ---------- Map chrome ---------- */
.hud { position: absolute; z-index: 3; top: 10px; left: 10px; right: 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.legend, .explore { background: rgba(255,255,255,.94); border-radius: 3px; box-shadow: 0 0 0 1px rgba(18,18,18,.07); font-family: var(--sans); }
.legend { padding: 8px 10px 9px; font-size: .6875rem; line-height: 1.3; color: var(--ink-2); max-width: 100%; transition: opacity .4s ease; }
.legend[hidden], .explore[hidden], .zoom[hidden], .tip[hidden] { display: none; }
.stage[data-view="chart"] .legend, .stage[data-view="chart"] .explore, .stage[data-view="chart"] .zoom { opacity: 0; pointer-events: none; }
.legend-title { font-weight: 650; color: var(--ink); margin-bottom: 6px; font-size: .75rem; }
.legend-items { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.legend-item { display: inline-flex; align-items: center; white-space: nowrap; }
.swatch { width: 11px; height: 11px; border-radius: 2px; margin-right: 6px; flex: none; }
.scale { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; min-width: 232px; }
.scale .cell { height: 9px; border-radius: 1px; }
.scale-labels { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; margin-top: 4px; text-align: center; font-size: .625rem; color: var(--ink-3); white-space: nowrap; }
.scale-ends { display: flex; justify-content: space-between; margin-bottom: 4px; }

.explore { padding: 10px; width: 100%; max-width: 26rem; }
.explore-title { font: 600 1.1875rem/1.1 var(--serif); letter-spacing: -.01em; color: var(--ink); padding: 0 2px; }
.explore-hint { display: none; }
.modes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; margin-top: 8px; }
.modes button, .zoom button {
  appearance: none; border: 1px solid #cfd3d7; background: #fff; color: var(--ink); border-radius: 3px; cursor: pointer;
  font: 500 .8125rem/1 var(--sans); padding: 9px 8px; -webkit-tap-highlight-color: transparent;
}
.modes button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.modes button:focus-visible, .zoom button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
@media (hover: hover) { .modes button:not([aria-pressed="true"]):hover, .zoom button:hover { border-color: var(--ink); } }

.zoom { position: absolute; z-index: 3; right: 10px; bottom: calc(var(--vh) - 100svh + 18px); display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.zoom button { min-width: 38px; height: 38px; padding: 0 10px; font-size: 1.125rem; box-shadow: 0 1px 4px rgba(18,18,18,.12); }
.zoom button[data-zoom="reset"] { font-size: .75rem; }

.tip {
  position: absolute; z-index: 4; left: 0; top: 0; pointer-events: none; min-width: 190px; max-width: 250px;
  background: #fff; border-radius: 3px; padding: 9px 11px 10px; font-family: var(--sans); color: var(--ink);
  box-shadow: 0 0 0 1px rgba(18,18,18,.1), 0 6px 20px -4px rgba(18,18,18,.28);
}
.tip-title { font-weight: 650; font-size: .8125rem; line-height: 1.25; margin-bottom: 6px; }
.tip-row { display: flex; justify-content: space-between; gap: 16px; font-size: .75rem; line-height: 1.55; color: var(--ink-2); }
.tip-row b { font-weight: 650; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tip-row .dot { width: 7px; height: 7px; margin-right: 5px; }

.maplibregl-cooperative-gesture-screen { font-family: var(--sans); font-size: 1rem; }

/* ---------- Notes ---------- */
.notes { max-width: 40rem; margin: 0 auto; padding: 64px 22px 96px; }
.notes h2 { font-weight: 600; font-size: 1.375rem; letter-spacing: -.01em; }
.notes ul { margin-top: 14px; padding-left: 1.1em; }
.notes li { font: 400 .875rem/1.55 var(--sans); color: var(--ink-2); margin-top: 9px; text-wrap: pretty; }
.notes li::marker { color: #b3b8bd; }
.sources { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--rule); font: 400 .8125rem/1.55 var(--sans); color: var(--ink-3); }
.notes a { color: var(--ink-2); text-decoration-color: #b3b8bd; text-underline-offset: 3px; }
.notes a:hover { color: var(--ink); text-decoration-color: var(--ink); }

/* ---------- Wide screens ---------- */
@media (min-width: 900px) {
  .step { min-height: 100vh; padding: 0 0 0 var(--gutter); }
  .step.hero { align-items: center; padding: 0 0 0 var(--gutter); }
  .stage::before { display: none; }
  .hero-inner { padding: 0 0 4vh; max-width: 31rem; }
  h1 { font-size: clamp(3.5rem, 5.4vw, 5rem); line-height: .98; }
  .dek { margin-top: 22px; font-size: 1.375rem; line-height: 1.32; }
  .meta { margin-top: 18px; font-size: .875rem; }
  .card { width: var(--col); max-width: none; margin: 0; padding: 22px 24px 24px; }
  .card h2 { font-size: 1.625rem; }
  .card p { font-size: 1.1875rem; }

  .plot { inset: 11vh 5vw 11vh calc(var(--gutter) + var(--col) + 64px); max-width: 820px; }
  .plot figcaption { font-size: .8125rem; }
  .plot figcaption strong { font-size: 1rem; }
  .plot text { font-size: 12px; }
  .plot text.callout { font-size: 14px; }
  .plot-note { font-size: .75rem; }

  .hud { display: contents; }
  .legend { position: absolute; z-index: 3; left: var(--gutter); bottom: 28px; padding: 11px 13px 12px; font-size: .75rem; max-width: var(--col); }
  .legend-title { font-size: .8125rem; }
  .scale-labels { font-size: .6875rem; }
  .explore { position: absolute; z-index: 3; left: var(--gutter); top: 50%; transform: translateY(-50%); width: var(--col); max-width: none; padding: 22px 24px 24px; background: rgba(255,255,255,.97); box-shadow: 0 0 0 1px rgba(18,18,18,.06), 0 10px 30px -8px rgba(18,18,18,.22); }
  .explore-title { font-size: 1.625rem; padding: 0; }
  .explore-hint { display: block; margin-top: 12px; font: 400 .8125rem/1.45 var(--sans); color: var(--ink-3); }
  .modes { grid-template-columns: 1fr; gap: 6px; margin-top: 14px; }
  .modes button { text-align: left; padding: 11px 12px; font-size: .9375rem; }
  .zoom { right: 24px; top: 24px; bottom: auto; }
  .notes { padding: 96px 22px 140px; }
}

@media (prefers-reduced-motion: reduce) {
  .plots, .plot, .medians, .rate-keys, .stage::before, .legend { transition: none !important; }
}
