/* PoliTick — editorial civic tokens */

:root {
  /* Paper/ink */
  --paper: #F6F3EC;
  --paper-2: #EFEBDE;
  --paper-3: #E8E2CF;
  --ink: #1A1814;
  --ink-2: #3A3530;
  --ink-3: #6B655B;
  --ink-4: #928B7E;
  --rule: #D9D3C3;
  --rule-2: #BFB7A2;

  /* Accent (civic red by default, swappable) */
  --accent: oklch(55% 0.15 25);
  --accent-dim: oklch(55% 0.15 25 / 0.12);

  /* Data reds — for heatmap */
  --hm-0: #F6F3EC;
  --hm-1: #EADFC3;
  --hm-2: #DCBC8A;
  --hm-3: #C68C54;
  --hm-4: #A05A2B;
  --hm-5: #6B2E12;

  /* Type */
  --serif: 'Source Serif 4', 'Source Serif Pro', 'Charter', Georgia, serif;
  --sans:  'Inter Tight', 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --mono:  'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Rhythm */
  --maxw: 1280px;
  --gutter: 32px;
  --row: 24px;

  --dens-pad: 16px;
  --dens-row: 14px;
}

[data-density="compact"] {
  --dens-pad: 10px;
  --dens-row: 10px;
}

[data-theme="dark"] {
  --paper: #121110;
  --paper-2: #1A1918;
  --paper-3: #22201E;
  --ink: #F1ECDF;
  --ink-2: #D4CDBB;
  --ink-3: #938B7A;
  --ink-4: #6B6454;
  --rule: #2E2B26;
  --rule-2: #403C34;
  --accent-dim: oklch(65% 0.15 25 / 0.18);
  --hm-0: #1A1918;
  --hm-1: #2A231A;
  --hm-2: #3D2E1E;
  --hm-3: #5E4422;
  --hm-4: #8C5E2B;
  --hm-5: #C08B4E;
}

[data-font="humanist"] { --serif: 'Source Serif 4', Georgia, serif; --sans: 'Inter Tight', sans-serif; }
[data-font="grotesque"] { --serif: 'IBM Plex Serif', Georgia, serif; --sans: 'IBM Plex Sans', sans-serif; }
[data-font="classical"] { --serif: 'Libre Caslon Text', Georgia, serif; --sans: 'Inter Tight', sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01","cv11";
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 0; }

/* Type primitives */
.serif { font-family: var(--serif); font-feature-settings: "liga","dlig","kern"; }
.sans  { font-family: var(--sans); }
.mono  { font-family: var(--mono); font-feature-settings: "tnum","zero"; }
.tnum  { font-variant-numeric: tabular-nums; }
.uc    { text-transform: uppercase; letter-spacing: 0.08em; }
.kicker{ font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.rule  { height: 1px; background: var(--rule); }
.rule-thick { height: 2px; background: var(--ink); }
.rule-dot { border-top: 1px dotted var(--rule-2); height: 0; }
.muted { color: var(--ink-3); }
.hair { color: var(--ink-4); }

/* Page shell */
.shell { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
@media (max-width: 720px) {
  :root { --gutter: 18px; }
}

/* Masthead */
.masthead {
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
  position: sticky; top: 0; z-index: 40;
}
.masthead-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 14px 0 12px;
}
.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.wordmark .dot {
  width: 8px; height: 8px; background: var(--accent);
  display: inline-block; transform: translateY(-2px);
  border-radius: 50%;
}
.wordmark .sub {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.nav { display: flex; gap: 2px; justify-content: center; }
.nav a {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  color: var(--ink-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -14px;
  transition: color .15s, border-color .15s;
}
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); border-bottom-color: var(--accent); }
.mast-tools { display: flex; gap: 14px; align-items: center; font-size: 12px; color: var(--ink-3); }
.mast-tools .live {
  display: inline-flex; gap: 6px; align-items: center;
  font-family: var(--mono); font-size: 11px;
}
.mast-tools .live::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 var(--accent); }
  70%  { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@media (max-width: 720px) {
  .masthead-inner { grid-template-columns: 1fr auto; }
  .nav { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
  .nav a { margin-bottom: -12px; padding: 6px 10px; font-size: 12px; white-space: nowrap; }
  .wordmark { font-size: 22px; }
  .wordmark .sub { display: none; }
}

/* Search input */
.search-inline {
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--ink-3);
  padding: 4px 0;
  min-width: 200px;
}
.search-inline input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 13px; color: var(--ink);
}
.search-inline input::placeholder { color: var(--ink-4); }
.search-inline .k {
  font-family: var(--mono); font-size: 10px; color: var(--ink-4);
  border: 1px solid var(--rule); padding: 1px 5px;
}

