/* ───────────────────────────────────────────────
   ROTTE · Migration Atlas — editorial
   warm paper canvas · dark sidebar · light/dark
   ─────────────────────────────────────────────── */

:root {
  --paper: #F3EFE6;
  --card: #FFFFFF;
  --ink: #1B2733;
  --ink-2: #4A5560;
  --ink-3: #616A75;
  --hair: rgba(27, 39, 51, 0.11);
  --hair-soft: rgba(27, 39, 51, 0.06);
  --field: #FBFAF6;

  --sidebar-bg: #14202C;
  --sidebar-ink: #E8EEF5;
  --sidebar-ink-2: rgba(232, 238, 245, 0.66);
  --sidebar-ink-3: rgba(232, 238, 245, 0.40);
  --sidebar-hair: rgba(232, 238, 245, 0.12);

  --primary: #3F6694;
  --primary-soft: #AAC9F3;
  --amber: #E0A33E;
  --teal: #5FAE9C;
  --steel: #5B8BB5;
  --crimson: #B34A4A;

  --rose-bg: #F7E7E3;
  --rose-border: rgba(179, 74, 74, 0.28);
  --rose-ink: #8A4040;

  --serif: "Newsreader", Georgia, serif;
  --sans: "Inter", -apple-system, "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 0.375rem;
  --sidebar-w: 264px;
  --gutter: clamp(1.25rem, 3.5vw, 3.25rem);
}

[data-theme="dark"] {
  --paper: #0F1822;
  --card: #18242F;
  --ink: #E6ECF3;
  --ink-2: #AEB8C4;
  --ink-3: #828D9A;
  --hair: rgba(232, 238, 245, 0.13);
  --hair-soft: rgba(232, 238, 245, 0.06);
  --field: #14202B;

  --sidebar-bg: #0B131B;
  --primary: #7E9CC4;
  --rose-bg: #2A1A1C;
  --rose-border: rgba(179, 74, 74, 0.45);
  --rose-ink: #E0A6A6;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--primary); color: #fff; }
a { color: inherit; }

/* ── sidebar ────────────────────────────────── */

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  padding: 1.6rem 1.4rem 1.3rem;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid rgba(0, 0, 0, 0.3);
}

.side-brand { display: block; text-decoration: none; margin-bottom: 1.5rem; }
.side-brand .brand-name {
  font-family: var(--serif);
  font-weight: 700; font-size: 1.5rem;
  letter-spacing: 0.04em; color: var(--sidebar-ink);
  display: block; line-height: 1;
}
.side-brand .brand-sub {
  font-family: var(--mono);
  font-size: 0.6rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--sidebar-ink-3); margin-top: 0.4rem; display: block;
}
.brand-wave { margin-top: 0.55rem; display: block; opacity: 0.6; }

.side-tagline {
  font-family: var(--serif);
  font-size: 1.18rem; font-weight: 500; line-height: 1.25;
  color: var(--sidebar-ink); margin-bottom: 0.85rem;
}
.side-about {
  font-size: 0.78rem; line-height: 1.55;
  color: var(--sidebar-ink-2); margin-bottom: 1.6rem;
}

.side-nav { display: flex; flex-direction: column; gap: 0.1rem; margin-bottom: auto; }
.side-nav a {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.5rem 0.4rem;
  text-decoration: none; color: var(--sidebar-ink-2);
  border-radius: var(--radius);
  transition: background 0.18s, color 0.18s;
}
.side-nav a:hover { background: rgba(232, 238, 245, 0.05); color: var(--sidebar-ink); }
.side-nav a.is-current { background: rgba(232, 238, 245, 0.07); color: var(--sidebar-ink); }
.side-nav .n-num {
  flex: 0 0 auto;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--sidebar-hair);
  font-family: var(--mono); font-size: 0.66rem; color: var(--sidebar-ink-2);
}
.side-nav a.is-current .n-num,
.side-nav a:hover .n-num { border-color: var(--primary-soft); color: var(--primary-soft); }
.side-nav .n-label { font-size: 0.86rem; line-height: 1.2; }
.side-nav .n-about .n-num { border-style: dashed; }

