/* story.css — "The simplest theory of radical-right success"
 * Scrollytelling house style, adapted from jessefrederik.com/cremaschi:
 * PT Serif (display + body) + Libre Franklin (UI/numbers), warm off-white,
 * viz-panels that bleed wider than the text column, scroll-reveal sections. */

:root {
  --bg: #FAFAF8;
  --surface: #F0EDE8;
  --grid: #E3E0DB;
  --text: #2D2D2D;
  --text-muted: #6B6B6B;
  --text-caption: #707070;
  --accent: #C44D3F;        /* brick red — emphasis, rules, AfD/restrictive */
  --voters: #2D5F7C;        /* blue — voters / public */
  --parl: #2D2D2D;          /* near-black — parliament */
  --gold: #D4A76A;
  --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; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}
.container { max-width: 680px; margin: 0 auto; padding: 40px 20px 100px; }

/* ── Top bar: kicker + language toggle ─────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.kicker {
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent);
}
.lang-toggle { display: inline-flex; }
.lang-toggle a {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  border: 1px solid var(--grid); background: #fff;
  padding: 3px 10px; 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; }

/* ── Header ────────────────────────────────────────────────────────────── */
h1 {
  font-family: var(--font-display);
  font-size: 38px; font-weight: 700; line-height: 1.15; margin-bottom: 8px;
}
h1::before {
  content: ''; display: block;
  width: 48px; height: 4px; background: var(--accent); margin-bottom: 22px;
}
.subtitle {
  font-family: var(--font-display); font-style: italic;
  font-size: 19px; color: var(--text-muted); margin-bottom: 16px; line-height: 1.5;
}
.byline { font-size: 13px; color: var(--text-muted); margin-bottom: 40px; }

/* ── Sections + scroll reveal ──────────────────────────────────────────── */
.section { margin-bottom: 8px; opacity: 0; transform: translateY(36px);
           transition: opacity 0.7s ease, transform 0.7s ease; }
.section.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .section { opacity: 1; transform: none; transition: none; } }

h2 {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 700; line-height: 1.25; margin: 44px 0 8px;
}
.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--accent); margin: 40px 0 4px;
}
p {
  font-family: var(--font-display);
  font-size: 18px; margin-bottom: 18px; line-height: 1.75;
}
p.small { font-size: 15px; color: var(--text-muted); font-family: var(--font); }
a { color: var(--accent); text-decoration: none; border-bottom: 1px solid currentColor; }
a:hover { color: var(--text); }
strong { font-weight: 700; }
.num { font-family: var(--font); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.todo { color: #b3552e; font-style: italic; font-family: var(--font); font-size: 0.85em; }

/* ── Viz panels (bleed wider than text on desktop) ─────────────────────── */
.viz-panel {
  background: var(--surface); border-radius: var(--radius);
  padding: 22px 24px 18px; margin: 30px -20px; position: relative;
}
@media (min-width: 900px) { .viz-panel { margin-left: -130px; margin-right: -130px; } }
.viz-panel .panel-head {
  font-family: var(--font); font-size: 13px; font-weight: 700;
  letter-spacing: 0.02em; color: var(--text); margin-bottom: 2px;
}
.viz-panel .panel-sub {
  font-family: var(--font); font-size: 12.5px; color: var(--text-muted); margin-bottom: 8px;
}
.viz-panel svg { display: block; width: 100%; overflow: visible; }
.viz-panel .caption {
  font-family: var(--font); font-size: 12px; color: var(--text-caption);
  margin-top: 12px; line-height: 1.5;
}
.viz-controls { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 0 12px; }
.viz-controls button {
  font-family: var(--font); font-size: 12.5px; font-weight: 600;
  padding: 4px 12px; border: 1px solid var(--grid); border-radius: var(--radius);
  background: #fff; color: var(--text); cursor: pointer; transition: all 0.12s;
}
.viz-controls button.active { background: var(--text); border-color: var(--text); color: #fff; }

/* ── Stat cards / infocard ─────────────────────────────────────────────── */
.infocard {
  background: var(--surface); border-left: 3px solid var(--accent);
  padding: 16px 20px; margin: 24px 0; border-radius: var(--radius);
  font-family: var(--font); font-size: 15.5px; line-height: 1.65;
}
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0; }
.card { border-radius: var(--radius); padding: 14px; text-align: center; background: var(--surface); }
.card.main { background: var(--text); color: var(--bg); }
.card .lab { font-family: var(--font); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.7; margin-bottom: 2px; }
.card .big { font-family: var(--font); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Axes / chart elements ─────────────────────────────────────────────── */
.axis path, .axis line { stroke: #cfcabf; }
.axis text { fill: var(--text-muted); font-family: var(--font); font-size: 10.5px; }
.gridline { stroke: var(--grid); stroke-dasharray: none; }
.chart-tip {
  position: fixed; pointer-events: none; z-index: 60;
  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;
  opacity: 0; transition: opacity 0.1s;
}

/* ── Source / footer ───────────────────────────────────────────────────── */
.references {
  font-family: var(--font); font-size: 13px; color: var(--text-caption);
  margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--grid); line-height: 1.6;
}
.references h2 { font-family: var(--font); font-size: 13px; font-weight: 700; letter-spacing: 0.5px;
                 text-transform: uppercase; color: var(--text-muted); margin: 0 0 14px; }
.ref-list { list-style: none; padding-left: 0; }
.ref-list li { padding-left: 1.5em; text-indent: -1.5em; margin-bottom: 10px; }
.references a { color: var(--text); }

/* ── Bilingual prose blocks (toggled by body class) ────────────────────── */
.lang { display: none; }
body.lang-en .lang.en { display: block; }
body.lang-nl .lang.nl { display: block; }

/* ── Build-a-migrant profile interactive ───────────────────────────────── */
.pb-meter { text-align: center; margin: 4px 0 18px; }
.pb-meter-num { font-family: var(--font); font-weight: 700; font-size: 30px;
  font-variant-numeric: tabular-nums; color: var(--accent); line-height: 1.1; }
.pb-bar { height: 9px; background: #e2ded7; border-radius: 5px; margin: 8px auto 5px;
  max-width: 460px; overflow: hidden; }
.pb-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--accent));
  width: 0; transition: width 0.35s cubic-bezier(.4,0,.2,1); }
