/*
  Friendly quiz look. Colour without picking a side:
  - Each topic has its own soft colour. Nine hues are used evenly, so none reads as a party's.
  - Buttons use violet. No party contesting the 2026 Victorian election campaigns in violet.
  - Option cards are always identical: colour never separates option A from option B.
  Calm rules kept: no animation or transitions, 18px minimum text, 48px tap targets.
  Every text colour pair is 4.5:1 or better and control edges are 3:1 or better, in both themes.
*/
:root {
  --bg: #f7f7fa;
  --surface: #ffffff;
  --text: #1f2130;
  --muted: #555a6e;
  --border: #e1e3ea;
  --border-strong: #858a9e;
  --brand: #5b3fd6;
  --brand-hover: #4a30c0;
  --brand-text: #ffffff;
  --brand-tint: #eeeafd;
  --bar-track: #e6e7ee;
  --focus: #1f2130;
  --shadow: 0 1px 2px rgba(31, 33, 48, 0.06), 0 4px 14px rgba(31, 33, 48, 0.06);
  --radius: 1rem;
  /* Topic colours: tint (backgrounds) and strong (text, fills) */
  --treaty-tint: #fdebd3; --treaty: #8a4510;
  --energy-tint: #fdf2c2; --energy: #745600;
  --housing-tint: #fde1da; --housing: #9b3218;
  --transport-tint: #dbeafc; --transport: #1c4f8c;
  --firearms-tint: #e4e8ef; --firearms: #3a4a60;
  --crime-tint: #e5e3fc; --crime: #3f37a0;
  --forests-tint: #d9f2e1; --forests: #1d6b38;
  --cost-tint: #d5f2ee; --cost: #0e5f57;
  --health-tint: #fbe0eb; --health: #9a2257;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14151b; --surface: #1d1f28; --text: #ecedf3; --muted: #a9adbd; --border: #2e3140; --border-strong: #6b7086;
    --brand: #ab9cff; --brand-hover: #c2b8ff; --brand-text: #14151b; --brand-tint: #2a2546; --bar-track: #2c2f3c;
    --focus: #ecedf3; --shadow: none;
    --treaty-tint: #3a2a1a; --treaty: #f2b77a; --energy-tint: #3a321a; --energy: #f1d36a;
    --housing-tint: #3d2421; --housing: #f6a491; --transport-tint: #1d2c40; --transport: #93c0f5;
    --firearms-tint: #262c36; --firearms: #b5c2d6; --crime-tint: #26244a; --crime: #b4adf7;
    --forests-tint: #1c3326; --forests: #8fd9a8; --cost-tint: #173330; --cost: #85d8cd;
    --health-tint: #3b2030; --health: #f3a3c6;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14151b; --surface: #1d1f28; --text: #ecedf3; --muted: #a9adbd; --border: #2e3140; --border-strong: #6b7086;
  --brand: #ab9cff; --brand-hover: #c2b8ff; --brand-text: #14151b; --brand-tint: #2a2546; --bar-track: #2c2f3c;
  --focus: #ecedf3; --shadow: none;
  --treaty-tint: #3a2a1a; --treaty: #f2b77a; --energy-tint: #3a321a; --energy: #f1d36a;
  --housing-tint: #3d2421; --housing: #f6a491; --transport-tint: #1d2c40; --transport: #93c0f5;
  --firearms-tint: #262c36; --firearms: #b5c2d6; --crime-tint: #26244a; --crime: #b4adf7;
  --forests-tint: #1c3326; --forests: #8fd9a8; --cost-tint: #173330; --cost: #85d8cd;
  --health-tint: #3b2030; --health: #f3a3c6;
  color-scheme: dark;
}

