/* ==========================================================================
   Water Allocation and Social Unrest — interactive companion page
   Light-only by deliberate commitment: the page is a companion to a printed
   paper and to mlarreboure.com, both of which are light surfaces.

   Palette provenance — every categorical set below was run through
   dataviz/scripts/validate_palette.py (OKLab CVD ΔE, lightness band, chroma
   floor, WCAG vs surface). Results recorded inline. Do not substitute hexes
   without re-running the validator.
   ========================================================================== */

:root {
  /* ── chart chrome & ink ────────────────────────────────────────────────── */
  --surface:        #fcfcfb;   /* chart surface (validator reference) */
  --plane:          #f7f7f4;   /* page plane */
  --ink:            #0b0b0b;
  --ink-2:          #52514e;
  --ink-muted:      #898781;
  --grid:           #e1e0d9;
  --axis:           #c3c2b7;
  --rule:           #e5e4dd;

  /* ── brand accent (carried over from the outreach one-pagers) ─────────── */
  --brand:          #14577a;
  --brand-soft:     #e8f0f5;

  /* ── outcomes: lawsuits vs protests ───────────────────────────────────────
     PASS all checks. worst adjacent CVD ΔE 21.5 (protan), normal 28.5.
     Same hexes as the paper's OUTCOME_COLS_TC.                              */
  --law:            #08519c;
  --prot:           #a63603;
  --law-soft:       rgba(8, 81, 156, 0.14);
  --prot-soft:      rgba(166, 54, 3, 0.14);

  /* ── streamflow first stage: upstream / local / downstream ────────────────
     PASS. worst adjacent CVD ΔE 10.9 (deutan), normal 31.1. Green is 2.82:1
     against the surface — a documented contrast relief, discharged by the
     direct labels every coefficient carries.                                */
  --up:             #c0392b;
  --local:          #4dac26;
  --down:           #2166ac;

  /* ── rights allocated vs renewable streamflow ─────────────────────────────
     PASS. worst adjacent CVD ΔE 20.9 (protan), normal 29.2. Paper's
     DECOMP_COLS.                                                            */
  --rights:         #d73027;
  --flow:           #4575b4;

  /* ── basin stress, as an ORDINAL ramp (one hue, light→dark) ───────────────
     PASS --ordinal: monotone L, all ΔL ≥ 0.06, light end 2.40:1, hue spread
     23°. Used for plot fills and the stress map. The paper's green→dark-red
     heat scale cannot pass (non-monotone L, 129° spread), so the plot uses
     this ramp and the single-value tier chip below carries the semantic
     colour instead.                                                         */
  --stress-1:       #f4894f;   /* Low (<25%)                */
  --stress-2:       #e85d2e;   /* Medium (25–50%)           */
  --stress-3:       #c1181d;   /* High (50–100%)            */
  --stress-4:       #67000d;   /* Over-appropriated (>100%) */

  /* ── stress tier chip: the status palette (fixed, never themed) ───────────
     Status colours ship with a text label, never colour alone — which is
     exactly what a chip is. Two of them are sub-3:1 by design; the label is
     the mitigation.                                                         */
  --tier-good:      #0ca30c;
  --tier-warning:   #b07d00;   /* darkened from #fab219 for label legibility */
  --tier-serious:   #c25a2c;
  --tier-critical:  #d03b3b;

  /* ── protest repertoire families ──────────────────────────────────────────
     Chroma/band/normal-vision PASS; worst adjacent CVD ΔE 7.5 (deutan) sits
     in the 6–8 floor band, legal only with secondary encoding — discharged
     by the family group labels and per-row direct labels.                    */
  --fam-tactics:    #2b6cb0;
  --fam-topics:     #ca6c0f;
  --fam-targets:    #2ca25f;

  /* ── holder sectors, collapsed to three + neutral ─────────────────────────
     PASS --pairs all. worst pair CVD ΔE 9.2 (deutan), normal 24.0. The
     paper's six-sector palette fails (#3182bd vs #756bb1 is ΔE 2.0 under
     deutan), so the web page collapses to the three the argument turns on
     and folds the rest into a labelled neutral.                             */
  --sec-ag:         #1baf7a;
  --sec-mining:     #eb6834;
  --sec-utilities:  #2a78d6;
  --sec-other:      #b9b8b1;

  /* ── macrozones ───────────────────────────────────────────────────────────
     PASS. worst adjacent CVD ΔE 18.0 (deutan), normal 19.3. Paper's
     ZONE_COLS.                                                              */
  --zone-north:     #e6550d;
  --zone-center:    #3182bd;
  --zone-south:     #2ca25f;

  --measure:        70ch;
  --wide:           1080px;
}

