:root {
  --paper: #eef3f1;
  --card: #ffffff;
  --ink: #12303f;
  --ink-soft: #4d6572;
  --line: #cfdcd8;
  --water: #1f6fa8;
  --dry: #a8641c;
  --focus: #e0a526;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.55 var(--sans); font-variant-numeric: tabular-nums;
}
a { color: var(--water); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem clamp(1rem, 4vw, 3rem);
  background: rgba(238, 243, 241, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.brand { font: 1.35rem var(--serif); color: var(--ink); text-decoration: none; }
.top nav { display: flex; gap: 1.1rem; overflow-x: auto; }
.top nav a { color: var(--ink-soft); text-decoration: none; font-size: .9rem; white-space: nowrap; }
.top nav a:hover { color: var(--ink); }

main { max-width: 1180px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 3rem) 4rem; }

.hero { padding: clamp(2.5rem, 7vw, 5.5rem) 0 2.5rem; }
.hero h1 {
  font: 400 clamp(2.2rem, 5.2vw, 4.1rem)/1.04 var(--serif);
  letter-spacing: -.01em; max-width: 17ch; margin: 0 0 1.4rem;
}
.lede { max-width: 62ch; font-size: 1.08rem; color: var(--ink-soft); margin: 0 0 2.2rem; }
.lede em { font-style: normal; color: var(--ink); font-weight: 600; }

.budget-bar {
  position: relative; height: 54px; border-radius: 4px;
  background: repeating-linear-gradient(90deg, #bcd6e8 0 2px, #d7e7f1 2px 9px);
  overflow: hidden;
}
.budget-cons {
  position: absolute; inset: 0 auto 0 0; background: var(--dry);
  transform-origin: left; animation: grow 1.4s .3s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes grow { from { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .budget-cons { animation: none; } }
.budget-legend { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: .55rem; font-size: .92rem; color: var(--ink-soft); }
.budget-legend b { color: var(--ink); }
.budget-legend .cons b { color: var(--dry); }

.chapter { padding-top: 3.5rem; border-top: 1px solid var(--line); margin-top: 2.5rem; }
.chapter-head h2, .sources h2 { font: 400 clamp(1.8rem, 3.4vw, 2.6rem)/1.1 var(--serif); margin: 0 0 .5rem; }
.chapter-head p { max-width: 68ch; color: var(--ink-soft); margin: 0 0 1.5rem; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--ink); border-radius: 999px; overflow: hidden; margin-bottom: 1.2rem; }
.seg button {
  font: 500 .88rem var(--sans); color: var(--ink); background: transparent;
  border: 0; padding: .45rem 1rem; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--ink); }
.seg button[aria-selected="true"] { background: var(--ink); color: #fff; }

.stack { display: flex; height: 76px; border-radius: 4px; overflow: hidden; }
.stack div {
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: .45rem .55rem; color: #fff; font-size: .8rem; line-height: 1.2;
  transition: flex-grow .6s cubic-bezier(.2,.7,.2,1); min-width: 0; overflow: hidden;
}
.stack div b { font-size: 1.25rem; font-weight: 600; }
.stack div span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (prefers-reduced-motion: reduce) { .stack div { transition: none; } }
.note { max-width: 70ch; color: var(--ink-soft); margin: .8rem 0 1.8rem; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; align-items: start; }
.grid2.wide-left { grid-template-columns: 1.35fr 1fr; }
@media (max-width: 860px) { .grid2, .grid2.wide-left { grid-template-columns: 1fr; } }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 1rem 1.1rem; margin: 0 0 1.2rem; }
figcaption { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .8rem; font-weight: 600; font-size: .95rem; margin-bottom: .6rem; }
figcaption small { flex-basis: 100%; font-weight: 400; color: var(--ink-soft); font-size: .8rem; }
select { font: .85rem var(--sans); color: var(--ink); padding: .3rem .4rem; border: 1px solid var(--line); border-radius: 4px; background: #fff; max-width: 100%; }
input[type=range] { accent-color: var(--ink); width: min(260px, 100%); }

.chart svg, .map svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text, .map text { font: 11px var(--sans); fill: var(--ink-soft); }
.chart .axis line, .chart .grid line { stroke: var(--line); }
.chart .zero { stroke: var(--ink); stroke-width: 1; }
.map path { stroke: #fff; stroke-width: .6; cursor: pointer; }
.map path:hover, .map path.sel { stroke: var(--ink); stroke-width: 1.6; }
.map path.sel { paint-order: stroke; }

.legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .78rem; color: var(--ink-soft); margin-top: .5rem; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.legend .ramp { display: flex; align-items: center; gap: .4rem; width: 100%; }
.legend .ramp span.bar { flex: 1; height: 10px; border-radius: 2px; }

.detail h3 { font: 400 1.7rem/1.1 var(--serif); margin: 0 0 .2rem; }
.detail .sub { color: var(--ink-soft); font-size: .88rem; margin: 0 0 .9rem; }
.detail .empty { color: var(--ink-soft); margin: 0; }
.strip { display: grid; grid-template-columns: repeat(36, 1fr); gap: 1px; margin: .3rem 0 .2rem; }
.strip span { height: 22px; }
.strip-scale { display: flex; justify-content: space-between; font-size: .72rem; color: var(--ink-soft); margin-bottom: 1rem; }
.stations { list-style: none; padding: 0; margin: 0 0 .8rem; font-size: .85rem; }
.stations li { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; border-top: 1px solid var(--line); }
.stations button { all: unset; cursor: pointer; flex: 1; }
.stations button:focus-visible { outline: 3px solid var(--focus); }
.stations li.on button { font-weight: 600; }
.stations i { width: 12px; height: 12px; border-radius: 2px; flex: none; }
.stations small { color: var(--ink-soft); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1.2rem 2rem; margin: 1rem 0 1.6rem; }
.fact b { display: block; font: 400 2.1rem/1 var(--serif); margin-bottom: .3rem; }
.fact p { margin: 0; font-size: .88rem; color: var(--ink-soft); }
.fact.dry b { color: var(--dry); }
.fact.wet b { color: var(--water); }

.sources dl { display: grid; grid-template-columns: 11rem 1fr; gap: .8rem 1.5rem; max-width: 900px; font-size: .9rem; }
.sources dt { font-weight: 600; }
.sources dd { margin: 0; color: var(--ink-soft); }
@media (max-width: 640px) { .sources dl { grid-template-columns: 1fr; } .sources dd { margin-bottom: .6rem; } }
.stamp { color: var(--ink-soft); font-size: .8rem; margin-top: 2rem; }

#tip {
  position: fixed; z-index: 20; pointer-events: none; max-width: 260px;
  background: var(--ink); color: #fff; font-size: .8rem; line-height: 1.35;
  padding: .45rem .6rem; border-radius: 4px;
}
#tip b { font-weight: 600; }
.loading { color: var(--ink-soft); font-size: .9rem; padding: 2rem 0; }

.stack div b { white-space: nowrap; }
@media (max-width: 640px) { .stack div span { display: none; } .stack div b { font-size: 1rem; } .stack div { padding: .4rem .3rem; } }
