/* Which Party quiz. Ballot paper and election ink.
   Self-hosted type, no external requests, mobile first, works in the WhatsApp in-app browser. */
@font-face {
  font-family: "Bricolage";
  font-style: normal; font-display: swap; font-weight: 200 800;
  src: url(fonts/bricolage-grotesque-latin-wght-normal.woff2) format("woff2-variations");
}
@font-face {
  font-family: "Instrument";
  font-style: normal; font-display: swap; font-weight: 400 700;
  src: url(fonts/instrument-sans-latin-wght-normal.woff2) format("woff2-variations");
}

:root {
  --paper: #ffffff;
  --page: #f4f3f9;
  --ink: #15141c;
  --ink-2: #4a4860;
  --muted: #76738c;
  --line: #e3e1ee;
  --line-strong: #cfccdf;
  --violet: #5b3fd6;
  --violet-deep: #3f2aa8;
  --violet-tint: #ece8fb;
  --violet-tint-2: #d9d2f6;
  --agree: #1b8a5a;  --agree-tint: #e3f5ec;
  --neutral: #b06f12; --neutral-tint: #fbefd9;
  --disagree: #c43d3d; --disagree-tint: #fbe5e5;
  --party: #e07a1f;
  --radius-s: 10px; --radius: 16px; --radius-l: 24px;
  --shadow: 0 1px 0 rgba(21,20,28,.04), 0 10px 30px -18px rgba(59,42,168,.25);
  --display: "Bricolage", "Instrument", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: "Instrument", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1c1b24; --page: #121118; --ink: #f1f0f7; --ink-2: #c9c6dc; --muted: #9b98b3;
    --line: #2f2d3d; --line-strong: #46435a;
    --violet: #a594ff; --violet-deep: #c3b7ff; --violet-tint: #27224a; --violet-tint-2: #352e66;
    --agree: #5ed19a; --agree-tint: #17352a; --neutral: #e6b14f; --neutral-tint: #3a2d12; --disagree: #ff8a8a; --disagree-tint: #3d1f1f;
    --party: #f0a05a; --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--page); }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font-family: var(--body); font-size: 17px; line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
}
a { color: var(--violet); text-underline-offset: 3px; }
h1, h2, h3, .display { font-family: var(--display); letter-spacing: -0.01em; }
h1 { font-size: 38px; line-height: 1.05; font-weight: 800; margin: 0 0 14px; letter-spacing: -0.025em; }
h2 { font-size: 24px; line-height: 1.15; font-weight: 700; margin: 0 0 10px; }
h3 { font-size: 18px; font-weight: 700; margin: 22px 0 10px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--paper); padding: 8px; }
.skip-link:focus { left: 8px; z-index: 10; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }

/* Frame */
.site-header { display: flex; justify-content: space-between; align-items: center; max-width: 720px; margin: 0 auto; padding: 18px 20px 6px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand .mark { width: 26px; height: 26px; color: var(--violet); }
.site-header nav a { font-size: 15px; font-weight: 500; }
.app { max-width: 720px; margin: 0 auto; padding: 6px 20px 40px; }
.site-footer { max-width: 720px; margin: 0 auto; padding: 22px 20px 48px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); }
.loading { color: var(--muted); padding: 40px 0; }
body.wide .site-header, body.wide .site-footer { max-width: 1040px; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; margin: 14px 0; box-shadow: var(--shadow); }

/* Buttons */
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 999px; border: 1.5px solid var(--line-strong);
  background: var(--paper); color: var(--ink); padding: 12px 20px; min-height: 48px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color .15s, border-color .15s, color .15s, transform .08s;
}
button:active, .btn:active { transform: translateY(1px); }
.btn-primary { background: var(--violet); color: #fff; border-color: var(--violet); }
.btn-primary:hover { background: var(--violet-deep); border-color: var(--violet-deep); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #15141c; } }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 18px; padding: 14px 28px; }
.btn-link { background: none; border: none; color: var(--violet); padding: 8px 6px; min-height: 44px; font-weight: 500; border-radius: 8px; }
.btn-link:hover { text-decoration: underline; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.btn-row > * { flex: 1 1 auto; }

/* Hero */
.hero { position: relative; overflow: hidden; padding: 36px 24px 30px; border-radius: var(--radius-l); background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); margin: 14px 0; }
.hero .xmark { position: absolute; right: -40px; top: -48px; width: 168px; height: 168px; color: var(--violet-tint-2); pointer-events: none; }
.hero h1 { position: relative; max-width: 11ch; font-size: clamp(36px, 9vw, 56px); padding-right: 12%; }
.hero p { position: relative; max-width: 42ch; font-size: 18px; color: var(--ink-2); }
.hero .facts { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 16px 0 24px; padding: 0; list-style: none; color: var(--muted); font-size: 15px; }
.hero .facts li { display: inline-flex; align-items: center; gap: 8px; }
.hero .facts li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--violet); }
.hero .btn-row { margin-top: 8px; }
.hero .fine { font-size: 14px; color: var(--muted); margin: 14px 0 0; }