/* ==========================================================================
   Reset & base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { line-height: 1.25; font-weight: 650; margin: 0; }
p  { margin: 0 0 1.05em; }
a  { color: var(--brand); text-decoration: none; border-bottom: 1px solid rgba(20, 87, 122, 0.3); }
a:hover { border-bottom-color: var(--brand); }
strong { font-weight: 650; }
em { font-style: italic; }

/* ==========================================================================
   Language toggle. Prose ships in both languages as sibling blocks and is
   switched with CSS; only chart labels and dynamic strings go through JS.
   ========================================================================== */

[data-lang="en"] .es,
[data-lang="es"] .en { display: none; }

.langswitch { display: inline-flex; border: 1px solid var(--axis); border-radius: 999px; overflow: hidden; }
.langswitch button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--ink-2); padding: 5px 13px; line-height: 1.4;
}
.langswitch button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.langswitch button:not([aria-pressed="true"]):hover { background: var(--brand-soft); }

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(252, 252, 251, 0.94);
  backdrop-filter: saturate(150%) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.site-header .bar {
  max-width: var(--wide); margin: 0 auto; padding: 9px 24px;
  display: flex; align-items: center; gap: 16px;
}
.site-header .short-title {
  font-size: 15px; font-weight: 650; letter-spacing: -0.01em;
  margin-right: auto; color: var(--ink);
}
.site-header .short-title .sub { color: var(--ink-muted); font-weight: 500; }
.header-links { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.header-links a { border-bottom: 0; color: var(--ink-2); font-weight: 550; }
.header-links a:hover { color: var(--brand); }
.header-links a.pdf {
  border: 1px solid var(--brand); color: var(--brand);
  border-radius: 6px; padding: 4px 11px;
}
.header-links a.pdf:hover { background: var(--brand); color: #fff; }

/* ==========================================================================
   Hero
   ========================================================================== */

.hero { background: var(--surface); border-bottom: 1px solid var(--rule); }
.hero .inner { max-width: var(--wide); margin: 0 auto; padding: 52px 24px 40px; }
.eyebrow {
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--brand); margin-bottom: 14px;
}
.hero h1 {
  font-size: clamp(28px, 4.4vw, 44px); letter-spacing: -0.022em;
  max-width: 22ch; margin-bottom: 18px;
}
.byline { font-size: 15px; color: var(--ink-2); margin-bottom: 26px; }
.byline .aff { color: var(--ink-muted); }
.standfirst {
  font-size: clamp(18px, 2.1vw, 21px); line-height: 1.52; color: var(--ink-2);
  max-width: 60ch; margin-bottom: 4px;
}
.standfirst strong { color: var(--ink); font-weight: 600; }

/* ── key numbers strip ─────────────────────────────────────────────────── */
.keynums {
  max-width: var(--wide); margin: 0 auto; padding: 0 24px 46px;
  display: grid; gap: 1px; background: var(--rule);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: 1px solid var(--rule); border-radius: 10px; overflow: hidden;
}
.keynums { padding: 0; margin: 0 24px 46px; max-width: calc(var(--wide) - 48px); }
@media (min-width: 1128px) { .keynums { margin: 0 auto 46px; } }
.keynum { background: var(--surface); padding: 17px 18px 15px; }
.keynum .v {
  font-size: 27px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1;
  color: var(--ink); display: block; margin-bottom: 5px;
}
.keynum .v.up   { color: var(--prot); }
.keynum .v.down { color: var(--law); }
.keynum .k { font-size: 13px; line-height: 1.4; color: var(--ink-2); display: block; }

/* ==========================================================================
   Sections & prose
   ========================================================================== */

main { max-width: var(--wide); margin: 0 auto; padding: 0 24px 80px; }

/* Story navigation: one sticky row of section anchors under the header. */
.storynav {
  position: sticky; top: 43px; z-index: 30;
  background: rgba(247, 247, 244, 0.96); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.storynav-inner {
  max-width: var(--wide); margin: 0 auto; padding: 0 24px;
  display: flex; gap: 0; overflow-x: auto; scrollbar-width: none;
}
.storynav-inner::-webkit-scrollbar { display: none; }
.storynav a {
  flex: 0 0 auto; padding: 11px 11px 9px; border-bottom: 2px solid transparent;
  color: var(--ink-2); font-size: 13px; font-weight: 650; white-space: nowrap;
}
.storynav a:hover { color: var(--brand); }
.storynav a.active { color: var(--brand); border-bottom-color: var(--brand); }
section[id] { scroll-margin-top: 92px; }

section { padding: 54px 0 6px; border-top: 1px solid var(--rule); }
section:first-of-type { border-top: 0; }

.secnum {
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--ink-muted); margin-bottom: 10px;
}
section > h2 {
  font-size: clamp(24px, 3vw, 31px); letter-spacing: -0.019em;
  max-width: 26ch; margin-bottom: 22px;
}
section h3 { font-size: 20px; letter-spacing: -0.012em; margin: 38px 0 14px; }

.prose { max-width: var(--measure); }
.prose.tight { max-width: 62ch; }

.design-steps {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px;
  max-width: var(--wide); margin: 28px 0 34px; background: var(--rule);
  border: 1px solid var(--rule); border-radius: 10px; overflow: hidden;
}
.design-steps > div { background: var(--surface); padding: 18px 19px 16px; }
.design-steps span {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  margin-bottom: 10px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  font-size: 13px; font-weight: 700;
}
.design-steps strong { display: block; font-size: 15px; line-height: 1.35; }
.design-steps p { margin: 6px 0 0; font-size: 14px; line-height: 1.45; color: var(--ink-2); }

.event-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
  margin: 28px 0 16px; max-width: var(--wide);
}
.event-grid article { background: var(--surface); border: 1px solid var(--rule); border-radius: 9px; padding: 17px 18px; }
.event-grid h3 { margin: 5px 0 7px; font-size: 17px; }
.event-grid p { margin: 0; font-size: 14.5px; line-height: 1.48; color: var(--ink-2); }
.event-year { color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.event-search { max-width: 620px; margin: 28px 0 16px; }
.event-search label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.event-search input { width: 100%; padding: 10px 12px; border: 1px solid var(--axis); border-radius: 7px; font: inherit; font-size: 16px; }
.event-search input:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }

/* pull quote / slogan */
.slogan {
  margin: 30px 0; padding: 20px 24px; background: var(--surface);
  border-left: 3px solid var(--prot); border-radius: 0 8px 8px 0;
  max-width: var(--measure);
}
.slogan .es-quote {
  font-size: 22px; font-weight: 650; letter-spacing: -0.015em;
  color: var(--ink); margin-bottom: 5px;
}
.slogan .gloss { font-size: 15px; color: var(--ink-2); }
.slogan-photo { padding: 0; border-left: 0; overflow: hidden; max-width: 820px; }
.slogan-photo img { display: block; width: 100%; height: min(52vw, 470px); object-fit: cover; object-position: center; }
.slogan-photo .gloss { display: block; padding: 14px 18px 15px; background: var(--surface); }

/* callout */
.callout {
  margin: 26px 0; padding: 18px 22px; background: var(--brand-soft);
  border-radius: 9px; max-width: var(--measure); font-size: 16px;
}
.callout p:last-child { margin-bottom: 0; }
.callout .label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--brand); margin-bottom: 7px;
}

/* inline term with a definition on hover/focus */
.term {
  border-bottom: 1px dotted var(--ink-muted); cursor: help; position: relative;
}
.term::after {
  content: attr(data-tip);
  position: absolute; left: 0; bottom: calc(100% + 9px); z-index: 60;
  width: max-content; max-width: 300px;
  background: var(--ink); color: #fff; font-size: 13.5px; line-height: 1.45;
  font-weight: 400; padding: 9px 12px; border-radius: 7px;
  opacity: 0; visibility: hidden; transition: opacity 0.13s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
.term:hover::after, .term:focus-visible::after { opacity: 1; visibility: visible; }

/* ==========================================================================
   Figure card
   ========================================================================== */

.fig {
  margin: 32px 0 8px; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 12px; overflow: hidden;
}
.fig > header { padding: 20px 24px 0; }
.fig .figlabel {
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--brand); margin-bottom: 7px;
}
.fig .figtitle {
  font-size: 18.5px; font-weight: 650; letter-spacing: -0.012em;
  margin-bottom: 6px; max-width: 46ch;
}
.fig .figsub { font-size: 14.5px; color: var(--ink-2); max-width: 66ch; margin-bottom: 0; }

