/* Registration Watch
   Type: Barlow Condensed for headings and figures (tally-board feel), Public Sans for text.
   Color: party blue/red carry data only; everything else is cool neutral. */

:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --ink: #1a2330;
  --muted: #5a6573;
  --rule: #d5dbe1;
  --focus: #e0a100;
  --dem: #2e5eaa;
  --rep: #c0303a;

  --d3: #1f4a91; --d2: #4c7dcb; --d1: #a8c1e8;
  --r1: #f0a9a9; --r2: #d9545a; --r3: #a51f2a;
  --even: #d9d4cc;
  --nodata: #c3cad2;
  --na: #e4e8ec;

  --display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --text: 'Public Sans', 'Segoe UI', system-ui, sans-serif;
  --wrap: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161d;
    --surface: #18202a;
    --ink: #e6ebf0;
    --muted: #98a4b1;
    --rule: #2b3642;
    --dem: #7aa3ee;
    --rep: #f07a80;
    --d3: #7aa3ee; --d2: #4a76c0; --d1: #2f4a70;
    --r1: #6e3036; --r2: #c2474f; --r3: #f07a80;
    --even: #4a4640;
    --nodata: #3a4450;
    --na: #202933;
  }
}

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

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.55 var(--text);
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 0.5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header / footer */
.site-header {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 1.1rem 1.25rem 0.9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  border-bottom: 1px solid var(--rule);
}
.brand {
  font: 700 1.45rem/1 var(--display);
  letter-spacing: 0.01em;
  text-decoration: none;
}
.site-header nav { display: flex; gap: 1.25rem; }
.site-header nav a { text-decoration: none; color: var(--muted); font-weight: 500; }
.site-header nav a:hover, .site-header nav a[aria-current] { color: var(--ink); }
.site-header nav a[aria-current] { box-shadow: inset 0 -2px 0 var(--ink); }

main { max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem 3rem; }
main > section { margin-top: 3rem; }

.site-footer {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer p { margin: 0.25rem 0; }

/* Type */
h1, h2, h3 { font-family: var(--display); line-height: 1.05; margin: 0; }
h1 { font-size: clamp(2.5rem, 6vw, 4rem); font-weight: 700; letter-spacing: -0.005em; margin-top: 2.25rem; }
h2 { font-size: 1.75rem; font-weight: 600; margin-bottom: 0.9rem; }
h3 { font-size: 1.25rem; font-weight: 600; }
.lede { font-size: 1.125rem; color: var(--muted); max-width: 62ch; margin: 0.6rem 0 0; }
.note { color: var(--muted); font-size: 0.875rem; margin: 0.6rem 0 0; max-width: 72ch; }
.error { color: var(--rep); font-weight: 500; }
code { font-size: 0.9em; background: var(--surface); border: 1px solid var(--rule); border-radius: 3px; padding: 0.05em 0.3em; }

/* Form bits */
.field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field.grow { flex: 1 1 14rem; }
input[type="search"], input[type="url"], input[type="date"], select, textarea {
  font: 400 1rem/1.3 var(--text);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.5rem 0.6rem;
  min-height: 2.5rem;
}
textarea { resize: vertical; font-size: 0.95rem; }
.check { display: flex; align-items: center; gap: 0.45rem; font-size: 0.95rem; min-height: 2.5rem; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--ink); }
.button {
  font: 600 0.95rem/1 var(--text);
  padding: 0.7rem 1rem;
  border-radius: 4px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
}
.button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Map block */
.intro { max-width: 60rem; }
.map-block { margin-top: 2rem; }
.controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem 1.5rem; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 5px; overflow: hidden; background: var(--surface); }
.seg button {
  font: 500 0.95rem/1 var(--text);
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0 1rem;
  min-height: 2.5rem;
  cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.metric-help { color: var(--muted); font-size: 0.9rem; margin: 0.75rem 0 0; }

.map-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16rem;
  gap: 1.5rem;
  align-items: start;
  margin-top: 1rem;
}
.map svg { width: 100%; height: auto; display: block; }
.map path.state { stroke: var(--bg); stroke-width: 0.9; stroke-linejoin: round; }
.map path.clickable { cursor: pointer; }
.map path.clickable:hover, .map path.clickable:focus-visible { stroke: var(--ink); stroke-width: 2; outline: none; }
.map .borders { fill: none; stroke: var(--bg); stroke-width: 0.9; pointer-events: none; }