/* Which topic colour applies. Unknown topics fall back to violet. */
[data-topic] { --t-tint: var(--brand-tint); --t: var(--brand); }
[data-topic="treaty"] { --t-tint: var(--treaty-tint); --t: var(--treaty); }
[data-topic="energy"] { --t-tint: var(--energy-tint); --t: var(--energy); }
[data-topic="housing"] { --t-tint: var(--housing-tint); --t: var(--housing); }
[data-topic="transport"] { --t-tint: var(--transport-tint); --t: var(--transport); }
[data-topic="firearms"] { --t-tint: var(--firearms-tint); --t: var(--firearms); }
[data-topic="crime"] { --t-tint: var(--crime-tint); --t: var(--crime); }
[data-topic="forests"] { --t-tint: var(--forests-tint); --t: var(--forests); }
[data-topic="cost-of-living"] { --t-tint: var(--cost-tint); --t: var(--cost); }
[data-topic="health"] { --t-tint: var(--health-tint); --t: var(--health); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.125rem; /* 18px */
  line-height: 1.55;
}
p { margin: 0 0 0.85rem; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1:focus, h3:focus, p:focus { outline: none; }

/* Header, with a strip of all nine topic colours */
.site-header { background: var(--surface); box-shadow: var(--shadow); }
.site-header .inner { max-width: 40rem; margin: 0 auto; padding: 0.75rem 1rem; display: flex; align-items: center; gap: 0.7rem; }
.logo { width: 2.25rem; height: 2.25rem; flex: none; }
.wordmark { font-weight: 800; letter-spacing: -0.01em; display: block; line-height: 1.25; }
.site-header .where { color: var(--muted); display: block; line-height: 1.3; }
.strip {
  height: 0.35rem;
  background: linear-gradient(90deg,
    var(--treaty) 0 11.11%, var(--energy) 11.11% 22.22%, var(--housing) 22.22% 33.33%,
    var(--transport) 33.33% 44.44%, var(--firearms) 44.44% 55.55%, var(--crime) 55.55% 66.66%,
    var(--forests) 66.66% 77.77%, var(--cost) 77.77% 88.88%, var(--health) 88.88% 100%);
}

main, footer { max-width: 40rem; margin: 0 auto; padding: 1.75rem 1rem 1rem; }
@media (min-width: 48rem) { main { padding-top: 2.75rem; } }

h1 { font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.35rem); line-height: 1.15; letter-spacing: -0.02em; font-weight: 800; margin: 0 0 0.9rem; }
h2 { font-size: 1.25rem; line-height: 1.3; font-weight: 800; margin: 2rem 0 0.6rem; }
h3 { font-size: 1.125rem; font-weight: 800; margin: 1.5rem 0 0.5rem; }
.lead { font-size: 1.25rem; line-height: 1.5; }
.muted, .note { color: var(--muted); }
.notice { background: var(--brand-tint); border-radius: 0.75rem; padding: 0.8rem 1rem; }

/* Buttons */
button {
  font: inherit; font-weight: 700; color: var(--text);
  min-height: 3rem; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  padding: 0.7rem 1.4rem; cursor: pointer; text-align: center;
}
button:hover { border-color: var(--text); }
button.primary { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
button.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
button:disabled, button:disabled:hover { opacity: 0.45; cursor: not-allowed; border-color: var(--border-strong); }
button.primary:disabled:hover { background: var(--brand); border-color: var(--brand); }
button.link {
  border: none; background: none; color: var(--brand); font-weight: 700;
  text-decoration: underline; text-underline-offset: 0.18em; padding: 0.7rem 0.25rem; align-self: flex-start; border-radius: 0.5rem;
}
.actions { display: flex; flex-direction: column; gap: 0.75rem; margin: 1.5rem 0; }
.actions button:not(.link) { width: 100%; }

/* Start: three steps in three topic colours */
.steps { list-style: none; padding: 0; margin: 1.5rem 0; display: grid; gap: 0.75rem; counter-reset: step; }
.steps li {
  counter-increment: step; display: grid; grid-template-columns: 2.6rem 1fr; column-gap: 0.9rem; align-items: center;
  background: var(--t-tint); border-radius: var(--radius); padding: 0.9rem 1rem;
}
.steps li:nth-child(1) { --t-tint: var(--transport-tint); --t: var(--transport); }
.steps li:nth-child(2) { --t-tint: var(--energy-tint); --t: var(--energy); }
.steps li:nth-child(3) { --t-tint: var(--health-tint); --t: var(--health); }
.steps li::before {
  content: counter(step); grid-row: span 2;
  width: 2.6rem; height: 2.6rem; border-radius: 50%; background: var(--t); color: var(--surface);
  display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; line-height: 1;
}
.step-title { font-weight: 800; display: block; }
.step-text { display: block; }
.info { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); padding: 0.4rem 1.15rem; margin: 2rem 0 0.5rem; }
.info h2 { margin: 0.85rem 0 0.25rem; font-size: 1.125rem; }
.info ul { list-style: none; padding: 0; margin: 0; }
.info li { padding: 0.65rem 0; border-top: 1px solid var(--border); }
.info li:first-child { border-top: none; }

/* Topic picker */
.topic-list { list-style: none; padding: 0; margin: 1.25rem 0 1rem; display: grid; gap: 0.6rem; }
.topic-list label {
  display: flex; align-items: center; gap: 0.85rem; min-height: 3.4rem; padding: 0.6rem 1rem;
  border: 1px solid var(--border); border-left: 0.45rem solid var(--t); border-radius: 0.85rem;
  background: var(--surface); box-shadow: var(--shadow); cursor: pointer;
}
.topic-list label:hover { border-color: var(--t); }
.topic-list label:has(input:checked) { background: var(--t-tint); border-color: var(--t); box-shadow: inset 0 0 0 1px var(--t); }
.topic-list input { width: 1.35rem; height: 1.35rem; margin: 0; flex: none; accent-color: var(--t); }
.topic-name { font-weight: 700; flex: 1; }
.topic-count { color: var(--muted); white-space: nowrap; }
.total { font-weight: 800; margin: 1.25rem 0 0; }

