/* govwatch dashboard styling.
 *
 * Colors come from the validated reference data-viz palette: chart surfaces,
 * ink, gridlines, the sequential blue ramp, and the first three categorical
 * slots. Charts stay inside that validated set — single-series bars use slot 1,
 * the heat grid uses the sequential blue ramp, and comparisons cap at three
 * series, which is the documented all-pairs limit. */

:root {
  color-scheme: light;
  --plane:          #f9f9f7;
  --surface:        #fcfcfb;
  --ink:            #0b0b0b;
  --ink-2:          #52514e;
  /* Darker than the palette's muted step. That step is documented for chart
     axis labels, where it reads against a mark; as page text at 12-13px it
     only reaches 3.5:1 on this surface, short of the 4.5:1 that body text
     needs. Chart ticks keep the original value in --chart-muted. */
  --ink-muted:      #6e6d68;
  --chart-muted:    #898781;
  --link:           #256abf;   /* seq 500: 5.3:1 on the light surface */
  --link-on-chip:   #1c5cab;   /* chips sit on a tinted fill, so links need a step darker */
  --grid:           #e1e0d9;
  --axis:           #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);
  --series-1:       #2a78d6;
  --series-2:       #eb6834;
  --series-3:       #1baf7a;
  --seq-100:        #cde2fb;
  --seq-250:        #86b6ef;
  --seq-400:        #3987e5;
  --seq-550:        #1c5cab;
  --seq-600:        #184f95;
  --seq-700:        #0d366b;
  --btn-bg:         #1c5cab;   /* seq 550: white text reads 6.6:1 */
  --btn-ink:        #ffffff;
  --good:           #0ca30c;
  --warning:        #fab219;
  --serious:        #ec835a;
  --critical:       #d03b3b;
  --chip:           #f0efec;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:      #0d0d0d;
    --surface:    #1a1a19;
    --ink:        #ffffff;
    --ink-2:      #c3c2b7;
    --ink-muted:  #898781;
    --chart-muted: #898781;
    --link:       #3987e5;
    --link-on-chip: #86b6ef;
    --grid:       #2c2c2a;
    --axis:       #383835;
    --border:     rgba(255, 255, 255, 0.10);
    --series-1:   #3987e5;
    --series-2:   #d95926;
    --series-3:   #199e70;
    --chip:       #383835;
    /* A light fill with dark ink on the dark page: white on a mid blue only
       reaches 3.6:1, which fails AA for button text. Inverting the button is
       what gets it to 9.3:1 without inventing a colour. */
    --btn-bg:     #86b6ef;
    --btn-ink:    #0b0b0b;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:      #0d0d0d;
  --surface:    #1a1a19;
  --ink:        #ffffff;
  --ink-2:      #c3c2b7;
  --ink-muted:  #898781;
  --chart-muted: #898781;
  --link:       #3987e5;
  --link-on-chip: #86b6ef;
  --grid:       #2c2c2a;
  --axis:       #383835;
  --border:     rgba(255, 255, 255, 0.10);
  --series-1:   #3987e5;
  --series-2:   #d95926;
  --series-3:   #199e70;
  --chip:       #383835;
  --btn-bg:     #86b6ef;
  --btn-ink:    #0b0b0b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px 64px; }

/* ---------- header ---------- */

header.top {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
header.top .wrap { padding-bottom: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 20px; }
header.top h1 { font-size: 17px; margin: 14px 0; letter-spacing: -0.01em; }
header.top h1 a { color: var(--ink); }
nav.main { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
nav.main a {
  padding: 14px 10px;
  color: var(--ink-2);
  border-bottom: 2px solid transparent;
  font-size: 14px;
}
nav.main a.on { color: var(--ink); border-bottom-color: var(--link); }
nav.main a:hover { text-decoration: none; color: var(--ink); }

/* ---------- generic blocks ---------- */

h2 { font-size: 20px; margin: 32px 0 4px; letter-spacing: -0.01em; }
h3 { font-size: 15px; margin: 24px 0 8px; }
p.lede { color: var(--ink-2); margin: 4px 0 20px; max-width: 68ch; }
.muted { color: var(--ink-muted); }
.small { font-size: 13px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin: 16px 0;
}

.scroll-x { overflow-x: auto; }

/* ---------- stat tiles ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 20px 0; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.tile .n { font-size: 28px; line-height: 1.1; letter-spacing: -0.02em; }
.tile .k { font-size: 13px; color: var(--ink-2); margin-top: 4px; }

/* ---------- filters ---------- */

form.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 18px 0 8px; }
form.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
form.filters select, form.filters input[type=search], form.filters input[type=text] {
  font: inherit;
  font-size: 14px;
  padding: 7px 9px;
  border: 1px solid var(--axis);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  min-width: 150px;
}
form.filters button {
  font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 7px;
  border: 1px solid var(--btn-bg); background: var(--btn-bg); color: var(--btn-ink); cursor: pointer;
}
form.filters a.clear { font-size: 13px; padding-bottom: 8px; }

/* ---------- meeting list ---------- */

ul.meetings { list-style: none; padding: 0; margin: 8px 0 0; }
ul.meetings li {
  display: grid;
  grid-template-columns: 118px 1fr auto;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--grid);
  align-items: start;
}
ul.meetings li:first-child { border-top: none; }
.when { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.when .day { display: block; color: var(--ink); font-size: 14px; }
.who { font-size: 13px; color: var(--ink-2); }
.what { font-weight: 500; }
.what a { color: var(--ink); }
.links { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; justify-content: flex-end; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip a { color: var(--link-on-chip); }
.chip.type { border: 1px solid var(--axis); background: transparent; }
/* border-color alone draws nothing — the base chip sets no border-style, so
   this rendered as bare red text beside pill-shaped siblings. */
.chip.cancelled { color: var(--critical); border: 1px solid var(--critical); background: transparent; }

/* ---------- agenda drilldown ---------- */

ol.agenda { list-style: none; padding: 0; margin: 0; counter-reset: none; }
ol.agenda li { padding: 12px 0; border-top: 1px solid var(--grid); }
ol.agenda li:first-child { border-top: none; }
ol.agenda .num { font-variant-numeric: tabular-nums; color: var(--ink-muted); font-size: 13px; margin-right: 8px; }
ol.agenda .body { margin-top: 6px; color: var(--ink-2); font-size: 14px; }
ol.agenda .outcome { margin-top: 6px; font-size: 13px; color: var(--ink-2); border-left: 2px solid var(--axis); padding-left: 10px; }
ol.agenda li.procedural { opacity: 0.65; }

/* ---------- tables ---------- */

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--grid); vertical-align: top; }
/* Column headers only. This applied to every th, and a row header is a th
   too, so it shouted the contest names down the first column of the elections
   table — capitals the source data had and the page had already fixed. */
thead th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-muted); font-weight: 600; }
tbody th { font-weight: 600; }

