/* Brussels 2031 — parody scrollytelling. Palette: cream / ink / EU blue / EU gold. */

:root {
  --cream: #faf7f0;
  --ink: #1a1a2e;
  --blue: #003399;
  --gold: #ffcc00;
  --muted: #8a8a99;
  --ghost: rgba(26, 26, 46, 0.08);
  --red: #b33;
  --nav-h: 3.2rem;
  --cell: 16px;
  --cell-gap: 4px;
  --ease-pop: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); }

h1, h2, h3, h4 { line-height: 1.2; font-weight: 800; }

time, .panel-period, .row-value, .stat-num, .ticker-value {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

/* ====================== HERO ====================== */

.hero {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 7rem 1.5rem 5rem;
  background: var(--blue);
  color: var(--cream);
}

.kicker {
  position: relative;
  margin: 0 0 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}

.hero h1 {
  position: relative;
  margin: 0 0 1.5rem;
  font-size: clamp(2.4rem, 10vw, 5.5rem);
  letter-spacing: -0.02em;
}

.dek {
  position: relative;
  max-width: 38rem;
  margin: 0 auto 1rem;
  font-size: 1.15rem;
  opacity: 0.92;
}

.byline {
  position: relative;
  margin: 0 auto 3rem;
  max-width: 34rem;
  font-size: 0.85rem;
  opacity: 0.65;
}

.ticker {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.8rem 1.4rem;
  border: 1px solid rgba(250, 247, 240, 0.3);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.ticker-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
}

.ticker-value {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--gold);
}

/* ====================== CHAPTER NAV ====================== */

.chapter-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 247, 240, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(26, 26, 46, 0.1);
}

.chapter-nav-inner {
  display: flex;
  gap: 0.25rem;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem;
  height: var(--nav-h);
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.chapter-nav-inner::-webkit-scrollbar { display: none; }

.chapter-nav a {
  flex: none;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
}

.chapter-nav a.nav-part {
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
}

.chapter-nav a.active {
  background: var(--blue);
  color: var(--cream);
}

/* ====================== PARTS / PROSE ====================== */

.part { padding: 6rem 1.5rem 4rem; }

.part-head {
  max-width: 38rem;
  margin: 0 auto 4rem;
}

.part-head h2 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0 0 1.2rem;
}

.part-num {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 0.6rem;
}

.part-intro {
  font-size: 1.05rem;
  color: rgba(26, 26, 46, 0.75);
}

.part-scenario .part-head {
  border-top: 4px solid var(--gold);
  padding-top: 2.5rem;
}

/* ====================== SCROLLY LAYOUT ====================== */

.scrolly {
  display: grid;
  grid-template-columns: minmax(0, 38rem) 20rem;
  gap: 4.5rem;
  justify-content: center;
  align-items: start;
  max-width: 72rem;
  margin: 0 auto;
}

.chapter {
  margin-bottom: 7rem;
  scroll-margin-top: calc(var(--nav-h) + 1.5rem);
}

.chapter h3 {
  font-size: 1.25rem;
  margin: 0 0 0.8rem;
}

.chapter h3 time {
  color: var(--blue);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 0.3rem;
}

.chapter p { margin: 0; }

/* ====================== STICKY PANEL ====================== */

.panel {
  position: sticky;
  top: calc(var(--nav-h) + 1.5rem);
  border: 1px solid rgba(26, 26, 46, 0.12);
  border-radius: 12px;
  background: #fff;
  padding: 1.2rem 1.3rem 1rem;
  box-shadow: 0 2px 12px rgba(26, 26, 46, 0.05);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.panel-head h4 {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-period {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--blue);
}

.panel-stat {
  margin-bottom: 1.1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(26, 26, 46, 0.08);
}

.stat-num {
  display: block;
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--blue);
  line-height: 1.1;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  display: block;
}

/* ---- line chart (ai-2027-style: drawn by scroll) ---- */

.panel-chart {
  margin-bottom: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid rgba(26, 26, 46, 0.08);
}

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

.chart-axis { stroke: rgba(26, 26, 46, 0.25); stroke-width: 1; }

.chart-year {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 8px;
  fill: var(--muted);
}

.chart-now { stroke: rgba(26, 26, 46, 0.3); stroke-width: 1; stroke-dasharray: 3 3; }

.chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-line.s-blue { stroke: var(--blue); }
.chart-line.s-gold { stroke: #c9a200; }

.chart-dot {
  opacity: 0;
  transform: scale(0.4);
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity 0.3s var(--ease-pop), transform 0.3s var(--ease-pop);
}
.chart-dot.on { opacity: 1; transform: scale(1); }
.chart-dot.s-blue, .chart-head.s-blue { fill: var(--blue); }
.chart-dot.s-gold, .chart-head.s-gold { fill: #c9a200; }

.chart-note {
  margin: 0.45rem 0 0;
  font-size: 0.68rem;
  line-height: 1.45;
  color: var(--muted);
}

.panel-row { margin-bottom: 0.9rem; }

.row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.row-label { font-size: 0.74rem; font-weight: 600; color: var(--ink); }

.row-value { font-size: 0.8rem; font-weight: 600; color: var(--blue); }

/* counter bump on change */
.row-value.bump, .stat-num.bump { animation: bump 0.45s var(--ease-pop); }
@keyframes bump {
  30% { color: var(--ink); transform: scale(1.12); }
}
.row-value, .stat-num { display: inline-block; transform-origin: right center; }
.stat-num { transform-origin: left center; }

/* ---- icon grids ---- */

.icon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cell-gap);
  align-content: flex-start;
}

/* reserve max height so growth never reflows the panel (docs: 41 icons @ ~13/row;
   papers: 29; bolts/dcs: one row) */
.grid-docs   { min-height: calc(4 * var(--cell) + 3 * var(--cell-gap)); }
.grid-papers { min-height: calc(3 * var(--cell) + 2 * var(--cell-gap)); }
.grid-bolts, .grid-dcs { min-height: var(--cell); }

.cell {
  width: var(--cell);
  height: var(--cell);
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.24s var(--ease-pop), transform 0.24s var(--ease-pop);
}

.cell svg { display: block; width: 100%; height: 100%; }

.grid-docs .cell, .grid-papers .cell { color: var(--blue); }
.grid-bolts .cell { color: #c9a200; }
.grid-dcs .cell { color: var(--blue); }

.cell.is-entering { opacity: 0; transform: scale(0.4); }

.cell.is-leaving {
  opacity: 0;
  transform: scale(0.4) translateY(4px);
  color: var(--red);
  transition-duration: 0.36s;
}

.panel-legend {
  margin: 0.4rem 0 0;
  font-size: 0.7rem;
  color: var(--muted);
}

.legend-icon {
  width: 11px;
  height: 11px;
  vertical-align: -1px;
}

/* ====================== EPILOGUE / FOOTER ====================== */

.part-epilogue {
  background: var(--ink);
  color: rgba(250, 247, 240, 0.92);
  padding-bottom: 6rem;
}

.part-epilogue .part-num { color: var(--gold); }
.part-epilogue h2 { color: var(--cream); }

.epilogue-body {
  max-width: 38rem;
  margin: 0 auto;
}

.epilogue-body p { margin: 0 0 1.6rem; }

.ticker-epilogue {
  margin-top: 2.5rem;
  border-color: rgba(250, 247, 240, 0.2);
  background: rgba(255, 255, 255, 0.04);
}

/* ====================== RESPONSIVE ====================== */

@media (max-width: 860px) {
  .scrolly {
    grid-template-columns: minmax(0, 38rem);
  }
  /* panel becomes a condensed sticky bar under the nav; chapters scroll beneath */
  .panel {
    order: -1;
    position: sticky;
    top: var(--nav-h);
    z-index: 40;
    margin-bottom: 2.5rem;
    padding: 0.7rem 1rem 0.6rem;
    --cell: 12px;
    --cell-gap: 3px;
  }
  .panel-stat { margin-bottom: 0.5rem; padding-bottom: 0.45rem; }
  .stat-num { font-size: 1.3rem; display: inline-block; margin-right: 0.5rem; }
  .stat-label { display: inline; }
  .panel-row { margin-bottom: 0.45rem; }
  .panel-legend { display: none; }
  .chapter { margin-bottom: 4.5rem; }
  /* the line chart is the star on small screens; the icon grids step aside */
  .icon-grid { display: none; }
  .panel-chart { margin-bottom: 0.55rem; padding-bottom: 0.5rem; }
  .chart-note { display: none; }
}

@media (max-width: 480px) {
  body { font-size: 1rem; }
  .part { padding-top: 4rem; }
}

/* ====================== REDUCED MOTION ====================== */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cell, .row-value, .stat-num, .chart-dot { transition: none !important; animation: none !important; }
}