/* control row: one row above the plot it scopes */
.controls {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 22px;
  padding: 18px 24px 4px;
}
.controls:empty { display: none; }
.ctl { display: flex; flex-direction: column; gap: 6px; }
.ctl > .ctl-label {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--ink-muted);
}
.segmented { display: inline-flex; border: 1px solid var(--axis); border-radius: 7px; overflow: hidden; }
.segmented button {
  appearance: none; border: 0; border-right: 1px solid var(--axis);
  background: var(--surface); cursor: pointer; font: inherit; font-size: 13.5px;
  font-weight: 550; color: var(--ink-2); padding: 7px 14px; min-height: 34px;
  white-space: nowrap;
}
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.segmented button:not([aria-pressed="true"]):hover { background: var(--brand-soft); color: var(--brand); }

/* slider */
.sliderctl { min-width: 268px; flex: 1 1 300px; }
/* Inside .ctl (a COLUMN flex box) that 300px basis became a HEIGHT: every
   slider control stood 300px tall over a 53px row, which was the empty band
   above both maps. Width comes from the parent .ctl instead. */
.ctl > .sliderctl { flex: 0 0 auto; width: 100%; }
.ctl:has(> .sliderctl) { flex: 1 1 320px; min-width: 268px; }
.sliderctl .row { display: flex; align-items: center; gap: 13px; }
.sliderctl .slider-track { flex: 1; min-width: 0; }
.sliderctl input[type="range"] { width: 100%; accent-color: var(--brand); height: 26px; }
.sliderctl .readout {
  font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 650;
  color: var(--ink); min-width: 5.6em; text-align: right;
}
.sliderctl .ticks {
  display: flex; justify-content: space-between; font-size: 11.5px;
  color: var(--ink-muted); font-variant-numeric: tabular-nums; margin-top: -2px;
}
.playbtn {
  appearance: none; border: 1px solid var(--axis); background: var(--surface);
  border-radius: 7px; cursor: pointer; font: inherit; font-size: 13.5px;
  font-weight: 550; color: var(--ink-2); padding: 7px 13px; min-height: 34px;
}
.playbtn:hover { background: var(--brand-soft); color: var(--brand); }

/* plot container: wide content scrolls inside its own box, never the page */
.plotwrap { padding: 6px 12px 4px; overflow-x: auto; }
.plot { width: 100%; min-width: 480px; }
.plot.tall { min-width: 560px; }

/* live reading of the current control state */
.reading {
  margin: 4px 24px 0; padding: 13px 16px; background: var(--plane);
  border-radius: 8px; font-size: 15px; line-height: 1.5; color: var(--ink-2);
}
.reading b { color: var(--ink); font-weight: 650; }
.reading .num { font-variant-numeric: tabular-nums; }

/* notes + method disclosure */
.fig footer { padding: 14px 24px 20px; }
.fignote {
  font-size: 13.5px; line-height: 1.55; color: var(--ink-muted);
  max-width: 82ch; margin: 0;
}
.fignote + .fignote { margin-top: 7px; }
details.method { margin-top: 13px; }
details.method > summary {
  cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--brand);
  list-style: none; display: inline-flex; align-items: center; gap: 6px;
}
details.method > summary::-webkit-details-marker { display: none; }
details.method > summary::before { content: "▸"; font-size: 11px; }
details.method[open] > summary::before { content: "▾"; }
details.method .body {
  margin-top: 12px; padding: 15px 18px; background: var(--plane);
  border-radius: 8px; font-size: 14.5px; line-height: 1.6; color: var(--ink-2);
  max-width: 78ch;
}
details.method .body p:last-child { margin-bottom: 0; }
details.method .body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
  background: #fff; border: 1px solid var(--rule); border-radius: 4px; padding: 1px 5px;
}
.eq {
  display: block; background: #fff; border: 1px solid var(--rule);
  border-radius: 6px; padding: 11px 14px; margin: 11px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; line-height: 1.6; overflow-x: auto; color: var(--ink);
}