.side-pages {
  display: flex; flex-direction: column; gap: 0.4rem;
  margin-top: 1.2rem; padding-top: 1.1rem; border-top: 1px solid var(--sidebar-hair);
}
.side-pages a {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.05em;
  color: var(--sidebar-ink-3); text-decoration: none; transition: color 0.2s;
}
.side-pages a:hover { color: var(--sidebar-ink); }

.side-foot { margin-top: 1.5rem; padding-top: 1.2rem; border-top: 1px solid var(--sidebar-hair); }

.theme-toggle {
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--sidebar-hair); border-radius: 999px;
  overflow: hidden; width: 100%;
}
.theme-toggle button {
  flex: 1; appearance: none; background: transparent; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.06em;
  color: var(--sidebar-ink-2);
  transition: background 0.18s, color 0.18s;
}
.theme-toggle button.is-active { background: rgba(232, 238, 245, 0.10); color: var(--sidebar-ink); }
.theme-toggle button svg { width: 13px; height: 13px; }

/* ── main shell ─────────────────────────────── */

.main-shell { margin-left: var(--sidebar-w); min-height: 100vh; }

.main-topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.7rem var(--gutter);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hair);
  min-height: 52px;
}
.main-topbar .mt-brand { display: none; font-family: var(--serif); font-weight: 700; font-size: 1.1rem; letter-spacing: 0.04em; }
.main-topbar .mt-date { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.main-topbar .mt-right { margin-left: auto; display: flex; align-items: center; gap: 0.7rem; }

.hamburger {
  display: none; appearance: none; background: transparent;
  border: 1px solid var(--hair); border-radius: var(--radius);
  width: 34px; height: 30px; cursor: pointer; color: var(--ink);
  align-items: center; justify-content: center;
}
.hamburger svg { width: 16px; height: 16px; }

.lang-toggle {
  appearance: none; display: inline-flex; align-items: center;
  background: var(--card); border: 1px solid var(--hair);
  border-radius: 999px; padding: 2px; cursor: pointer;
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.06em; color: var(--ink-2);
}
.lang-toggle .lang-sep { display: none; }
.lang-toggle [data-lang-opt] { padding: 0.2rem 0.6rem; border-radius: 999px; transition: background 0.18s, color 0.18s; }
.lang-toggle [data-lang-opt].is-active { background: var(--primary); color: #fff; font-weight: 500; }

.scrim {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(11, 19, 27, 0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

/* ── hero ───────────────────────────────────── */

.hero { padding: clamp(1.5rem, 3vw, 2.6rem) var(--gutter) clamp(2.5rem, 5vh, 4rem); }

.hero-banner {
  position: relative; overflow: hidden;
  border: 1px solid var(--hair); border-radius: 0.6rem;
  background: linear-gradient(105deg, #EFE9DC 0%, #ECE6D9 38%, #E4E2D9 64%, #DCE2E2 100%);
  min-height: clamp(230px, 34vw, 380px);
  display: flex; align-items: flex-start;
}
[data-theme="dark"] .hero-banner {
  background: linear-gradient(105deg, #1A2530 0%, #1B2832 42%, #1E2C36 70%, #243641 100%);
  border-color: var(--hair);
}
.hero-art { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.hero-copy { position: relative; z-index: 1; padding: clamp(1.4rem, 3vw, 2.6rem); max-width: 40rem; }

.hero-date {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-2); margin-bottom: 1rem;
}
.hero h1 {
  font-family: var(--serif); font-optical-sizing: auto;
  font-size: clamp(2.1rem, 4.6vw, 3.6rem);
  font-weight: 600; line-height: 1.06; letter-spacing: -0.02em;
  color: var(--ink); margin-bottom: 1rem;
}
.hero h1 em { font-style: normal; }
.hero-sub { font-size: clamp(1rem, 1.5vw, 1.18rem); color: var(--ink-2); max-width: 32rem; }
.hero-lede { margin-top: 1rem; font-size: clamp(0.92rem, 1.15vw, 1.02rem); line-height: 1.6; color: var(--ink-2); max-width: 40rem; }
.hero-lede b { color: var(--ink); font-weight: 600; }
.hero-freshness {
  margin: 1.5rem 0 0; max-width: 60rem;
  font-family: var(--mono); font-size: 0.72rem; line-height: 1.55; color: var(--ink-2);
  background: rgba(224, 163, 62, 0.10);
  border: 1px solid rgba(224, 163, 62, 0.40);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius); padding: 0.7rem 0.9rem;
}
.hero-freshness b { color: var(--ink); font-weight: 600; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 1rem; margin-top: 1.1rem;
}
.stat {
  background: var(--card); border: 1px solid var(--hair); border-radius: var(--radius);
  padding: 1.1rem 1.2rem 0.7rem;
  display: flex; flex-direction: column;
}
.stat-label {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.04em;
  line-height: 1.45; color: var(--ink-3); margin-bottom: 0.55rem;
}
.stat-label b { display: block; font-weight: 500; color: var(--primary); font-size: 0.72rem; letter-spacing: 0.02em; }
.stat.is-asylum .stat-label b { color: var(--teal); }
.stat.is-deaths .stat-label b { color: var(--crimson); }
.stat-num {
  font-family: var(--serif); font-size: clamp(1.7rem, 2.7vw, 2.3rem);
  font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.05; color: var(--ink);
}
.stat.is-deaths .stat-num { color: var(--crimson); }
.stat-unit { font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.04em; color: var(--ink-3); margin-top: 0.3rem; }
.stat-spark { width: 100%; height: 44px; margin-top: 0.55rem; }

.scroll-cue {
  display: block; text-align: center; margin-top: 1.6rem;
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.1em;
  text-transform: uppercase; text-decoration: none; color: var(--ink-3);
}
.scroll-cue span { display: block; font-size: 1rem; margin-top: 0.2rem; animation: bob 2.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(6px); } }

/* ── chapters ───────────────────────────────── */

.chapter { padding: clamp(2.5rem, 6vh, 4.5rem) var(--gutter); border-top: 1px solid var(--hair); scroll-margin-top: var(--topbar-h, 52px); }

/* ── titolo di capitolo «sticky scroll» ─────────
   una barra sottile per capitolo, incollata sotto la topbar: compare quando
   il titolo vero scivola fuori dallo schermo e viene spinta via dal capitolo
   successivo (position: sticky dentro la sezione fa entrambe le cose). */
.chapter-sticky {
  position: sticky; top: var(--topbar-h, 52px); z-index: 30;
  display: flex; align-items: center; gap: 0.75rem;
  height: 2.4rem; margin: 0 calc(-1 * var(--gutter)) -2.4rem;
  padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hair);
  text-decoration: none;
  opacity: 0; pointer-events: none;
  transition: opacity 0.22s ease-out;
}
.chapter-sticky.is-stuck { opacity: 1; pointer-events: auto; }
.chapter-sticky .cs-no {
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--primary); white-space: nowrap; flex: none;
}
.chapter-sticky .cs-title {
  font-family: var(--serif); font-weight: 600; font-size: 0.95rem; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chapter-sticky:hover .cs-title { color: var(--primary); }
@media (prefers-reduced-motion: reduce) { .chapter-sticky { transition: none; } }

.chapter-head { max-width: 52rem; margin-bottom: 2.2rem; }
.chapter-no {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--primary); margin-bottom: 0.85rem;
}
.chapter h2 {
  font-family: var(--serif); font-size: clamp(1.8rem, 3.6vw, 2.7rem);
  font-weight: 600; line-height: 1.12; letter-spacing: -0.015em; margin-bottom: 1rem;
}
.chapter h2 em { font-style: italic; font-weight: 500; color: var(--primary); }
.chapter-intro { color: var(--ink-2); font-size: 1.02rem; max-width: 46rem; }
.chapter-body { color: var(--ink-2); font-size: 0.95rem; line-height: 1.75; max-width: 46rem; margin-top: 0.8rem; }
.chapter-body a { color: var(--primary); text-underline-offset: 3px; }
.note-inline { font-style: italic; color: var(--ink-3); }
.red-figure { color: var(--crimson); font-weight: 600; }

/* ── panels & charts ────────────────────────── */

.panel {
  position: relative;
  border: 1px solid var(--hair); border-radius: var(--radius);
  background: var(--card); padding: 1.4rem 1.4rem 1.1rem;
}
.panel-head {
  display: flex; flex-direction: column; align-items: stretch;
  gap: 0.9rem; margin-bottom: 1.1rem;
}
.panel-head .panel-title { margin-bottom: 0; }

.panel-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.9rem 1.4rem; margin-bottom: 1.1rem; }

.panel-title { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; margin-bottom: 0.9rem; }
.panel-title-sub { display: block; font-family: var(--sans); font-size: 0.92rem; font-weight: 400; color: var(--ink-2); margin-top: 0.15rem; }
.panel-title-unit { font-family: var(--mono); font-size: 0.62rem; font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }

.seg-label, .ctrl-label { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin-right: 0.1rem; }

.seg { display: inline-flex; background: var(--field); border: 1px solid var(--hair); border-radius: var(--radius); overflow: hidden; }
.seg-btn {
  appearance: none; background: transparent; border: none; color: var(--ink-2);
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.46rem 0.9rem; cursor: pointer; transition: background 0.18s, color 0.18s;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--hair); }
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active { background: var(--primary); color: #fff; font-weight: 500; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  appearance: none; display: inline-flex; align-items: center; gap: 0.42rem;
  background: var(--card); border: 1px solid var(--hair); border-radius: 999px;
  color: var(--ink-2); font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.03em;
  padding: 0.3rem 0.7rem; cursor: pointer;
  transition: border-color 0.18s, color 0.18s, opacity 0.18s, background 0.18s;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--primary)); }
