/* ============================================================
   Vote Clarity — styles
   Dark-first theme (deep navy + teal/violet) with a light variant.
   Toggle via <html data-theme="dark|light">.
   ============================================================ */

:root {
  /* brand palette — shared by both themes */
  --teal: #2dd4bf;
  --teal-deep: #14b8a6;
  --violet: #8b5cf6;
  --violet-deep: #7c3aed;
  --green: #34d399;
  --amber: #f59e0b;
  --pink: #e879f9;
  /* Editorial restyle: a single, calm accent instead of the old tri-colour
     blue→violet→magenta sweep. The accent is a NEUTRAL VIOLET on purpose —
     almost no major party owns purple, so it avoids implying we favour a
     "blue" or "red" side. Per-theme overrides below tune the exact violet. */
  --grad: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);

  --radius: 12px;
  --radius-sm: 8px;
  --maxw: 900px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  /* Serif for headings → newspaper/editorial gravitas (Georgia fallback). */
  --font-display: "Source Serif 4", Georgia, "Iowan Old Style", "Palatino Linotype",
    Palatino, "Times New Roman", serif;
}

/* ---------- DARK (default) ---------- */
:root,
:root[data-theme="dark"] {
  --page-bg: radial-gradient(1100px 650px at 78% -12%, #172a5e, #06080f);
  --surface: #111a2c;
  --surface-2: #0e1525;
  --surface-3: #1b2740;
  --ink: #e7ecf6;
  --ink-soft: #9fb0cf;
  --ink-faint: #6c7b99;
  --line: #243049;
  --brand: #a855f7;
  --brand-deep: #9333ea;
  --accent: #a855f7;
  --good: #34d399;
  --warn: #f59e0b;
  --link: #c4a5fb;
  --grad: linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%);

  --selected-bg: rgba(168, 85, 247, 0.16);
  --selected-border: var(--brand);
  --chip-bg: rgba(139, 92, 246, 0.18);
  --chip-ink: #c4b5fd;
  --chip-border: rgba(139, 92, 246, 0.38);
  --notice-bg: rgba(245, 158, 11, 0.1);
  --notice-border: #d98a0b;
  --notice-ink: #f3d5a0;
  --notice-strong: #fde7c4;
  --ok-bg: rgba(52, 211, 153, 0.12);
  --ok-border: rgba(52, 211, 153, 0.35);
  --ok-ink: #9be8c4;
  --input-bg: var(--surface-2);
  --overlay: rgba(4, 8, 16, 0.66);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
}

/* ---------- LIGHT ---------- */
:root[data-theme="light"] {
  --page-bg: radial-gradient(1100px 650px at 78% -12%, #e9f0fb, #f2f5fb);
  --surface: #ffffff;
  --surface-2: #f5f7fc;
  --surface-3: #e9eef7;
  --ink: #16203a;
  --ink-soft: #51607a;
  --ink-faint: #8a97ad;
  --line: #e3e8f2;
  --brand: #7c3aed;
  --brand-deep: #6d28d9;
  --accent: #7c3aed;
  --good: #059669;
  --warn: #b45309;
  --link: #6d28d9;
  --grad: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);

  --selected-bg: #f1ecff;
  --selected-border: #7c3aed;
  --chip-bg: #f1ecff;
  --chip-ink: #6d28d9;
  --chip-border: #ddd2fb;
  --notice-bg: #fff8ec;
  --notice-border: #f59e0b;
  --notice-ink: #7c4a03;
  --notice-strong: #663d00;
  --ok-bg: #ecfdf3;
  --ok-border: #c5ead1;
  --ok-ink: #166534;
  --input-bg: #ffffff;
  --overlay: rgba(16, 24, 40, 0.45);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.12);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, 0.18);
}

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

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--page-bg);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport height — correct on mobile browsers */
  line-height: 1.55;
  overflow-wrap: break-word; /* long words/URLs never force horizontal scroll */
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.3s ease, color 0.3s ease;
}

.wrap {
  max-width: var(--maxw); margin: 0 auto;
  /* keep content clear of notches / status bar / home indicator on phones */
  padding:
    calc(28px + env(safe-area-inset-top))
    calc(20px + env(safe-area-inset-right))
    calc(90px + env(safe-area-inset-bottom))
    calc(20px + env(safe-area-inset-left));
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); right: calc(16px + env(safe-area-inset-right)); z-index: 70;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
  padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.theme-toggle:hover { background: var(--surface-3); }