/* table view twin */
.tableview { margin-top: 13px; }
.tableview > summary {
  cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  list-style: none; display: inline-flex; align-items: center; gap: 6px;
}
.tableview > summary::-webkit-details-marker { display: none; }
.tableview > summary::before { content: "▸"; font-size: 11px; }
.tableview[open] > summary::before { content: "▾"; }
.tablescroll { overflow-x: auto; margin-top: 11px; }
table.data {
  border-collapse: collapse; font-size: 13.5px; width: 100%; min-width: 460px;
}
table.data th, table.data td {
  text-align: right; padding: 6px 11px; border-bottom: 1px solid var(--rule);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
table.data th { color: var(--ink-muted); font-weight: 650; font-variant-numeric: normal; }
table.data th:first-child, table.data td:first-child {
  text-align: left; font-variant-numeric: normal;
}
table.data tbody tr:hover { background: var(--plane); }

/* swatch used in tables and inline legends */
.sw {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  margin-right: 7px; vertical-align: baseline;
}

/* ==========================================================================
   Basin explorer
   ========================================================================== */

.search-wrap { position: relative; max-width: 440px; padding: 18px 24px 0; }
.search-wrap input {
  width: 100%; font: inherit; font-size: 16px; padding: 11px 14px;
  border: 1px solid var(--axis); border-radius: 8px; background: #fff;
  color: var(--ink);
}
.search-wrap input:focus {
  outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand);
}
.dropdown {
  position: absolute; left: 24px; right: 24px; top: calc(100% + 4px); z-index: 50;
  background: #fff; border: 1px solid var(--axis); border-radius: 8px;
  max-height: 288px; overflow-y: auto; display: none;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.11);
}
.dropdown.open { display: block; }
.dd-item { padding: 9px 14px; cursor: pointer; font-size: 15px; line-height: 1.35; }
.dd-item .basin { color: var(--ink-muted); font-size: 13px; }
.dd-item:hover, .dd-item.active { background: var(--brand-soft); }

.basin-panel { padding: 4px 24px 0; }
.basin-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px;
  padding: 20px 0 4px;
}
.basin-head h4 { font-size: 22px; letter-spacing: -0.015em; }
.chip {
  font-size: 12px; font-weight: 700; letter-spacing: 0.03em; padding: 3px 9px;
  border-radius: 999px; color: #fff; white-space: nowrap;
}
.chip.good     { background: var(--tier-good); }
.chip.warning  { background: var(--tier-warning); }
.chip.serious  { background: var(--tier-serious); }
.chip.critical { background: var(--tier-critical); }
.chip.nodata   { background: var(--ink-muted); }
.chip.zone     { background: transparent; color: var(--ink-2); border: 1px solid var(--axis); }

.infogrid {
  display: grid; gap: 12px; margin: 16px 0 4px;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
}
.infocard {
  background: var(--plane); border-radius: 9px; padding: 13px 15px;
}
.infocard .k {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-muted); margin-bottom: 5px;
}
.infocard .v {
  font-size: 21px; font-weight: 650; letter-spacing: -0.015em; color: var(--ink);
  line-height: 1.15;
}
.infocard .v small { font-size: 13px; font-weight: 500; color: var(--ink-2); }

#basin-map {
  height: 380px; border-radius: 10px; margin: 18px 0 4px;
  border: 1px solid var(--rule); background: var(--plane);
}
.leaflet-container { font: inherit; font-size: 13px; border-radius: 10px; }

.holders { margin-top: 20px; }
.holders h5 {
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-muted); margin: 0 0 9px;
}
.holderscroll { max-height: 330px; overflow-y: auto; border: 1px solid var(--rule); border-radius: 8px; }
table.holders-table { border-collapse: collapse; width: 100%; font-size: 14px; }
table.holders-table th {
  position: sticky; top: 0; background: var(--surface); z-index: 1;
  text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--axis);
  font-size: 12px; font-weight: 650; color: var(--ink-muted);
}
table.holders-table td {
  padding: 7px 12px; border-bottom: 1px solid var(--rule); vertical-align: top;
}
table.holders-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.holders-table tbody tr:last-child td { border-bottom: 0; }

