/* data-center dashboard.
   Look: a county planning sheet. Light is a blueline print (white paper, ink
   and linework in blue-black), dark is the blueprint of the same sheet. The
   data ramps are the paper's figure palette (analysis/figures.py); the dark
   ramp runs the other way so "more" always moves away from the surface. */

@font-face {
  font-family: "Overpass";
  src: url(/fonts/overpass-latin-wght-normal.woff2) format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --plane: #edf0f5;
  --surface: #ffffff;
  --land: #fbfcfe;
  --ink: #101c30;
  --ink-2: #414e68;
  --muted: #647089;
  --line: #d5dbe6;
  --line-strong: #98a5bb;
  --county-line: #c5cedc;
  --state-line: #5a6c8c;
  --link: #1c5cab;
  --s1: #cde2fb; --s2: #86b6ef; --s3: #3987e5; --s4: #1c5cab; --s5: #0d366b;
  --d0: #1c5cab; --d1: #3987e5; --d2: #86b6ef; --d3: #e3e5ea; --d4: #eba6a6; --d5: #d96a6a; --d6: #b93030;
  --na-line: #b4bfd0;
  --site: #eb6834;
  --bar: #86b6ef; --bar-on: #1c5cab;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #0a1422;
    --surface: #101c2e;
    --land: #17253b;
    --ink: #f1f5fb;
    --ink-2: #bcc7d9;
    --muted: #8a98b0;
    --line: #24344e;
    --line-strong: #43577a;
    --county-line: #2b3d5c;
    --state-line: #8298bd;
    --link: #86b6ef;
    --s1: #184f95; --s2: #256abf; --s3: #3987e5; --s4: #86b6ef; --s5: #cde2fb;
    --d0: #9ec5f4; --d1: #3987e5; --d2: #1c5cab; --d3: #2c3a55; --d4: #8e3535; --d5: #d96a6a; --d6: #f2b0b0;
    --na-line: #3a4d6e;
    --site: #d95926;
    --bar: #256abf; --bar-on: #86b6ef;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0a1422;
  --surface: #101c2e;
  --land: #17253b;
  --ink: #f1f5fb;
  --ink-2: #bcc7d9;
  --muted: #8a98b0;
  --line: #24344e;
  --line-strong: #43577a;
  --county-line: #2b3d5c;
  --state-line: #8298bd;
  --link: #86b6ef;
  --s1: #184f95; --s2: #256abf; --s3: #3987e5; --s4: #86b6ef; --s5: #cde2fb;
  --d0: #9ec5f4; --d1: #3987e5; --d2: #1c5cab; --d3: #2c3a55; --d4: #8e3535; --d5: #d96a6a; --d6: #f2b0b0;
  --na-line: #3a4d6e;
  --site: #d95926;
  --bar: #256abf; --bar-on: #86b6ef;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0;
  font: 400 14px/1.5 "Overpass", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--plane);
  -webkit-text-size-adjust: 100%;
}
h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--link); text-underline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 6px 10px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---- header ---- */

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  height: 56px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--line-strong);
}
.brand { margin: 0; font: inherit; }
.brand a { display: flex; align-items: baseline; gap: 10px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand strong { font-size: 19px; font-weight: 850; letter-spacing: -.01em; }
.brand span { font-size: 13px; color: var(--muted); }

.search { position: relative; flex: 0 1 300px; margin-left: 8px; }
.search input {
  width: 100%; height: 34px; padding: 3px 10px 0;
  background: var(--plane); border: 1px solid var(--line);
}
.search input::placeholder { color: var(--muted); }
.search input:focus { background: var(--surface); border-color: var(--line-strong); }
#searchList {
  position: absolute; left: 0; right: 0; top: 38px; z-index: 30;
  background: var(--surface); border: 1px solid var(--line-strong); max-height: 320px; overflow-y: auto; padding: 4px 0;
}
#searchList li { padding: 6px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
#searchList li span { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
#searchList li[aria-selected="true"], #searchList li:hover { background: var(--plane); }
#searchList li.empty { color: var(--muted); cursor: default; background: none; }

.sections { margin-left: auto; display: flex; gap: 18px; }
.sections a { color: var(--ink-2); text-decoration: none; font-size: 13.5px; }
.sections a:hover { color: var(--ink); text-decoration: underline; }

.icon {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none;
  background: none; border: 1px solid var(--line); color: var(--ink-2);
}
.icon:hover { border-color: var(--line-strong); color: var(--ink); }

/* ---- workspace: map stage + record panel ---- */

.workspace {
  display: grid; grid-template-columns: minmax(0, 1fr) 408px; grid-template-rows: minmax(0, 1fr);
  height: calc(100vh - 56px); min-height: 600px;
}
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px 20px 14px; gap: 10px; }

