/* ================================================================
   election2026.nz — civic paper + electoral orange
   Display: Bricolage Grotesque · Body: IBM Plex Sans · Data: IBM Plex Mono
   ================================================================ */

:root {
  /* surfaces & ink (light) */
  --surface: #FAF9F6;
  --surface-raised: #FFFFFF;
  --surface-sunken: #F1EFE9;
  --ink: #1A1C20;
  --ink-2: #4B5058;
  --ink-3: #83888F;
  --hairline: #E3E0D8;
  --accent: #E4570B;          /* NZ electoral orange */
  --accent-ink: #C74A07;
  --focus: #0B5BAE;

  /* party palette — validated for light surface */
  --c-nat: #0B5BAE;
  --c-lab: #D93A2B;
  --c-grn: #26843B;
  --c-act: #AD8B00;
  --c-nzf: #000000;
  --c-tpm: #8F1D3C;
  --c-top: #0D9C8F;
  --c-oth: #9A968C;

  --radius: 14px;
  --wrap: 1100px;
  --shadow: 0 1px 2px rgba(26,28,32,.05), 0 8px 28px -12px rgba(26,28,32,.12);
}

[data-theme="dark"] {
  --surface: #16181D;
  --surface-raised: #1D2027;
  --surface-sunken: #101216;
  --ink: #ECEDEF;
  --ink-2: #AEB2BA;
  --ink-3: #767B84;
  --hairline: #2A2E36;
  --accent: #F0692B;
  --accent-ink: #F0692B;
  --focus: #5B9BE8;

  /* party palette — validated for dark surface */
  --c-nat: #2E6AB4;
  --c-lab: #E05146;
  --c-grn: #3E9B52;
  --c-act: #F7D347;
  --c-nzf: #A8ADB5;
  --c-tpm: #CE5470;
  --c-top: #6CEAE0;
  --c-oth: #6E7278;

  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px -12px rgba(0,0,0,.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #16181D; --surface-raised: #1D2027; --surface-sunken: #101216;
    --ink: #ECEDEF; --ink-2: #AEB2BA; --ink-3: #767B84; --hairline: #2A2E36;
    --accent: #F0692B; --accent-ink: #F0692B; --focus: #5B9BE8;
    --c-nat: #2E6AB4; --c-lab: #E05146; --c-grn: #3E9B52; --c-act: #F7D347;
    --c-nzf: #A8ADB5; --c-tpm: #CE5470; --c-top: #6CEAE0; --c-oth: #6E7278;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px -12px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
a { color: var(--accent-ink); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------- top bar ---------------- */

.topbar {
  border-bottom: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 40;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; }

.wordmark { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.wordmark-mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--accent);
  position: relative; flex: none;
}
.wordmark-mark::after {
  content: ""; position: absolute; left: 5px; right: 5px; bottom: 5px; height: 7px;
  border-radius: 7px 7px 0 0; background: var(--surface);
}
.wordmark-text {
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 500;
  font-size: 17px; letter-spacing: -.01em;
}
.wordmark-text b { font-weight: 800; }
.wordmark-text i { font-style: normal; color: var(--ink-3); font-weight: 500; }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.updated { font-size: 11.5px; color: var(--ink-3); letter-spacing: .01em; }

.countdown {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent-ink);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px; padding: 4px 11px;
  white-space: nowrap;
}
.countdown b { font-weight: 600; }
@media (max-width: 640px) {
  .updated { display: none; }   /* keep the countdown; the footer restates the data stamp */
}

.theme-toggle {
  display: grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid var(--hairline); border-radius: 9px;
  background: var(--surface-raised); color: var(--ink-2); cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-3); }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }
[data-theme="dark"] .theme-toggle .sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
}

/* ---------------- hero ---------------- */

.hero { padding: 56px 0 30px; border-bottom: 1px solid var(--hairline); }

.eyebrow {
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent-ink); margin-bottom: 14px;
}

.headline {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  font-size: clamp(28px, 4.6vw, 52px);
  line-height: 1.06;
  letter-spacing: -.02em;
  max-width: 21ch;
  text-wrap: balance;
  margin-bottom: 8px;
  min-height: 2.1em;
}
.headline .hl { color: var(--accent-ink); }

.chamber-stage {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(300px, 720px) minmax(120px, 1fr);
  align-items: end;
  gap: 12px;
  margin-top: 18px;
}