.chip:hover { border-color: var(--primary); color: var(--ink); }
.chip.is-off { opacity: 0.4; }
.chip.is-off .dot { background: transparent; border: 1px solid var(--ink-3); }
.chip-more { border-style: dashed; color: var(--primary); font-weight: 500; }
.chip-more:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }

.chart { width: 100%; height: 380px; }
.chart-tall { height: 460px; }
.chart-offset { margin-top: 2.55rem; }

.panel-hint {
  display: block; margin: -0.1rem 0 1rem; padding: 0.65rem 0.9rem;
  border: 1px solid rgba(224, 163, 62, 0.4); border-left: 3px solid var(--amber);
  border-radius: var(--radius); background: rgba(224, 163, 62, 0.08);
  font-family: var(--sans); font-size: 0.85rem; line-height: 1.6; color: var(--ink-2); max-width: 60rem;
}

/* caveat: full-width warning strip under the panel controls (never over the chart) */
.caveat {
  display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap;
  border: 1px solid var(--rose-border); border-radius: var(--radius);
  background: var(--rose-bg); padding: 0.6rem 0.85rem;
}
.caveat .caveat-label { font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--crimson); flex: 0 0 auto; }
.caveat .caveat-text { font-size: 0.85rem; line-height: 1.5; color: var(--rose-ink); }

