/* Colors and fonts are overridden at runtime from [branding] in the config (data/site.json). */
:root {
  --bg: #000000;
  --surface: #161616;
  --surface-2: color-mix(in srgb, var(--surface) 80%, var(--text));
  --line: color-mix(in srgb, var(--surface) 75%, var(--text));
  --text: #ffffff;
  --muted: #a3a3a3;
  --accent: #fec900;
  --accent-text: #000000;
  --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface));
  --accent-light: color-mix(in srgb, var(--accent) 50%, var(--surface));
  --coalition: #cf7bcc;
  --gradient: linear-gradient(90deg, #cf7bcc, #fdc801);
  --font-heading: "Bebas Neue", Impact, sans-serif;
  --font-body: Roboto, Helvetica, Arial, sans-serif;
  --radius: 4px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

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

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.warn { color: var(--accent); font-weight: 500; }

/* Header ------------------------------------------------------------------------------------------ */
.header { background: var(--bg); border-bottom: 1px solid var(--line); }
.header__inner {
  max-width: 1400px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 32px; flex-wrap: wrap;
}
.header__brand img { height: 34px; display: block; }
.header__party { font: 2rem/1 var(--font-heading); }
.header__nav { display: flex; gap: 24px; }
.header__nav a {
  font: 1.6rem/1 var(--font-heading); letter-spacing: 0.02em; text-decoration: none;
  padding: 6px 0; border-bottom: 3px solid transparent; color: var(--muted);
}
.header__nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.header__nav a:hover { color: var(--text); }
.header__status { margin-left: auto; font-size: 0.9rem; color: var(--muted); }
.gradient-bar { height: 5px; background: var(--gradient); }

/* Page ------------------------------------------------------------------------------------------ */
.page { max-width: 1400px; margin: 0 auto; padding: 24px 24px 48px; }

.hero { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 8px 0 20px; }
.hero h1 { font: clamp(2.6rem, 6vw, 4.5rem)/0.95 var(--font-heading); margin: 0; letter-spacing: 0.01em; }
.slogan {
  /* The gradient is painted only inside the element's box: leave room above the caps
     for diacritics (Ť, Ž), otherwise the carons get cut off. */
  font: clamp(1.8rem, 4vw, 3rem)/1.2 var(--font-heading); margin: 0; padding-top: 0.15em;
  background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* Filters: one row above everything they scope */
.filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 24px;
  padding: 16px 0 20px; border-bottom: 1px solid var(--line); margin-bottom: 24px;
}
.field { display: grid; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.field select, .field input {
  font: inherit; font-size: 1rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 12px; min-width: 220px;
}
.field--search { margin-left: auto; }
.segmented { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0; }
.segmented legend { font-size: 0.85rem; color: var(--muted); padding: 0; margin-bottom: 6px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: block; padding: 9px 14px; border: 1px solid var(--line); background: var(--surface);
  margin-left: -1px; cursor: pointer; font-size: 0.95rem;
}
.segmented label:first-of-type span { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.segmented label:last-of-type span { border-radius: 0 var(--radius) var(--radius) 0; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 500; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* KPI tiles ---------------------------------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 16px; }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 22px 24px; display: flex; flex-direction: column; gap: 4px; }
.kpi--hero { border-top: 4px solid var(--accent); }
.kpi:not(.kpi--hero) { border-top: 4px solid var(--line); }
.kpi__label { font-size: 1.05rem; font-weight: 500; margin: 0; }
.kpi__value { margin: 6px 0 0; display: flex; align-items: baseline; gap: 12px; }
.kpi__num { font: clamp(3.5rem, 7vw, 6rem)/0.9 var(--font-heading); color: var(--accent); }
.kpi:not(.kpi--hero) .kpi__num { color: var(--text); }
.kpi__of { font: clamp(1.8rem, 3vw, 2.6rem)/1 var(--font-heading); color: var(--muted); }
.kpi__caption { margin: 0 0 8px; color: var(--muted); }
.kpi__note { margin: auto 0 0; font-size: 0.9rem; color: var(--muted); }
.kpi__legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; font-size: 0.85rem; color: var(--muted); }
.kpi__legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--accent); margin-right: 6px; }
.kpi__legend .key--light { background: var(--accent-light); }
.kpi__compare { margin: 8px 0 0; font-size: 0.85rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }

