/* The Count: static pages (electorates, how it works, about). Same tokens as the app. */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #eceef2; --ink: #16181d; --ink-2: #3f4452; --ink-3: #5b6170;
  --line: #d9dce3; --accent: #5b2a6e; --accent-ink: #ffffff; --orange: #f26b21;
  --warn-bg: #fbeadf; --warn-ink: #a4460e; --ok-bg: #e3f3ea; --ok-ink: #1f7a4d; --info-bg: #e4eef7; --info-ink: #2b5b84;
  --serif: "IBM Plex Sans Condensed", "Arial Narrow", system-ui, sans-serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
/* Dark: follows the device unless the visitor chose a theme in the app (saved as nzel-theme, applied as data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121318; --surface: #1b1d24; --surface-2: #23262f; --ink: #eceef3; --ink-2: #c3c8d3; --ink-3: #a2a8b6;
    --line: #323644; --accent: #c79ad8; --accent-ink: #121318;
    --warn-bg: #3a2418; --warn-ink: #f0a070; --ok-bg: #183026; --ok-ink: #5fcf93; --info-bg: #1b2b3a; --info-ink: #8dbbe6;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #121318; --surface: #1b1d24; --surface-2: #23262f; --ink: #eceef3; --ink-2: #c3c8d3; --ink-3: #a2a8b6;
    --line: #323644; --accent: #c79ad8; --accent-ink: #121318;
    --warn-bg: #3a2418; --warn-ink: #f0a070; --ok-bg: #183026; --ok-ink: #5fcf93; --info-bg: #1b2b3a; --info-ink: #8dbbe6;
    color-scheme: dark;
}
* { box-sizing: border-box; }
:root { --tb-max: 960px; }
/* ---- Site header, shared by the app and the static pages (keep the two copies in step) ---- */
.topbar { background: var(--surface); border-bottom: 3px solid #f26b21; position: relative; z-index: 40; }
.tb-inner { max-width: var(--tb-max, 1280px); margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px 24px; }
.tb-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); margin-right: auto; }
.tb-brand img { width: 30px; height: 30px; display: block; }
.tb-name { font: 700 22px/1 var(--serif); letter-spacing: -.01em; }
.tb-tag { font: 600 11px/1 var(--serif); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding-left: 10px; border-left: 1px solid var(--line); }
.tb-nav { display: flex; align-items: center; gap: 2px; }
.tb-nav a { color: var(--ink-2); font-weight: 600; font-size: 14px; text-decoration: none; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.tb-nav a:hover { background: var(--surface-2); color: var(--ink); }
.tb-nav a[aria-current="page"] { color: var(--accent); background: var(--surface-2); }
.tb-theme { margin-left: 8px; font: 600 12px var(--sans); color: var(--ink-2); background: transparent; border: 1px solid var(--line); border-radius: 99px; padding: 5px 10px; cursor: pointer; white-space: nowrap; }
.tb-theme:hover { border-color: var(--accent); color: var(--accent); }
.tb-menu { display: none; font: 600 14px var(--sans); color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.tb-nav a:focus-visible, .tb-theme:focus-visible, .tb-menu:focus-visible, .tb-brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 900px) {
  .tb-menu { display: inline-block; }
  .tb-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 10px 24px rgba(0,0,0,.12); padding: 6px 12px 12px; }
  .topbar.open .tb-nav { display: flex; }
  .tb-nav a { padding: 11px 10px; font-size: 16px; border-radius: 8px; }
  .tb-theme { margin: 8px 10px 0; align-self: flex-start; font-size: 14px; padding: 7px 12px; }
}
@media (max-width: 420px) { .tb-tag { display: none; } }