.panel-foot { margin-top: 0.9rem; font-family: var(--mono); font-size: 0.74rem; line-height: 1.75; color: var(--ink-3); max-width: 72rem; }
.panel-foot.solo { margin-top: 1.2rem; }
.panel-foot code { color: var(--ink-2); }
.panel-foot a, .panel-hint a { color: var(--primary); }

/* ── map ────────────────────────────────────── */

.chart-map { height: 540px; }
.map-panel { margin-bottom: 1.1rem; }
.map-controls { align-items: center; gap: 1.1rem; }
.map-play { border: 1px solid var(--hair); border-radius: var(--radius); min-width: 6rem; background: var(--field); }

.year-slider {
  appearance: none; -webkit-appearance: none; flex: 1;
  min-width: 160px; max-width: 460px; height: 3px; border-radius: 2px;
  background: var(--hair); outline: none; cursor: pointer;
}
.year-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--primary); border: 2px solid var(--card); box-shadow: 0 1px 4px rgba(27,39,51,0.25); }
.year-slider::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid var(--card); }
.map-year-label { font-family: var(--serif); font-size: 1.8rem; font-weight: 600; color: var(--primary); font-variant-numeric: tabular-nums; min-width: 3.2ch; line-height: 1; }

/* ── single-select & layout helpers ─────────── */

