/* GridPop dashboard. Tokens, type and chrome follow the PC-Map dashboard v2
   (Ramathibodi-HPSR/thailand-primary-care) so the two read as one family. */
:root {
  color-scheme: dark;
  --bg: #0b0f15;
  --surface: #111824;
  --surface-2: #172131;
  --hair: rgba(255, 255, 255, .10);
  --line: rgba(255, 255, 255, .22);
  --text: #ffffff;
  --text-2: #d3d1c8;
  --muted: #9b998f;
  --accent: #fb8d94;
  --focus: #ffc2c6;
  --land: #19212f;        /* land with no one on it: lighter than the sea (--bg, 1.19:1), darker than --d1 (1.42:1) */
  --border: #33415a;
  --comparator: #7d8799;  /* comparison layers (WorldPop, house register) in the charts */

  /* People per 1 km cell: one hue (OKLCH h 22, the accent's), lightness rising 0.355 -> 0.96 in even
     steps (delta L 0.067), chroma low at both ends so the countryside recedes and the cities light up,
     while the lowest class still stands off empty land. Checked with the dataviz validator (--ordinal):
     monotone, every step >= 0.06 apart, one hue. */
  --d1: #533130; --d2: #713c3b; --d3: #904746; --d4: #af5353; --d5: #ca6363;
  --d6: #e37675; --d7: #f1928f; --d8: #fbafac; --d9: #ffcecb; --d10: #ffedec;

  /* Compare two: A - B per 1 km cell. Diverging, two hues with a neutral grey midpoint and five equal
     steps per arm: warm (Okabe-Ito orange, OKLCH h 68) = more in A, cool (Okabe-Ito sky blue, h 238) =
     more in B, the hues PC-Map uses. Lightness rises with the size of the difference (0.44 -> 0.86 per
     arm). Checked with the dataviz validator: each arm passes the ordinal checks on --land (monotone,
     steps >= 0.06 apart, one hue, >= 2:1 at its dark end); the two arms pass CVD and normal-vision
     separation at every step. The grey midpoint ("within 10") sits close to empty land (1.19:1), so a
     change map is background where nothing changes and each arm's first step stands 1.7:1 above it. */
  --dvB5: #a1d9ff; --dvB4: #5cb8f1; --dvB3: #3596cc; --dvB2: #2376a4; --dvB1: #19587c;
  --dv0: #2c2e33;
  --dvA1: #744703; --dvA2: #9b5f02; --dvA3: #c37902; --dvA4: #ed9824; --dvA5: #ffc484;

  --serif: "DM Serif Display", Georgia, serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-hero: clamp(2rem, 1.3rem + 2.4vw, 3.3rem);
  --fs-h2: clamp(1.35rem, 1rem + 1.1vw, 1.95rem);
  --fs-body: clamp(1rem, .95rem + .25vw, 1.12rem);
  --fs-small: clamp(.8rem, .76rem + .15vw, .9rem);
  --gutter: clamp(16px, 3vw, 40px);
  --container: 1440px;
  --topbar: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar) + 12px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text-2);
  font: 400 var(--fs-body)/1.6 var(--sans); font-variant-numeric: tabular-nums;
}
h1, h2, h3 { color: var(--text); font-weight: 400; margin: 0 0 .45em; line-height: 1.2; }
h1, h2 { font-family: var(--serif); letter-spacing: .005em; text-wrap: balance; }
h3 { font: 600 1rem/1.4 var(--sans); }
p { margin: 0 0 .8em; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: fixed; left: -999px; top: 8px; z-index: 2000; background: var(--accent); color: var(--bg); padding: 8px 12px; }
.skip:focus { left: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.container { max-width: var(--container); margin-left: auto; margin-right: auto; padding-left: var(--gutter); padding-right: var(--gutter); }
[data-f] { color: var(--text); font-weight: 500; white-space: nowrap; }
.error { background: #4a1d22; color: #fff; padding: 10px var(--gutter); font-size: var(--fs-small); }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 1100; height: var(--topbar);
  display: flex; align-items: center; gap: 18px; padding: 0 var(--gutter);
  background: rgba(11, 15, 21, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--hair);
}
.brand { color: var(--text); text-decoration: none; font-weight: 600; white-space: nowrap; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.brand-long { color: var(--text-2); font-weight: 500; }
.toc { display: flex; gap: 16px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.toc a { color: var(--muted); text-decoration: none; font-size: var(--fs-small); white-space: nowrap; padding: 4px 0; border-bottom: 2px solid transparent; }
.toc a:hover { color: var(--text); }
.toc a.on { color: var(--text); border-bottom-color: var(--accent); }
.badge { font-size: .75rem; color: var(--accent); border: 1px solid rgba(251, 141, 148, .5); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.badge-short { display: none; }

/* hero */
.hero { padding-top: clamp(40px, 7vh, 88px); padding-bottom: 40px; }
.kicker { color: var(--muted); font-size: var(--fs-small); letter-spacing: .06em; text-transform: uppercase; margin-bottom: .9em; }
.hero h1 { font-size: var(--fs-hero); max-width: 22ch; line-height: 1.08; }
.hero-sub { font-size: clamp(1.06rem, 1rem + .4vw, 1.3rem); color: var(--text-2); max-width: 52ch; margin: .3em 0 1em; }
.byline { color: var(--muted); font-size: var(--fs-small); margin-bottom: 1.4em; }
.byline [data-f] { color: var(--text-2); font-weight: 400; }
.lede { color: var(--text-2); max-width: 66ch; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 28px; }
.kpi { border-top: 2px solid var(--accent); padding-top: 12px; }
.kpi-num { font-family: var(--serif); font-size: clamp(2rem, 1.4rem + 2vw, 2.9rem); line-height: 1.05; color: var(--text); }
.kpi-num [data-f] { font-weight: 400; }
.kpi-num small { font-family: var(--sans); font-size: .4em; color: var(--muted); vertical-align: middle; }
.kpi-label { font-size: var(--fs-small); color: var(--text-2); margin-top: 6px; }
.kpi-label [data-f] { font-weight: 400; color: var(--text); }
.kpi-link { display: inline-block; margin-top: 4px; font-weight: 500; white-space: nowrap; }
.kpi-link::after { content: " →"; }
@media (min-width: 1100px) {
  .hero { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr); gap: 56px; align-items: end; }
  .kpis { grid-template-columns: 1fr; margin-top: 0; gap: 22px; }
}

/* sections */
main > section:not(.hero) { padding-top: 44px; padding-bottom: 20px; }
.section-head { margin-bottom: 16px; max-width: 80ch; }
.section-head h2, .card h2 { font-size: var(--fs-h2); }
.section-sub { color: var(--muted); font-size: var(--fs-small); margin: 0; }
.panel { background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; min-width: 0; position: relative; }

/* explorer: the layer list and the province beside the map */
.explorer {
  display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); gap: 16px;
  height: clamp(560px, calc(100svh - var(--topbar) - 40px), 920px);
}
.side { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.map-panel { overflow: hidden; display: flex; flex-direction: column; }
.map-pick { display: none; }
.map-box { position: relative; flex: 1 1 auto; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--bg); }
#map:focus-visible { outline-offset: -3px; border-radius: 12px; }
.map-status { position: absolute; right: 12px; top: 12px; z-index: 500; font-size: .75rem; color: var(--text-2); line-height: 1.45;
  background: rgba(17, 24, 36, .92); border: 1px solid var(--hair); border-radius: 8px; padding: 4px 9px; pointer-events: none; max-width: calc(100% - 90px); }
.map-status .hint { display: block; color: var(--text-2); }
.map-status .hint::before {  /* an "i" mark, so the hint reads as help, not as GridPop's accent */
  content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 5px; vertical-align: -1px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='5.25' fill='none' stroke='%23d3d1c8' stroke-width='1.2'/%3E%3Cpath d='M6 5.2v3.6M6 3.2v.4' stroke='%23d3d1c8' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.ctl-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: .78rem; letter-spacing: .05em; text-transform: uppercase; }

/* the layer list: one radio group of seven layers, grouped by source */
.layers { border: 0; margin: 0; padding: 0; min-width: 0; }
.layers legend { padding: 0; }
.lgrp { padding: 9px 0 8px; border-top: 1px solid var(--hair); }
.layers legend + .lgrp { border-top: 0; padding-top: 2px; }
.lgrp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lgrp-name { color: var(--text); font-weight: 600; font-size: .95rem; }
.lgrp-use { color: var(--muted); font-size: .78rem; line-height: 1.35; margin: 2px 0 0; }
.lgrp-sub { color: var(--muted); font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; margin: 6px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
.lgrp-sub + .lgrp { border-top: 0; padding-top: 4px; }
.chips { display: inline-flex; gap: 6px; flex: none; }
.chip { position: relative; display: inline-block; }
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chip > span { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; min-height: 32px; line-height: 24px;
  font-size: var(--fs-small); color: var(--text-2); }
.chip:hover > span { color: var(--text); border-color: var(--text-2); }
.chip input:checked + span { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 500; }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (hover: none) { .chip > span { min-height: 40px; line-height: 32px; padding: 3px 14px; } }  /* touch tablets, where the list shows */

.seg { display: inline-flex; gap: 6px; }
.seg button {
  border: 1px solid var(--line); background: transparent; color: var(--text-2);
  border-radius: 999px; padding: 4px 12px; font-size: var(--fs-small); min-height: 34px;
}
.seg button:hover:not(:disabled) { color: var(--text); border-color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* map mode: one layer or the difference of two */
.mode-seg { display: flex; width: 100%; gap: 0; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.mode-seg button { flex: 1 1 0; border: 0; min-height: 32px; padding: 4px 10px; font-weight: 500; }
.mode-slot[hidden], .cmp-slot[hidden], .cmp-slot:has(> .cmp-ctl[hidden]) { display: none; }
.cmp-ctl { display: flex; flex-direction: column; gap: 12px; }
.cmp-ctl[hidden] { display: none; }
.cmp-ctl .ctl-label { margin-bottom: 0; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button {
  border: 1px solid var(--line); background: transparent; color: var(--text-2); border-radius: 10px; padding: 6px 10px;
  font-size: .8rem; line-height: 1.3; text-align: left; min-height: 34px;
}
.presets button:hover { color: var(--text); border-color: var(--text-2); }
.presets button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 500; }
.ab { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto; gap: 6px 8px; align-items: center; }
.ab label { display: flex; align-items: center; }
.ab select {
  min-width: 0; min-height: 36px; font: inherit; font-size: .88rem; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px;
}
.ab .lab-a { grid-column: 1; grid-row: 1; } .ab #cmp-a { grid-column: 2; grid-row: 1; }
.ab .lab-b { grid-column: 1; grid-row: 2; } .ab #cmp-b { grid-column: 2; grid-row: 2; }
.swap-btn {
  grid-column: 3; grid-row: 1 / 3; align-self: stretch; border: 1px solid var(--line); background: transparent; color: var(--text-2);
  border-radius: 8px; padding: 0 10px; font-size: 1.05rem; min-width: 40px;
}
.swap-btn:hover { color: var(--text); border-color: var(--text-2); }
/* the A and B keys: a letter in text colour beside a swatch of its side of the scale */
.ab-key { display: inline-flex; align-items: center; gap: 4px; font: 600 .78rem/1 var(--sans); color: var(--text); margin-right: 6px; }
.ab-key::before { content: ""; width: 10px; height: 10px; border-radius: 2px; }
.ab-key.ab-a::before { background: var(--dvA3); }   /* the middle step: between the brown dark end and the light end */
.ab-key.ab-b::before { background: var(--dvB3); }
/* in the preset chips, a dot before the A half and the B half */
.presets .pa::before, .presets .pb::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; }
.presets .pa::before { background: var(--dvA3); }
.presets .pb::before { background: var(--dvB3); }
.ctl-note { text-transform: none; letter-spacing: 0; color: var(--muted); font-size: .74rem; margin-left: 6px; }
.cmp-fold { display: none; margin: 0; font-size: .88rem; color: var(--text-2); padding-right: 3.2em; }
.cmp-fold b { color: var(--text); font-weight: 600; }
.layer-cards.collapsed .cmp-card h3, .layer-cards.collapsed .cmp-dl { display: none; }
.layer-cards.collapsed .cmp-fold { display: block; }
.cmp-card h3 { margin-bottom: 6px; }
.cmp-dl { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 0 0 8px; font-size: .88rem; }
.cmp-dl dt { color: var(--text-2); display: flex; align-items: center; }
.cmp-dl dd { margin: 0; color: var(--text); text-align: right; font-weight: 500; }
.cmp-dl dt.diff, .cmp-dl dt.diff + dd { border-top: 1px solid var(--hair); padding-top: 3px; margin-top: 2px; }
.cmp-dl dd.big { font-family: var(--serif); font-weight: 400; font-size: 1.2rem; }

/* the layer card and the province card */
.layer-cards { position: relative; border-top: 1px solid var(--line); padding-top: 14px; }
.layer-card h3 { margin-bottom: 2px; }
.layer-total { font-family: var(--serif); font-size: 1.7rem; color: var(--text); line-height: 1.15; margin-bottom: 6px; }
.layer-total [data-f] { font-weight: 400; }
.layer-more p { font-size: var(--fs-small); }
.layer-more p:last-child { margin-bottom: 0; }
.layer-use { display: none; }
.layer-cards.collapsed .layer-more, .layer-cards.collapsed .layer-use { display: none !important; }
.layer-cards.collapsed .layer-total { font-size: 1.25rem; margin-bottom: 0; }
.layer-cards:has(.more-btn:not([hidden])) h3 { padding-right: 3.2em; }
.link-btn { background: none; border: 0; color: var(--accent); font-size: var(--fs-small); padding: 2px 0; }
.more-btn { position: absolute; top: 14px; right: 0; }
.prov-card { border-top: 1px solid var(--line); padding-top: 14px; }
.prov-card:focus-visible { outline-offset: 4px; }
.prov-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.prov-head h3 { font: 400 1.35rem/1.2 var(--serif); margin: 0; }
.prov-card dl { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 8px 0 0; font-size: .84rem; }
.prov-card dt { color: var(--muted); padding-left: 8px; }
.prov-card dd { margin: 0; color: var(--text-2); text-align: right; }
.prov-card dt.on { color: var(--text); font-weight: 600; box-shadow: inset 2px 0 0 var(--text); }
.prov-card dt.on + dd { color: var(--text); font-weight: 600; }
.prov-card dt.sep, .prov-card dt.sep + dd { margin-top: 6px; }
.prov-card dt.wrap { line-height: 1.35; }
.prov-card dt .ab-key { margin-right: 4px; }
.prov-empty { color: var(--muted); font-size: var(--fs-small); margin: 0; border-top: 1px solid var(--hair); padding-top: 12px; }

/* the legend, on the map */
.map-legend {
  position: absolute; right: 12px; bottom: 24px; z-index: 500; width: 264px; background: rgba(17, 24, 36, .94);
  border: 1px solid var(--hair); border-radius: 10px; padding: 9px 12px 8px; font-size: .78rem; color: var(--text-2);
}
.map-legend .ttl { color: var(--text); font-weight: 500; line-height: 1.3; margin-bottom: 6px; padding-right: 26px; }
.map-legend .lg-toggle { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; padding: 0; border: 1px solid var(--hair); border-radius: 6px;
  background: transparent; color: var(--text-2); font: 500 .95rem/1 var(--sans); }
.map-legend .lg-toggle:hover { color: var(--text); border-color: var(--line); }
.map-legend.short .row, .map-legend.short .note { display: none; }
.map-legend .ttl .avg { display: block; color: var(--muted); font-weight: 400; font-size: .72rem; }
.map-legend .ramp { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.map-legend .ramp span { height: 12px; border-radius: 2px; }
.map-legend .ramp span:first-child { border-radius: 4px 2px 2px 4px; }
.map-legend .ramp span:last-child { border-radius: 2px 4px 4px 2px; }
.map-legend .ticks { position: relative; height: 1.2em; color: var(--muted); font-size: .7rem; margin-top: 3px; }
.map-legend .ticks span { position: absolute; top: 0; transform: translateX(-50%); }
.map-legend .row { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--text-2); }
.map-legend .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.map-legend .sw.none { background: var(--land); border-radius: 2px; box-shadow: inset 0 0 0 1px var(--line); }  /* a sample of empty land, not a checkbox */
.map-legend .note { color: var(--muted); font-size: .7rem; line-height: 1.4; margin-top: 4px; }
.map-legend .ramp.dv { grid-template-columns: repeat(11, 1fr); }
.map-legend .ramp.dv span:nth-child(6) { box-shadow: inset 0 0 0 1px var(--line); }  /* the neutral midpoint */
.map-legend .ends { display: flex; justify-content: space-between; gap: 10px; font-size: .7rem; line-height: 1.3; color: var(--muted); margin-top: 2px; }
.map-legend .ends b { color: var(--text-2); font-weight: 500; }
.map-legend .ends .end-a { text-align: right; }

.leaflet-container { font-family: var(--sans); background: var(--bg); }
.leaflet-control-attribution { background: rgba(11, 15, 21, .7) !important; color: var(--muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--text-2) !important; }
.leaflet-bar a, .leaflet-bar button { background: var(--surface-2); color: var(--text); border-color: var(--hair); }
.leaflet-bar a:hover, .leaflet-bar button:hover { background: var(--surface); color: var(--text); }
.leaflet-bar.home-ctl button { border: 0; border-radius: 4px; font: 500 .75rem/1 var(--sans); padding: 8px 10px; min-height: 32px; }
.leaflet-bar.move-ctl button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.leaflet-control-scale-line { background: rgba(11, 15, 21, .75); color: var(--text-2); border-color: var(--text-2); font-size: 10px; }
.gridpop-tiles { image-rendering: pixelated; }

#tip {
  position: fixed; z-index: 2000; pointer-events: none; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: .8rem; line-height: 1.5;
  max-width: 300px; box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
#tip .t-head { font-weight: 600; }
#tip .t-sub { color: var(--muted); }
#tip .t-foot { color: var(--muted); font-size: .74rem; margin-top: 4px; }
#tip table { border-collapse: collapse; margin-top: 4px; }
#tip td { padding: 0 0 0 10px; text-align: right; }
#tip td:first-child { padding-left: 0; text-align: left; color: var(--text-2); }
#tip tr.on td { color: var(--text); font-weight: 600; }
#tip tr.diff td { color: var(--text); font-weight: 600; border-top: 1px solid var(--line); }
#tip tr.rest td { border-top: 1px solid var(--hair); padding-top: 2px; }
#tip .ab-key { margin-right: 4px; }

/* province table */
.table-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 10px; }
.search input {
  background: var(--surface); border: 1px solid var(--line); color: var(--text); border-radius: 999px;
  padding: 6px 14px; font: inherit; font-size: var(--fs-small); min-height: 34px; width: 220px; max-width: 100%;
}
.search input::placeholder { color: var(--muted); }
.dl-link { font-size: var(--fs-small); margin-left: auto; }
.table-note { color: var(--muted); font-size: .8rem; margin-bottom: 8px; }
.table-frame { position: relative; }
.table-frame::after {  /* a fade at the right edge while more columns sit off screen */
  content: ""; position: absolute; top: 1px; right: 1px; bottom: 1px; width: 36px; pointer-events: none; border-radius: 0 12px 12px 0;
  background: linear-gradient(to right, rgba(17, 24, 36, 0), var(--surface)); opacity: 0; transition: opacity .15s;
}
.table-frame.more-right::after { opacity: 1; }
.table-wrap { max-height: 560px; overflow: auto; border: 1px solid var(--hair); border-radius: 12px; background: var(--surface); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: var(--fs-small); }
th, td { padding: 7px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--hair); }
th:first-child, td:first-child { text-align: left; }
tr > :first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: inset -1px 0 0 var(--hair); }
thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-2); font-weight: 500; vertical-align: bottom; }
thead tr > :first-child { z-index: 3; background: var(--surface-2); }
thead th button { all: unset; cursor: pointer; display: inline-block; white-space: normal; max-width: 14ch; line-height: 1.3; }
thead th button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
thead th .sort { color: var(--muted); }
thead th .th-sub { display: block; color: var(--muted); font-size: .74rem; font-weight: 400; }
thead th[aria-sort="ascending"] .sort, thead th[aria-sort="descending"] .sort { color: var(--accent); }
thead th.layer-on { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
thead th[data-ab="A"] { box-shadow: inset 0 -3px 0 var(--dvA3); }
thead th[data-ab="B"] { box-shadow: inset 0 -3px 0 var(--dvB3); }
thead th[data-ab="AB"] { box-shadow: inset 0 -3px 0 var(--text-2); }
thead th[data-ab] button { max-width: 24ch; }

tbody tr { cursor: pointer; }
tbody tr:hover > * { background-color: #1b212d; }
tbody tr.sel > * { background-color: #2d2631; }  /* --surface with 12% of --accent, opaque for the sticky column */
/* the focus ring drawn on the cells, so the sticky province cell carries it too */
tbody tr:focus-visible { outline: none; }
tbody tr:focus-visible > * { box-shadow: inset 0 3px 0 var(--focus), inset 0 -3px 0 var(--focus); }
tbody tr:focus-visible > :first-child { box-shadow: inset 3px 0 0 var(--focus), inset 0 3px 0 var(--focus), inset 0 -3px 0 var(--focus); }
tbody tr:focus-visible > :last-child { box-shadow: inset -3px 0 0 var(--focus), inset 0 3px 0 var(--focus), inset 0 -3px 0 var(--focus); }
tbody tr:focus-visible:not(.sel) > * { background-color: #1b212d; }
tbody th { font-weight: 400; color: var(--text); }
tbody td { color: var(--text-2); }
tbody tr.empty td { text-align: left; color: var(--muted); cursor: default; position: static; }
tfoot th, tfoot td { position: sticky; bottom: 0; background: var(--surface-2); color: var(--text); border-top: 1px solid var(--line); border-bottom: 0; }
tfoot tr > :first-child { z-index: 3; background: var(--surface-2); }
tfoot [data-f] { font-weight: 500; }

/* accuracy and access */
.findings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.card { padding: 22px 24px; }
.card h3 { margin-top: 1.3em; }
.card .key + h3 { margin-top: .6em; }
.card p { font-size: var(--fs-small); }
.card-note { color: var(--muted); }
.card-note [data-f] { color: var(--text-2); }
.h-note { color: var(--muted); font-weight: 400; }
.key { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .78rem !important; margin: -4px 0 0; }
.key .sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.key .sw.ours { background: var(--accent); }
.key .sw.cmp { background: var(--comparator); margin-left: 10px; }

.bars, .dots { list-style: none; margin: 10px 0 14px; padding: 0; display: grid; }
.bars { gap: 6px; }
.bars li, .dots li { display: grid; grid-template-columns: minmax(0, 14rem) minmax(80px, 1fr); gap: 12px; align-items: center; font-size: var(--fs-small); }
.b-label { color: var(--text-2); line-height: 1.3; }
li.ours .b-label { color: var(--text); }
/* the plot area leaves room after the longest bar for its value */
.b-plot, .d-plot { position: relative; display: block; height: 16px; margin-right: 3.6rem; }
.b-plot { border-left: 1px solid var(--line); }
.b-plot::after { content: ""; position: absolute; right: 0; top: -3px; bottom: -3px; border-right: 1px dashed var(--line); }
.b-fill { position: absolute; left: 0; top: 1px; bottom: 1px; width: var(--w); background: var(--comparator); border-radius: 0 4px 4px 0; }
li.ours .b-fill { background: var(--accent); }
.b-val, .d-val { position: absolute; top: 50%; transform: translateY(-50%); white-space: nowrap; line-height: 1; }
.b-val { left: calc(var(--w) + 6px); }
.b-val [data-f], .d-val [data-f] { font-weight: 500; }
.b-axis, .d-axis { height: 1.3em; }
.b-axis .b-plot, .d-axis .d-plot { height: 1.3em; border-left: 0; }
.b-axis .b-plot::after { display: none; }
.axis-l { position: absolute; top: 0; left: 0; color: var(--muted); font-size: .72rem; line-height: 1.3; }
.axis-l.end { left: auto; right: 0; transform: translateX(50%); }
.axis-break {  /* the axis does not start at zero: a zig-zag cut in the axis line near its start */
  position: absolute; left: 14px; top: -6px; width: 14px; height: 11px; background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 11'%3E%3Cpath d='M0 5.5h3l2-4 4 8 2-4h3' fill='none' stroke='%239b998f' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px 11px no-repeat;
}
.d-axis .axis-l:not(.end) { transform: translateX(-50%); }

.dots li:not(.d-axis) { min-height: 28px; }
.dots .d-plot { height: 28px; background: linear-gradient(var(--hair), var(--hair)) 0 50% / 100% 1px no-repeat; }
.dots .d-plot::before { content: ""; position: absolute; top: 0; bottom: 0; left: var(--g); border-left: 1.5px dashed var(--text-2); opacity: .55; }
.dots .d-axis .d-plot { background: none; border-top: 1px solid var(--line); }
.dots .d-axis .d-plot::before { display: none; }
.d-dot { position: absolute; top: 50%; left: var(--x); width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%;
  background: var(--comparator); box-shadow: 0 0 0 2px var(--surface); }
li.ours .d-dot { background: var(--accent); }
.d-val { left: calc(var(--x) + 11px); padding: 1px 3px; background: var(--surface); border-radius: 3px; }

/* data */
.dl-now { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 4px 0 18px; }
.btn-primary { display: inline-block; background: var(--text); color: var(--bg); text-decoration: none; font-weight: 600; font-size: var(--fs-small);
  border-radius: 999px; padding: 8px 18px; }
.btn-primary:hover { background: var(--focus); }
.dl-now-note { color: var(--muted); font-size: var(--fs-small); }
.dl-status { color: var(--text-2); font-size: var(--fs-small); margin-bottom: 6px; }
.todo { color: var(--accent); }
.planned { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 18px; max-width: 980px; }
.planned li { display: flex; flex-direction: column; padding: 8px 0; border-top: 1px solid var(--hair); color: var(--muted); font-size: var(--fs-small); }
.pl-name { color: var(--text-2); }
.pl-meta { font-size: .78rem; }
.cite { font-size: var(--fs-small); color: var(--muted); max-width: 90ch; }
.cite strong { color: var(--text-2); font-weight: 500; }

/* methods */
.methods { padding-top: 60px; padding-bottom: 80px; border-top: 1px solid var(--hair); margin-top: 40px; }
.methods h2 { font-size: var(--fs-h2); margin-bottom: .1em; }
.methods .cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; margin-top: 18px; }
.methods ul { padding-left: 1.1em; margin: 0; font-size: var(--fs-small); }
.methods li { margin-bottom: .55em; }
.credits { font-size: var(--fs-small); color: var(--muted); margin-top: 24px; }

/* zoom buttons only where there is a mouse */
@media (hover: none) { .leaflet-control-zoom { display: none; } }
@media (max-width: 1100px) {
  .findings { grid-template-columns: 1fr; }
}
/* phones and narrow windows: a compact picker, the map with its legend strip, then the cards */
@media (max-width: 900px) {
  .toc { display: none; }
  .badge-long { display: none; }
  .badge-short { display: inline; }
  .topbar { gap: 8px; }
  .brand { font-size: .88rem; flex: 1 1 auto; }
  .kpis { grid-template-columns: 1fr; gap: 14px; }
  .explorer { display: flex; flex-direction: column; height: auto; }
  .map-panel { order: -1; }
  .map-pick { display: flex; flex-direction: column; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--hair); }
  .pick-one { display: flex; align-items: center; gap: 10px; }
  .pick-one[hidden] { display: none; }
  .map-pick .ctl-label { margin: 0; flex: none; }
  .map-pick .cmp-ctl { gap: 8px; }
  .map-pick .cmp-ctl > .ctl-label { display: none; }
  .map-pick .presets { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -10px; padding: 0 10px; }
  .map-pick .presets button { flex: none; white-space: nowrap; min-height: 36px; }
  .pick-one select {
    flex: 1 1 auto; min-width: 0; min-height: 38px; font: inherit; font-size: .92rem; color: var(--text); background: var(--surface-2);
    border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  }
  .map-box { flex: none; }
  #map { position: relative; inset: auto; height: 52svh; min-height: 300px; }
  #map:focus-visible { border-radius: 0; }
  .map-legend { position: static; width: auto; border: 0; border-top: 1px solid var(--hair); border-radius: 0; padding: 6px 10px 7px;
    display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 2px 10px; font-size: .7rem; }
  .map-legend .ttl { margin: 0; padding: 0; font-size: .72rem; max-width: 9.5em; }
  .map-legend .lg-toggle { display: none; }
  .map-legend.short .row, .map-legend.short .note { display: flex; }
  .map-legend.short .note { display: block; }
  .map-legend .ttl .avg { font-size: .66rem; }
  .map-legend .ramp span { height: 10px; }
  .map-legend .ticks { font-size: .64rem; margin-top: 1px; }
  .map-legend .row, .map-legend .note { grid-column: 1 / -1; margin-top: 0; font-size: .66rem; }
  .map-legend .row { gap: 6px; }
  .map-legend .sw { width: 10px; height: 10px; }
  .map-legend .scale-box { min-width: 0; }
  .map-status { right: 8px; top: 8px; font-size: .7rem; max-width: calc(100% - 128px); }
  .map-status .st-round { display: none; }  /* the legend strip says it */
  .side { overflow: visible; }
  .layers { display: none; }
  .layer-cards { border-top: 0; padding-top: 0; }
  .layer-use { display: block; color: var(--muted); font-size: var(--fs-small); margin-bottom: 6px; }
  .prov-card:not([hidden]) + .layer-cards { border-top: 1px solid var(--line); padding-top: 14px; }
  .prov-card { border-top: 0; padding-top: 0; }
  .bars li, .dots li { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .bars li.b-axis .b-label, .dots li.d-axis .b-label { display: none; }
  .card { padding: 18px 16px; }
  .methods .cols { grid-template-columns: 1fr; }
  .dl-link { margin-left: 0; }
  .table-wrap { max-height: 55svh; }
}
@media (max-width: 430px) { .brand-long { display: none; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .table-frame::after { transition: none; } }
/* a narrow window with a mouse: the preset chips wrap, since a wheel cannot scroll the row */
@media (max-width: 900px) and (hover: hover) {
  .map-pick .presets { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
}
