/* =========================================================
   Everything, Right Now — shared design system
   Section files must only use classes prefixed with their
   section id (e.g. .globe-*), plus the shared classes here.
   ========================================================= */
:root {
  /* surfaces */
  --bg: #04050a;
  --bg-2: #0a0d18;
  --panel: rgba(18, 22, 40, 0.55);
  --panel-solid: #0f1324;
  --line: rgba(160, 180, 255, 0.14);
  --line-strong: rgba(160, 180, 255, 0.3);

  /* text */
  --ink: #eef1fa;
  --ink-2: #aab3cc;
  --ink-3: #6c7591;

  /* accents (one per chapter, all usable anywhere) */
  --cyan: #5cf2ff;
  --magenta: #ff4fd8;
  --amber: #ffb547;
  --lime: #a6ff6a;
  --violet: #9b7bff;
  --red: #ff5a5f;
  --accent: var(--cyan); /* sections override locally */

  /* type */
  --f-display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --f-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  /* scale */
  --step--1: clamp(0.8rem, 0.76rem + 0.2vw, 0.9rem);
  --step-0: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --step-1: clamp(1.25rem, 1.1rem + 0.7vw, 1.6rem);
  --step-2: clamp(1.6rem, 1.3rem + 1.4vw, 2.4rem);
  --step-3: clamp(2.2rem, 1.6rem + 3vw, 4.2rem);
  --step-4: clamp(3rem, 1.8rem + 6vw, 7.5rem);

  --gutter: clamp(16px, 4vw, 56px);
  --maxw: 1240px;
  --radius: 18px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--step-0);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img, canvas, svg, video { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
::selection { background: var(--magenta); color: #000; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* grain overlay for richness */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 90; opacity: .05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---------- sections ---------- */
.sec { position: relative; padding: clamp(80px, 12vh, 160px) 0; isolation: isolate; }
.sec + .sec { border-top: 1px solid var(--line); }
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }

.sec__kicker {
  font-family: var(--f-mono); font-size: var(--step--1); letter-spacing: .22em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 18px; display: flex; align-items: center; gap: 12px;
}
.sec__kicker::before { content: ""; width: 34px; height: 1px; background: currentColor; }
.sec__title {
  font-family: var(--f-display); font-weight: 700; font-size: var(--step-3); line-height: 1.02;
  letter-spacing: -0.02em; margin: 0 0 24px; text-wrap: balance;
}
.sec__title em { font-style: normal; color: var(--accent); }
.sec__lede { font-size: var(--step-1); color: var(--ink-2); max-width: 46ch; margin: 0 0 40px; line-height: 1.45; font-weight: 300; }

/* ---------- shared components ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(18px, 2.4vw, 28px); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.card h3 { font-family: var(--f-display); font-weight: 500; font-size: var(--step-0); margin: 0 0 12px; letter-spacing: .01em; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat__value { font-family: var(--f-mono); font-weight: 600; font-size: var(--step-2); line-height: 1.05; font-variant-numeric: tabular-nums; color: var(--ink); }
.stat__value small { font-size: .45em; color: var(--ink-2); margin-left: .25em; font-weight: 400; }
.stat__label { font-size: var(--step--1); color: var(--ink-2); line-height: 1.35; }

/* Live badge: <span class="live" data-state="live|loading|cached|error">Source name</span> */
.live {
  display: inline-flex; align-items: center; gap: 8px; font-family: var(--f-mono); font-size: 11px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2);
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: rgba(0,0,0,.3);
}
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.live[data-state="live"]::before { background: var(--lime); box-shadow: 0 0 0 0 var(--lime); animation: live-ping 1.6s infinite; }
.live[data-state="loading"]::before { background: var(--amber); animation: live-blink 0.8s infinite alternate; }
.live[data-state="cached"]::before { background: var(--amber); }
.live[data-state="error"]::before { background: var(--red); }
@keyframes live-ping { 0% { box-shadow: 0 0 0 0 rgba(166,255,106,.7); } 100% { box-shadow: 0 0 0 9px rgba(166,255,106,0); } }
@keyframes live-blink { to { opacity: .25; } }

.chip { display: inline-block; font-family: var(--f-mono); font-size: 11px; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); color: var(--ink-2); }

/* reveal on scroll: add data-reveal; core.js adds .is-in */
[data-reveal] { opacity: 0; transform: translateY(28px); transition: opacity .9s var(--ease-out), transform .9s var(--ease-out); }
[data-reveal].is-in { opacity: 1; transform: none; }
[data-reveal="fade"] { transform: none; }
[data-reveal="scale"] { transform: scale(.94); }

/* skeleton shimmer while loading */
.skeleton { position: relative; overflow: hidden; background: rgba(255,255,255,.04); border-radius: 8px; min-height: 1em; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- rail + chapters ---------- */
.rail { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 100; background: transparent; }
.rail__fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--amber)); box-shadow: 0 0 12px var(--magenta); }

.chapters { position: fixed; right: 18px; top: 50%; transform: translateY(-50%); z-index: 80; display: flex; flex-direction: column; gap: 14px; }
.chapters a { display: flex; align-items: center; justify-content: flex-end; gap: 10px; text-decoration: none; color: var(--ink-3); font-family: var(--f-mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
.chapters a span { opacity: 0; transform: translateX(6px); transition: .3s var(--ease-out); }
.chapters a i { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--ink-3); transition: .3s; }
.chapters a:hover span, .chapters a:focus-visible span { opacity: 1; transform: none; }
.chapters a span { background: rgba(4,5,10,.8); padding: 2px 6px; border-radius: 4px; }
/* the active label is always shown only where there is free space beside the content */
@media (min-width: 1500px) { .chapters a.is-active span { opacity: 1; transform: none; } }
.chapters a.is-active { color: var(--ink); }
.chapters a.is-active i { background: var(--accent-active, var(--cyan)); border-color: transparent; box-shadow: 0 0 10px var(--accent-active, var(--cyan)); }
@media (max-width: 760px) { .chapters { display: none; } }

/* ---------- link back to the hub page ---------- */
.home-link {
  position: fixed; top: 14px; left: 14px; z-index: 95; font-family: var(--f-mono); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-2); text-decoration: none; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(4,5,10,.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: color .2s, border-color .2s;
}
.home-link:hover, .home-link:focus-visible { color: var(--ink); border-color: var(--line-strong); }

/* ---------- HUD (content owned by hero.js) ---------- */
.hud { position: fixed; left: 50%; bottom: 16px; transform: translate(-50%, 140%); z-index: 85; transition: transform .6s var(--ease-out); max-width: calc(100vw - 32px); }
.hud.is-shown { transform: translate(-50%, 0); }

/* ---------- outro ---------- */
.sec--outro { --accent: var(--magenta); padding-bottom: 140px; }
.outro__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.outro__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: var(--step--1); color: var(--ink-2); }
.outro__list li { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--line); padding-bottom: 8px; }
.outro__list b { color: var(--ink); font-weight: 500; }
.outro__stamp { color: var(--ink-3); font-size: 12px; margin-top: 18px; }
.card p { color: var(--ink-2); margin: 0 0 12px; }
@media (max-width: 760px) { .outro__grid { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  [data-reveal] { opacity: 1; transform: none; }
}