.single-select { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.single-select-label { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.single-select .chip { padding: 0.24rem 0.55rem; }
.single-select .chip.is-on { border-color: var(--primary); background: var(--primary); color: #fff; }

.duo-gap { margin-top: 1.2rem; }
.chart-offset2 { margin-top: 2.5rem; }
.chips-row { margin-bottom: 0.9rem; }

/* ── small multiples ────────────────────────── */

.multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 1rem; }
.mcard {
  position: relative; overflow: hidden;
  border: 1px solid var(--hair); border-top: 3px solid var(--c, var(--primary)); border-radius: var(--radius);
  background: var(--card); padding: 1rem 1.05rem 0.4rem;
  transition: box-shadow 0.25s;
}
.mcard:hover { box-shadow: 0 6px 20px rgba(27, 39, 51, 0.07); }
.mcard-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; }
.mcard-name { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; }
.mcard-total { font-family: var(--mono); font-size: 0.66rem; color: var(--ink-2); white-space: nowrap; }
.mcard-sub { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.03em; color: var(--ink-3); margin-top: 0.2rem; }
.mchart { width: 100%; height: 140px; margin-top: 0.4rem; }

/* ── somber chapter ─────────────────────────── */

.chapter-somber { background: var(--rose-bg); }
.chapter-somber .chapter-no { color: var(--crimson); }
.chapter-somber h2 em { color: var(--crimson); }
.chapter-somber .panel { border-top: 3px solid var(--crimson); }

/* ── footer ─────────────────────────────────── */

.footer { border-top: 1px solid rgba(0,0,0,0.3); padding: 3rem var(--gutter) 1.5rem; background: var(--sidebar-bg); color: var(--sidebar-ink); }
.footer-grid { display: grid; grid-template-columns: 1.3fr 1.1fr 1fr 1.3fr; gap: 2.5rem; margin-bottom: 2.2rem; }
.footer-brand { font-family: var(--serif); font-weight: 700; letter-spacing: 0.04em; font-size: 1.35rem; }
.footer-brand small { display: block; font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--sidebar-ink-3); margin-top: 0.35rem; font-weight: 400; }
.footer-tag { margin-top: 1rem; font-family: var(--serif); font-size: 1.02rem; font-style: italic; color: var(--sidebar-ink-2); max-width: 22rem; }
.footer-h { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--sidebar-ink-3); margin-bottom: 0.9rem; }
.footer ul { list-style: none; }
.footer li { margin-bottom: 0.5rem; }
.footer li a { font-family: var(--mono); font-size: 0.76rem; color: var(--sidebar-ink-2); text-underline-offset: 3px; transition: color 0.2s; }
.footer li a:hover { color: var(--sidebar-ink); }
.footer-note { font-size: 0.84rem; line-height: 1.65; color: var(--sidebar-ink-2); }
.footer-bar { display: flex; align-items: center; gap: 1rem 1.4rem; padding-top: 1.3rem; border-top: 1px solid var(--sidebar-hair); flex-wrap: wrap; }
.footer-bar .fb-copy { font-family: var(--mono); font-size: 0.66rem; color: var(--sidebar-ink-3); }
.footer-legal { margin-left: auto; display: flex; align-items: center; gap: 1.1rem; }
.footer-legal a, .footer-consent {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.04em;
  color: var(--sidebar-ink-2); text-decoration: none; text-underline-offset: 3px;
  background: none; border: none; padding: 0; cursor: pointer; transition: color 0.2s;
}
.footer-legal a:hover, .footer-consent:hover { color: var(--sidebar-ink); text-decoration: underline; }
.footer-contact {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.04em;
  color: var(--sidebar-ink-2); text-decoration: none; text-underline-offset: 3px; transition: color 0.2s;
}
.footer-contact:hover { color: var(--sidebar-ink); text-decoration: underline; }