/* Generic chrome */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  border-top: 2px solid var(--ink);
  padding: 10px 0 8px;
  margin-top: 32px;
}
.section-head h2 {
  font-family: var(--serif);
  font-size: 22px; font-weight: 600; letter-spacing: -0.01em;
  margin: 0;
}
.section-head .kicker-r { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }

.card {
  border-top: 1px solid var(--rule);
  padding: var(--dens-row) 0;
}
.card:first-child { border-top: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--sans); font-size: 12px; font-weight: 500;
  padding: 7px 14px;
  border: 1px solid var(--ink);
  color: var(--ink);
  background: transparent;
  transition: background .12s, color .12s;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.sm { padding: 4px 10px; font-size: 11px; }
.btn.accent { border-color: var(--accent); color: var(--accent); }
.btn.accent:hover { background: var(--accent); color: var(--paper); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--sans); font-size: 11px; font-weight: 500;
  padding: 3px 8px;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  background: var(--paper);
  transition: border-color .12s, color .12s;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip.solid { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.tag-topic {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--sans); font-size: 11px; font-weight: 500;
  padding: 2px 7px;
  color: var(--ink-2);
  background: var(--paper-3);
  transition: background .12s;
}
.tag-topic:hover { background: var(--ink); color: var(--paper); }

.party-dot {
  display: inline-block; width: 8px; height: 8px;
  margin-right: 6px; transform: translateY(-1px);
  border-radius: 1px;
}

/* Layouts */
.grid-home {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 48px;
  padding: 40px 0 0;
}
@media (max-width: 960px) {
  .grid-home { grid-template-columns: 1fr; gap: 32px; }
}

/* Numbered big stats */
.stat {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 0;
  border-top: 1px solid var(--rule);
}
.stat .n { font-family: var(--serif); font-size: 34px; line-height: 1; font-weight: 600; letter-spacing: -0.02em; }
.stat .l { font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }

/* Tables */
table.ptable {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.ptable th, .ptable td {
  text-align: left;
  padding: 10px 10px 10px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.ptable th {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-3);
  border-bottom: 1px solid var(--ink);
}
.ptable tr:hover td { background: var(--paper-2); }
.ptable .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* Pulse bars */
.pulse-row { display: flex; gap: 4px; align-items: flex-end; height: 56px; }
.pulse-bar {
  width: 14px; background: var(--ink-2);
  position: relative; cursor: pointer; transition: background .12s;
}
.pulse-bar:hover { background: var(--accent); }
.pulse-bar.active { background: var(--accent); }

/* Heatmap cell */
.hm-cell {
  width: 100%; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10px; color: var(--ink);
  transition: outline .12s;
  outline: 1px solid transparent;
}
.hm-cell:hover { outline: 1px solid var(--ink); z-index: 1; position: relative; }

/* Tweaks panel */
.tweaks {
  position: fixed;
  right: 16px; bottom: 16px;
  width: 280px;
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 14px 14px 12px;
  z-index: 50;
  font-size: 12px;
  box-shadow: 3px 3px 0 var(--ink);
}
.tweaks h3 {
  margin: 0 0 10px; font-family: var(--serif); font-size: 14px; font-weight: 600;
  display: flex; justify-content: space-between; align-items: baseline;
}
.tweak-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px dotted var(--rule); }
.tweak-row:first-of-type { border-top: 0; }
.tweak-row .lbl { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; }
.tweak-opts { display: flex; gap: 2px; }
.tweak-opts button {
  padding: 3px 7px; font-size: 11px; border: 1px solid var(--rule); color: var(--ink-2);
}
.tweak-opts button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.tweak-swatch { width: 18px; height: 18px; border: 1px solid var(--rule); cursor: pointer; }
.tweak-swatch[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 1px; }

/* Focus + selection */
::selection { background: var(--accent); color: var(--paper); }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* Mobile tweaks */
@media (max-width: 720px) {
  .tweaks { left: 16px; right: 16px; width: auto; bottom: 12px; }
}