.chamber-wrap { position: relative; }
#chamber { width: 100%; height: auto; display: block; }
#chamber circle { transition: transform .8s cubic-bezier(.6,.05,.2,1), fill .4s; }
@media (prefers-reduced-motion: reduce) {
  #chamber circle { transition: none; }
}

.majority-flag {
  position: absolute; top: -4px; left: 50%; transform: translateX(-50%);
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3);
  padding-bottom: 2px;
}

.center-figure {
  position: absolute; left: 50%; bottom: 24%;
  transform: translateX(-50%);
  text-align: center;
}
.center-figure-value {
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 700;
  font-size: clamp(18px, 2.4vw, 28px); display: block; line-height: 1;
}
.center-figure-label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }

.bloc-figure { text-align: center; padding-bottom: 8px; }
.bloc-figure-value {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800; font-size: clamp(40px, 6vw, 72px); line-height: 1;
  display: block; font-variant-numeric: normal;
}
.bloc-figure--left .bloc-figure-value { color: var(--c-lab); }
.bloc-figure--right .bloc-figure-value { color: var(--c-nat); }
.bloc-figure-label { font-size: 13px; font-weight: 600; color: var(--ink-2); display: block; margin-top: 6px; }
.bloc-figure-parties { display: block; font-weight: 400; font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.bloc-figure-value.is-majority::after {
  content: "✓ majority";
  display: block; font-family: "IBM Plex Mono", monospace;
  font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent-ink); margin-top: 4px;
}

.hero-note { color: var(--ink-2); font-size: 14px; max-width: 62ch; margin: 10px auto 0; text-align: center; }

.assume-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  flex-wrap: wrap; margin-top: 16px;
}
.assume-label {
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3);
}
.assume-chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.assume-chip {
  display: inline-flex; align-items: center; gap: 7px;
  appearance: none; cursor: pointer;
  font: 500 12.5px "IBM Plex Sans", sans-serif;
  padding: 6px 12px 6px 9px; border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface-raised); color: var(--ink-2);
  transition: border-color .15s, color .15s, opacity .15s;
}
.assume-chip .a-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.assume-chip .assume-check {
  width: 15px; height: 15px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font: 600 10px "IBM Plex Mono", monospace;
  background: var(--surface-sunken); color: var(--ink-3);
}
.assume-chip:hover { border-color: var(--ink-3); color: var(--ink); }
.assume-chip.is-on { border-color: var(--ink); color: var(--ink); }
.assume-chip.is-on .assume-check { background: var(--ink); color: var(--surface); }
.assume-chip:not(.is-on) .a-dot { opacity: .35; }

@media (max-width: 760px) {
  .chamber-stage { grid-template-columns: 1fr 1fr; grid-template-areas: "chamber chamber" "left right"; }
  .chamber-wrap { grid-area: chamber; }
  .bloc-figure--left { grid-area: left; }
  .bloc-figure--right { grid-area: right; }
}

/* ---------------- sections ---------------- */

.section { padding: 52px 0 8px; }
.section-head { margin-bottom: 22px; max-width: 70ch; }
.section-head h2 {
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 700;
  font-size: clamp(21px, 2.6vw, 28px); letter-spacing: -.015em; margin-bottom: 8px;
}
.section-sub { color: var(--ink-2); font-size: 15px; }

