/* Party energy policies. Visual language taken from Rewiring's party policy PDFs:
   cream paper, ink-bordered cards with a hard offset shadow, hand-cut caps headings. */
@font-face {
  font-family: 'RA Election Display';
  src: url('../fonts/RA-Election-Display.woff2') format('woff2');
  font-display: swap;
}

:root {
  /* sampled from the PDFs (see reviews/visual-design.md); *-text values pass AA on cream */
  --paper: #FFFAF0;
  --paper-2: #F6EBD9;
  --ink: #1F2727;
  --ink-2: #252525;
  --muted: #666666;
  --rule: #999999;
  --card: #FFFFFF;
  --link: var(--ink);
  --yellow: #FFC754;
  --mint: #527570;

  --national: #00529F;
  --labour: #C92019;
  --green: #097D34;
  --act: #CA016B;
  --nzfirst: #0B1F35;
  --tpm: #C92019;
  --top: #007680;

  --display: 'RA Election Display', 'Londrina Solid', 'Arial Narrow', sans-serif;
  --body: 'Rubik', system-ui, sans-serif;

  --pad: clamp(16px, 3.2vw, 48px);
  --gap: clamp(12px, 1.6vw, 22px);
  --radius: 10px;
  --border: 3px;
  --shadow: 4px 4px 0 var(--ink);
  --tap: 44px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--body); font-weight: 400; font-size: clamp(15px, .35vw + 13.5px, 18px); line-height: 1.5;
}
a { color: var(--link); text-underline-offset: 2px; }
.wrap { max-width: 1520px; margin: 0 auto; padding: 0 var(--pad); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 99; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }

.display { font-family: var(--display); font-weight: 400; text-transform: uppercase; letter-spacing: .005em; line-height: .95; }

/* ---------- hero ---------- */
.hero { padding: calc(var(--pad) * 1.1) 0 var(--gap); }
.brand { margin: 0 0 var(--gap); font-weight: 700; }
.brand a { color: var(--ink); text-decoration: none; }
.hero h1 { font-size: clamp(44px, 8.5vw, 132px); margin: 0; }
.kicker { font-size: clamp(15px, 1.5vw, 24px); margin: .7em 0 0; line-height: 1.15; }
.lede { max-width: 46ch; margin: 1em 0 0; font-size: 1.1em; }

/* ---------- controls ---------- */
.controls { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(6px); border-bottom: 2px solid var(--ink); padding: 12px 0; }
.controls .wrap { display: grid; gap: 10px; }
.seg { display: inline-flex; justify-self: start; border: var(--border) solid var(--ink); border-radius: 999px; background: var(--card); padding: 3px; box-shadow: 3px 3px 0 var(--ink); }
.seg button { font: inherit; font-weight: 700; border: 0; background: none; color: var(--ink); min-height: calc(var(--tap) - 6px); padding: 0 1.1em; border-radius: 999px; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 4px 6px 2px; margin: 0 calc(var(--pad) * -1); padding-left: var(--pad); padding-right: var(--pad); }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; font: inherit; font-size: .9em; font-weight: 600; min-height: 38px; padding: 0 .95em; border: 2px solid var(--ink); border-radius: 999px; background: var(--card); color: var(--ink); cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.chips.parties .chip { font-family: var(--display); font-size: 1.05em; letter-spacing: .02em; text-transform: uppercase; padding-top: 2px; }
.chips.parties .chip[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: #fff; }
.chips.parties .chip[aria-pressed="false"] { color: var(--c); border-color: color-mix(in srgb, var(--c) 45%, var(--paper)); }
.search input { width: 100%; max-width: 420px; font: inherit; min-height: var(--tap); padding: 0 14px; border: 2px solid var(--ink); border-radius: 10px; background: var(--card); color: var(--ink); }

/* ---------- cards (the PDF row) ---------- */
#results { padding-top: calc(var(--gap) * 1.4); padding-bottom: calc(var(--pad) * 2); display: grid; gap: calc(var(--gap) * 1.1); }
.card { background: var(--card); border: var(--border) solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); }
.row { display: grid; grid-template-columns: minmax(150px, 25%) 1fr; }
.row-label { padding: 18px 22px; border-right: 2px solid var(--rule); }
.row-label h2, .row-label h3 { font-family: var(--display); font-weight: 400; text-transform: uppercase; font-size: clamp(22px, 2vw, 32px); line-height: 1; margin: 0; }
.row-label p { margin: .5em 0 0; font-weight: 400; color: var(--ink-2); font-size: .92em; line-height: 1.3; }
.row-label .share { margin-top: 14px; }
.row-body { padding: 14px 20px 16px; min-width: 0; }

