/* Same visual system as the early-vote trackers (early.professorbutts.com/<st>/style.css): one page column, sticky
   header, sections split by rules, the same buttons, nav, tables and callouts. Only the colors are this site's own:
   party blue and red, light tints for a seat still waiting, hatching for a lead. */
:root {
  color-scheme: light;
  --page: #fcfcfb; --surface: #ffffff; --ink: #0b0b0b; --ink-2: #52514e; --muted: #6b6a66;
  --ring: #e4e3df; --grid: #ececE8; --axis: #d6d5d0; --wash: #f2f1ee; --accent: #2a78d6;
  /* parties: solid = won, tint = held now / no count yet */
  --D: #2f63c9; --D2: #a8c0ee; --R: #cc3b33; --R2: #f0b1ab; --I: #7d5bb5; --I2: #cdbde6; --wait: #d8d7d1; --none: #f2f1ee;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #1a1a19; --surface: #222221; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #a09f98;
    --ring: #383835; --grid: #2e2e2c; --axis: #4a4a46; --wash: #2b2b29; --accent: #3987e5;
    --D: #5b8ff0; --D2: #2d4677; --R: #ef6a5f; --R2: #73332e; --I: #a787dd; --I2: #4b3a68; --wait: #3d3d3a; --none: #2b2b29;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #1a1a19; --surface: #222221; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #a09f98;
  --ring: #383835; --grid: #2e2e2c; --axis: #4a4a46; --wash: #2b2b29; --accent: #3987e5;
  --D: #5b8ff0; --D2: #2d4677; --R: #ef6a5f; --R2: #73332e; --I: #a787dd; --I2: #4b3a68; --wait: #3d3d3a; --none: #2b2b29;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 150px; }
body { margin: 0; background: var(--page); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 6px 10px; z-index: 50; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* header (as on the trackers) */
.top { position: sticky; top: 0; z-index: 20; background: var(--page); border-bottom: 1px solid var(--ring); }
.top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-top: 12px; }
.top-actions { display: flex; gap: 8px; flex: none; }
h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.01em; }
h1 a { color: inherit; text-decoration: none; }
.sub { margin: 2px 0 0; color: var(--ink-2); font-size: .9rem; }
.nav { display: flex; gap: 4px 14px; overflow-x: auto; padding-top: 6px; padding-bottom: 6px; white-space: nowrap; scrollbar-width: none; }
.nav a { color: var(--ink-2); text-decoration: none; font-size: .9rem; padding: 2px 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--ink); border-bottom-color: var(--accent); }

/* buttons (as on the trackers) */
.btn { font: inherit; font-size: .9rem; color: var(--ink); background: var(--surface); border: 1px solid var(--ring);
  border-radius: 6px; padding: 6px 10px; max-width: 100%; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--wash); }

/* sections (as on the trackers) */
section { padding: 28px 0 8px; border-bottom: 1px solid var(--ring); }
section:last-of-type { border-bottom: 0; }
h2 { margin: 0 0 6px; font-size: 1.3rem; }
h3 { margin: 22px 0 6px; font-size: 1.05rem; }
h4 { margin: 0 0 4px; font-size: .9rem; font-weight: 600; }
.lede { color: var(--ink-2); margin: 0 0 14px; max-width: 78ch; }
.note { color: var(--muted); font-size: .85rem; max-width: 90ch; margin: 8px 0 0; }
.muted { color: var(--muted); }
.callout { margin: 16px 0 0; padding: 10px 14px; max-width: 90ch; background: var(--wash); border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0; color: var(--ink-2); font-size: .92rem; }
.callout b { color: var(--ink); }
.foot { color: var(--muted); font-size: .8rem; padding-top: 24px; padding-bottom: 40px; }

/* tables (as on the trackers; race tables hold names and words, so left-aligned and allowed to wrap) */
.tablewrap { overflow-x: auto; border: 1px solid var(--ring); border-radius: 8px; background: var(--surface); margin-top: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--ring); vertical-align: top; }
thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; font-weight: 600; color: var(--ink-2); font-size: .8rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--wash); }
.st-status { white-space: nowrap; }
.pill { display: inline-block; min-width: 1.6em; text-align: center; border-radius: 3px; padding: 0 4px; font-size: .75rem; font-weight: 700; color: #fff; }
.pill.D { background: var(--D); } .pill.R { background: var(--R); } .pill.I, .pill.L, .pill.G { background: var(--I); }

/* seat bars: one cell per seat, in party order, with the majority line */
.bar-wrap { position: relative; padding-top: 18px; }
.bar-wrap .marklabel { position: absolute; top: 0; transform: translateX(-50%); font-size: .75rem; color: var(--ink-2); white-space: nowrap; }
.bar { position: relative; display: flex; height: 34px; border-radius: 6px; overflow: hidden; background: var(--wait); margin: 8px 0 4px; border: 1px solid var(--ring); }
.bar span { height: 100%; }
.bar .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); }
.barlabel { font-size: .8rem; font-weight: 600; color: var(--ink-2); margin: 14px 0 0; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .85rem; color: var(--ink-2); margin: 4px 0 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: 0; margin-right: 6px; }
.D { background: var(--D); } .D2 { background: var(--D2); } .R { background: var(--R); } .R2 { background: var(--R2); }
.I { background: var(--I); } .I2 { background: var(--I2); } .W { background: var(--wait); }
.hatchD { background: repeating-linear-gradient(135deg, var(--D2) 0 4px, var(--D) 4px 6px); }
.hatchR { background: repeating-linear-gradient(135deg, var(--R2) 0 4px, var(--R) 4px 6px); }