/* Question: the topic colour frames the heading; the options below are always identical */
.q-head { background: var(--t-tint); border-radius: var(--radius); padding: 1rem 1.15rem 0.35rem; }
.q-head h1 { color: var(--text); margin-bottom: 0.35rem; }
.progress-text { color: var(--text); font-weight: 600; margin: 0 0 0.45rem; }
.progress { height: 0.5rem; background: var(--surface); border-radius: 0.25rem; overflow: hidden; margin-bottom: 1rem; }
.progress > span { display: block; height: 100%; background: var(--t); }
.prompt { color: var(--text); }
.options { display: grid; gap: 0.85rem; margin-top: 1.25rem; }
.option {
  display: grid; grid-template-columns: 2.5rem 1fr; column-gap: 1rem; align-items: start;
  width: 100%; padding: 1.1rem 1.15rem; text-align: left; font-weight: 400; line-height: 1.55;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.option:hover { border-color: var(--brand); }
.option .letter {
  width: 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--bar-track); color: var(--text);
  display: grid; place-items: center; font-weight: 800; font-size: 1.15rem; line-height: 1;
}
.option[aria-pressed="true"] { background: var(--brand-tint); border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.option[aria-pressed="true"] .letter { background: var(--brand); color: var(--brand-text); }
.neither { width: 100%; background: transparent; color: var(--muted); border-color: var(--border-strong); }
.neither:hover { color: var(--text); }
.neither[aria-pressed="true"] { background: var(--brand-tint); color: var(--text); border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }

/* Results */
.result-list { list-style: none; padding: 0.25rem 1.15rem; margin: 1.25rem 0 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.result-list li { display: grid; grid-template-columns: 2.4rem 1fr; column-gap: 0.75rem; padding: 0.85rem 0; border-top: 1px solid var(--border); }
.result-list li:first-child { border-top: none; }
.result-list li.unranked { grid-template-columns: 1fr; }
.rank {
  width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--brand-tint); color: var(--text);
  display: grid; place-items: center; font-weight: 800; line-height: 1;
}
.result-list .name { font-weight: 800; display: block; }
.result-list .count { color: var(--muted); }
.bar { height: 0.55rem; background: var(--bar-track); border-radius: 0.3rem; overflow: hidden; margin-top: 0.5rem; }
.bar > span { display: block; height: 100%; background: var(--brand); }
.none-found { background: var(--surface); border: 1px solid var(--border); border-radius: 0.85rem; padding: 0.85rem 1rem; }

details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); margin: 1rem 0; }
summary {
  min-height: 3rem; padding: 0.85rem 1.15rem; cursor: pointer; font-weight: 800;
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: ""; flex: none; width: 0.6rem; height: 0.6rem; margin-right: 0.2rem;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-25%) rotate(45deg);
}
details[open] > summary::after { transform: translateY(25%) rotate(225deg); }
details[open] > summary { border-bottom: 1px solid var(--border); }
details > div { padding: 0.25rem 1.15rem 1.15rem; }
.pick { padding-top: 0.9rem; margin-top: 0.9rem; border-top: 1px solid var(--border); }
.pick:first-child { border-top: none; margin-top: 0; }
.pill { display: inline-block; background: var(--t-tint); color: var(--text); border-radius: 999px; padding: 0.1rem 0.75rem; font-weight: 700; margin-right: 0.35rem; }
.pick ul { padding-left: 1.2rem; margin: 0.35rem 0 0; }
.pick li { margin-bottom: 0.5rem; }

/* Ballot */
label[for="place"] { display: block; font-weight: 700; margin: 0.75rem 0 0.4rem; }
input[type="search"] {
  font: inherit; color: inherit; background: var(--bg); width: 100%; min-height: 3rem;
  padding: 0.55rem 1rem; border: 1px solid var(--border-strong); border-radius: 0.85rem;
}
.suggestions { list-style: none; padding: 0; margin: 0.6rem 0; display: grid; gap: 0.4rem; }
.suggestions button { width: 100%; text-align: left; border-radius: 0.85rem; }
.candidates { list-style: none; padding: 0; margin: 0.5rem 0 1rem; }
.candidates li { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }

/* Footer */
footer { color: var(--muted); padding-bottom: 3rem; margin-top: 1.5rem; }
footer details { color: var(--text); box-shadow: none; }
body[data-screen="start"] .footer-disclosure { display: none; } /* the start screen already shows it */

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