.pb-meter-cap { font-family: var(--font); font-size: 12px; color: var(--text-muted); }
.pb-rows { display: flex; flex-direction: column; gap: 9px; }
.pb-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 10px; }
.pb-label { font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--text); }
.pb-opts { display: flex; gap: 5px; flex-wrap: wrap; }
.pb-opt { font-family: var(--font); font-size: 12.5px; padding: 5px 11px;
  border: 1px solid var(--grid); border-radius: var(--radius); background: #fff;
  color: var(--text-muted); cursor: pointer; transition: all 0.12s; }
.pb-opt:hover { border-color: var(--accent); color: var(--text); }
.pb-opt.active { background: var(--text); border-color: var(--text); color: #fff; }
@media (max-width: 620px) {
  .pb-row { grid-template-columns: 1fr; gap: 4px; }
  .pb-label { font-size: 12px; }
}

/* ── "Who's judging" dot-plot (View B) ─────────────────────────────────── */
.pb-modtoggle { display: flex; gap: 5px; flex-wrap: wrap; margin: 0 0 8px; }
.pb-modbtn { font-family: var(--font); font-size: 12px; padding: 4px 10px;
  border: 1px solid var(--grid); border-radius: var(--radius); background: #fff;
  color: var(--text-muted); cursor: pointer; }
.pb-modbtn.active { background: var(--text); border-color: var(--text); color: #fff; }
.pb-legend { display: flex; gap: 16px; font-family: var(--font); font-size: 12px;
  color: var(--text-muted); margin-bottom: 6px; }
.pb-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 5px; vertical-align: middle; }
.pb-judges svg { display: block; width: 100%; overflow: visible; }

.pb-caveat { font-family: var(--font); font-size: 11.5px; color: var(--text-caption);
  font-style: italic; margin: 14px 0 0; line-height: 1.5; }

/* ── interaction-aware meter: effect badges + 50% mark ─────────────────── */
.pb-bar { position: relative; }
.pb-mark { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px;
  background: #b3ada3; }
.pb-row { grid-template-columns: 150px 1fr auto; }
.pb-eff { font-family: var(--font); font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; color: var(--text-muted); }
.pb-eff.pos { color: #2f7d3f; }
.pb-eff.neg { color: var(--accent); }
.pb-rbtn.active { background: var(--accent); border-color: var(--accent); }
@media (max-width: 620px) { .pb-row { grid-template-columns: 1fr auto; } }

/* ── preset example applicants ─────────────────────────────────────────── */
.pb-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; }
.pb-prelab { font-family: var(--font); font-size: 12px; font-weight: 600; color: var(--text-muted); }
.pb-prebtn { font-family: var(--font); font-size: 12.5px; padding: 4px 11px;
  border: 1px solid var(--accent); border-radius: 999px; background: #fff;
  color: var(--accent); cursor: pointer; transition: all 0.12s; }
.pb-prebtn:hover { background: var(--accent); color: #fff; }

/* ── explorer chrome: country selector + view tabs ─────────────────────── */
.controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; margin: 18px 0 26px; }
.ctrl label { display: block; font-family: var(--font); font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 5px; }
.ctrl select { font-family: var(--font-display); font-size: 19px; font-weight: 700; color: var(--text);
  border: none; border-bottom: 2px solid var(--accent); background: transparent; padding: 2px 22px 3px 2px;
  cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23C44D3F'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 4px center; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { font-family: var(--font); font-size: 13px; font-weight: 600; padding: 7px 14px;
  border: 1px solid var(--grid); border-radius: var(--radius); background: #fff; color: var(--text-muted); cursor: pointer; }
.tab.active { background: var(--text); border-color: var(--text); color: #fff; }
.view-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; margin: 6px 0 2px; }
.view-sub { font-family: var(--font); font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.amce-attr { font-family: var(--font); font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.03em; margin: 16px 0 4px; }

/* ── build-a-migrant: acceptance density across respondents ─────────────── */
.pb-density { max-width: 480px; margin: 8px auto 0; }
.pb-density svg { display: block; width: 100%; overflow: visible; }
.pb-dens-cap { font-family: var(--font); font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

.ideo-chart svg { display: block; width: 100%; height: auto; }

/* ── i18n: language toggle + show/hide ──────────────────────────────────── */
body.lang-en .nl, body.lang-nl .en { display: none; }
.topbar { display: flex; align-items: center; justify-content: space-between; }
.langtoggle button { font-family: var(--font); font-size: 11.5px; font-weight: 700; letter-spacing: .5px;
  border: 1px solid var(--grid); background: transparent; color: var(--text-muted); padding: 3px 9px; cursor: pointer; }
.langtoggle button:first-child { border-radius: 3px 0 0 3px; border-right: none; }
.langtoggle button:last-child { border-radius: 0 3px 3px 0; }
.langtoggle button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.small-note { font-family: var(--font); font-size: 13px; color: var(--text-caption); line-height: 1.6; }
