/* pol.codepretzels.com — shared styles for the home page and all chart pages.
   Palette + typography live here so every chart inherits one consistent look;
   chart-specific data stays in each chart's own chart.js. */

:root {
  color-scheme: light dark;
  --bg: #f4f2ec;
  --surface: #fbfaf6;
  --border: #e1e0d9;
  --text-primary: #201f1b;
  --text-secondary: #55534d;
  --text-muted: #898781;
  --accent: #eb6834;
  --bar: #898781;
  --soft: #c9c6ba;
  --maxw: 880px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a18;
    --surface: #201f1d;
    --border: #2c2c2a;
    --text-primary: #f1efe8;
    --text-secondary: #b7b5ac;
    --text-muted: #898781;
    --soft: #4d4b46;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 52px 20px 80px; }

.kicker {
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); font-weight: 700; margin: 0 0 12px;
}
h1 {
  font-size: clamp(27px, 4.6vw, 42px); line-height: 1.1; letter-spacing: -0.022em;
  margin: 0 0 16px; font-weight: 800;
}
.dek { font-size: clamp(15px, 2.1vw, 18px); color: var(--text-secondary); margin: 0 0 12px; max-width: 64ch; }
a { color: var(--accent); }
.sr-only { position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0); }

/* Back link (chart pages) */
.back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; text-decoration: none;
  color: var(--text-secondary); margin: 0 0 22px;
}
.back:hover { color: var(--accent); }

/* Surface panel that holds a chart */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 22px 20px;
  margin: 36px 0 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
canvas { display: block; }

/* Method / footnotes */
footer { margin-top: 30px; font-size: 12.5px; color: var(--text-muted); max-width: 74ch; }
footer p { margin: 0 0 10px; }
footer strong { color: var(--text-secondary); }

/* Home page: grid of chart cards */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px; margin: 36px 0 0;
}
.chart-card {
  display: flex; flex-direction: column; gap: 9px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px 20px 18px;
  text-decoration: none; color: inherit;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.chart-card:hover {
  border-color: var(--accent); transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.09);
}
.chart-card h3 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.chart-card p { margin: 0; font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; }
.chart-card .swatches { display: flex; gap: 5px; margin-top: 2px; }
.chart-card .swatches i { width: 24px; height: 6px; border-radius: 3px; display: block; }
.chart-card .go { margin-top: auto; padding-top: 4px; font-size: 12.5px; font-weight: 700; color: var(--accent); }

/* ─── SVG chart primitives (shared by all SVG-based charts) ───────────────── */
.card svg { width: 100%; height: auto; display: block; }
.gridline { stroke: var(--border); stroke-width: 1; }
.baseline { stroke: var(--text-muted); stroke-width: 1.25; }
.ytick    { fill: var(--text-muted); font-size: 13px; }
.xtick    { fill: var(--text-primary); font-size: 15px; font-weight: 600; }
.xsub     { fill: var(--text-muted); font-size: 11.5px; }
.vlabel   { fill: var(--text-primary); font-size: 14.5px; font-weight: 700; }
.refline  { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 5 4; opacity: .55; }
.reflabel { fill: var(--text-muted); font-size: 12px; font-style: italic; }
.zerolab  { fill: var(--text-muted); font-size: 12.5px; font-style: italic; }

/* Grow-in animation for bar-chart <rect class="bar">. These charts share a
   440px baseline; a chart with a different baseline sets --bar-baseline. */
.bar { transform-origin: center var(--bar-baseline, 440px);
       animation: grow .9s cubic-bezier(.2,.7,.2,1) both; }
.bar:nth-child(2){animation-delay:.05s} .bar:nth-child(3){animation-delay:.10s}
.bar:nth-child(4){animation-delay:.15s} .bar:nth-child(5){animation-delay:.20s}
.bar:nth-child(6){animation-delay:.25s} .bar:nth-child(7){animation-delay:.30s}
.bar:nth-child(8){animation-delay:.35s} .bar:nth-child(9){animation-delay:.40s}
.bar:nth-child(10){animation-delay:.45s} .bar:nth-child(11){animation-delay:.50s}
.bar:nth-child(12){animation-delay:.55s}
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .bar { animation: none; } }

/* ─── Sub-panels inside a chart card (magnified inset, source table, readings) ── */
.inset, .counts, .reading {
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
.inset  { margin-top: 26px; padding: 18px 20px 8px; }
.counts { margin-top: 26px; padding: 18px 20px; }
.inset h2, .counts h2, .reading h3 {
  font-size: 13px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-secondary); margin: 0 0 8px;
}
.inset p { font-size: 13px; color: var(--text-muted); margin: 0 0 6px; }