/* ── in-content ads (manual units, between chapters) ───────── */

.ad-slot {
  display: flex; flex-direction: column; align-items: center; gap: 0.55rem;
  padding: clamp(1.75rem, 4.5vh, 3.25rem) var(--gutter);
  border-top: 1px solid var(--hair);
}
.ad-slot .ad-label {
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ink-3);
}
.ad-slot ins { display: block; width: 100%; max-width: 728px; }

/* ── reveal on scroll ───────────────────────── */

.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.7s cubic-bezier(0.22,0.6,0.25,1), transform 0.7s cubic-bezier(0.22,0.6,0.25,1); }
.reveal.d1 { transition-delay: 0.08s; }
.reveal.d2 { transition-delay: 0.16s; }
.reveal.d3 { transition-delay: 0.28s; }
.reveal.is-in { opacity: 1; transform: none; }

/* ── responsive ─────────────────────────────── */

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.trio { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

@media (max-width: 1100px) {
  .trio { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 980px) {
  .duo { grid-template-columns: 1fr; }
  .chart-offset, .chart-offset2 { margin-top: 1rem; }
  .footer-grid { grid-template-columns: 1fr; gap: 1.8rem; }
}

/* ── article pages (methodology, FAQ, glossary, about) ───────── */

.article-page { background: var(--paper); color: var(--ink); }

.article-top {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.8rem var(--gutter);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hair);
}
.at-brand { font-family: var(--serif); font-weight: 700; font-size: 1.2rem; letter-spacing: 0.04em; color: var(--ink); text-decoration: none; }
.at-brand span { font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3); margin-left: 0.5rem; font-weight: 400; }
.at-spacer { margin-left: auto; }
.at-back { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.04em; color: var(--primary); text-decoration: none; }
.at-back:hover { text-decoration: underline; }
.at-lang {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em;
  color: var(--ink-2); text-decoration: none;
  border: 1px solid var(--hair); border-radius: 999px; padding: 0.3rem 0.75rem;
  background: var(--card); transition: color 0.2s, border-color 0.2s;
}
.at-lang:hover { color: var(--primary); border-color: var(--primary); }

.article-wrap { max-width: 46rem; margin: 0 auto; padding: clamp(2rem, 5vw, 4rem) var(--gutter) 3.5rem; }
.article-kicker { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--primary); margin-bottom: 0.9rem; }
.article-wrap h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.9rem, 4vw, 2.7rem); line-height: 1.12; letter-spacing: -0.02em;
  margin-bottom: 0.8rem; text-wrap: balance; color: var(--ink);
}
.article-sub { font-size: 1.05rem; line-height: 1.65; color: var(--ink-2); max-width: 40rem; margin-bottom: 1rem; }
.article-meta {
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.04em; color: var(--ink-3);
  padding-bottom: 1.6rem; border-bottom: 1px solid var(--hair); margin-bottom: 2.2rem;
}