/* language toggle (top-left; shown only for non-English countries) */
.lang-toggle {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); left: calc(16px + env(safe-area-inset-left)); z-index: 70;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
  padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.lang-toggle:hover { background: var(--surface-3); }
.lang-toggle[hidden] { display: none; }

/* ---------- Header ---------- */
.site-header { text-align: center; color: var(--ink); padding: 18px 0 8px; }
.site-header .badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--surface); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.site-header h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 42px); margin: 16px 0 6px; font-weight: 700;
  letter-spacing: -0.01em; color: var(--brand); -webkit-text-fill-color: var(--brand);
}
.site-header p { color: var(--ink-soft); margin: 0; font-size: 16px; }
.country-bar {
  margin-top: 14px; display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--ink-soft);
  background: var(--surface); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.country-bar:empty { display: none; }
.cc-name { color: var(--ink); font-weight: 800; }

/* one-time country chooser (fallback when IP detection can't confirm a country) */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 16px; }
.pick-btn {
  display: inline-flex; align-items: center; gap: 10px; text-align: left;
  font: inherit; font-weight: 700; color: var(--ink); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  padding: 13px 15px; border-radius: var(--radius-sm);
}
.pick-btn:hover { border-color: var(--brand); background: var(--surface-2); }
.pick-flag { font-size: 20px; }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px; margin-top: 24px;
  animation: rise 0.4s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

h2 { font-family: var(--font-display); font-size: 24px; margin: 0 0 12px; letter-spacing: -0.005em; font-weight: 700; }
h3 { font-family: var(--font-display); font-size: 18px; margin: 0 0 10px; font-weight: 600; }
p { margin: 0 0 14px; }
a { color: var(--link); }

.lead { font-size: 17px; color: var(--ink-soft); }
.muted { color: var(--ink-faint); }
.small { font-size: 13px; }

/* The product name always renders in the brand purple, wherever it appears. */
.brand-name { color: var(--brand); font-weight: 700; -webkit-text-fill-color: var(--brand); }

/* ---------- Welcome / launch screen ---------- */
.welcome { text-align: center; padding: 40px 34px; }
.welcome-kicker {
  text-transform: uppercase; letter-spacing: 0.16em; font-size: 12px;
  font-weight: 700; color: var(--ink-faint); margin: 0 0 14px;
}
.welcome-sections {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  margin: 22px auto 4px; max-width: 46ch;
}
.welcome-sections .wsec {
  flex: 1 1 120px; min-width: 110px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 10px; display: flex; flex-direction: column; gap: 3px;
}
.wsec-n {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 700; color: var(--brand);
}
.wsec-q { font-size: 16px; font-weight: 700; color: var(--ink); }
.welcome-title {
  font-size: clamp(26px, 5.2vw, 38px); line-height: 1.15;
  margin: 0 auto 20px; max-width: 15ch;
}
.welcome-lead {
  font-size: 17px; color: var(--ink-soft); line-height: 1.6;
  max-width: 46ch; margin: 0 auto 14px;
}
.welcome-free { font-size: 15px; color: var(--ink-faint); }
.welcome .btn-row { justify-content: center; margin-top: 26px; }
.welcome .btn-lg { min-width: 240px; }

/* ---------- How-it-works steps ---------- */
.steps {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin: 22px 0;
}
.step {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 16px;
}
.step .n {
  display: inline-flex; width: 28px; height: 28px;
  align-items: center; justify-content: center; border-radius: 50%;
  background: var(--grad); color: #fff; font-weight: 800; font-size: 14px;
  margin-bottom: 8px;
}
.step strong { display: block; }
.step span { font-size: 14px; color: var(--ink-soft); }

/* ---------- Notice / disclaimer ---------- */
.notice {
  border-left: 4px solid var(--notice-border);
  background: var(--notice-bg); color: var(--notice-ink);
  padding: 14px 16px; border-radius: 8px; font-size: 14px; margin: 18px 0;
}
.notice strong { color: var(--notice-strong); }
.notice a { color: var(--notice-strong); }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: none; font: inherit; font-weight: 600;
  cursor: pointer; border-radius: 12px; padding: 13px 22px;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { box-shadow: var(--shadow-md); }