.controls { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.layers { display: flex; gap: 2px; flex-wrap: wrap; }
.layers button {
  padding: 6px 12px 4px; background: none; border: 0; border-bottom: 3px solid transparent;
  color: var(--ink-2); font-size: 14px;
}
.layers button:hover { color: var(--ink); border-bottom-color: var(--line); }
.layers button[aria-pressed="true"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink); }
.overlay { display: flex; align-items: center; gap: 6px; padding-bottom: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.overlay input { margin: 0 2px 2px 0; accent-color: var(--ink); }
.site { fill: var(--site); }

.legend { display: flex; align-items: flex-end; gap: 22px; flex-wrap: wrap; min-height: 34px; font-size: 12.5px; color: var(--ink-2); }
.legend .title { color: var(--ink); font-weight: 600; padding-bottom: 1px; }
.legend ol { display: flex; gap: 3px; }
.legend li { display: flex; flex-direction: column; gap: 3px; min-width: 46px; padding-right: 8px; white-space: nowrap; }
.legend li i { display: block; height: 10px; margin-right: -8px; border: 1px solid var(--line); }
.legend li.gap { margin-left: 14px; }
.legend .sizes { display: flex; align-items: flex-end; gap: 6px; }
.legend .sizes text { font: 12.5px "Overpass", system-ui, sans-serif; fill: var(--ink-2); }
.legend .sizes circle { stroke: var(--surface); stroke-width: 1.5; }

/* fills shared by the map and its legend */
.f-none { fill: var(--land); background: var(--land); }
.f-s1 { fill: var(--s1); background: var(--s1); }
.f-s2 { fill: var(--s2); background: var(--s2); }
.f-s3 { fill: var(--s3); background: var(--s3); }
.f-s4, .f-enact { fill: var(--s4); background: var(--s4); }
.f-s5 { fill: var(--s5); background: var(--s5); }
.f-d0 { fill: var(--d0); background: var(--d0); }
.f-d1 { fill: var(--d1); background: var(--d1); }
.f-d2 { fill: var(--d2); background: var(--d2); }
.f-d3 { fill: var(--d3); background: var(--d3); }
.f-d4 { fill: var(--d4); background: var(--d4); }
.f-d5 { fill: var(--d5); background: var(--d5); }
.f-d6 { fill: var(--d6); background: var(--d6); }
.f-prop { fill: var(--s2); background: var(--s2); }
.f-na { fill: url(#hatch); background: repeating-linear-gradient(45deg, var(--land) 0 2.5px, var(--na-line) 2.5px 3.5px); }

.plate {
  position: relative; flex: 1 1 0; min-height: 200px;
  background: var(--plane); border: 1px solid var(--line-strong);
  overflow: hidden;
}
#usmap { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; cursor: default; }
#usmap.zoomed { touch-action: none; cursor: grab; }
#usmap.dragging { cursor: grabbing; }
#usmap .viewport { transform-origin: 0 0; }
#usmap .viewport.glide { transition: transform .35s ease; }
#usmap .counties path {
  stroke: var(--county-line); stroke-width: .5; vector-effect: non-scaling-stroke;
  transition: fill .2s linear; cursor: pointer;
}
#usmap .states { fill: none; stroke: var(--state-line); stroke-width: .9; vector-effect: non-scaling-stroke; stroke-linejoin: round; pointer-events: none; }
#usmap .sites circle { fill: var(--site); fill-opacity: .88; stroke: var(--land); stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: pointer; }
#usmap .marks path { fill: none; vector-effect: non-scaling-stroke; stroke-linejoin: round; pointer-events: none; }
#usmap .marks .neighbor { stroke: var(--ink); stroke-width: 1.2; }
#usmap .marks .hover { stroke: var(--ink); stroke-width: 1.5; }
#usmap .marks .selected { stroke: var(--ink); stroke-width: 3; }
#usmap #hatch rect { fill: var(--land); }
#usmap #hatch line { stroke: var(--na-line); stroke-width: 1; }

.zoom { position: absolute; top: 10px; right: 10px; z-index: 3; display: flex; flex-direction: column; }
.zoom button {
  display: grid; place-items: center; width: 32px; height: 32px; padding: 2px 0 0;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink); font-size: 18px; line-height: 1;
}
.zoom button + button { border-top: 0; }
.zoom button:hover { background: var(--plane); }

.tip {
  position: absolute; z-index: 4; pointer-events: none; max-width: 260px;
  background: var(--surface); border: 1px solid var(--ink);
  padding: 7px 10px 5px; font-size: 13px;
}
.tip b { display: block; font-weight: 700; }
.tip span { display: block; color: var(--ink-2); }

.status {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; text-align: center;
  padding: 24px; color: var(--ink-2); font-size: 15px;
}
.status.error { color: var(--ink); }

.note { font-size: 13px; color: var(--ink-2); max-width: 100ch; }

/* ---- timeline (moratoriums over time) ---- */

.timeline { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: end; }
.timeline .play {
  grid-row: 1 / span 2; align-self: center;
  display: grid; place-items: center; width: 40px; height: 40px;
  background: var(--ink); color: var(--surface); border: 0;
}
.timeline .play svg { fill: currentColor; }
.timeline .readout { grid-column: 2; font-size: 14px; color: var(--ink-2); }
.timeline .readout b { color: var(--ink); font-weight: 700; }
.timeline .track { grid-column: 2; position: relative; }
.timeline input[type="range"] { display: block; width: 100%; margin: 2px 0 0; accent-color: var(--ink); }

.panel .bars { height: 84px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 56px; border-bottom: 1px solid var(--line-strong); }
.bars .bar { flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; padding: 0; background: none; border: 0; position: relative; }
.bars .bar i { display: block; width: 100%; background: var(--bar); }
.bars .bar.on i { background: var(--bar-on); }
.bars .bar:hover i, .bars .bar.now i { outline: 1.5px solid var(--ink); outline-offset: 0; }
.bars .bar .peak { position: absolute; left: 50%; transform: translateX(-50%); font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
.years { display: flex; font-size: 11.5px; color: var(--muted); padding-top: 2px; }
.years span { border-left: 1px solid var(--line-strong); padding-left: 4px; min-width: 0; overflow: hidden; }

/* ---- panel: national summary or county record ---- */

.panel { background: var(--surface); border-left: 1px solid var(--line-strong); overflow-y: auto; padding: 20px 22px 28px; }
.panel h2 { font-size: 26px; line-height: 1.15; font-weight: 800; letter-spacing: -.012em; text-wrap: balance; }
.panel h3 { font-size: 14px; font-weight: 700; margin: 22px 0 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.panel .lede { margin-top: 10px; color: var(--ink-2); font-size: 14.5px; }
.panel .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.panel .fine { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.panel .back { background: none; border: 0; padding: 0; margin-bottom: 12px; color: var(--link); font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; text-underline-offset: 2px; text-align: left; }

.verdict { margin-top: 12px; font-size: 15px; font-weight: 600; }
.verdict + p { margin-top: 2px; color: var(--ink-2); }

.leaders li { display: grid; grid-template-columns: 124px minmax(0, 1fr) 28px; align-items: center; gap: 10px; padding: 3px 0 1px; }
.leaders .meter { height: 12px; }
.leaders .meter i { display: block; height: 100%; background: var(--bar-on); }
.leaders b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.picks { margin-top: 6px; }
.picks li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0 3px; border-bottom: 1px solid var(--line); }
.picks li span { color: var(--ink-2); font-size: 13px; white-space: nowrap; }

table.facts { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.facts th { font-weight: 400; text-align: left; color: var(--ink-2); padding: 5px 8px 3px 0; }
table.facts td { padding: 5px 0 3px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.facts td.rank { width: 76px; padding-right: 10px; }
table.facts tr { border-bottom: 1px solid var(--line); }
table.facts thead th { font-size: 12px; color: var(--muted); padding-bottom: 2px; }
table.facts thead th:nth-child(2) { text-align: left; }
.rank i { display: block; position: relative; height: 9px; border-left: 1px solid var(--line-strong); border-right: 1px solid var(--line-strong); background: linear-gradient(var(--line-strong), var(--line-strong)) center / 100% 1px no-repeat; }
.rank i::after { content: ""; position: absolute; top: -1px; left: var(--at); width: 3px; height: 11px; margin-left: -1.5px; background: var(--ink); }

.events > li { padding: 12px 0 10px; border-bottom: 1px solid var(--line); }
.events > li:first-child { padding-top: 2px; }
.event-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.event-head time { font-weight: 700; }
.tag { font-size: 12px; padding: 2px 7px 0; border: 1px solid var(--line-strong); color: var(--ink-2); white-space: nowrap; }
.tag.enacted { background: var(--s4); border-color: var(--s4); color: #fff; }
:root[data-theme="dark"] .tag.enacted { color: #0a1422; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tag.enacted { color: #0a1422; } }
.tag.proposed { border-color: var(--s3); color: var(--ink); }
.tag.failed { text-decoration: line-through; }
.event-what { margin-top: 3px; font-size: 13px; color: var(--ink-2); }
.event-text { margin-top: 6px; font-size: 13.5px; }
.event-text.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; }
.event-more { margin-top: 2px; font-size: 13px; }
.event-meta { margin-top: 6px; font-size: 12.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.event-meta a { margin-right: 8px; white-space: nowrap; }
.event-meta.trace { color: var(--muted); }
details.statewide { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }
details.statewide summary { cursor: pointer; font-weight: 700; }
details.statewide .events { margin-top: 10px; }

/* ---- sections below the map ---- */

.band { background: var(--surface); border-top: 1px solid var(--line-strong); padding: 36px 20px 44px; }
.band > * { max-width: 1180px; margin-left: auto; margin-right: auto; }
.band-head { margin-bottom: 18px; }
.band h2 { font-size: 26px; font-weight: 800; letter-spacing: -.012em; line-height: 1.15; }
.band-head p { margin-top: 6px; color: var(--ink-2); max-width: 74ch; font-size: 14.5px; }
.band h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.fine { color: var(--muted); font-size: 12.5px; margin-top: 10px; }

.filters { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13.5px; color: var(--ink-2); }
.filters select { margin-left: 6px; height: 32px; padding: 2px 8px 0; background: var(--surface); border: 1px solid var(--line-strong); }
.filters .check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.filters .check input { margin: 0 0 2px; accent-color: var(--ink); }
.filters .count { margin-left: auto; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
#countyTable { font-size: 13.5px; min-width: 640px; }
#countyTable th { text-align: right; font-weight: 600; padding: 0; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
#countyTable th:first-child, #countyTable td:first-child { text-align: left; }
#countyTable th button { width: 100%; text-align: inherit; background: none; border: 0; padding: 8px 10px 5px; font-weight: 600; }
#countyTable th button:hover { background: var(--plane); }
#countyTable th[aria-sort="ascending"] button::after { content: " ↑"; }
#countyTable th[aria-sort="descending"] button::after { content: " ↓"; }
#countyTable td { padding: 6px 10px 4px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#countyTable tbody tr:hover { background: var(--plane); }
#countyTable tbody tr.current { background: var(--plane); font-weight: 700; }
#countyTable td small { color: var(--muted); font-size: 12.5px; margin-left: 4px; }
.more { margin-top: 14px; padding: 7px 14px 5px; background: none; border: 1px solid var(--line-strong); }
.more:hover { background: var(--plane); }

.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 40px; }
.downloads li { padding: 9px 0 7px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; }
.downloads a { font-weight: 700; }
.downloads span { color: var(--ink-2); font-size: 13.5px; }
table.sources { font-size: 13.5px; min-width: 560px; }
table.sources th { text-align: left; font-weight: 600; padding: 0 12px 5px 0; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
table.sources td { padding: 8px 12px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-2); }
table.sources td:first-child { color: var(--ink); }
table.sources td:nth-child(n+3) { white-space: nowrap; }

.notes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 40px; }
.notes dt { font-weight: 700; font-size: 15px; }
.notes dd { margin-top: 3px; color: var(--ink-2); max-width: 62ch; }

.foot { padding: 18px 20px 28px; border-top: 1px solid var(--line-strong); color: var(--muted); font-size: 12.5px; display: flex; gap: 6px 28px; flex-wrap: wrap; }

/* ---- narrow screens: one column, the page scrolls ---- */

@media (max-width: 960px) {
  .top { height: auto; flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
  .sections { display: none; }
  .search { order: 3; flex: 1 0 100%; margin-left: 0; }
  #themeBtn { margin-left: auto; }
  html { scroll-padding-top: 8px; }
  .top { position: static; }
  .workspace { display: block; height: auto; min-height: 0; }
  .stage { padding: 10px 16px 14px; }
  /* the map comes straight after the layer tabs; its key follows it */
  .plate { aspect-ratio: 975 / 640; flex: none; order: 1; }
  .legend { order: 2; }
  .timeline { order: 3; }
  .note { order: 4; }
  .layers { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
  .layers button { white-space: nowrap; }
  .note { min-height: 0; }
  .panel { border-left: 0; border-top: 1px solid var(--line-strong); padding: 20px 16px 28px; overflow: visible; }
  .band { padding: 28px 16px 36px; }
  .split, .notes { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .downloads li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .filters .count { margin-left: 0; }
}
@media (max-width: 480px) {
  .brand span { display: none; }
  .legend li { min-width: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  #usmap .counties path, #usmap .viewport.glide { transition: none; }
}

@media print {
  .top, .zoom, .search, .more { display: none; }
  .workspace { height: auto; display: block; }
  .plate { aspect-ratio: 975 / 640; }
}