/* US map, in a panel like the trackers' maps */
.usfig { margin: 14px 0 0; background: var(--surface); border: 1px solid var(--ring); border-radius: 8px; padding: 10px; }
.usmap { display: block; width: 100%; height: auto; }
.usmap path { stroke: var(--surface); stroke-width: .8; fill: var(--none); }
.usmap a path { cursor: pointer; }
.usmap a:hover path, .usmap a:focus-visible path { stroke: var(--ink); stroke-width: 1.6; }

/* House: one square per district, grouped by state */
.hgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 6px 14px; margin: 14px 0 0; }
.hrow { display: flex; align-items: flex-start; gap: 8px; text-decoration: none; color: var(--ink); padding: 2px 0; }
.hrow b { width: 2.2em; flex: none; font-size: .85rem; }
.hrow .sq { display: flex; flex-wrap: wrap; gap: 2px; }
.hrow .sq span { width: 11px; height: 11px; border-radius: 2px; }
.hrow .sq span:not([class]) { background: var(--wait); }
.hrow:hover b { color: var(--accent); }

/* state list: cards like the trackers' tiles */
.stlist { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 12px; }
.stlist a { display: block; padding: 10px 12px; border: 1px solid var(--ring); border-radius: 8px; background: var(--surface); text-decoration: none; color: var(--ink); }
.stlist a:hover { background: var(--wash); }
.stlist small { display: block; color: var(--muted); font-size: .78rem; }

/* one state's contests: panels like the trackers' chart panels */
.back { display: inline-block; margin: 14px 0 0; font-size: .9rem; }
.contests { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--ring); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.card h4 { margin: 0; font-size: .95rem; }
.card .meta { color: var(--muted); font-size: .8rem; margin: 2px 0 8px; }
.cand { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; align-items: baseline; font-size: .9rem; margin: 5px 0 0; }
.cand .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand .v { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: .85rem; }
.cand .track { grid-column: 1 / -1; height: 6px; background: var(--grid); border-radius: 3px; overflow: hidden; margin-top: 2px; }
.cand .track span { display: block; height: 100%; }
.cand.win .nm { font-weight: 700; }
.mapbtn { margin-top: 10px; }
.cmap { display: block; width: 100%; height: auto; margin-top: 10px; }
.cmap path { stroke: var(--surface); stroke-width: .5; vector-effect: non-scaling-stroke; fill: var(--wait); }
.cmap .outline { fill: none; stroke: var(--ink-2); stroke-width: 1; }
.methods { padding-left: 18px; color: var(--ink-2); max-width: 90ch; }
.methods li { margin: 6px 0; }

/* the header logo: the ring fades in, then the check draws itself like a pen stroke (short leg, a beat at the corner,
   the long leg) and stays. The corner sits 33% along the check's length. Reduced-motion users get the finished mark. */
h1 a { display: inline-flex; align-items: center; gap: 10px; }
.logo { width: 40px; height: 40px; flex: none; border-radius: 9px; }
.logo .ring { animation: ring-in .35s ease-out both; }
.logo .ck path { stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; animation: ck-draw 1.05s .3s forwards; }
@keyframes ring-in { from { opacity: 0; transform: scale(.94); transform-origin: 256px 330px; } to { opacity: 1; transform: none; } }
@keyframes ck-draw {
  0%   { stroke-dashoffset: 1; opacity: 1; animation-timing-function: cubic-bezier(.45, 0, .75, .6); }
  30%  { stroke-dashoffset: .669; opacity: 1; }
  40%  { stroke-dashoffset: .669; opacity: 1; animation-timing-function: cubic-bezier(.25, .2, .15, 1); }
  100% { stroke-dashoffset: 0; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .logo .ring, .logo .ck path { animation: none; opacity: 1; stroke-dashoffset: 0; }
}

@media (max-width: 640px) { .top-row { flex-wrap: wrap; row-gap: 10px; } .top-row > .ttl { flex: 1 1 100%; } .top-actions { flex-wrap: wrap; } }
@media (max-width: 560px) {
  html { scroll-padding-top: 190px; }
  h1 { font-size: 1.25rem; } section { padding-top: 22px; }
  .top-actions { gap: 6px; } .top-actions .btn { padding: 3px 8px; font-size: .78rem; }
  .logo { width: 32px; height: 32px; border-radius: 7px; } h1 a { gap: 8px; }
}