/* party columns inside an issue/user row */
.cols { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 0; }
.col { padding: 4px 16px 6px; border-left: 1.5px solid #E6E0D8; min-width: 0; }
.col:first-child { border-left: 0; padding-left: 0; }
.col h4 { font-family: var(--display); font-weight: 400; text-transform: uppercase; color: var(--c); font-size: clamp(20px, 1.6vw, 28px); margin: 0 0 6px; line-height: 1; }
.col h4 a { color: inherit; text-decoration: none; }
ul.pol { list-style: none; margin: 0; padding: 0; display: grid; gap: .45em; }
ul.pol li { position: relative; padding-left: 1em; line-height: 1.4; }
ul.pol li::before { content: ''; position: absolute; left: .15em; top: .62em; width: .32em; height: .32em; border-radius: 50%; background: var(--ink); }
ul.pol li.none { color: var(--muted); font-style: italic; font-weight: 400; }
ul.pol li.none::before { background: var(--muted); }
mark { background: color-mix(in srgb, var(--yellow) 60%, transparent); color: inherit; padding: 0 .1em; border-radius: 3px; }
.new { display: inline-block; font-family: var(--display); font-size: .8em; background: var(--yellow); border: 1.5px solid var(--ink); border-radius: 5px; padding: 0 .35em; margin-left: .3em; vertical-align: .1em; line-height: 1.3; }

/* party sheet header */
.sheet-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
.sheet-head h2 { font-family: var(--display); font-weight: 400; text-transform: uppercase; color: var(--c); font-size: clamp(44px, 7vw, 104px); line-height: .9; margin: 0; }
.colheads { display: grid; grid-template-columns: minmax(150px, 25%) 1fr; color: var(--c); }
.colheads span { font-family: var(--display); text-transform: uppercase; font-size: clamp(22px, 2.4vw, 40px); padding: 0 20px; line-height: 1; }
.colheads span + span { border-left: 2px solid var(--ink); }

.share { font: inherit; font-size: .85em; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 .9em; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); color: var(--ink); cursor: pointer; }
.share svg { width: 1.1em; height: 1.1em; }
.share:hover { background: var(--yellow); }
.empty-state { text-align: center; padding: 40px 20px; }

/* ---------- footer ---------- */
.foot { border-top: 2px solid var(--ink); padding: calc(var(--pad) * 1.2) 0 calc(var(--pad) * 2); }
.foot-grid { display: grid; grid-template-columns: 1fr minmax(260px, 420px); gap: var(--pad); align-items: start; }
.small { font-size: .82em; font-weight: 400; line-height: 1.45; }
.small p { margin: 0 0 .5em; }
.promoter { font-weight: 600; }
.official { padding: 16px 20px; }
.tilt { transform: rotate(3deg); }
.official ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: 6px 16px; }
.official a { overflow-wrap: anywhere; }
.official a { font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-weight: 600; z-index: 50; }