.hint { font-size: 14.5px; color: var(--ink-muted); padding: 16px 0 4px; }

/* all-basins table, the alternative entry point to the search box */
.allbasins { margin-top: 8px; }
table.basins-table { border-collapse: collapse; width: 100%; min-width: 620px; font-size: 14px; }
table.basins-table th {
  position: sticky; top: 0; background: var(--surface); z-index: 1;
  text-align: right; padding: 9px 11px; border-bottom: 1px solid var(--axis);
  font-size: 12px; font-weight: 650; color: var(--ink-muted); cursor: pointer;
  white-space: nowrap; user-select: none;
}
table.basins-table th:first-child { text-align: left; }
table.basins-table th[aria-sort]::after { content: " ↕"; opacity: 0.45; }
table.basins-table th[aria-sort="ascending"]::after  { content: " ↑"; opacity: 1; }
table.basins-table th[aria-sort="descending"]::after { content: " ↓"; opacity: 1; }
table.basins-table td {
  text-align: right; padding: 7px 11px; border-bottom: 1px solid var(--rule);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
table.basins-table td:first-child { text-align: left; font-variant-numeric: normal; }
table.basins-table tbody tr { cursor: pointer; }
table.basins-table tbody tr:hover { background: var(--brand-soft); }

/* ==========================================================================
   Policy list & footer
   ========================================================================== */

.reforms { counter-reset: r; max-width: var(--measure); margin: 24px 0 0; padding: 0; list-style: none; }
.reforms > li {
  counter-increment: r; position: relative; padding: 0 0 0 46px; margin-bottom: 22px;
}
.reforms > li::before {
  content: counter(r); position: absolute; left: 0; top: 1px;
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); font-size: 14px; font-weight: 700;
  display: grid; place-items: center;
}
.reforms h4 { font-size: 17px; margin-bottom: 4px; }
.reforms p { font-size: 16px; color: var(--ink-2); margin-bottom: 0; }

.site-footer {
  background: var(--surface); border-top: 1px solid var(--rule);
  padding: 44px 0 56px; font-size: 14.5px; color: var(--ink-2);
}
.site-footer .inner { max-width: var(--wide); margin: 0 auto; padding: 0 24px; }
.site-footer h3 {
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-muted); margin: 0 0 10px;
}
.footgrid {
  display: grid; gap: 34px; grid-template-columns: repeat(auto-fit, minmax(258px, 1fr));
}
.cite {
  background: var(--plane); border-radius: 8px; padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; overflow-x: auto;
  color: var(--ink-2); margin: 0;
}
.copybtn {
  appearance: none; border: 1px solid var(--axis); background: var(--surface);
  border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px;
  font-weight: 550; color: var(--ink-2); padding: 5px 11px; margin-top: 9px;
}
.copybtn:hover { background: var(--brand-soft); color: var(--brand); }
.site-footer ul { margin: 0; padding-left: 18px; }
.site-footer li { margin-bottom: 5px; }
.colophon {
  margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--rule);
  font-size: 13.5px; color: var(--ink-muted);
}

/* ==========================================================================
   Loading / error states
   ========================================================================== */

.loading, .errorbox {
  padding: 34px 24px; text-align: center; font-size: 14.5px; color: var(--ink-muted);
}
.errorbox { color: var(--tier-critical); }
.stale { opacity: 0.45; transition: opacity 0.12s ease; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 860px) {
  body { font-size: 16.5px; }
  .design-steps { grid-template-columns: 1fr; }
  .event-grid { grid-template-columns: 1fr; }
  .hero .inner { padding: 38px 20px 30px; }
  main { padding: 0 20px 60px; }
  .site-header .bar { padding: 8px 20px; }
  .header-links { gap: 10px; font-size: 13px; }
  .header-links a.home { display: none; }
  .fig > header, .controls, .fig footer, .basin-panel, .search-wrap { padding-left: 18px; padding-right: 18px; }
  .reading { margin-left: 18px; margin-right: 18px; }
  .dropdown { left: 18px; right: 18px; }
  .keynums { margin-left: 20px; margin-right: 20px; }
  section { padding-top: 42px; }
}

