/* Landing map (/map), after style.css, on that page only: every rule is scoped to body[data-page="map"]. The map fills
   the window, the header floats over it, the footer's links sit in a corner. Both themes follow the device (the --map-*
   colours and the shared tokens the header reads). Overlay positions come from landing.js (--x / --y). Until its first
   good frame (and without script, and on the static tier) the outline map and the county list show. */
body[data-page="map"] {
  --map-bg: #06141b; --map-fg: #cfe8e0; --map-muted: #8fb2a8; --map-line: rgba(160,220,200,.16);
  --map-glass: rgba(9,28,36,.52); --map-glass-hi: rgba(160,230,210,.1); --map-panel: rgba(7,22,29,.9);
  --map-accent: #8be28b; --map-teal: #1f8a8a; --map-label: #eafff2; --map-label-edge: rgba(2,10,13,.85);
  --map-fill: rgba(31,138,138,.22); --map-fill-hi: rgba(139,226,139,.3); --map-rain: rgba(190,225,235,.22);
  --map-shadow: 0 12px 40px rgba(0,0,0,.35);
  --bg: #06141b; --ink: #dfe3e2; --muted: #adb8bb; --field: rgba(74,92,106,.3); --field-hover: rgba(74,92,106,.46);
  --accent: #ccd0cf; --accent-hover: #fff; --accent-ink: #06141b; --accent-soft: rgba(155,168,171,.16);
  --hairline: #22323d; --line: #1c2c37; --glass: #11212d; --glass-strong: #162a38; --pop-bg: #172b39;
  --ring: rgba(155,168,171,.4); --shadow-pop: 0 16px 48px rgba(0,0,0,.55);
  --accent-terra: #c4744f;
  background: var(--map-bg);
  color: var(--map-fg);
  overflow: hidden;
}
@media (prefers-color-scheme: light) {
  body[data-page="map"] {
    color-scheme: light;
    --map-bg: #edeae6; --map-fg: #1c2a2a; --map-muted: #4f605c; --map-line: rgba(30,50,50,.16);
    --map-glass: rgba(250,248,244,.62); --map-glass-hi: rgba(255,255,255,.55); --map-panel: rgba(250,248,244,.95);
    --map-accent: #2d8a3a; --map-teal: #0d6767; --map-label: #10201f; --map-label-edge: rgba(250,248,244,.9);
    --map-fill: rgba(13,103,103,.16); --map-fill-hi: rgba(45,138,58,.26); --map-rain: rgba(40,70,90,.2);
    --map-shadow: 0 12px 40px rgba(30,40,40,.18);
    --bg: #edeae6; --ink: #1c2a2a; --muted: #4f5f5c; --field: rgba(30,50,50,.08); --field-hover: rgba(30,50,50,.14);
    --accent: #1f3b3b; --accent-hover: #0b2222; --accent-ink: #f7f5f2; --accent-soft: rgba(30,60,60,.12);
    --hairline: rgba(30,50,50,.16); --line: rgba(30,50,50,.12); --glass: rgba(250,248,244,.8);
    --glass-strong: #f7f5f2; --pop-bg: #f7f5f2; --ring: rgba(13,103,103,.45); --shadow-pop: 0 16px 48px rgba(30,40,40,.2);
    --accent-terra: #b66d4c;
  }
}
html:has(> body[data-page="map"]) { overflow: hidden; scrollbar-gutter: auto; }

/* ---- the shell: a floating header, a full-window main, the footer's links in a corner ---- */
body[data-page="map"] header.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50; background: transparent; border-bottom: 0; pointer-events: none;
  --capsule-bg: var(--map-glass); --capsule-line: var(--map-line);
}
body[data-page="map"] header.top :is(.brand, .links, details.more, .who) { pointer-events: auto; }
body[data-page="map"] header.top .brand { text-shadow: 0 0 6px var(--map-bg); }
body[data-page="map"] main {
  position: fixed; inset: 0; z-index: 0; margin: 0; padding: 0; overflow: hidden;
  --map-narrow: "Arial Narrow", "Roboto Condensed", "Liberation Sans Narrow", sans-serif;
}
body[data-page="map"] main > .notice { position: fixed; z-index: 8; top: 80px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); }
body[data-page="map"] .site-footer {
  position: fixed; z-index: 5; right: 18px; bottom: 10px; margin: 0; padding: 0; border: 0; background: none;
}
body[data-page="map"] .site-footer .foot-brand { display: none; }
body[data-page="map"] .site-footer nav { gap: 2px 12px; }
body[data-page="map"] .site-footer nav a { min-height: 0; min-width: 0; font-size: 11px; color: var(--map-muted); text-shadow: 0 0 4px var(--map-bg); }