.card {
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------------- party cards ---------------- */

.party-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.party-card {
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-top: 4px solid var(--party, var(--hairline));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 12px;
  display: flex; flex-direction: column; gap: 8px;
}

.party-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.party-abbr {
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 19px;
  letter-spacing: -.01em;
}
.party-name { font-size: 12px; color: var(--ink-3); line-height: 1.3; }

.party-figures { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.party-share { font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; font-size: 26px; line-height: 1; }
.party-share small { font-size: 13px; font-weight: 500; color: var(--ink-3); }
.party-seats { font-size: 13px; color: var(--ink-2); text-align: right; }
.party-seats b { font-size: 17px; color: var(--ink); }

.party-meter {
  height: 5px; border-radius: 3px; background: var(--surface-sunken);
  position: relative; overflow: visible;
}
.party-meter-fill {
  position: absolute; inset: 0 auto 0 0; border-radius: 3px;
  background: var(--party); min-width: 2px;
  transition: width .6s cubic-bezier(.6,.05,.2,1);
}
.party-meter-threshold {
  position: absolute; top: -3px; bottom: -3px; width: 1px;
  background: var(--ink-3);
}

.party-flags { font-size: 11px; color: var(--ink-3); min-height: 15px; }
.party-flags .warn { color: var(--accent-ink); }

.align-toggle {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  border: 1px solid var(--hairline); border-radius: 9px; overflow: hidden;
  background: var(--surface-sunken);
}
.align-toggle button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font-family: "IBM Plex Mono", monospace; font-size: 11px; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 7px 0; color: var(--ink-3);
}
.align-toggle button:hover { color: var(--ink); }
.align-toggle button.is-on { background: var(--ink); color: var(--surface); }
.align-toggle button:focus-visible { outline-offset: -2px; }
.align-toggle.is-locked button { cursor: default; }
.align-toggle.is-locked button:not(.is-on) { opacity: .35; }

/* ---------------- chances ---------------- */

.section-head .eyebrow { margin-bottom: 8px; }

.chances-card { padding: 22px 24px 18px; }
.chances-bars { display: flex; flex-direction: column; gap: 4px; }
.chance-row { display: grid; grid-template-columns: minmax(190px, 300px) 1fr 52px; align-items: center; gap: 14px; padding: 6px 0; }
.chance-label { font-size: 14px; font-weight: 500; }
.chance-track { height: 20px; border-radius: 5px; background: var(--surface-sunken); position: relative; }
.chance-fill {
  position: absolute; inset: 0 auto 0 0; border-radius: 5px;
  background: var(--bar); min-width: 3px;
  transition: width .6s cubic-bezier(.6,.05,.2,1);
}
.chance-val {
  font-family: "IBM Plex Mono", monospace; font-size: 14px; font-weight: 500;
  text-align: right; font-variant-numeric: tabular-nums;
}
@media (max-width: 640px) {
  .chance-row { grid-template-columns: 1fr 60px; grid-template-areas: "label val" "track track"; row-gap: 4px; }
  .chance-label { grid-area: label; font-size: 13px; }
  .chance-track { grid-area: track; }
  .chance-val { grid-area: val; }
}

.chances-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  border-top: 1px solid var(--hairline); margin-top: 16px; padding-top: 16px;
}
.prob-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--ink-2);
  border: 1px solid var(--hairline); border-radius: 999px;
  padding: 7px 14px; background: var(--surface);
}
.prob-chip b { font-family: "IBM Plex Mono", monospace; font-size: 13px; color: var(--ink); font-weight: 500; }
.prob-chip .a-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.prob-chip--none { border-style: dashed; color: var(--ink-3); }

.party-range { display: block; font-size: 11px; color: var(--ink-3); margin-top: 1px; }

.wildcard {
  border-top: 1px solid var(--hairline);
  margin-top: 16px; padding-top: 14px;
}
.wildcard-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.wildcard-title {
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; font-size: 13.5px;
}
.wildcard-badge {
  font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent-ink); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px; padding: 2px 8px; cursor: help;
}
.wildcard-row { display: flex; align-items: baseline; gap: 10px; }
.wildcard-dots { display: inline-flex; gap: 3px; flex: none; align-self: center; }
.wildcard-dots .a-dot { width: 9px; height: 9px; border-radius: 50%; }
.wildcard-label { font-size: 14px; font-weight: 500; }
.wildcard-val {
  font-family: "IBM Plex Mono", monospace; font-size: 15px; font-weight: 500;
  margin-left: auto; flex: none;
}
.wildcard-note { font-size: 12px; color: var(--ink-3); margin-top: 7px; max-width: 90ch; }

/* ---------------- filter row ---------------- */

.filter-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-right: 4px; }
.range-btn {
  appearance: none; cursor: pointer;
  border: 1px solid var(--hairline); background: var(--surface-raised); color: var(--ink-2);
  font: 500 12.5px "IBM Plex Sans", sans-serif;
  padding: 6px 14px; border-radius: 999px;
}
.range-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.range-btn.is-active { background: var(--ink); border-color: var(--ink); color: var(--surface); }

/* ---------------- trend chart ---------------- */

.chart-card { padding: 18px 14px 10px; }
.chart-holder { position: relative; }
#trend { width: 100%; display: block; }

#trend .grid-line { stroke: var(--hairline); stroke-width: 1; }
#trend .axis-text { font: 11px "IBM Plex Mono", monospace; fill: var(--ink-3); }
#trend .threshold-line { stroke: var(--ink-3); stroke-width: 1; }
#trend .threshold-text { font: 10px "IBM Plex Mono", monospace; fill: var(--ink-3); letter-spacing: .08em; }
#trend .poll-dot { opacity: .22; }
#trend .avg-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
#trend .end-label { font: 600 11.5px "IBM Plex Sans", sans-serif; fill: var(--ink); }
#trend .end-label .pct { font-family: "IBM Plex Mono", monospace; font-weight: 500; fill: var(--ink-2); }
#trend .election-mark { stroke: var(--ink-3); stroke-width: 1; }
#trend .crosshair { stroke: var(--ink-3); stroke-width: 1; }

