/* ───────────────────────────────────────────────
   ROTTE — atlante notturno
   ink #0B141D · bone #E8E0D0 · amber #E9A23B
   ─────────────────────────────────────────────── */

:root {
  --ink: #0B141D;
  --ink-2: #0E1A26;
  --bone: #E8E0D0;
  --bone-dim: rgba(232, 224, 208, 0.62);
  --bone-faint: rgba(232, 224, 208, 0.38);
  --hair: rgba(232, 224, 208, 0.13);
  --hair-soft: rgba(232, 224, 208, 0.07);
  --amber: #E9A23B;
  --amber-soft: rgba(233, 162, 59, 0.14);
  --teal: #62B3A4;
  --steel: #7E9CC4;
  --terra: #C97E6B;
  --mauve: #B48EAD;
  --sage: #9DB58B;
  --slate: #6B7684;
  --red: #C25E50;
  --serif-d: "Fraunces", Georgia, serif;
  --serif-b: "Newsreader", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --gutter: clamp(1.25rem, 5vw, 5rem);
}

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

html { scroll-behavior: smooth; }

body {
  background-color: var(--ink);
  background-image:
    radial-gradient(115% 70% at 50% 0%, rgba(34, 58, 78, 0.35), transparent 60%),
    repeating-linear-gradient(0deg, var(--hair-soft) 0 1px, transparent 1px 112px),
    repeating-linear-gradient(90deg, var(--hair-soft) 0 1px, transparent 1px 112px);
  color: var(--bone);
  font-family: var(--serif-b);
  font-size: 1.1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--amber); color: var(--ink); }

a { color: inherit; }

.grain {
  position: fixed; inset: -50%;
  width: 200%; height: 200%;
  pointer-events: none;
  z-index: 60;
  opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  animation: grain-shift 1.4s steps(3) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-2%, 1.4%); }
  66% { transform: translate(1.6%, -1%); }
  100% { transform: translate(0, 0); }
}