/* Progress */
.topbar { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 10px 0 10px; font-size: 14px; color: var(--muted); }
.topbar .sec { font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--ink); letter-spacing: -0.01em; }
.topbar .count { font-variant-numeric: tabular-nums; }
.bar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.bar > div { height: 100%; background: var(--violet); width: 0; transition: width .25s; border-radius: 3px; }

/* Statement */
.q { padding: 26px 22px 20px; }
.statement { font-family: var(--display); font-size: clamp(24px, 6.4vw, 32px); line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 16px; text-wrap: balance; }
.explainer { font-size: 16px; color: var(--ink-2); margin: 0 0 16px; }
.means { display: grid; gap: 6px; margin: 0 0 20px; font-size: 15px; }
.means div { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; color: var(--ink-2); }
.means .ic { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; margin-top: 1px; }
.means .ic.a { background: var(--agree-tint); color: var(--agree); }
.means .ic.d { background: var(--disagree-tint); color: var(--disagree); }
.means b { color: var(--ink); font-weight: 600; }

.answers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.answers button { padding: 14px 6px; min-height: 60px; font-size: 16px; font-weight: 600; border-radius: 14px; border-width: 1.5px; }
.answers .agree { color: var(--agree); border-color: var(--agree-tint); background: var(--agree-tint); }
.answers .neutral { color: var(--neutral); border-color: var(--neutral-tint); background: var(--neutral-tint); }
.answers .disagree { color: var(--disagree); border-color: var(--disagree-tint); background: var(--disagree-tint); }
.answers .agree.sel, .answers .agree:active { background: var(--agree); color: #fff; border-color: var(--agree); }
.answers .neutral.sel, .answers .neutral:active { background: var(--neutral); color: #fff; border-color: var(--neutral); }
.answers .disagree.sel, .answers .disagree:active { background: var(--disagree); color: #fff; border-color: var(--disagree); }
.under { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.under .btn-link { color: var(--muted); }
.under .btn-link.sel { color: var(--violet); font-weight: 600; }

/* Expectation and weights */
.party-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 8px; }
.party-grid button { min-height: 54px; border-radius: 14px; font-weight: 500; }
.party-grid button.sel { border-color: var(--violet); background: var(--violet-tint); color: var(--violet-deep); font-weight: 700; }
.nav-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
.nav-row .btn-primary { flex: 1; }
.wlist { list-style: none; padding: 0; margin: 6px 0 0; }
.wlist li { border-top: 1px solid var(--line); }
.wlist li:first-child { border-top: none; }
.wlist button { width: 100%; display: grid; grid-template-columns: 26px 1fr; gap: 12px; align-items: start; text-align: left; border: none; border-radius: 10px; background: none; padding: 12px 6px; font-weight: 500; min-height: 0; }
.wlist button:hover { background: var(--page); }
.wlist button.sel { background: var(--violet-tint); }
.wlist .box { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line-strong); margin-top: 2px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 15px; }
.wlist button.sel .box { background: var(--violet); border-color: var(--violet); }
.wlist .wt { display: block; font-weight: 600; }
.wlist .ws { display: block; font-size: 14px; color: var(--muted); }
.wsec { font-family: var(--display); font-weight: 700; font-size: 15px; color: var(--muted); margin: 14px 0 2px; }
.sticky-bottom { position: sticky; bottom: 0; padding: 12px 0 14px; background: linear-gradient(to top, var(--page) 70%, transparent); }

/* Results */
.top-match { position: relative; overflow: hidden; padding: 26px 22px; border-radius: var(--radius-l); background: var(--paper); border: 1.5px solid var(--violet-tint-2); box-shadow: var(--shadow); margin: 14px 0; }
.top-match .xmark { position: absolute; right: -16px; top: -18px; width: 120px; height: 120px; color: var(--violet-tint); pointer-events: none; }
.top-match .lead { position: relative; font-size: 15px; color: var(--muted); margin-bottom: 6px; }
.top-match .pname { position: relative; font-family: var(--display); font-size: clamp(28px, 7.5vw, 40px); font-weight: 800; letter-spacing: -0.025em; line-height: 1.05; margin: 0 0 6px; }
.top-match .pct { font-family: var(--display); font-size: clamp(40px, 12vw, 64px); font-weight: 800; letter-spacing: -0.03em; line-height: 1; color: var(--violet); }
.top-match .reveal { position: relative; margin: 12px 0 0; color: var(--ink-2); font-size: 16px; }
.rank { list-style: none; padding: 0; margin: 4px 0 0; }
.rank li { padding: 14px 0 12px; border-top: 1px solid var(--line); }
.rank li:first-child { border-top: none; padding-top: 4px; }
.rank .row { display: flex; align-items: baseline; gap: 12px; }
.rank .pos { font-family: var(--display); font-weight: 700; color: var(--muted); width: 24px; flex: none; font-variant-numeric: tabular-nums; }
.rank .name { flex: 1; font-weight: 600; font-size: 17px; }
.rank .pct { font-family: var(--display); font-weight: 800; font-size: 24px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.rank .barwrap { height: 8px; background: var(--line); border-radius: 4px; margin: 8px 0 6px; overflow: hidden; }
.rank .barwrap > div { height: 100%; background: var(--violet); border-radius: 4px; }
.rank .sub { font-size: 14px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.rank .open { font-size: 14px; padding: 4px 0; min-height: 36px; }
.rank li.nomatch .pct { color: var(--muted); font-size: 15px; font-weight: 500; font-family: var(--body); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.tag { background: var(--violet-tint); color: var(--violet-deep); font-size: 13px; font-weight: 500; padding: 4px 10px; border-radius: 999px; }
.tags .lbl { font-size: 13px; color: var(--muted); }

.results-grid { display: grid; gap: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.chip { font: inherit; font-size: 14px; font-weight: 500; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line-strong); background: var(--paper); color: var(--ink); min-height: 40px; }
.chip.sel { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.legend { display: flex; gap: 18px; font-size: 14px; color: var(--muted); margin: 4px 0 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; margin-right: 7px; }
.legend i.you { background: var(--violet); }
.legend i.party { background: transparent; border: 3px solid var(--party); }
svg.chart { width: 100%; height: auto; display: block; }
svg text { font-family: var(--body); fill: var(--ink); }
svg text.muted { fill: var(--muted); }
.dial { margin: 12px 0 16px; }
.dial .axis-name { font-family: var(--display); font-weight: 700; font-size: 16px; }
.dial .ends { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); gap: 8px; }
.dial .track { position: relative; height: 28px; }
.dial .track::before { content: ""; position: absolute; left: 0; right: 0; top: 13px; height: 4px; background: var(--line); border-radius: 2px; }
.dial .track::after { content: ""; position: absolute; left: 50%; top: 7px; width: 2px; height: 16px; background: var(--line-strong); }
.dial .mark { position: absolute; top: 5px; width: 20px; height: 20px; border-radius: 50%; margin-left: -10px; }
.dial .mark.you { background: var(--violet); box-shadow: 0 0 0 3px var(--paper); }
.dial .mark.party { border: 3px solid var(--party); background: var(--paper); width: 22px; height: 22px; top: 4px; margin-left: -11px; }
.dial .nodata { font-size: 13px; color: var(--muted); }
.map-controls { display: flex; align-items: center; gap: 10px; font-size: 15px; margin-bottom: 10px; flex-wrap: wrap; }
select { font: inherit; padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--line-strong); background: var(--paper); color: var(--ink); min-height: 44px; }

/* Compare */
.cmp-item { padding: 14px 0; border-top: 1px solid var(--line); }
.cmp-item:first-of-type { border-top: none; }
.cmp-item .stmt { font-family: var(--display); font-weight: 700; font-size: 18px; line-height: 1.25; margin-bottom: 8px; letter-spacing: -0.01em; }
.cmp-item .vs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.pill { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--line); color: var(--ink-2); }
.pill.agree { background: var(--agree-tint); color: var(--agree); }
.pill.neutral { background: var(--neutral-tint); color: var(--neutral); }
.pill.disagree { background: var(--disagree-tint); color: var(--disagree); }
.pill.skip, .pill.none { background: var(--line); color: var(--muted); font-weight: 500; }
.pill.wt { background: var(--violet-tint); color: var(--violet-deep); }
.cmp-item .just { font-size: 15px; color: var(--ink-2); margin: 0 0 4px; }
.cmp-item .src { font-size: 13px; color: var(--muted); }
.sticky-top { position: sticky; top: 0; background: var(--page); padding: 6px 0; z-index: 2; }
.share-note { font-size: 14px; color: var(--muted); }
.ok { color: var(--agree); font-weight: 600; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Larger screens */
@media (min-width: 600px) {
  .site-header { padding: 24px 24px 8px; }
  .app { padding: 8px 24px 56px; }
  .card { padding: 26px 26px; }
  .q { padding: 32px 30px 26px; }
  .hero { padding: 48px 44px 40px; }
  .hero .xmark { right: 16px; top: -6px; width: 230px; height: 230px; }
  .hero h1 { padding-right: 0; }
  .party-grid { grid-template-columns: repeat(4, 1fr); }
  .answers button { min-height: 64px; font-size: 17px; }
}
@media (min-width: 960px) {
  .app.results { max-width: 1040px; }
  .results-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 6fr); align-items: start; }
  .results-grid .col > .card:first-child { margin-top: 14px; }
}
@media (prefers-reduced-motion: reduce) { .bar > div, button, .btn { transition: none; } }