/* Phones: plots fit the screen instead of scrolling sideways inside .plotwrap.
   Must match NARROW_PX in app.js, which stacks the multi-column figures and
   tightens their margins at the same width. */
@media (max-width: 599px) {
  .plot, .plot.tall { min-width: 0; }
  .plotwrap { padding: 6px 4px 4px; overflow-x: visible; }
  .fig > header, .controls, .fig footer { padding-left: 14px; padding-right: 14px; }
  .reading { margin-left: 14px; margin-right: 14px; }
  .segmented { flex-wrap: wrap; }
  .segmented button { white-space: normal; }
}

@media (max-width: 560px) {
  .keynum .v { font-size: 23px; }
  .controls { gap: 15px; }
  .sliderctl { min-width: 100%; }
  #basin-map { height: 300px; }
  .basin-head h4 { font-size: 19px; }
}

@media print {
  .site-header, .langswitch, .controls, details.method, .tableview { display: none; }
  body { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   Hydrological-position figure (map beside a stacked-area chart)
   ========================================================================== */

.hydrogrid {
  display: grid; gap: 14px; padding: 8px 24px 4px;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}
#hydro-map {
  height: 560px; border-radius: 10px;
  border: 1px solid var(--rule); background: #fff;
}
.hydro-legend {
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  padding: 2px 24px 0; font-size: 13.5px; color: var(--ink-2);
}
.hydro-legend .item { display: inline-flex; align-items: center; gap: 7px; }
.hydro-legend .dot {
  width: 11px; height: 11px; border-radius: 50%; display: inline-block;
}
.hydro-legend .dot.open { background: transparent; border: 2px solid currentColor; }

.selectctl select {
  font: inherit; font-size: 14px; padding: 6px 10px; min-height: 34px;
  border: 1px solid var(--axis); border-radius: 7px; background: var(--surface);
  color: var(--ink); max-width: 260px;
}
.selectctl select:hover { border-color: var(--brand); }

@media (max-width: 860px) {
  .hydrogrid { grid-template-columns: 1fr; padding-left: 18px; padding-right: 18px; }
  #hydro-map { height: 330px; }
  .hydro-legend { padding-left: 18px; padding-right: 18px; }
}


/* ==========================================================================
   Added 2026-09-24: story sections
   ========================================================================== */

.cards-lead { max-width: var(--measure); margin: 26px 0 0; font-weight: 600; color: var(--ink); }
.model-cards { margin-top: 14px; }
.model-cards strong { font-size: 16px; }

section h3.subhead { margin-top: 46px; }

/* agricultural transformation: two panels side by side */
.ag-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px;
  padding: 8px 24px 0;
}

/* national over-appropriation map: tall narrow map beside the counter */
.overmap-grid {
  display: grid; grid-template-columns: minmax(260px, 380px) minmax(0, 1fr); gap: 26px;
  padding: 8px 24px 4px; align-items: start;
}
#overmap-map {
  height: 640px; border-radius: 10px; border: 1px solid var(--rule); background: #fff;
}
.overmap-side { padding-top: 6px; }
.overmap-count .big {
  font-size: 64px; font-weight: 750; letter-spacing: -0.03em; line-height: 1;
  color: var(--stress-4);
}
.overmap-count .lbl { font-size: 17px; font-weight: 650; color: var(--ink); margin-top: 6px; }
.overmap-count .sub { font-size: 14px; color: var(--ink-2); margin: 2px 0 14px; }
.overmap-legend { display: grid; gap: 6px; margin-top: 16px; font-size: 13.5px; color: var(--ink-2); }
.overmap-legend .sw {
  display: inline-block; width: 14px; height: 14px; border-radius: 3px;
  margin-right: 8px; vertical-align: -2px;
}

/* disclosures that hold secondary material */
details.moredetail {
  margin: 34px 0 10px; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--surface); max-width: var(--wide);
}
details.moredetail > summary {
  cursor: pointer; padding: 14px 20px; font-weight: 650; color: var(--brand); font-size: 15px;
}
details.moredetail[open] > summary { border-bottom: 1px solid var(--rule); }
details.moredetail > .prose, details.moredetail > .event-search,
details.moredetail > .event-grid { margin-left: 20px; margin-right: 20px; }
details.moredetail > .fig { margin: 16px 12px 12px; }