/* ── topbar ─────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 2rem;
  padding: 0.85rem var(--gutter);
  background: rgba(11, 20, 29, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hair);
}

.brand { display: flex; align-items: baseline; gap: 0.65rem; text-decoration: none; }

.brand-mark {
  width: 13px; height: 13px; border-radius: 50%;
  align-self: center;
  border: 2px dashed var(--amber);
  animation: spin 24s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.brand-name {
  font-family: var(--serif-d);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.16em;
}

.brand-sub {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bone-faint);
}

.topnav { margin-left: auto; display: flex; gap: 1.6rem; }

.topnav a {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--bone-dim);
  transition: color 0.2s;
}
.topnav a:hover { color: var(--amber); }

.updated-badge {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  color: var(--amber);
  border: 1px solid rgba(233, 162, 59, 0.4);
  border-radius: 99px;
  padding: 0.3rem 0.75rem;
  white-space: nowrap;
}

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

.hero {
  position: relative;
  min-height: calc(100vh - 60px);
  display: flex; flex-direction: column; justify-content: center;
  padding: 5rem var(--gutter) 6rem;
  overflow: hidden;
}

.hero-arcs {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

.compass-ring {
  fill: none;
  stroke: var(--hair);
  stroke-width: 1;
}
.compass-ring.faint { stroke: var(--hair-soft); }
.compass-ticks line { stroke: rgba(232, 224, 208, 0.22); stroke-width: 1; }
.compass-ticks line.major { stroke: rgba(233, 162, 59, 0.55); }

.arc {
  fill: none;
  stroke: rgba(233, 162, 59, 0.34);
  stroke-width: 1.4;
  stroke-dasharray: 7 9;
  animation: arc-drift 26s linear infinite;
}
.arc.a2 { stroke: rgba(98, 179, 164, 0.28); animation-duration: 34s; }
.arc.a3 { stroke: rgba(126, 156, 196, 0.26); animation-duration: 42s; animation-direction: reverse; }
.arc.a4 { stroke: rgba(233, 162, 59, 0.18); animation-duration: 30s; }
@keyframes arc-drift { to { stroke-dashoffset: -640; } }

.vessel { fill: var(--amber); opacity: 0; }
.v1 { offset-path: path("M -60 620 C 240 600, 420 470, 640 430 S 1040 330, 1280 260"); animation: sail 21s linear infinite; }
.v2 { offset-path: path("M -60 700 C 300 660, 520 560, 700 480 S 1060 380, 1280 360"); animation: sail 29s linear 6s infinite; fill: var(--teal); }
.v3 { offset-path: path("M -60 520 C 200 530, 460 420, 660 350 S 1010 230, 1260 140"); animation: sail 25s linear 12s infinite; }
@keyframes sail {
  0% { offset-distance: 0%; opacity: 0; }
  6% { opacity: 0.95; }
  92% { opacity: 0.95; }
  100% { offset-distance: 100%; opacity: 0; }
}

.hero-inner { position: relative; z-index: 1; max-width: 60rem; }

.kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 1.6rem;
}
.kicker::before {
  content: "";
  display: inline-block;
  width: 2.4rem; height: 1px;
  background: var(--amber);
  vertical-align: middle;
  margin-right: 0.8rem;
}

.hero h1 {
  font-family: var(--serif-d);
  font-optical-sizing: auto;
  font-size: clamp(2.9rem, 7.6vw, 6.4rem);
  font-weight: 560;
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin-bottom: 1.8rem;
}
.hero h1 em, .chapter h2 em {
  font-style: italic;
  font-weight: 420;
  color: var(--amber);
}

.lede {
  max-width: 44rem;
  font-size: clamp(1.05rem, 1.6vw, 1.28rem);
  line-height: 1.65;
  color: var(--bone-dim);
  margin-bottom: 3.2rem;
}

.stat-row {
  display: flex; flex-wrap: wrap;
  gap: clamp(1.5rem, 4vw, 4.5rem);
  border-top: 1px solid var(--hair);
  padding-top: 2rem;
}

.stat { position: relative; }
.stat::before {
  content: "✛";
  position: absolute; top: -2rem; left: 0;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: var(--amber);
}

.stat-num {
  display: block;
  font-family: var(--serif-d);
  font-size: clamp(2.1rem, 4vw, 3.4rem);
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--bone);
}
.stat-num.is-red { color: var(--red); }

.stat-label {
  display: block;
  margin-top: 0.45rem;
  font-family: var(--mono);
  font-size: 0.67rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  line-height: 1.7;
  color: var(--bone-faint);
}

.scroll-cue {
  position: absolute; bottom: 2rem; left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  font-family: var(--mono);
  text-decoration: none;
  color: var(--amber);
  animation: bob 2.2s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translate(-50%, 8px); } }

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

.chapter {
  padding: clamp(4rem, 9vh, 7.5rem) var(--gutter);
  border-top: 1px solid var(--hair);
  position: relative;
}
.chapter::before {
  content: "✛";
  position: absolute; top: -0.6em; left: var(--gutter);
  font-size: 0.8rem;
  color: rgba(233, 162, 59, 0.6);
  background: var(--ink);
  padding: 0 0.5rem;
  margin-left: -0.5rem;
}

.chapter-head { max-width: 52rem; margin-bottom: 3rem; }

.chapter-no {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 1.1rem;
}

.chapter h2 {
  font-family: var(--serif-d);
  font-size: clamp(2.1rem, 4.6vw, 3.6rem);
  font-weight: 560;
  line-height: 1.06;
  margin-bottom: 1.3rem;
}

.chapter-intro {
  color: var(--bone-dim);
  font-size: 1.08rem;
  max-width: 46rem;
}

.note-inline {
  font-style: italic;
  color: var(--bone-faint);
}

.red-figure { color: var(--red); font-weight: 600; }

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

.panel {
  position: relative;
  border: 1px solid var(--hair);
  background: linear-gradient(180deg, rgba(232, 224, 208, 0.028), rgba(232, 224, 208, 0.012));
  padding: 1.6rem 1.6rem 1.2rem;
}
/* cartographic corner ticks */
.panel::before, .panel::after,
.mcard::before, .mcard::after {
  content: "";
  position: absolute;
  width: 11px; height: 11px;
  pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-top: 2px solid var(--amber); border-left: 2px solid var(--amber); }
.panel::after { bottom: -1px; right: -1px; border-bottom: 2px solid var(--amber); border-right: 2px solid var(--amber); }

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

.panel-title {
  font-family: var(--serif-d);
  font-size: 1.25rem;
  font-weight: 560;
  margin-bottom: 1rem;
}
.panel-title-unit {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bone-faint);
}

.seg {
  display: inline-flex;
  border: 1px solid var(--hair);
  border-radius: 2px;
  overflow: hidden;
}