/* Data tables (in a .counts panel or a .panel) */
.counts table, .panel table { width: 100%; border-collapse: collapse; font-size: 14px; }
.counts th, .panel th {
  text-align: left; font-weight: 600; color: var(--text-secondary);
  font-size: 12.5px; letter-spacing: .03em; padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.counts td, .panel td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.counts tr:last-child td, .panel tr:last-child td { border-bottom: none; }
.counts .num, .panel .num { text-align: right; }
.counts td.num, .panel td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.counts tr.hl td { background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 600; }

/* Two-up interpretation grid */
.readings { margin-top: 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .readings { grid-template-columns: 1fr; } }
.reading { padding: 16px 18px; font-size: 14px; color: var(--text-secondary); line-height: 1.6; }
.reading h3 { color: var(--text-primary); margin: 0 0 6px; }

/* ─── Chart legend (color key above a chart) ──────────────────────────────── */
.legend { display: flex; flex-wrap: wrap; gap: 18px; margin: 14px 0 6px; font-size: 13px; color: var(--text-secondary); }
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }

/* Horizontal bar charts: category labels sit on the y-axis (.ylab/.ysub);
   the value ticks along the bottom reuse .ytick (muted, role = value tick). */
.ylab { fill: var(--text-primary); font-size: 14.5px; font-weight: 600; }
.ysub { fill: var(--text-muted); font-size: 11px; }
.barh { transform-origin: var(--barh-origin, 180px) center; animation: growx .9s cubic-bezier(.2,.7,.2,1) both; }
@keyframes growx { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .barh { animation: none; } }

/* ─── Prose analysis sections (chart pages with written commentary) ───────── */
.prose { margin-top: 30px; }
.prose h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 10px; }
.prose h3 { font-size: 14px; font-weight: 600; margin: 16px 0 6px; color: var(--text-primary); }
.prose p { font-size: 14.5px; color: var(--text-secondary); line-height: 1.65; margin: 0 0 12px; max-width: 76ch; }
.prose ul { margin: 0 0 12px 20px; font-size: 13.5px; color: var(--text-secondary); line-height: 1.65; }
.prose li { margin-bottom: 5px; }
.prose strong, .panel strong { color: var(--text-primary); font-weight: 600; }

/* Warning / caveat callout (accent left border, subtle tinted background) */
.warn { border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); padding: 12px 16px; margin: 10px 0 14px; font-size: 13px; color: var(--text-secondary); line-height: 1.6; max-width: 78ch; }
.warn strong { color: var(--text-primary); font-weight: 600; }

/* Analysis panels (bordered boxes; pair inside .grid2 for a two-up layout) */
.panel { border: 1px solid var(--border); border-radius: 10px; background: var(--bg); padding: 18px 20px; margin-top: 14px; }
.panel h3 { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); margin: 0 0 8px; }
.panel p { font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; margin: 0 0 8px; }
.panel p:last-child { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
@media (max-width: 680px) { .grid2 { grid-template-columns: 1fr; } }

/* ─── Multi-panel "accountability" charts: row labels, values, status pills ─── */
.rowlab { fill: var(--text-primary); font-size: 14px; font-weight: 600; }
.val    { fill: var(--text-primary); font-size: 13px; font-weight: 700; }
.vala   { fill: var(--accent); font-size: 13px; font-weight: 700; }
.zero   { fill: var(--text-muted); font-size: 12.5px; font-style: italic; }
.note   { fill: var(--text-muted); font-size: 11.5px; }
.axis   { stroke: var(--text-muted); stroke-width: 1; }
.prose .sub { font-size: 13.5px; color: var(--text-secondary); margin: 0 0 14px; max-width: 74ch; }

/* Status pills (adjudication state in accountability tables) */
.status { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .04em; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.s-final { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.s-pend  { background: color-mix(in srgb, var(--text-muted) 16%, transparent); color: var(--text-secondary); }
.s-vac   { background: color-mix(in srgb, #4f9a3f 22%, transparent); color: #4f9a3f; }

/* ─── Yes/No/Partial compliance matrix ──────────────────────────────────────── */
.tablewrap { overflow-x: auto; }
.matrix { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 8px; }
.matrix th { font-weight: 600; color: var(--text-secondary); font-size: 12px; letter-spacing: .03em; padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: center; }
.matrix th:first-child { text-align: left; min-width: 200px; }
.matrix td { padding: 10px 6px; border-bottom: 1px solid var(--border); text-align: center; vertical-align: middle; }
.matrix td:first-child { text-align: left; color: var(--text-secondary); font-weight: 600; font-size: 13px; }
.pill { display: inline-block; min-width: 58px; font-size: 11.5px; font-weight: 700; letter-spacing: .03em; padding: 4px 10px; border-radius: 11px; }
.pill.y { background: color-mix(in srgb, #4f9a3f 20%, transparent); color: #4f9a3f; }
.pill.n { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.pill.p { background: color-mix(in srgb, #b0862f 24%, transparent); color: #b0862f; }
.keynote { display: flex; gap: 16px; flex-wrap: wrap; margin: 10px 0 4px; font-size: 12.5px; color: var(--text-secondary); }
.keynote span { display: flex; align-items: center; gap: 6px; }

/* Accent-highlighted table cell (e.g. money flowing to the subject) */
.counts td.hi, .panel td.hi { color: var(--accent); font-weight: 600; }