/* sampled events: definition list inside each card */
.event-grid dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 14px; }
.event-grid dt { color: var(--ink-muted); font-weight: 600; }
.event-grid dd { margin: 0; color: var(--ink-2); }
.event-grid .muted { color: var(--ink-muted); font-style: italic; }
.event-intro { max-width: var(--measure); }

/* fieldwork quotes */
.quotes {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px;
  margin: 22px 0 10px; max-width: var(--wide);
}
.quotes blockquote {
  margin: 0; padding: 18px 20px 16px; background: var(--surface);
  border-left: 3px solid var(--brand); border-radius: 0 9px 9px 0;
}
.quotes blockquote p { margin: 0 0 10px; font-size: 16px; line-height: 1.5; color: var(--ink); }
.quotes cite { font-style: normal; font-size: 13px; font-weight: 650; color: var(--ink-muted); }

@media (max-width: 860px) {
  .ag-grid { grid-template-columns: 1fr; padding-left: 18px; padding-right: 18px; }
  .overmap-grid { grid-template-columns: 1fr; padding-left: 18px; padding-right: 18px; }
  #overmap-map { height: 520px; }
  .quotes { grid-template-columns: 1fr; }
  .storynav-inner { padding: 0 12px; }
}

/* These plots sit outside a scrolling .plotwrap, so the 480px minimum would clip
   them on a phone instead of letting them scroll. They are simple enough to shrink. */
.ag-grid .plot, .overmap-side .plot { min-width: 0; }
.hydro-legend .ring { width: 13px; height: 13px; border-radius: 50%; display: inline-block; border: 1.4px dashed #3f3f3c; }

/* ── 2026-09-24 author comments ─────────────────────────────────────────── */
/* Titles on one row: the width caps (22ch / 26ch) were what forced the wraps. */
.hero h1 { max-width: none; }
section > h2 { max-width: none; }
.fig .figtitle { max-width: none; }

.keylead {
  /* the same box as .keynums below it, so the two left edges line up */
  max-width: calc(var(--wide) - 48px); margin: 0 24px 12px;
  font-size: 15px; font-weight: 600; color: var(--ink-2);
}
@media (min-width: 1128px) { .keylead { margin: 0 auto 12px; } }
@media (max-width: 860px) { .keylead { margin-left: 20px; margin-right: 20px; } }

/* smaller slogan photo */
.slogan-photo { max-width: 600px; }
.slogan-photo img { height: min(40vw, 320px); }

/* category key in the research design */
.category-key strong { font-size: 16px; margin-bottom: 4px; }
.category-key p { font-size: 14px; }
.category-key p.muted { color: var(--ink-muted); margin-top: 8px; }
.category-key .dotkey {
  width: 14px; height: 14px; border-radius: 50%; margin-bottom: 10px; background: transparent;
}
.category-key .dotkey.open { border: 2.5px solid #2166ac; }
.design-steps.tests a { white-space: nowrap; font-weight: 600; }

/* measure definitions */
dl.defs { margin: 0; padding: 14px 20px 18px; display: grid; grid-template-columns: 220px 1fr; gap: 12px 18px; }
dl.defs dt { font-weight: 650; color: var(--ink); }
dl.defs dd { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink-2); }
details.method .eq { overflow-x: auto; margin: 8px 0 12px; }
@media (max-width: 860px) { dl.defs { grid-template-columns: 1fr; gap: 4px 0; } dl.defs dd { margin-bottom: 10px; } }

/* (i) information popover, used on the explorer's concentration card */
.info {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; margin-left: 4px; border-radius: 50%;
  border: 1px solid var(--ink-muted); color: var(--ink-muted);
  font-size: 10px; font-weight: 700; font-style: italic; text-transform: none; letter-spacing: 0;
  cursor: help; vertical-align: 1px;
}
.info .info-pop {
  display: none; position: absolute; z-index: 60; left: 50%; top: 22px; transform: translateX(-50%);
  width: 290px; padding: 11px 13px; background: var(--ink); color: #fff; border-radius: 8px;
  font-size: 13px; font-weight: 400; font-style: normal; line-height: 1.45; text-align: left;
}
.info:hover .info-pop, .info:focus .info-pop { display: block; }
.infocard { overflow: visible; }
.event-grid .event-src { margin-top: 8px; font-size: 12.5px; color: var(--ink-muted); }