.seg-btn {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--bone-dim);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--hair); }
.seg-btn:hover { color: var(--bone); }
.seg-btn.is-active { background: var(--amber); color: var(--ink); font-weight: 500; }

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.chip {
  appearance: none;
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: 99px;
  color: var(--bone-dim);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  padding: 0.32rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, opacity 0.18s;
}
.chip .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c, var(--amber));
  box-shadow: 0 0 6px var(--c, var(--amber));
}
.chip:hover { border-color: var(--bone-faint); color: var(--bone); }
.chip.is-off { opacity: 0.38; }
.chip.is-off .dot { background: transparent; box-shadow: none; border: 1px solid var(--bone-faint); }

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

.panel-foot {
  margin-top: 0.9rem;
  font-family: var(--mono);
  font-size: 0.64rem;
  line-height: 1.8;
  letter-spacing: 0.03em;
  color: var(--bone-faint);
}
.panel-foot.solo { margin-top: 1.2rem; }
.panel-foot code { color: var(--bone-dim); }

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

.multiples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.1rem;
}

.mcard {
  position: relative;
  border: 1px solid var(--hair);
  background: linear-gradient(180deg, rgba(232, 224, 208, 0.028), rgba(232, 224, 208, 0.01));
  padding: 1.15rem 1.15rem 0.4rem;
  transition: border-color 0.25s, transform 0.25s;
}
.mcard::before { top: -1px; left: -1px; border-top: 2px solid var(--c, var(--amber)); border-left: 2px solid var(--c, var(--amber)); }
.mcard::after { bottom: -1px; right: -1px; border-bottom: 2px solid var(--c, var(--amber)); border-right: 2px solid var(--c, var(--amber)); }
.mcard:hover { border-color: var(--bone-faint); transform: translateY(-3px); }

.mcard-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; }

.mcard-name {
  font-family: var(--serif-d);
  font-size: 1.06rem;
  font-weight: 560;
}

.mcard-total {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--c, var(--amber));
  white-space: nowrap;
}

.mcard-sub {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--bone-faint);
  margin-top: 0.2rem;
}

.mchart { width: 100%; height: 150px; margin-top: 0.4rem; }

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

.chapter-somber {
  background:
    radial-gradient(90% 70% at 50% 110%, rgba(194, 94, 80, 0.10), transparent 70%);
}
.chapter-somber .chapter-no { color: var(--red); }
.chapter-somber .chapter h2 em { color: var(--red); }
.chapter-somber .panel::before, .chapter-somber .panel::after { border-color: var(--red); }
.chapter-somber .stat::before { color: var(--red); }

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

.footer {
  border-top: 1px solid var(--hair);
  padding: 3.5rem var(--gutter) 4rem;
  background: var(--ink-2);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr 1.4fr;
  gap: 3rem;
  max-width: 76rem;
}

.footer-brand {
  font-family: var(--serif-d);
  font-weight: 800;
  letter-spacing: 0.16em;
  font-size: 1.2rem;
}

.footer-tag, .footer-note {
  margin-top: 0.7rem;
  font-size: 0.92rem;
  color: var(--bone-faint);
  line-height: 1.7;
}

.footer-h {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 0.9rem;
}

.footer ul { list-style: none; }
.footer li { margin-bottom: 0.55rem; font-size: 0.95rem; }
.footer li a { color: var(--bone-dim); text-decoration-color: var(--hair); text-underline-offset: 3px; transition: color 0.2s; }
.footer li a:hover { color: var(--amber); }

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

.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.8s cubic-bezier(0.22, 0.6, 0.25, 1), transform 0.8s cubic-bezier(0.22, 0.6, 0.25, 1);
}
.reveal.d1 { transition-delay: 0.12s; }
.reveal.d2 { transition-delay: 0.24s; }
.reveal.d3 { transition-delay: 0.38s; }
.reveal.is-in { opacity: 1; transform: none; }

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

@media (max-width: 980px) {
  .duo { display: block; }
  .duo .panel + .panel { margin-top: 1.2rem; }
  .chart-offset { margin-top: 1rem; }
  .footer-grid { grid-template-columns: 1fr; gap: 2rem; }
}

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

@media (max-width: 760px) {
  .topnav { display: none; }
  .chart { height: 320px; }
  .chart-tall { height: 380px; }
  .updated-badge { display: none; }
  .stat-row { gap: 1.6rem; }
}

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