body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--sans); }
a { color: var(--accent); }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
main { padding-top: 20px; padding-bottom: 24px; }
h1 { font: 700 34px/1.15 var(--serif); margin: 6px 0 6px; }
h2 { font: 700 21px/1.25 var(--serif); margin: 0 0 8px; }
.lede { font-size: 18px; color: var(--ink-2); }
.kicker { color: var(--ink-3); margin: 0 0 14px; }
.crumbs { font-size: 14px; color: var(--ink-3); margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin: 14px 0; }
.card p:last-child, .card ul:last-child { margin-bottom: 0; }
.muted, .small { color: var(--ink-3); }
.small { font-size: 13px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.tag.warn { background: var(--warn-bg); color: var(--warn-ink); white-space: normal; }
.pill { display: inline-block; font-weight: 600; font-size: 13px; padding: 1px 8px; border-radius: 99px; }
.pill.knife { background: var(--warn-bg); color: var(--warn-ink); }
.pill.marg { background: var(--info-bg); color: var(--info-ink); }
.pill.fair, .pill.safe { background: var(--surface-2); color: var(--ink-2); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.nw { white-space: nowrap; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); border-bottom: 2px solid var(--line); padding: 6px 8px; }
td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; }
.num { text-align: right; white-space: nowrap; }
table.cands td .small { margin-top: 3px; }
.stats { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; text-align: center; }
.stats li { background: var(--surface-2); border-radius: 10px; padding: 10px 4px; line-height: 1.3; }
.stats b { font: 700 26px var(--serif); }
.cta { margin: 20px 0; display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; padding: 10px 16px; border-radius: 10px; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.pager { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
footer.foot { color: var(--ink-3); font-size: 13px; padding-top: 8px; padding-bottom: 40px; border-top: 1px solid var(--line); }
@media (max-width: 600px) {
  h1 { font-size: 28px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  table.elist th:nth-child(4), table.elist td:nth-child(4) { display: none; }   /* swing = half the margin: dropped on phones */
  table.elist { table-layout: fixed; font-size: 14px; }
  table.elist th:nth-child(1) { width: 34%; } table.elist th:nth-child(2) { width: 27%; }
  table.elist th:nth-child(3) { width: 17%; } table.elist th:nth-child(5) { width: 22%; }
  table.elist .over { display: none; }
  table.elist td { overflow-wrap: anywhere; }
  td, th { padding: 7px 5px; }
}
/* Live results box on electorate pages (src/live-box.js) */
.card.live { border: 2px solid var(--accent); }
.live-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.live-head h2 { margin: 0; }
.flag { font-size: 12px; font-weight: 700; letter-spacing: .03em; background: var(--warn-bg); color: var(--warn-ink); padding: 2px 8px; border-radius: 6px; }
.live-count { margin: 8px 0 6px; }
.pbar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: 10px; }
.pbar span { display: block; height: 100%; background: var(--accent); }
.call { display: inline-block; font-size: 13px; font-weight: 700; padding: 1px 9px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.call.st-projected, .call.st-elected { background: var(--ok-bg); color: var(--ok-ink); }
.call.st-tooclose { background: var(--warn-bg); color: var(--warn-ink); }
table.live-t tr.lead td:first-child { font-weight: 700; }
table.live-t .barc { width: 34%; }
.vbar { height: 12px; border-radius: 3px; min-width: 2px; }
@media (max-width: 600px) { table.live-t .barc { width: 22%; } }
/* "What the polls suggest" on the electorates index */
.headline-num { font-size: 18px; margin: 0 0 10px; }
.headline-num b { font: 700 32px var(--serif); margin-right: 4px; }
ul.flips { list-style: none; padding: 0; margin: 0 0 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
ul.flips li { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; line-height: 1.35; }
ul.flips li a { font-weight: 700; }
.flip-to { font-size: 15px; }
.pollavg { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 4px 0 2px; font-size: 15px; }
.pa { white-space: nowrap; }
.pa .up { color: var(--ok-ink); font-size: 13px; font-weight: 600; }
.pa .down { color: var(--warn-ink); font-size: 13px; font-weight: 600; }
details.polls summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: 14px; }
details.polls ul { margin: 4px 0 0; padding-left: 18px; }
.who-leads { font-size: 17px; margin: 4px 0 2px; }
/* Polls and party list pages */
td.up { color: var(--ok-ink); font-weight: 600; }
td.down { color: var(--warn-ink); font-weight: 600; }
table.polltable { font-size: 14px; }
table.polltable td, table.polltable th { padding: 6px 5px; }
table.plist tr.in td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.tag.ok { background: var(--ok-bg); color: var(--ok-ink); }
h1 .sw { width: 18px; height: 18px; border-radius: 4px; vertical-align: 2px; margin-right: 10px; }
table.plist { table-layout: fixed; }
table.plist th:nth-child(1) { width: 40px; } table.plist th:nth-child(4) { width: 112px; }
table.plist td { overflow-wrap: anywhere; }
@media (max-width: 600px) { table.plist th:nth-child(1) { width: 30px; } table.plist th:nth-child(4) { width: 92px; } table.plist .tag.ok { font-size: 11px; padding: 1px 5px; } }
@media (max-width: 600px) {
  .card { padding: 14px 14px; margin: 12px 0; border-radius: 10px; }
  main { padding-top: 14px; }
  .lede { font-size: 17px; }
}
/* Ad unit (same AdSense unit as the app); hidden if Google has no ad to fill it */
.ad-slot { margin: 4px 0 14px; text-align: center; }
.ad-slot .ad-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin-bottom: 4px; }
/* The slot must stay laid out (AdSense needs its width), so before an ad arrives only the label is hidden;
   if Google has nothing to show, the whole slot goes */
.ad-slot:not(:has(ins[data-ad-status="filled"])) .ad-label { display: none; }
.ad-slot:has(ins[data-ad-status="unfilled"]) { display: none; }
/* "Try the calculator" / "See the full results" card (src/promo.js): bottom-right on wide screens, a bar along the bottom on phones */
.promo { position: fixed; right: 20px; bottom: 20px; z-index: 60; width: min(380px, calc(100vw - 32px)); display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-top: 4px solid #f26b21; border-radius: 14px; padding: 16px 16px 16px 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,.22); transform: translateY(24px); opacity: 0; transition: transform .25s ease, opacity .25s ease; }
.promo.in { transform: none; opacity: 1; }
.promo img { flex: none; margin-top: 2px; }
.promo-body strong { display: block; font: 700 18px/1.25 var(--serif); margin: 0 24px 4px 0; }
.promo-body p { margin: 0 0 10px; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.promo-body .btn { padding: 8px 14px; font-size: 14px; }
.promo-x { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 24px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.promo-x:hover, .promo-x:focus-visible { color: var(--ink); background: var(--surface-2); }
@media (max-width: 600px) {
  .promo { left: 8px; right: 8px; bottom: 8px; width: auto; padding: 12px 12px 12px 10px; }
  .promo img { width: 36px; height: 36px; }
  .promo-body strong { font-size: 16px; }
  .promo-body p { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { .promo { transition: none; } }
.tb-name, .tb-tag { white-space: nowrap; }
@media (max-width: 1180px) { .tb-tag { display: none; } }
/* Sort switch above the electorates table */
.tbl-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 8px; }
.tbl-head h2 { margin: 0; }
.sortseg { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; padding: 2px; background: var(--surface-2); }
.sortseg button { border: 0; background: none; font: 600 13px var(--sans); color: var(--ink-2); padding: 6px 14px; border-radius: 99px; cursor: pointer; }
.sortseg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.sortseg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* /results/ page */
ul.egrid { list-style: none; padding: 0; margin: 0; columns: 3 180px; column-gap: 20px; }
ul.egrid li { padding: 3px 0; break-inside: avoid; }
/* Buy Me a Coffee button: same look as their official button (yellow, black outline, Bree Serif), without their script */
.bmc-btn { display: inline-flex; align-items: center; gap: 8px; background: #FFDD00; color: #000; border: 1px solid #000; border-radius: 10px;
  padding: 8px 18px; font: 400 18px/1.2 "Bree Serif", Georgia, serif; text-decoration: none; letter-spacing: .2px; white-space: nowrap; }
.bmc-btn:hover { background: #ffe64d; text-decoration: none; }
.bmc-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.support-row { margin: 10px 0 6px; }

/* Election day (until polls close on 7 Nov): electorate pages show only the candidates */
.eday-only { display: none; }
html.eday .eday-only { display: block; }
html.eday .eday-hide { display: none !important; }
.eday-note { background: var(--accent); color: var(--accent-ink); padding: 12px 16px; border-radius: 10px; }
.eday-note a { color: inherit; text-decoration: underline; }
.eday-list { columns: 3 200px; padding-left: 18px; margin: 0; }
.eday-list li { margin: 3px 0; break-inside: avoid; }