/* A right-aligned number needs a gutter on the side it is aligned to, or it
   touches whatever follows: cells carry no left padding, so padding-right: 0
   here rendered "MEETINGSLAST SUCCESS" and "13210 min ago". These columns are
   never last, so hugging the edge bought nothing. */
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; padding-right: 18px; }
td.n:last-child, th.n:last-child { padding-right: 0; }

/* ---------- charts ---------- */

figure { margin: 12px 0 0; }
figcaption { font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.chart svg { display: block; max-width: 100%; height: auto; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--chart-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .label { fill: var(--ink-2); font-size: 12px; }
.chart .value { fill: var(--ink-2); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--series-1); }
.chart .bar:hover, .chart .cell:hover { opacity: 0.82; }
.chart .spark { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cell { stroke: var(--surface); stroke-width: 2; }

.multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-top: 12px; }
.multiple { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--surface); }
.multiple .name { font-size: 13px; font-weight: 500; }
.multiple .n { font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin: 8px 0 0; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ---------- status ---------- */

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 7px; vertical-align: 1px; }
.dot.ok { background: var(--good); }
.dot.warn { background: var(--warning); }
.dot.bad { background: var(--critical); }
.state { white-space: nowrap; }

/* ---------- small layout utilities ---------- */

/* These replace style="" attributes in the templates. The CSP sets
   style-src 'self' with no unsafe-inline, so every one of those attributes was
   being dropped by the browser and the spacing they described never applied. */