.btn-ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }
/* Keep the primary/Start button's label bright white + bold even when disabled;
   signal "disabled" with a muted background instead of dimming the text. */
.btn-primary:disabled { opacity: 1; background-image: none; background-color: #2a3550; color: #fff; box-shadow: none; cursor: not-allowed; }
.btn-lg { padding: 16px 30px; font-size: 17px; font-weight: 800; color: #fff; }

/* ---------- Quiz ---------- */
.progress-wrap { margin-bottom: 22px; }
.progress-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--ink-faint); margin-bottom: 8px;
}
.cat-chip {
  font-weight: 600; color: var(--chip-ink);
  background: var(--chip-bg); border: 1px solid var(--chip-border);
  padding: 3px 10px; border-radius: 999px; font-size: 12px;
}
.progress-bar { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%; background: var(--grad); border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.q-count { font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.stage-hint { margin-top: 8px; color: var(--chip-ink); font-weight: 600; }

/* During the quiz, hide the big site header so each question sits at the top —
   no scrolling past the logo/tagline on every question. */
body.quiz-active .site-header { display: none; }
body.quiz-active .wrap { padding-top: calc(16px + env(safe-area-inset-top)); }
body.quiz-active .card { margin-top: 8px; }
/* Hide the AI assistant during the quiz — it keeps the screen clear for the
   sticky Next bar, and the assistant could reveal party stances we deliberately
   keep hidden while answering. */
body.quiz-active .vc-fab, body.quiz-active .vc-chat { display: none; }

/* gentle slide as each question appears */
.quiz-card { animation: qslide 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes qslide { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: translateX(0); } }

/* hint that only shows on touch devices (swipe tip); .no-touch hides on touch */
.touch-only { display: none; }
@media (hover: none) and (pointer: coarse) { .touch-only { display: block; } }

.q-statement { font-family: var(--font-display); font-size: clamp(20px, 3.4vw, 26px); font-weight: 600; letter-spacing: -0.005em; margin: 6px 0 22px; line-height: 1.35; }
.q-context { color: var(--ink-soft); font-size: 15px; margin-bottom: 22px; }

/* per-question "?" explainer */
.q-head { display: flex; align-items: flex-start; gap: 12px; margin: 6px 0 16px; }
.q-head .q-statement { flex: 1; margin: 0; }
.q-help {
  flex: none; width: 30px; height: 30px; margin-top: 4px;
  border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-soft);
  font-weight: 800; font-size: 15px; line-height: 1; cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.q-help:hover, .q-help.on { background: var(--chip-bg); color: var(--chip-ink); border-color: var(--chip-border); }
.q-explain {
  margin: 0 0 20px; padding: 12px 14px;
  border-left: 3px solid var(--brand); background: var(--surface-2);
  border-radius: 8px; color: var(--ink-soft); font-size: 14px; line-height: 1.5;
  animation: rise 0.2s ease both;
}
.q-explain strong { color: var(--ink); }

.options { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left; color: var(--ink);
  background: var(--surface); border: 2px solid var(--line);
  border-radius: 12px; padding: 14px 16px; cursor: pointer; font: inherit; font-weight: 600;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.opt:hover { border-color: var(--brand); background: var(--surface-2); }
.opt .key {
  width: 26px; height: 26px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px; background: var(--surface-3); color: var(--ink-faint);
  font-size: 13px; font-weight: 700;
}
.opt .opt-label { flex: 1; }
.opt .opt-check {
  flex: none; margin-left: auto; color: var(--brand); font-weight: 800; font-size: 18px;
  opacity: 0; transform: scale(0.6); transition: opacity 0.12s ease, transform 0.12s ease;
}
.opt.selected { border-color: var(--selected-border); background: var(--selected-bg); }
.opt.selected .key { background: var(--brand); color: #fff; }
.opt.selected .opt-check { opacity: 1; transform: scale(1); }
.opt .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
/* Calm diverging scale: violet (agree) → slate (neutral) → amber (disagree).
   Violet (not blue) at the agree end keeps the scale off any party's colour. */
.opt[data-v="2"] .dot { background: #7c3aed; }
.opt[data-v="1"] .dot { background: #a78bfa; }
.opt[data-v="0"] .dot { background: #94a3b8; }
.opt[data-v="-1"] .dot { background: #e0a040; }
.opt[data-v="-2"] .dot { background: #d9822b; }

/* Importance is OPTIONAL and visually secondary, so it never competes with the
   main agree/disagree choice or slows people down. */
.importance { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.importance .imp-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; background: transparent; font: inherit; font-size: 13px;
  font-weight: 600; color: var(--ink-faint); cursor: pointer; padding: 2px 0;
}
.importance .imp-toggle:hover { color: var(--ink-soft); }
.importance .imp-chev { transition: transform 0.15s ease; display: inline-block; }
.importance .imp-toggle.open .imp-chev { transform: rotate(90deg); }
.importance .imp-opt { font-weight: 500; opacity: 0.8; }
.importance .imp-panel { margin-top: 10px; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 4px; gap: 4px; }
.seg button {
  border: none; background: transparent; font: inherit; font-weight: 600;
  padding: 8px 16px; border-radius: 8px; cursor: pointer; color: var(--ink-soft);
}
.seg button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.seg-imp { display: flex; } /* full-width on small screens via the mobile rule */

/* Nav: Back + the dominant Next share the top row; Skip is a quiet link on its
   own row BELOW Next, so it can't be mis-tapped in place of Next. */
.quiz-nav { display: flex; flex-wrap: wrap; align-items: center; margin-top: 26px; gap: 12px; }
.quiz-nav .btn-back { order: 1; flex: 0 0 auto; }
.quiz-nav .btn-next { order: 2; flex: 1 1 auto; }
.quiz-nav .btn-skip {
  order: 3; flex-basis: 100%; margin-top: 2px;
  background: transparent; border: none; color: var(--ink-faint);
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.quiz-nav .btn-skip:hover { color: var(--ink-soft); }

/* ---------- About-you (optional, unscored demographics) ---------- */
.demo-list { margin-top: 8px; }
.demo-item { margin: 16px 0; padding-top: 16px; border-top: 1px dashed var(--line); }
.demo-item:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.demo-q { font-weight: 600; margin-bottom: 10px; }
.demo-seg { display: flex; flex-wrap: wrap; gap: 8px; }
.demo-seg button {
  border: 2px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 9px 14px; border-radius: 10px; cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.demo-seg button:hover { border-color: var(--brand); background: var(--surface-2); }
.demo-seg button.on { border-color: var(--selected-border); background: var(--selected-bg); }

/* "keep going" — invitation to answer the next batch of questions (staged quiz) */
.keep-going {
  border: 2px solid transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--grad) border-box;
}
.keep-going h2 { color: var(--ink); }

/* donate / support card */
.donate-card { border-color: var(--brand); }
.donate-card h2 { color: var(--ink); }

/* ---------- Results ---------- */
.winner { text-align: center; border-radius: var(--radius); padding: 26px; color: #fff; margin-bottom: 8px; box-shadow: var(--shadow-md); }
.winner .eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; opacity: 0.9; }
.winner .name { font-family: var(--font-display); font-size: clamp(26px, 5vw, 38px); font-weight: 700; margin: 6px 0; }
.winner .pct { font-size: 16px; opacity: 0.95; }
.winner .tie { font-size: 14px; opacity: 0.92; margin-top: 8px; }

.bars { display: grid; gap: 14px; margin: 22px 0 6px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 52px; gap: 12px; align-items: center; }
.bar-name { font-weight: 700; font-size: 15px; }
.bar-name small { display: block; font-weight: 500; color: var(--ink-faint); font-size: 11px; }
.bar-track { background: var(--surface-3); border-radius: 999px; height: 26px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: 999px; width: 0; transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1); }
.bar-pct { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }

/* category heatmap */
.matrix-scroll { overflow-x: auto; margin: 6px -6px; padding: 0 6px; }
table.matrix { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 560px; }
table.matrix th, table.matrix td { padding: 9px 8px; text-align: center; border-bottom: 1px solid var(--line); }
table.matrix th:first-child, table.matrix td:first-child { text-align: left; font-weight: 600; white-space: nowrap; }
table.matrix thead th { color: var(--ink-soft); font-weight: 700; }
.cell { display: inline-block; min-width: 42px; padding: 4px 6px; border-radius: 6px; font-weight: 700; color: #0b1020; }

/* per-issue breakdown */
.party-detail { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.party-detail summary {
  cursor: pointer; list-style: none; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; font-weight: 700;
}
.party-detail summary::-webkit-details-marker { display: none; }
.party-detail summary .swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.party-detail summary .pc { margin-left: auto; font-weight: 800; }
.issue { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 14px; }
.issue .stmt { font-weight: 600; margin-bottom: 6px; }
.issue .cmp { display: flex; gap: 18px; flex-wrap: wrap; color: var(--ink-soft); font-size: 13px; }
.issue .tag { font-weight: 700; }
.agree-yes { color: var(--brand); }
.agree-no { color: #e24ce0; }

/* how the parties line up on every issue (ranked by agreement) */
.agree-list { display: flex; flex-direction: column; gap: 10px; }
.agree-row {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 13px 16px;
}
.agree-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 7px; }
.agree-badge {
  font-size: 12px; font-weight: 800; color: #0b1020;
  border: 1px solid transparent;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  min-width: 80px; text-align: center;
}
.agree-row .stmt { font-weight: 600; font-size: 15px; margin-bottom: 7px; }
.agree-split { display: flex; flex-wrap: wrap; gap: 5px 16px; color: var(--ink-soft); }
.agree-split .grp { white-space: normal; }
.agree-split .pn { font-weight: 700; }

/* sources / about */
details.about summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.src-list { columns: 2; column-gap: 24px; font-size: 14px; }
.src-list li { margin-bottom: 6px; break-inside: avoid; }

/* Collapsible result deep-dives — closed by default so they don't eat scroll;
   tap the heading to reveal. */
.card.collapse { padding: 0; }
.collapse > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 22px 24px; border-radius: var(--radius);
}
.collapse > summary::-webkit-details-marker { display: none; }
.collapse > summary:hover { background: var(--surface-2); }
.collapse-title { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
.collapse-hint { color: var(--brand); font-weight: 700; font-size: 13px; white-space: nowrap; flex: none; }
.collapse .c-open { display: none; }
.collapse[open] .c-open { display: inline; }
.collapse[open] .c-closed { display: none; }
.collapse-body { padding: 4px 24px 24px; }

.section { margin-top: 30px; }
.section h3 { display: flex; align-items: center; gap: 8px; }
hr.soft { border: none; border-top: 1px solid var(--line); margin: 26px 0; }

.footer-note { color: var(--ink-faint); text-align: center; font-size: 13px; margin-top: 28px; }
.footer-note a { color: var(--link); }

/* policy-update badge */
.data-status {
  margin: 16px 0 0; background: var(--ok-bg); border: 1px solid var(--ok-border);
  color: var(--ok-ink); padding: 10px 14px; border-radius: 10px;
}
.data-status a { color: var(--ok-ink); font-weight: 600; }

/* contribute-to-aggregate card */
.vc-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-soft); cursor: pointer; }
.consent input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--brand); }
.intro-consent { margin-top: 16px; background: var(--surface-2); border: 1px solid var(--line); padding: 12px 14px; border-radius: var(--radius-sm); }

/* Compact "agree to T&C" row on the intro — tick box + title + ⓘ that opens
   the full disclaimer, so the first screen stays short (mobile-first). */
.consent-box {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 0 16px; padding: 14px 16px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
/* Gentle pulse to draw the eye to the required tick box — removed once ticked. */
@keyframes consentPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0); border-color: var(--line); }
  50%      { box-shadow: 0 0 0 5px rgba(168, 85, 247, 0.30); border-color: var(--brand); }
}
.consent-box.nudge { animation: consentPulse 1.8s ease-in-out infinite; }
.consent-box .consent-gate {
  display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0;
  margin: 0; cursor: pointer; color: var(--ink);
}
.consent-box input[type="checkbox"] {
  width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--brand); cursor: pointer;
}
.consent-title { font-weight: 700; }
.consent-info {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--brand);
  font-size: 19px; font-weight: 800; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.consent-info:hover { background: var(--surface-3); border-color: var(--brand); }

/* secondary intro links (guide / FAQ / how-it-works / terms) — parked at the
   bottom of the start screen, separated from the primary flow */
.intro-secondary { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.contrib-status { min-height: 1em; }

/* "who are you leaning toward" + vote-vs-answers */
.intended-row {
  margin: 16px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-size: 14px; color: var(--ink-soft);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 12px 14px; border-radius: var(--radius-sm);
}
.intended-row label { font-weight: 600; color: var(--ink); }
.intended-row select, .vc-pick {
  font: inherit; color: var(--ink); background: var(--input-bg);
  border: 2px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer;
}
.intended-row select:focus, .vc-pick:focus { outline: none; border-color: var(--brand); }
.vc-issue { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.agg-token {
  flex: 1; font: inherit; padding: 11px 14px; color: var(--ink);
  background: var(--input-bg); border: 2px solid var(--line); border-radius: 10px;
}
.agg-token:focus { outline: none; border-color: var(--brand); }

/* ---------- "How voting works" guide overlay ---------- */
.guide-overlay {
  position: fixed; inset: 0; z-index: 80; background: var(--overlay);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow: auto; animation: rise 0.2s ease both;
}
.guide-modal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; max-width: 720px; width: 100%;
  box-shadow: var(--shadow-lg); padding: 26px;
}
.guide-head { display: flex; align-items: center; justify-content: space-between; }
.guide-head h2 { margin: 0; }
/* Donation popup — a short, focused prompt, narrower than the info modals */
.donate-modal { max-width: 460px; }
.donate-prompt-body { margin-top: 14px; }
.donate-prompt-body p { font-size: 16px; }
.guide-list { margin: 16px 0; }
.guide-item { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.guide-item summary {
  cursor: pointer; list-style: none; padding: 14px 16px; font-weight: 700;
  display: flex; gap: 10px; align-items: center;
}
.guide-item summary::-webkit-details-marker { display: none; }
.guide-item summary::before { content: "▸"; color: var(--brand); transition: transform 0.15s ease; }
.guide-item[open] summary::before { transform: rotate(90deg); }
.guide-item .ga { padding: 0 16px 14px; color: var(--ink-soft); font-size: 14px; }
.guide-item .ga p { margin: 0 0 8px; }
.guide-item .ga ul { margin: 4px 0 8px; padding-left: 20px; }
.guide-item .ga li { margin-bottom: 4px; }
.guide-item .ga strong { color: var(--ink); }

/* ---------- AI chat widget ---------- */
.vc-fab {
  position: fixed; right: calc(18px + env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 50;
  width: 52px; height: 52px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; background: var(--grad); color: #fff;
  font-size: 24px; line-height: 1; border-radius: 50%; box-shadow: var(--shadow-lg);
}
.vc-fab:hover { transform: translateY(-1px); }

.vc-chat {
  position: fixed; right: calc(20px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 60;
  width: min(400px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 40px));
  height: min(620px, calc(100dvh - 40px));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-lg); overflow: hidden; animation: rise 0.25s ease both;
}
.vc-chat[hidden] { display: none; }
.vc-chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; color: #fff; background: var(--grad);
}
.vc-chat-head strong { font-size: 15px; }
.vc-mode {
  display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.22);
  vertical-align: middle;
}
.vc-mode.on { background: rgba(255, 255, 255, 0.3); }
.vc-mode.off { background: rgba(0, 0, 0, 0.22); }
.vc-x { background: transparent; border: none; color: inherit; cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 8px; }
.vc-x:hover { background: rgba(255, 255, 255, 0.18); }

.vc-msgs { flex: 1; overflow-y: auto; padding: 16px; background: var(--surface-2); }
.vc-msg { margin-bottom: 12px; font-size: 14px; line-height: 1.5; }
.vc-msg p { margin: 0 0 8px; }
.vc-msg ul { margin: 4px 0 8px; padding-left: 20px; }
.vc-msg li { margin-bottom: 3px; }
.vc-user {
  margin-left: auto; max-width: 85%; width: fit-content;
  background: var(--grad); color: #fff; padding: 9px 13px; border-radius: 14px 14px 4px 14px;
}
.vc-user p { margin: 0; }
.vc-assistant {
  max-width: 92%; background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); padding: 11px 14px; border-radius: 14px 14px 14px 4px;
}
.vc-assistant strong { color: var(--ink); }
.vc-thinking { color: var(--ink-faint); font-style: italic; }
.vc-note { color: var(--ink-faint); font-size: 12px; margin-top: 6px; }

.vc-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--surface); }
.vc-input input {
  flex: 1; font: inherit; padding: 11px 14px; color: var(--ink);
  background: var(--input-bg); border: 2px solid var(--line); border-radius: 10px;
}
.vc-input input::placeholder { color: var(--ink-faint); }
.vc-input input:focus { outline: none; border-color: var(--brand); }
.vc-input .btn { padding: 11px 16px; }
.vc-foot { padding: 8px 12px; font-size: 11px; color: var(--ink-faint); text-align: center; background: var(--surface); border-top: 1px solid var(--line); }

/* hide desktop-only hints (e.g. keyboard tips) on touch devices */
@media (hover: none) and (pointer: coarse) {
  .no-touch { display: none !important; }
}

@media (max-width: 560px) {
  .card { padding: 22px 18px; }
  .bar-row { grid-template-columns: 84px 1fr 44px; gap: 10px; }
  .src-list { columns: 1; }

  /* Welcome screen: comfortable on a phone, button within thumb reach */
  .welcome { padding: 30px 20px 26px; }
  .welcome-title { font-size: 28px; max-width: none; }
  .welcome-lead { font-size: 16px; }
  .welcome .btn-lg { width: 100%; min-width: 0; }
  /* Keep the three section tiles on one row on a phone */
  .welcome-sections { gap: 8px; }
  .welcome-sections .wsec { flex: 1 1 0; min-width: 0; padding: 11px 6px; }
  .wsec-q { font-size: 15px; }

  /* Mobile quiz: compact so the question + all five answers + Next fit on one
     screen with little or no scrolling. */
  body.quiz-active .card { padding: 16px 16px; }
  .quiz-card .progress-wrap { margin-bottom: 12px; }
  .quiz-card .stage-hint { margin-top: 6px; }
  .quiz-card .q-head { margin: 4px 0 12px; }
  .q-statement { font-size: 19px; line-height: 1.25; }
  .options { gap: 8px; }
  .opt { padding: 12px 14px; gap: 12px; }
  .opt .key { display: none; } /* keyboard hints are irrelevant on a phone */
  .opt .dot { width: 12px; height: 12px; }
  .importance { margin-top: 12px; padding-top: 10px; }
  .importance .seg { width: 100%; }
  .importance .seg button { flex: 1; text-align: center; padding: 9px 6px; font-size: 13px; }

  /* Sticky bottom action bar — Next always within thumb reach (Back + Next on
     one row). Bleeds to the compact card edges. */
  .quiz-card .quiz-nav {
    position: sticky; bottom: 0; z-index: 6; margin: 14px -16px -16px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -8px 22px rgba(0, 0, 0, 0.16);
  }
  .quiz-card .quiz-nav .btn-back { padding: 13px 16px; }
  .quiz-card .quiz-nav .btn-next { padding: 14px; font-size: 16px; font-weight: 800; }
  .quiz-tip { display: none; } /* the sticky bar makes the action obvious */

  /* Stack action rows full-width so each tap target is easy to hit */
  .btn-row .btn { flex: 1 1 auto; }
  .keep-going .btn-lg { flex-basis: 100%; }

  .winner { padding: 22px 18px; }
  h2 { font-size: 21px; }

  /* compact collapsible result boxes on phones */
  .collapse > summary { padding: 16px; }
  .collapse-title { font-size: 16px; }
  .collapse-body { padding: 2px 16px 18px; }
}
@media (max-width: 460px) {
  /* full-screen chat anchored inside the safe area on small phones */
  .vc-chat {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    width: auto; height: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; color: #000; }
  .site-header h1 { color: #000; -webkit-text-fill-color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; background: #fff; }
  .no-print { display: none !important; }
  .party-detail[open] .issue { break-inside: avoid; }
}