/* ---- the stage: the canvas (shown after its first good frame) over the outline map ---- */
body[data-page="map"] .map-stage { position: absolute; inset: 0; }
body[data-page="map"] .map-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; display: block; touch-action: none; cursor: crosshair;
  visibility: hidden; pointer-events: none;
}
body[data-page="map"].map-live .map-canvas { visibility: visible; pointer-events: auto; }
body[data-page="map"] .map-svg { position: absolute; top: 80px; left: 16px; width: calc(100% - 32px); height: calc(100% - 230px); }
body[data-page="map"].map-live .map-svg { display: none; }
body[data-page="map"] .map-area {
  fill: var(--map-fill); stroke: var(--map-accent); stroke-width: 1.2; vector-effect: non-scaling-stroke; transition: fill .15s;
}
body[data-page="map"] .map-svg a:hover .map-area { fill: var(--map-fill-hi); }

/* ---- overlays ---- */
body[data-page="map"] .map-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
body[data-page="map"]:not(.map-live) .map-labels,
body[data-page="map"]:not(.map-live) .map-rain { display: none; }
body[data-page="map"] .map-labels > * {
  position: absolute; left: 0; top: 0; transform: translate3d(var(--x, -999px), var(--y, -999px), 0); will-change: transform;
}
body[data-page="map"] .county-label {
  font-family: var(--map-narrow); font-stretch: condensed; font-weight: 700; text-transform: uppercase; letter-spacing: .32em;
  font-size: clamp(18px, 3vw, 46px); line-height: 1; color: var(--map-label); white-space: nowrap; opacity: 0; transition: opacity .18s;
  margin-left: .16em; translate: -50% -50%;
  text-shadow: 0 0 2px var(--map-label-edge), 0 0 6px var(--map-label-edge), 0 1px 0 var(--map-label-edge);
}
body[data-page="map"] .county-label.show { opacity: .94; }
body[data-page="map"] .reticle {
  width: 34px; height: 34px; translate: -50% -50%; border-radius: 50%; border: 1.5px solid var(--map-label); opacity: 0;
  transition: opacity .15s, width .15s, height .15s;
  mask: conic-gradient(from 22deg, #000 0 46deg, transparent 0 90deg, #000 0 136deg, transparent 0 180deg, #000 0 226deg, transparent 0 270deg, #000 0 316deg, transparent 0);
}
body[data-page="map"] .reticle.show { opacity: .55; }
body[data-page="map"] .reticle.on-county { width: 42px; height: 42px; opacity: .9; }
body[data-page="map"] .city { display: flex; align-items: center; gap: 6px; opacity: 0; transition: opacity .2s; translate: -5px -50%; }
body[data-page="map"] .city.show { opacity: 1; }
body[data-page="map"] .city-ring {
  width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--map-label); flex: none; box-shadow: 0 0 0 1px var(--map-label-edge);
}
body[data-page="map"] .city-name {
  font: 600 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--map-label); white-space: nowrap;
  text-shadow: 0 0 2px var(--map-label-edge), 0 0 4px var(--map-label-edge);
}

/* ---- rain: a CSS-only layer, no script frames ---- */
body[data-page="map"] .map-rain { position: absolute; inset: 0; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity .8s; }
body[data-page="map"] .map-rain.on { opacity: .45; }
body[data-page="map"] .map-rain.heavy { opacity: .7; }
body[data-page="map"] .map-rain::before,
body[data-page="map"] .map-rain::after {
  content: ""; position: absolute; inset: -160px 0 0 -160px; width: calc(100% + 320px); height: calc(100% + 320px);
  background-image: repeating-linear-gradient(105deg, transparent 0 22px, var(--map-rain) 22px 23px, transparent 23px 61px);
  background-size: 61px 140px; animation: map-rain-fall .55s linear infinite;
}
body[data-page="map"] .map-rain::after { display: none; background-size: 37px 90px; animation-duration: .4s; opacity: .8; }
body[data-page="map"] .map-rain.heavy::after { display: block; }
@keyframes map-rain-fall { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-37px, 140px, 0); } }

/* ---- readouts ---- */
body[data-page="map"] .map-weather,
body[data-page="map"] .map-credit { position: fixed; z-index: 5; left: 18px; bottom: 34px; margin: 0; font-size: 11px; }
body[data-page="map"] .map-credit a { color: var(--map-muted); text-shadow: 0 0 4px var(--map-bg); text-decoration: none; }
body[data-page="map"] .map-readout { position: fixed; z-index: 5; pointer-events: none; text-shadow: 0 0 4px var(--map-bg); }
body[data-page="map"] .map-weather {
  left: 18px; bottom: 14px; max-width: 46vw; font: 600 11px/1.3 var(--mono); letter-spacing: .1em; color: var(--map-muted);
}
body[data-page="map"] .map-readout { right: 18px; bottom: 34px; text-align: right; display: flex; flex-direction: column; gap: 2px; }
body[data-page="map"] .readout-name { font: 700 15px/1.1 var(--map-narrow); letter-spacing: .14em; text-transform: uppercase; color: var(--map-fg); }
body[data-page="map"] .readout-line { font: 12px/1.2 var(--mono); color: var(--map-muted); }

