/* tokens.css — jessefrederik.com interactive house style (cremaschi/bundestag).
   Design tokens as CSS variables + base component styles. Link this, then
   reach for the component classes (.container, .viz-panel, .controls, .viz-bar,
   .legend, .gapline, .caption, .references, .tooltip). Fonts: load PT Serif + Libre
   Franklin (CDN in the template; self-hosted woff2 in production). */

:root {
  /* surfaces */
  --bg:           #FAFAF8;   /* warm off-white page */
  --surface:      #F0EDE8;   /* viz-panel / cards */
  --grid:         #E3E0DB;   /* hairlines, borders */
  /* ink */
  --text:         #2D2D2D;
  --text-muted:   #6B6B6B;
  --text-caption: #707070;
  /* accent (use sparingly: rules, kickers, notes, links) */
  --accent:       #C44D3F;   /* brick red */
  /* chart semantics */
  --voters:       #2D5F7C;   /* control / reference group (blue) */
  --series-dark:  #2D2D2D;   /* primary series (near-black) */
  --series-rest:  #8F8A82;   /* "the rest" / muted warm grey */
  /* type */
  --font:         'Libre Franklin', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: 'PT Serif', Georgia, "Times New Roman", serif;
  --radius:       2px;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

/* text column; viz-panels break out wider than this on desktop */
.container { max-width: 680px; margin: 0 auto; padding: 60px 20px 80px; }

.kicker {
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 18px;
}
h1::before {
  content: ''; display: block;
  width: 48px; height: 4px; background: var(--accent); margin-bottom: 20px;
}
h1 { font-family: var(--font-display); font-size: 34px; font-weight: 700; line-height: 1.2; margin-bottom: 14px; }
.subtitle {
  font-family: var(--font-display); font-style: italic;
  font-size: 17px; color: var(--text-muted); margin-bottom: 32px; line-height: 1.55;
}
.subtitle b { font-style: normal; font-weight: 700; }

/* --- controls (selects + a language toggle) --- */
.controls { display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 10px; }
.controls .ctl { display: flex; flex-direction: column; gap: 4px; }
.controls label {
  color: var(--text-muted); text-transform: uppercase;
  font-size: 10.5px; letter-spacing: 0.05em; font-weight: 600;
}
select {
  font-family: var(--font); font-size: 14px; padding: 5px 8px;
  border: 1px solid var(--grid); border-radius: var(--radius);
  background: #fff; color: var(--text); cursor: pointer;
}
.lang-toggle { display: inline-flex; margin-left: auto; }
.lang-toggle a {
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  border: 1px solid var(--grid); background: #fff; padding: 4px 12px; cursor: pointer; user-select: none;
}
.lang-toggle a:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.lang-toggle a:last-child  { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; }
.lang-toggle a.active { background: var(--text); border-color: var(--text); color: #fff; }

/* --- chart control bar: underline TABS (the primary choice — which series /
   question) + pill MODES (the secondary view — e.g. over-time vs correlation),
   on one row. The two shapes/weights read as two distinct controls, not one
   button row. Wire each button to set state and call your redraw(); mark the
   chosen one `.active`. Collapses to stacked full-width controls on phones.
   (The /bundestag salience panel's pattern.) --- */
.viz-bar { display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin: 4px 0 14px; border-bottom: 1px solid var(--grid); }
.viz-tabs { display: flex; gap: 22px; }
.viz-tabs button {
  font: 700 13px/1.5 var(--font); background: none; border: none;
  border-bottom: 2px solid transparent; padding: 4px 1px 7px; margin-bottom: -1px;
  color: var(--text-muted); cursor: pointer; transition: color .12s, border-color .12s;
}
.viz-tabs button:hover { color: var(--text); }
.viz-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.viz-modes { display: inline-flex; gap: 4px; padding-bottom: 4px; }
.viz-modes button {
  font: 600 11.5px/1.4 var(--font); padding: 3px 9px; border: 1px solid var(--grid);
  border-radius: 999px; background: transparent; color: var(--text-muted); cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.viz-modes button:hover { color: var(--text); border-color: var(--text-muted); }
.viz-modes button.active { background: var(--text); border-color: var(--text); color: #fff; }
.viz-tabs button:focus-visible, .viz-modes button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 560px) {
  .viz-bar { flex-direction: column; align-items: stretch; gap: 8px; border-bottom: none; }
  .viz-tabs { border-bottom: 1px solid var(--grid); gap: 0; justify-content: space-between; }
  .viz-tabs button { flex: 1; text-align: center; font-size: 12.5px; padding: 7px 2px 9px; }
  .viz-modes { align-self: flex-start; padding-bottom: 0; }
}

/* --- legend --- */
.legend { display: flex; gap: 18px; margin: 10px 0 6px; font-size: 13px; flex-wrap: wrap; }
.legend .chip { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); white-space: nowrap; }
.legend .chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend .chip i.line { width: 16px; height: 3px; border-radius: 2px; }

/* --- viz-panel: runs wider than the text column on desktop, near full-bleed
   on mobile. NB the SVG height is set here (NOT a fixed viewBox) — see
   mobile-scaling.md. --- */
.viz-panel {
  background: var(--surface); border-radius: var(--radius);
  padding: 22px 24px 18px; margin: 30px -20px; position: relative;
}
@media (min-width: 860px) { .viz-panel { margin-left: -120px; margin-right: -120px; } }

.viz-panel svg { display: block; width: 100%; height: 340px; overflow: visible; }
@media (max-width: 680px) { .viz-panel svg { height: 300px; } }

.chart-title { font-size: 14px; font-weight: 700; letter-spacing: 0.03em; color: var(--text); margin-bottom: 2px; }
.chart-note  { font-size: 12.5px; font-style: italic; color: var(--accent); margin: 2px 0 0; min-height: 16px; }
.gapline     { font-family: var(--font-display); font-size: 15px; color: var(--text); margin: 4px 0 6px; line-height: 1.55; }
.gapline b   { font-family: var(--font); font-weight: 700; font-variant-numeric: tabular-nums; }
.gapline span { font-size: 13.5px; }

.y-axis text { font-family: var(--font); font-size: 10.5px; fill: var(--text-muted); }
.y-axis .tick line { stroke: var(--grid); }
.y-axis .domain { display: none; }

/* --- explainer card + caption + references --- */
.explainer {
  background: var(--surface); border-left: 3px solid var(--accent); border-radius: var(--radius);
  padding: 16px 20px; margin: 34px 0 0; font-size: 15px; line-height: 1.65; font-family: var(--font-display);
}
.explainer b { font-family: var(--font); font-size: 13.5px; }
.caption {
  font-size: 12.5px; color: var(--text-caption); margin-top: 40px;
  padding-top: 18px; border-top: 1px solid var(--grid); line-height: 1.6;
}
.references { font-size: 13px; color: var(--text-caption); margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--grid); line-height: 1.6; }
.references h2 { font-size: 13px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 14px; }
.ref-list { list-style: none; padding-left: 0; margin: 0; }
.ref-list li { padding-left: 1.5em; text-indent: -1.5em; margin-bottom: 12px; }
.references a { color: var(--accent); word-break: break-word; text-decoration: none; }
.references a:hover { text-decoration: underline; }

/* --- tooltip (position with JS off the cursor) --- */
.tooltip {
  position: absolute; visibility: hidden; pointer-events: none; z-index: 50;
  background: var(--text); color: var(--bg);
  font-family: var(--font); font-size: 12px; padding: 6px 9px;
  border-radius: var(--radius); font-variant-numeric: tabular-nums; line-height: 1.5; white-space: nowrap;
}
.tooltip b { font-weight: 700; }
</content>