.article-body h2 { font-family: var(--serif); font-weight: 600; font-size: 1.45rem; letter-spacing: -0.01em; margin: 2.4rem 0 0.8rem; color: var(--ink); text-wrap: balance; }
.article-body h3 { font-size: 1.02rem; font-weight: 600; margin: 1.5rem 0 0.4rem; color: var(--ink); }
.article-body p, .article-body dd, .article-body li { font-size: 1rem; line-height: 1.75; color: var(--ink-2); }
.article-body p { margin-bottom: 0.95rem; }
.article-body a { color: var(--primary); text-underline-offset: 3px; }
.article-body b, .article-body strong { color: var(--ink); font-weight: 600; }
.article-body em { font-style: italic; }
.article-body code { font-family: var(--mono); font-size: 0.85em; color: var(--ink-2); background: var(--hair-soft); padding: 0.05em 0.35em; border-radius: 4px; }

.faq-item { margin-bottom: 1.6rem; }
.faq-item h2 { font-size: 1.24rem; margin: 2rem 0 0.6rem; }

.glossary dt { font-family: var(--serif); font-weight: 600; font-size: 1.14rem; color: var(--ink); margin: 1.7rem 0 0.35rem; }
.glossary dd { margin: 0; }

.article-table { overflow-x: auto; margin: 0.4rem 0 1.4rem; }
.article-table table { width: 100%; border-collapse: collapse; font-size: 0.78rem; font-family: var(--mono); }
.article-table caption { text-align: left; font-size: 0.68rem; letter-spacing: 0.04em; color: var(--ink-3); padding-bottom: 0.5rem; }
.article-table th, .article-table td { padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--hair); text-align: right; white-space: nowrap; }
.article-table th:nth-child(2), .article-table td:nth-child(2) { text-align: left; }
.article-table thead th { font-weight: 600; color: var(--ink-2); }
.article-table th[scope="row"], .article-table th.rh { text-align: left; font-weight: 500; color: var(--ink-2); }

/* ── profili paese ── */

:root { --cp-imm: #0E7A66; --cp-emi: #C2503C; --cp-asy: #3F6694; --cp-acq: #BD8912; }
[data-theme="dark"] { --cp-imm: #2FA189; --cp-emi: #D0705C; --cp-asy: #7E9CC4; --cp-acq: #D9A62E; }

.cp-crumb { margin-bottom: 1.4rem; }
.cp-crumb a { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.04em; color: var(--primary); text-decoration: none; }
.cp-crumb a:hover { text-decoration: underline; }

.cp-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem 1.4rem; margin: 0 0 1.6rem;
  padding: 1.1rem 0 1.3rem; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair);
}
.cp-stat { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.cp-stat-l { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.cp-stat-v { font-family: var(--sans); font-size: 1.45rem; font-weight: 650; letter-spacing: -0.01em; color: var(--ink); }
.cp-stat-s { font-family: var(--mono); font-size: 0.62rem; color: var(--ink-3); }

.cp-svg { display: block; width: 100%; height: auto; margin: 0.3rem 0 0.6rem; }
.cp-svg-t { fill: var(--ink-3); font-family: var(--mono); font-size: 11px; }
.cp-keys { display: flex; gap: 1.1rem; margin: 0.2rem 0 0 !important; }
.cp-key { display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--mono); font-size: 0.66rem; color: var(--ink-2); }
.cp-key i { width: 14px; height: 3px; border-radius: 2px; background: var(--c); }

.article-note {
  background: var(--hair-soft); border: 1px solid var(--hair); border-radius: var(--radius);
  padding: 0.85rem 1rem; margin: 2rem 0 1rem;
  font-size: 0.9rem; line-height: 1.65; color: var(--ink-2);
}
.article-note a { color: var(--primary); }
.article-note b { color: var(--ink); }
.cp-more { font-family: var(--mono); font-size: 0.74rem; color: var(--ink-3); }
.cp-more a { color: var(--primary); }

.cp-index th[scope="row"] a { color: var(--primary); text-decoration: none; }
.cp-index th[scope="row"] a:hover { text-decoration: underline; }

.article-foot { max-width: 46rem; margin: 0 auto; padding: 1.4rem var(--gutter) 3rem; border-top: 1px solid var(--hair); }
.article-foot nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-bottom: 0.9rem; }
.article-foot nav a { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.04em; color: var(--primary); text-decoration: none; }
.article-foot nav a:hover { text-decoration: underline; }
.article-foot nav a[aria-current] { color: var(--ink-3); pointer-events: none; }
.article-foot > p { font-family: var(--mono); font-size: 0.64rem; color: var(--ink-3); }

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    width: 280px; transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.22,0.6,0.25,1);
  }
  .sidebar.is-open { transform: translateX(0) !important; box-shadow: 0 0 40px rgba(0,0,0,0.4); }
  .main-shell { margin-left: 0; }
  .main-topbar .mt-brand { display: block; }
  .main-topbar .mt-date { display: none; }
  .hamburger { display: inline-flex; }
}