/* ---- the county list: chips; over the animated map on a wide screen, off screen until focused ---- */
body[data-page="map"] .map-counties { position: fixed; z-index: 6; left: 18px; bottom: 44px; max-width: min(760px, 60vw); }
body[data-page="map"] .map-counties ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
body[data-page="map"] .county-link {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12px; white-space: nowrap;
  color: var(--map-fg); text-decoration: none; background: var(--map-glass); border: 1px solid var(--map-line);
  backdrop-filter: blur(10px);
}
body[data-page="map"] .county-link:hover { border-color: var(--map-accent); text-decoration: none; }
body[data-page="map"] .county-link.pinned { border-color: var(--map-accent); color: var(--map-accent); }
body[data-page="map"] .cl-name { font-weight: 650; }
body[data-page="map"] .cl-n { font: 11px/1.2 var(--mono); color: var(--map-muted); }
@media (min-width: 761px) {
  body[data-page="map"].map-live .map-counties:not(:focus-within) { width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

/* ---- the pinned county's panel ---- */
body[data-page="map"] .map-panel {
  position: fixed; z-index: 6; right: 16px; top: 80px; width: min(340px, calc(100vw - 32px)); max-height: calc(100vh - 160px); overflow: auto;
  padding: 18px 18px 14px; border-radius: 16px; background: var(--map-panel); border: 1px solid var(--map-line);
  backdrop-filter: blur(16px); box-shadow: var(--map-shadow); color: var(--map-fg);
}
body[data-page="map"] .map-panel-close {
  position: absolute; right: 8px; top: 6px; min-height: 36px; min-width: 36px; margin: 0; padding: 0; border: 0; background: none;
  color: var(--map-muted); font-size: 22px; line-height: 1;
}
body[data-page="map"] .map-panel-close:hover { background: var(--field); color: var(--map-fg); }
body[data-page="map"] .panel-title {
  margin: 0 32px 4px 0; font: 700 22px/1.1 var(--map-narrow); letter-spacing: .08em; text-transform: uppercase; color: var(--map-fg);
}
body[data-page="map"] .panel-title:focus { outline: none; }
body[data-page="map"] .panel-title:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
body[data-page="map"] .panel-totals { margin: 0 0 8px; color: var(--map-muted); font: 12px/1.3 var(--mono); }
body[data-page="map"] .panel-all { font-size: 13px; font-weight: 600; color: var(--map-accent); }
body[data-page="map"] .panel-h { margin: 14px 0 6px; font: 600 11px/1.3 var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--map-muted); }
body[data-page="map"] .panel-list { list-style: none; margin: 0; padding: 0; }
body[data-page="map"] .panel-list li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-top: 1px solid var(--map-line); }
body[data-page="map"] .panel-list a { color: var(--map-fg); text-decoration: none; min-width: 0; overflow-wrap: anywhere; }
body[data-page="map"] .panel-list a:hover { text-decoration: underline; }
body[data-page="map"] .panel-n { color: var(--map-muted); font: 12px/1.6 var(--mono); white-space: nowrap; }

/* ---- #debug ---- */
body[data-page="map"] .map-debug {
  position: fixed; z-index: 8; left: 16px; top: 80px; margin: 0; padding: 8px 10px; border-radius: 8px; max-width: 46vw;
  font: 11px/1.4 var(--mono); color: var(--map-fg); background: var(--map-panel); border: 1px solid var(--map-line);
  white-space: pre-wrap; pointer-events: none;
}

/* ---- narrow screens: the county chips are the main control ---- */
@media (max-width: 760px) {
  /* no blur over the moving map on a phone: a denser plain fill */
  body[data-page="map"] header.top { --capsule-bg: var(--map-panel); }
  body[data-page="map"] header.top :is(.links, summary, .signin) { -webkit-backdrop-filter: none; backdrop-filter: none; }
  body[data-page="map"] .map-svg { top: 104px; left: 12px; width: calc(100% - 24px); height: calc(100% - 240px); }
  body[data-page="map"] .map-counties { left: 0; right: 0; bottom: 78px; max-width: none; padding: 0 12px; }
  body[data-page="map"] .map-counties ul { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  body[data-page="map"] .county-link { padding: 8px 12px; font-size: 13px; }
  body[data-page="map"].map-live .cl-n { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  body[data-page="map"] .map-weather { left: 12px; bottom: 34px; max-width: 50vw; font-size: 10px; }
  body[data-page="map"] .map-readout { right: 12px; bottom: 34px; }
  body[data-page="map"] .readout-name { font-size: 13px; }
  body[data-page="map"] .site-footer { left: 0; right: 0; bottom: 4px; }
  body[data-page="map"] .map-credit { left: 0; right: 0; bottom: 54px; text-align: center; }
  body[data-page="map"] .site-footer .foot-row { justify-content: center; }
  body[data-page="map"] .site-footer nav a { min-height: 26px; }
  body[data-page="map"] .map-panel { left: 12px; right: 12px; top: auto; bottom: 128px; width: auto; max-height: 46vh; }
  body[data-page="map"] .map-debug { top: 108px; left: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  body[data-page="map"] .map-rain::before,
  body[data-page="map"] .map-rain::after { animation: none; }
  body[data-page="map"] .county-label,
  body[data-page="map"] .reticle,
  body[data-page="map"] .city,
  body[data-page="map"] .map-area { transition: none; }
}