.bin-d3 { fill: var(--d3); } .bin-d2 { fill: var(--d2); } .bin-d1 { fill: var(--d1); }
.bin-r1 { fill: var(--r1); } .bin-r2 { fill: var(--r2); } .bin-r3 { fill: var(--r3); }
.bin-0 { fill: var(--even); } .bin-none { fill: var(--nodata); } .bin-na { fill: var(--na); }

.legend { display: grid; gap: 0.35rem; font-size: 0.85rem; }
.legend-row { display: flex; align-items: center; gap: 0.5rem; }
.swatch { width: 1.1rem; height: 0.8rem; border-radius: 2px; flex: none; }
.swatch.bin-d3 { background: var(--d3); } .swatch.bin-d2 { background: var(--d2); } .swatch.bin-d1 { background: var(--d1); }
.swatch.bin-r1 { background: var(--r1); } .swatch.bin-r2 { background: var(--r2); } .swatch.bin-r3 { background: var(--r3); }
.swatch.bin-none { background: var(--nodata); } .swatch.bin-na { background: var(--na); border: 1px solid var(--rule); }
.legend-gap { height: 0.4rem; }

.national { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
.national h3 { margin-bottom: 0.75rem; }
.national dl { margin: 0; display: grid; gap: 0.9rem; }
.national dt { font-size: 0.85rem; color: var(--muted); }
.national dd { margin: 0.15rem 0 0; display: flex; gap: 1rem; font: 600 1.35rem/1.1 var(--display); }
.national .d { color: var(--dem); } .national .r { color: var(--rep); }
.national dd .muted { font: 500 1rem/1.3 var(--text); color: var(--muted); }

/* Tooltip */
.tip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.55rem 0.7rem;
  font-size: 0.875rem;
  line-height: 1.4;
  max-width: 17rem;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.12);
}
.tip strong { display: block; font: 600 1.1rem/1.1 var(--display); margin-bottom: 0.2rem; }
.tip .muted { color: var(--muted); }

/* Tables */
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: flex-end; }
.table-wrap { overflow-x: auto; margin-top: 0.75rem; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.data th, table.data td { padding: 0.55rem 0.75rem; text-align: left; border-bottom: 1px solid var(--rule); white-space: nowrap; }
table.data thead th { font-size: 0.8rem; font-weight: 600; color: var(--muted); border-bottom: 2px solid var(--ink); }
table.data tbody th { font-weight: 600; }
table.data .num { text-align: right; }
table.data thead button {
  all: unset;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
table.data thead button:focus-visible { outline: 3px solid var(--focus); }
table.data thead th[aria-sort] button { color: var(--ink); }
table.data thead th[aria-sort="ascending"] button::after { content: ' \2191'; }
table.data thead th[aria-sort="descending"] button::after { content: ' \2193'; }
table.data tr.derived td, table.data tr.derived th { color: var(--muted); font-style: italic; }
table.data tr.empty td, table.data tr.empty th { color: var(--muted); }
.split-col { width: 10rem; }
.d-lead { color: var(--dem); font-weight: 600; } .r-lead { color: var(--rep); font-weight: 600; }

.split { display: flex; height: 0.5rem; min-width: 8rem; border-radius: 2px; overflow: hidden; position: relative; }
.split::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: var(--bg); }
.split-d { background: var(--dem); } .split-r { background: var(--rep); }
.split-big { height: 0.9rem; margin-top: 1.5rem; }

/* Updates */
.updates { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; }
.updates li { display: grid; grid-template-columns: 7rem 1fr auto; gap: 0.25rem 1rem; padding: 0.8rem 0; border-bottom: 1px solid var(--rule); align-items: baseline; }
.updates time { color: var(--muted); font-size: 0.9rem; }
.updates .what a { font-weight: 600; }
.updates .figs { color: var(--muted); display: block; font-size: 0.9rem; }
.updates .src { font-size: 0.9rem; }

/* State page */
.crumbs { margin-top: 1.5rem; font-size: 0.9rem; }
.crumbs + h1 { margin-top: 0.5rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: 1.25rem 2rem; margin-top: 2rem; }
.stat { display: flex; flex-direction: column; border-left: 3px solid var(--rule); padding-left: 0.9rem; }
.stat.dem { border-color: var(--dem); } .stat.rep { border-color: var(--rep); }
.stat-label { font-size: 0.875rem; color: var(--muted); font-weight: 500; }
.stat-num { font: 700 2.6rem/1.05 var(--display); }
.stat.dem .stat-num { color: var(--dem); } .stat.rep .stat-num { color: var(--rep); }
.stat-sub { font-size: 0.875rem; color: var(--muted); }

.trend-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); gap: 1.5rem 2.5rem; }
.trend-pair h3 { margin-bottom: 0.25rem; }
.rep-h { color: var(--rep); } .dem-h { color: var(--dem); }
.chart { width: 100%; min-height: 12rem; }
.chart.tall { min-height: 26rem; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--muted); font: 400 12px var(--text); }
.chart .axis path, .chart .axis line { stroke: var(--rule); }
.chart .grid line { stroke: var(--rule); stroke-opacity: 0.6; }
.chart .grid path { display: none; }
.chart .line { fill: none; stroke-width: 2.5; }
.chart .dem { stroke: var(--dem); color: var(--dem); }
.chart .rep { stroke: var(--rep); color: var(--rep); }
.chart .pt { stroke-width: 2; }
.chart .pt.solid { fill: currentColor; }
.chart .pt.hollow { fill: var(--bg); }
.chart .ref { stroke-dasharray: 5 4; stroke-width: 1.5; }
.chart .ref-label, .chart .end-label { font: 600 13px var(--text); }
.chart .ref-label { font-weight: 500; }
.chart .bar.dem { fill: var(--dem); } .chart .bar.rep { fill: var(--rep); }
.chart .zero { stroke: var(--ink); stroke-width: 1; }
.empty { color: var(--muted); }
.chart .guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; pointer-events: none; }
.chart .hover-area { fill: transparent; }
.chart svg circle.pt { pointer-events: none; }
.seg-small { margin-bottom: 0.75rem; }
.seg-small button { min-height: 2.1rem; font-size: 0.875rem; }
.button-quiet { background: none; color: var(--ink); border-color: var(--rule); margin-top: 0.75rem; }
.button-quiet:hover { border-color: var(--ink); }
.src-cell a { font-weight: 500; }
.post-diff, .post-match { display: block; font-size: 0.8rem; white-space: nowrap; }
.post-diff { color: var(--rep); }
.post-match { color: var(--muted); }