/* Meter: same-hue track, solid + lighter segment separated by a 2px surface gap */
.meter { display: flex; gap: 2px; height: 10px; border-radius: 5px; background: var(--accent-track); overflow: hidden; }
.meter__fill { display: block; height: 100%; background: var(--accent); border-radius: 5px; transition: width 0.6s ease; }
.meter__fill--light { background: var(--accent-light); }
.meter__fill--cut { background: var(--bg); margin-left: auto; }
.kpi__legend .key--cut { background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.meter__fill[style="width:0%"] { display: none; }

.progress { display: flex; flex-wrap: wrap; gap: 8px 32px; align-items: flex-end; margin: 24px 0 8px; }
.progress__ours { flex: 1 1 420px; display: grid; gap: 8px; }
.progress__ours p { margin: 0; }
.progress__national { margin: 0; font-size: 0.9rem; flex: 1 1 300px; text-align: right; }
.progress .meter { height: 6px; }

/* Sections ----------------------------------------------------------------------------------------- */
.section-title { font: 2.2rem/1 var(--font-heading); margin: 40px 0 16px; letter-spacing: 0.01em; display: inline-block; }
.section-title .count { color: var(--accent); margin-left: 6px; }
details.section summary { cursor: pointer; list-style: none; }
details.section summary::-webkit-details-marker { display: none; }
details.section summary .section-title::after { content: " ▸"; color: var(--muted); font-size: 1.4rem; }
details.section[open] summary .section-title::after { content: " ▾"; }
details.section > p { margin: 0 0 12px; }
.help { margin: -8px 0 20px; font-size: 0.9rem; color: var(--muted); }
.help summary { cursor: pointer; width: fit-content; }
.help summary:hover { color: var(--text); }
.help ul { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 6px; max-width: 90ch; }
.help strong { color: var(--text); font-weight: 500; }
.empty { color: var(--muted); padding: 24px; background: var(--surface); border-radius: var(--radius); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.card__head h3 { font-size: 1.25rem; margin: 0 0 2px; }
.card__head p { margin: 0; font-size: 0.85rem; }
.party { border-top: 1px solid var(--line); padding-top: 10px; }
.party__name { margin: 0; font-weight: 500; }
.party__result { margin: 2px 0 8px; color: var(--muted); }
.party__result strong { color: var(--accent); font-weight: 700; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.people li { display: flex; align-items: center; gap: 8px; }
.person__name { flex: 1; }
.person__votes { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

.tag {
  display: inline-block; font-size: 0.72rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 3px; border: 1px solid var(--muted); color: var(--muted); white-space: nowrap;
}
.tag--member { border-color: var(--accent); color: var(--accent); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 0.85rem; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--surface-2); vertical-align: top; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.button {
  margin-top: 12px; font: inherit; color: var(--text); background: transparent; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px;
}
.button:hover { border-color: var(--accent); color: var(--accent); }
.plain-list { margin: 0; padding-left: 20px; columns: 2 420px; column-gap: 32px; }
.plain-list li { margin-bottom: 6px; break-inside: avoid; }

/* Senate -------------------------------------------------------------------------------------------- */
/* One candidate per row; fixed rank/votes columns keep the numbers aligned across rows. */
.cands { display: grid; gap: 10px; margin-top: 16px; }
.cand {
  display: grid; align-items: center; gap: 12px 24px; padding: 16px 20px;
  grid-template-columns: 64px minmax(0, 1.5fr) 100px 140px minmax(0, 1.3fr);
  grid-template-areas: "photo who rank votes info";
  background: var(--surface); border-radius: var(--radius); border-left: 6px solid var(--accent);
}
.cand--coalition { border-left-color: var(--coalition); }
.cand p { margin: 0; }
.cand__photo { grid-area: photo; width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.cand__photo--initials { display: grid; place-items: center; font: 1.8rem/1 var(--font-heading); color: var(--muted); }
.cand__who { grid-area: who; }
.cand__who h3 { font-size: 1.25rem; margin: 6px 0 2px; }
.cand__who p { margin-bottom: 2px; }
.cand__party { color: var(--text); font-weight: 500; }
.badge {
  display: inline-block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 3px 8px; border-radius: 3px; background: var(--accent); color: var(--accent-text);
}
.badge--coalition { background: var(--coalition); color: #000; }
.cand__rank { grid-area: rank; display: grid; gap: 2px; }
.cand__place { font: 2.6rem/1 var(--font-heading); color: var(--accent); }
.cand--coalition .cand__place { color: var(--coalition); }
.cand__votes { grid-area: votes; display: grid; gap: 2px; text-align: right; }
.cand__votes strong { font: 2.6rem/1 var(--font-heading); }
.cand__info { grid-area: info; display: grid; gap: 4px; }
.cand__info .meter { height: 6px; margin: 2px 0; }
.status { margin: 0; font-weight: 500; }
.status--won { color: var(--accent); }

/* Footer ------------------------------------------------------------------------------------------- */
.footer { border-top: 1px solid var(--line); padding: 24px; text-align: center; color: var(--muted); font-size: 0.85rem; }
.footer p { margin: 4px 0; }
.footer__slogan { font: 1.8rem/1 var(--font-heading); color: var(--accent); margin-top: 12px !important; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: 1fr; }
  .field--search { margin-left: 0; }
  .progress__national { text-align: left; }
}
@media (max-width: 1100px) {
  .cand {
    grid-template-columns: 56px minmax(0, 1fr) auto;
    grid-template-areas: "photo who who" "rank rank votes" "info info info";
    align-items: start;
  }
  .cand__photo { width: 56px; height: 56px; }
  .cand__rank { display: flex; align-items: baseline; gap: 8px; }
  .cand__rank, .cand__votes { border-top: 1px solid var(--line); padding-top: 10px; align-self: stretch; }
}
@media (max-width: 600px) {
  .page { padding: 16px 16px 40px; }
  .header__inner { padding: 10px 16px; gap: 12px 20px; }
  .header__status { margin-left: 0; width: 100%; }
  .field select, .field input { min-width: 0; width: 100%; }
  .field { width: 100%; }
  .cards { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .meter__fill { transition: none; }
}