.legend {
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  padding: 10px 8px 8px; border-top: 1px solid var(--hairline); margin-top: 8px;
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.legend-swatch { width: 14px; height: 3px; border-radius: 2px; background: var(--sw); }

.tooltip {
  position: absolute; pointer-events: none; z-index: 10;
  background: var(--surface-raised);
  border: 1px solid var(--hairline); border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 9px 12px; font-size: 12px; min-width: 150px;
}
.tooltip-date { font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 5px; text-transform: uppercase; }
.tooltip-row { display: flex; align-items: center; gap: 7px; line-height: 1.75; }
.tooltip-row .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tooltip-row .val { margin-left: auto; font-family: "IBM Plex Mono", monospace; color: var(--ink); }

/* ---------------- polls table ---------------- */

.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }

.polls-table { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 720px; }
.polls-table th, .polls-table td { padding: 9px 12px; text-align: right; white-space: nowrap; }
.polls-table th:first-child, .polls-table td:first-child,
.polls-table th:nth-child(2), .polls-table td:nth-child(2) { text-align: left; }
.polls-table thead th {
  font: 500 10.5px "IBM Plex Mono", monospace; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; background: var(--surface-raised);
}
.polls-table thead .party-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.polls-table tbody td { border-bottom: 1px solid color-mix(in srgb, var(--hairline) 55%, transparent); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.polls-table tbody td.num-top { color: var(--ink); font-weight: 600; }
.polls-table td.pollster { color: var(--ink); font-weight: 500; }
.polls-table td.date { color: var(--ink-3); font-family: "IBM Plex Mono", monospace; font-size: 11.5px; }
.polls-table tr.election-row td { background: color-mix(in srgb, var(--accent) 7%, transparent); color: var(--ink); }
.polls-table .lead-chip {
  display: inline-block; min-width: 44px; text-align: center;
  font-family: "IBM Plex Mono", monospace; font-size: 11px;
  padding: 2px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--lead) 14%, transparent);
  color: var(--ink);
}

.show-more {
  display: block; width: 100%; appearance: none; cursor: pointer;
  border: 0; border-top: 1px solid var(--hairline);
  background: transparent; color: var(--accent-ink);
  font: 600 13px "IBM Plex Sans", sans-serif; padding: 12px;
}
.show-more:hover { background: var(--surface-sunken); }

/* ---------------- preferred PM ---------------- */

.pm-card { padding: 20px 22px 16px; }
.pm-row { display: grid; grid-template-columns: 150px 1fr 52px; align-items: center; gap: 12px; padding: 7px 0; }
.pm-name { font-weight: 600; font-size: 14px; }
.pm-name small { display: block; font-weight: 400; font-size: 11px; color: var(--ink-3); }
.pm-bar-track { height: 18px; border-radius: 4px; background: var(--surface-sunken); position: relative; }
.pm-bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px 4px 4px 4px; background: var(--bar); transition: width .6s cubic-bezier(.6,.05,.2,1); }
.pm-val { font-family: "IBM Plex Mono", monospace; font-size: 13px; text-align: right; }
.pm-note { margin-top: 12px; font-size: 12px; color: var(--ink-3); }
@media (max-width: 560px) { .pm-row { grid-template-columns: 110px 1fr 46px; } }

/* ---------------- method ---------------- */

.section--method { padding-bottom: 40px; }
.method-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 760px) { .method-grid { grid-template-columns: 1fr; } }
.method-col h3 {
  font-family: "Bricolage Grotesque", sans-serif; font-size: 15px; font-weight: 700;
  margin: 18px 0 6px;
}
.method-col h3:first-child { margin-top: 0; }
.method-col p { font-size: 14px; color: var(--ink-2); margin-bottom: 8px; }

/* ---------------- footer ---------------- */

.footer { border-top: 1px solid var(--hairline); margin-top: 28px; background: var(--surface-sunken); }
.footer-inner { padding: 28px 24px 36px; }
.footer p { font-size: 13px; color: var(--ink-2); max-width: 82ch; margin-bottom: 8px; }
.footer-stamp { font-size: 11px; color: var(--ink-3); margin-top: 14px; }