.county-map svg { width: 100%; max-width: 44rem; height: auto; display: block; }
.county-map path { stroke: var(--bg); stroke-width: 0.6; }
.county-map .outline { fill: none; stroke: var(--ink); stroke-width: 1; }

.posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 1rem; align-items: start; }
.posts .twitter-tweet { margin: 0 !important; }
.post-text { margin: 0; padding: 1rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; white-space: pre-wrap; font-size: 0.925rem; }
.post-text footer { margin-top: 0.75rem; color: var(--muted); font-size: 0.85rem; }

/* Compare */
.compare { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 2rem; margin-top: 2rem; }
.picker { border: 0; padding: 0; margin: 0; }
.picker legend { font: 600 1.25rem/1 var(--display); margin-bottom: 0.6rem; }
.picker input[type="search"] { width: 100%; }
.pick-list input { margin: 0; accent-color: var(--ink); }
.pick-list { margin-top: 0.5rem; max-height: 28rem; overflow-y: auto; display: grid; }
.pick-list label { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.1rem; cursor: pointer; }
.pick-list .key { width: 0.8rem; height: 0.8rem; border-radius: 50%; flex: none; background: var(--rule); }
.compare-main .field { max-width: 26rem; margin-bottom: 1rem; }
.compare-main select { width: 100%; }

/* Admin */
.admin { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; margin-top: 2rem; }
.admin-form { display: grid; gap: 1rem; align-content: start; }
.json { background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; padding: 1rem; font-size: 0.8rem; overflow-x: auto; max-height: 24rem; }
.msg-list { padding-left: 1.2rem; margin: 0.5rem 0; }
.msg-list.errors { color: var(--rep); }
.msg-list.warnings { color: var(--muted); }

/* About */
.prose { max-width: 68ch; }
.prose h2 { margin-top: 2rem; margin-bottom: 0.5rem; }
.prose li + li { margin-top: 0.5rem; }

@media (max-width: 860px) {
  .map-grid, .compare, .admin { grid-template-columns: 1fr; }
  .map-side { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
  .national { margin-top: 0; padding-top: 0; border-top: 0; }
  .pick-list { max-height: 12rem; }
}
@media (max-width: 560px) {
  .map-side { grid-template-columns: 1fr; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 0 0.5rem; font-size: 0.85rem; }
  .updates li { grid-template-columns: 1fr; }
  .split-col, .states-table td:nth-child(5) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
[hidden] { display: none !important; }