/* ---------- small screens: stack the PDF row ---------- */
@media (max-width: 860px) {
  :root { --border: 2px; --radius: 8px; --shadow: 3px 3px 0 var(--ink); }
  .row, .colheads { grid-template-columns: 1fr; }
  .colheads span + span { display: none; }
  .row-label { border-right: 0; border-bottom: 1.5px solid var(--rule); padding: 14px 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
  .row-label p { flex-basis: 100%; margin: 0; }
  .row-label .share { margin: 0; }
  .row-body { padding: 10px 16px 14px; }
  .cols { grid-template-columns: 1fr; }
  .col { border-left: 0; padding: 10px 0; border-top: 1.5px solid #EEE8DF; }
  .col:first-child { border-top: 0; padding-top: 2px; }
  .foot-grid { grid-template-columns: 1fr; }
}

/* ---------- print: one view per page, like the A4s ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 10pt; }
  .controls, .share, .skip, .toast { display: none !important; }
  .card { box-shadow: 2px 2px 0 var(--ink); break-inside: avoid; }
  .hero { padding-top: 0; }
  .hero .lede { display: none; }
  .foot { border: 0; }
  a { color: inherit; }
}

@media (prefers-reduced-motion: no-preference) {
  .card { transition: transform .15s ease, box-shadow .15s ease; }
  .card:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
  .tilt:hover { transform: rotate(0deg); }
}

/* many parties: one line each, label left like the party sheets */
.prow { display: grid; grid-template-columns: 10rem 1fr; gap: 16px; padding: 10px 0; border-top: 1.5px solid #EEE8DF; }
.prow:first-child { border-top: 0; padding-top: 4px; }
.prow h4 { font-family: var(--display); font-weight: 400; text-transform: uppercase; color: var(--c); font-size: clamp(20px, 1.6vw, 26px); margin: 0; line-height: 1.05; }
.prow h4 a { color: inherit; text-decoration: none; }
.nonelist { margin: 10px 0 0; padding-top: 10px; border-top: 1.5px solid #EEE8DF; }
.nonelist:first-child { margin-top: 4px; padding-top: 0; border-top: 0; }
.nonelist { color: var(--muted); font-style: italic; font-weight: 400; }
.nonelist span { margin-right: .2em; }
.nonelist a { font-style: normal; font-weight: 600; color: var(--c); text-decoration: none; }
@media (max-width: 860px) { .prow { grid-template-columns: 1fr; gap: 4px; } }

/* hero extras */
.updated { margin: .9em 0 0; font-size: .95em; }
.howto { list-style: none; padding: 0; margin: .8em 0 0; display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: .92em; font-weight: 400; }
.why { font-style: normal; font-weight: 600; color: var(--ink); margin-left: .25em; }
.gov { margin: 8px 0 14px; padding: 10px 14px; border: 2px dashed var(--yellow); border-radius: 10px; background: var(--card); font-weight: 400; }

/* method, questions, asks */
.extras { display: grid; gap: calc(var(--gap) * 1.1); padding-bottom: calc(var(--pad) * 1.5); }
.method summary { cursor: pointer; list-style: none; padding: 16px 22px; font-size: clamp(22px, 2vw, 30px); display: flex; justify-content: space-between; align-items: center; min-height: var(--tap); }
.method summary::-webkit-details-marker { display: none; }
.method summary::after { content: '+'; font-family: var(--body); font-weight: 700; }
.method[open] summary::after { content: '\2013'; }
.method > div { padding: 0 22px 18px; max-width: 80ch; font-weight: 400; }
.qs { padding-left: 1.3em; display: grid; gap: .5em; }
.asks { border: 3px dashed var(--yellow); border-radius: 14px; padding: clamp(16px, 2.4vw, 30px); background: var(--card); }
.asks h2 { font-size: clamp(28px, 3.4vw, 48px); margin: 0 0 .3em; }
.asks > p { max-width: 75ch; font-weight: 400; }
.asks-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: var(--gap); margin: 14px 0; }
.ask { background: var(--paper); border-radius: 10px; padding: 14px 16px; }
.ask h3 { margin: .1em 0 .4em; font-size: 1.15em; }
.ask p { margin: 0; font-weight: 400; }
.eyebrow { text-transform: uppercase; font-size: .75em; font-weight: 700; letter-spacing: .04em; color: #244E4C; }

/* phones: give every policy its own tile and every party clear air, so a topic doesn't read as one block */
@media (max-width: 860px) {
  .row-body { padding: 6px 14px 14px; }
  .prow, .col { padding: 18px 0 6px; border-top: 2px solid #ECE5D9; }
  .prow:first-child, .col:first-child { border-top: 0; padding-top: 10px; }
  .prow h4, .col h4 { font-size: 26px; margin-bottom: 10px; }
  ul.pol { gap: 0; }
  ul.pol li { padding: 11px 0; line-height: 1.45; border-top: 1px solid #E3DCD0; }
  ul.pol li:first-child { border-top: 0; padding-top: 2px; }
  ul.pol li::before { display: none; }
  ul.pol li.none { background: none; padding: 2px 0; }
  .nonelist { margin-top: 16px; padding-top: 14px; border-top: 2px solid #ECE5D9; line-height: 1.6; }
  #results { gap: 22px; }
}

/* filter drop-down: desktop shows the controls inline; phones get one compact bar */
.filter-toggle, .fp-head, .fp-done { display: none; }
.filter-panel { display: contents; }
@media (max-width: 860px) {
  .controls { padding: 10px 0; }
  .controls .wrap { gap: 0; }
  .filter-toggle { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 14px; font: inherit; text-align: left; color: var(--ink); background: var(--card); border: 2px solid var(--ink); border-radius: 12px; box-shadow: 3px 3px 0 var(--ink); cursor: pointer; }
  .ft-label { font-family: var(--display); text-transform: uppercase; font-size: 20px; padding-top: 2px; }
  .ft-sum { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); font-size: .9em; }
  .ft-caret { width: 10px; height: 10px; border: solid var(--ink); border-width: 0 3px 3px 0; transform: rotate(45deg); margin: -4px 4px 0 0; transition: transform .2s; }
  .filter-toggle[aria-expanded="true"] .ft-caret { transform: rotate(-135deg); margin-top: 4px; }
  .filter-panel { display: none; }
  .filter-panel.open { display: grid; gap: 8px; margin-top: 10px; padding: 14px; background: var(--card); border: 2px solid var(--ink); border-radius: 12px; box-shadow: 3px 3px 0 var(--ink); max-height: calc(100dvh - 120px); overflow-y: auto; }
  .fp-head { display: block; margin: 6px 0 0; font-size: .75em; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
  .fp-head:first-child { margin-top: 0; }
  .filter-panel .chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
  .filter-panel .seg { justify-self: stretch; display: flex; box-shadow: none; }
  .filter-panel .seg button { flex: 1; padding: 0 .4em; }
  .filter-panel .search input { max-width: none; }
  .fp-done { display: block; margin-top: 8px; min-height: 48px; font: inherit; font-weight: 700; color: var(--paper); background: var(--ink); border: 0; border-radius: 999px; cursor: pointer; }
}

/* phones: the view is a row of tabs that stays visible; topic, parties and search sit in the Filters drop-down */
@media (max-width: 860px) {
  .controls .seg { display: flex; justify-self: stretch; width: 100%; margin-bottom: 10px; box-shadow: 3px 3px 0 var(--ink); }
  .controls .seg button { flex: 1; padding: 0 .3em; font-size: .92em; }
}

[hidden] { display: none !important; }
.sheet { display: grid; gap: calc(var(--gap) * 1.1); }
.sheet + .sheet { margin-top: calc(var(--pad) * 1.2); padding-top: calc(var(--pad) * 1.2); border-top: 3px solid var(--ink); }

/* downloads */
.downloads { padding: clamp(16px, 2.4vw, 28px); }
.downloads h2 { font-size: clamp(28px, 3.4vw, 48px); margin: 0 0 .3em; }
.downloads > p { max-width: 75ch; margin: 0 0 14px; }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: var(--gap) calc(var(--gap) * 2); }
.dl-grid h3 { font-family: var(--display); font-weight: 400; text-transform: uppercase; font-size: 22px; margin: 0 0 6px; }
.dl-grid ul { list-style: none; margin: 0; padding: 0; }
.dl-grid li { padding: 9px 0; border-top: 1px solid #E3DCD0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.dl-grid li:first-child { border-top: 0; }
.dl-grid a { font-weight: 600; }
.dl-grid span { color: var(--muted); font-size: .85em; }

/* desktop: one calm row (view tabs + Filters button); topics, parties and search open in a drop-down panel */
@media (min-width: 861px) {
  .controls { padding: 12px 0; }
  .controls .wrap { display: flex; align-items: center; gap: 14px; position: relative; }
  .filter-toggle { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 16px; font: inherit; color: var(--ink); background: var(--card); border: 2px solid var(--ink); border-radius: 999px; box-shadow: 3px 3px 0 var(--ink); cursor: pointer; max-width: 560px; }
  .ft-label { font-family: var(--display); text-transform: uppercase; font-size: 20px; padding-top: 2px; }
  .ft-sum { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); font-size: .92em; }
  .ft-caret { width: 9px; height: 9px; border: solid var(--ink); border-width: 0 3px 3px 0; transform: rotate(45deg); margin: -4px 2px 0 0; transition: transform .2s; }
  .filter-toggle[aria-expanded="true"] .ft-caret { transform: rotate(-135deg); margin-top: 4px; }
  .filter-panel { display: none; }
  .filter-panel.open { display: grid; gap: 8px; position: absolute; top: calc(100% + 10px); left: var(--pad); width: min(760px, calc(100% - 2 * var(--pad))); padding: 18px 20px; background: var(--card); border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: 4px 4px 0 var(--ink); z-index: 20; }
  .fp-head { display: block; margin: 6px 0 0; font-size: .75em; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
  .fp-head:first-child { margin-top: 0; }
  .filter-panel .chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
  .filter-panel .search input { max-width: none; }
  .fp-done { display: block; justify-self: start; margin-top: 6px; min-height: 44px; padding: 0 22px; font: inherit; font-weight: 700; color: var(--paper); background: var(--ink); border: 0; border-radius: 999px; cursor: pointer; }
  .hero { padding-bottom: calc(var(--gap) * 1.6); }
}

@media (min-width: 861px) {
  .controls .wrap > .search { flex: 1; max-width: 640px; margin-left: auto; }
  .controls .wrap > .search input { max-width: none; min-height: 48px; font-size: 1.05em; padding: 0 18px; border-radius: 999px; box-shadow: 3px 3px 0 var(--ink); }
}

/* By party: the party chips are jump links, so they stay solid colour */
.chips.parties.jump .chip[aria-pressed="false"] { background: var(--c); border-color: var(--c); color: #fff; }