.links.start { justify-content: flex-start; }
.mb-lg { margin-bottom: 20px; }
.mb-md { margin-bottom: 18px; }
.mb-sm { margin-bottom: 12px; }
.flush-top { margin-top: 0; }
td.note { padding-top: 0; border-bottom: 1px solid var(--grid); }

/* ---------- tooltip ---------- */

#tip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 12.5px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  max-width: 260px;
  display: none;
  white-space: pre-line;
}

footer.foot { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 13px; color: var(--ink-muted); }

@media (max-width: 720px) {
  ul.meetings li { grid-template-columns: 1fr; gap: 6px; }
  .links { justify-content: flex-start; }
}

/* ---------- accessibility ---------- */

/* A skip link is the fastest way past a sticky nav for keyboard users. It stays
 * out of the way until focused, rather than being hidden from everyone. */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 16px;
  border: 2px solid var(--link);
  border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

/* Focus must be visible on every interactive thing, including the SVG marks,
 * which are focusable so a keyboard user can read their values. */
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 3px;
}
.chart [tabindex]:focus-visible { outline-offset: 1px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* The site name is a link, not a heading, so it needs its own type. */
p.brand { font-size: 17px; font-weight: 600; margin: 14px 0; letter-spacing: -0.01em; }
p.brand a { color: var(--ink); }

h1 { font-size: 22px; margin: 30px 0 4px; letter-spacing: -0.015em; }

nav.main button#theme-toggle {
  font: inherit;
  font-size: 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ink-2);
  padding: 14px 10px;
  cursor: pointer;
}
nav.main button#theme-toggle:hover { color: var(--ink); }

caption {
  caption-side: top;
  text-align: left;
  font-size: 13px;
  color: var(--ink-2);
  padding-bottom: 8px;
}

/* Reduced motion: nothing here animates, but a tooltip that follows the pointer
 * is motion. Pin it in place for anyone who asks for less of that. */
@media (prefers-reduced-motion: reduce) {
  #tip { transition: none !important; }
}

details.data-table { margin-top: 10px; }
details.data-table summary { cursor: pointer; font-size: 13px; color: var(--ink-2); }
details.data-table table { margin-top: 10px; }

/* Search result context: the agenda line that actually matched. */
.snippet {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 5px;
  border-left: 2px solid var(--axis);
  padding-left: 10px;
}
.snippet mark {
  background: var(--seq-100);
  color: var(--ink);
  padding: 0 2px;
  border-radius: 2px;
}
:root[data-theme="dark"] .snippet mark { background: var(--seq-600); color: #ffffff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .snippet mark { background: var(--seq-600); color: #ffffff; }
}

/* ---------- agenda revisions ---------- */

ul.revisions { list-style: none; padding: 0; margin: 8px 0 0; }
ul.revisions > li { padding: 12px 0; border-top: 1px solid var(--grid); }
ul.revisions > li:first-child { border-top: none; }
ul.revisions ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
ul.revisions ul li { margin: 3px 0; }

ul.board-list { list-style: none; padding: 0; margin: 8px 0 0; columns: 2; column-gap: 32px; }
ul.board-list li { padding: 4px 0; break-inside: avoid; }
@media (max-width: 640px) { ul.board-list { columns: 1; } }

.panel.participate { border-left: 3px solid var(--link); }

/* An uncontested or unfilled seat is a finding, not decoration. It gets the
 * status color plus its own words, never color alone. */
.chip.warn-chip {
  background: transparent;
  border: 1px solid var(--serious);
  color: var(--ink-2);
}