@media (max-width: 640px) {
  .panel { padding: 1.05rem 0.85rem 0.85rem; }
  .seg { flex-wrap: wrap; }
  .seg-btn { padding: 0.42rem 0.6rem; font-size: 0.62rem; letter-spacing: 0.04em; }
  .chart { height: 300px; }
  .chart-tall { height: 360px; }
  .chart-map { height: 380px; }
  .map-year-label { font-size: 1.35rem; }
  .caveat { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}

/* ── crawlable data tables (the chart figures as accessible HTML) ─────── */
/* ── piccoli multipli (una serie per riquadro, scala condivisa) ── */

.chart-multis {
  height: auto; min-height: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem 1.1rem;
}
.mm { min-width: 0; }
.mm-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem;
  margin-bottom: 0.15rem;
}
.mm-name {
  font-size: 0.82rem; font-weight: 600; color: var(--ink);
  display: inline-flex; align-items: center; gap: 0.4rem; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mm-name .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.mm-val { font-family: var(--mono); font-size: 0.66rem; color: var(--ink-3); white-space: nowrap; }
.mm-chart { width: 100%; height: 96px; }
@media (max-width: 480px) { .chart-multis { grid-template-columns: 1fr; } }

.data-table { margin: 0.75rem 0 0; }
.data-table > summary {
  cursor: pointer; list-style: none; user-select: none;
  font-family: var(--mono); font-size: 0.74rem; color: var(--ink-3);
  padding: 0.4rem 0;
}
.data-table > summary::-webkit-details-marker { display: none; }
.data-table > summary::before {
  content: "▸"; display: inline-block; margin-right: 0.4rem; transition: transform 0.15s;
}
.data-table[open] > summary::before { transform: rotate(90deg); }
.data-table > summary:hover { color: var(--primary); }
.data-table-scroll {
  overflow-x: auto; border: 1px solid var(--hair); border-radius: var(--radius);
}
.data-table table {
  border-collapse: collapse; width: 100%; font-family: var(--mono); font-size: 0.72rem;
}
.data-table caption {
  text-align: left; color: var(--ink-3); font-family: var(--sans);
  font-size: 0.74rem; padding: 0.55rem 0.65rem;
}
.data-table th, .data-table td {
  padding: 0.3rem 0.65rem; text-align: right; white-space: nowrap;
  border-top: 1px solid var(--hair-soft);
}
.data-table thead th { font-weight: 600; color: var(--ink-2); background: var(--field); }
.data-table tbody th[scope="row"], .data-table th.rh {
  text-align: left; font-weight: 500; color: var(--ink);
}
.data-table tbody tr:hover td, .data-table tbody tr:hover th { background: var(--hair-soft); }
