/* =========================================================
   THE KEIGHLEY — styles
   Palette: near-black / bone-white / film-amber / brushed grey
   ========================================================= */

:root {
  --bg:        #0a0a0a;
  --bg-soft:   #111111;
  --ink:       #f4f1ea;       /* bone white */
  --ink-dim:   rgba(244,241,234,0.62);
  --ink-faint: rgba(244,241,234,0.32);
  --amber:     #e8a33d;       /* film amber */
  --amber-dim: rgba(232,163,61,0.18);
  --metal:     #9a9a9a;
  --line:      rgba(244,241,234,0.14);

  --display: "Anton", "Arial Narrow", sans-serif;
  --sans:    "Inter", system-ui, -apple-system, sans-serif;

  --maxw: 1320px;
  --side-pad: clamp(20px, 6vw, 96px);
}

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

html { scroll-behavior: auto; } /* JS controls smoothing; no instant jumps */

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  /* subtle vignette over the whole page */
  background-image:
    radial-gradient(120% 80% at 50% 40%, transparent 40%, rgba(0,0,0,0.65) 100%);
}

/* The fixed 3D canvas behind everything */
.scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
  pointer-events: none; /* hover handled by raycaster on window, see main.js */
}

/* Leader-line SVG sits above canvas but below text */
.leaders {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  pointer-events: none;
}
.leaders line {
  stroke: var(--amber);
  stroke-width: 1;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.leaders.is-active line { opacity: 0.55; }

/* 3D-tracked labels for the exploded view */
.labels {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2;
  pointer-events: none;
}
.label {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.45s ease;
  padding: 4px 8px;
}
.label b {
  display: block;
  font-weight: 600;
  color: var(--amber);
  font-size: 13px;
  letter-spacing: 0.08em;
}
.label span {
  display: block;
  color: var(--ink-dim);
  font-weight: 300;
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: none;
  max-width: 220px;
  white-space: normal;
  margin-top: 3px;
}
.label.is-active { opacity: 1; }
.label.is-hot b { color: #ffce7a; }

/* Scroll progress */
.progress {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 2px;
  background: rgba(255,255,255,0.04);
  z-index: 30;
}
.progress__bar {
  height: 100%;
  width: 0%;
  background: var(--amber);
  transform-origin: left;
}

/* Wordmark */
.wordmark {
  position: fixed;
  top: clamp(14px, 2vw, 26px);
  left: var(--side-pad);
  z-index: 20;
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0.28em;
  color: var(--ink-dim);
}

/* ---------------- Scroll structure ---------------- */
#scroll-root {
  position: relative;
  z-index: 5;
}
.section {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  padding: 0 var(--side-pad);
}
.section--tall { min-height: 320vh; }       /* room for the exploded scrub */
.section--odyssey { min-height: 130vh; }
.section--closer  { min-height: 110vh; }

/* Panels (text columns) */
.panel {
  position: relative;
  max-width: 540px;
  background: linear-gradient(180deg, rgba(10,10,10,0.42), rgba(10,10,10,0.72));
  backdrop-filter: blur(2px);
  padding: 38px 34px;
  border-left: 1px solid var(--line);
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(.2,.7,.2,1);
}
.panel.is-in { opacity: 1; transform: none; }

.panel--hero {
  max-width: 720px;
  border-left: none;
  background: none;
  backdrop-filter: none;
  padding: 0;
  text-align: left;
}
.panel--center {
  margin: 0 auto;
  text-align: center;
  border-left: none;
  background: none;
  backdrop-filter: none;
  padding: 0;
}
.panel--left  { margin-right: auto; }
.panel--right { margin-left: auto; }
.panel--intro { max-width: 640px; }
.panel--outro { max-width: 680px; padding-bottom: 6vh; }

/* Hero */
.section--hero {
  align-items: center;
}
.display {
  font-family: var(--display);
  font-size: clamp(56px, 15vw, 220px);
  line-height: 0.86;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: var(--ink);
}
.display--end {
  margin-top: 0.5em;
  font-size: clamp(48px, 12vw, 180px);
}
.lede {
  margin-top: 22px;
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 300;
  color: var(--ink-dim);
  max-width: 460px;
}

.scrollcue {
  margin-top: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.scrollcue__line {
  display: block;
  width: 54px;
  height: 1px;
  background: var(--ink-faint);
  position: relative;
  overflow: hidden;
}
.scrollcue__line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--amber);
  transform: translateX(-100%);
  animation: cue 2.4s ease-in-out infinite;
}
@keyframes cue {
  0%   { transform: translateX(-100%); }
  60%  { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}

/* Section copy */
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 22px;
}
.headline {
  font-family: var(--display);
  font-size: clamp(44px, 8vw, 120px);
  line-height: 0.9;
  letter-spacing: -0.005em;
  text-transform: uppercase;
  margin-bottom: 26px;
}
.body {
  font-size: clamp(15px, 1.3vw, 18px);
  font-weight: 300;
  color: var(--ink-dim);
  margin-bottom: 18px;
  max-width: 46ch;
}
.body strong { color: var(--ink); font-weight: 500; }
.body.accent { color: var(--amber); }
.body.quiet  { color: var(--ink-faint); font-size: 14px; }

/* Pull-quote */
.pullquote {
  margin: 30px 0;
  padding-left: 18px;
  border-left: 2px solid var(--amber);
}
.pullquote p {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.005em;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.18;
  text-transform: none;
  color: var(--ink);
}
.pullquote cite {
  display: block;
  margin-top: 12px;
  font-style: normal;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* Stats */
.stats {
  list-style: none;
  margin-top: 40px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.stats li { min-width: 0; }
.stat__num {
  display: block;
  font-family: var(--display);
  font-size: clamp(28px, 4vw, 52px);
  line-height: 1;
  color: var(--amber);
}
.stat__label {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.stat__label small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--ink-faint);
  line-height: 1.4;
}

/* Inline readout (blimp weight) */
.readout--inline {
  margin-top: 26px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.readout__row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.readout__row b { color: var(--amber); font-weight: 500; }

/* Footer */
.footnote {
  position: relative;
  z-index: 5;
  padding: 40px var(--side-pad) 60px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
}

/* WebGL fallback */
.webgl-fallback {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8vw;
}
.webgl-fallback__inner { max-width: 520px; text-align: center; }
.webgl-fallback h2 {
  font-family: var(--display);
  font-size: clamp(32px, 6vw, 64px);
  letter-spacing: -0.01em;
  margin-bottom: 18px;
}
.webgl-fallback p { color: var(--ink-dim); margin-bottom: 14px; }
.webgl-fallback__small { color: var(--ink-faint); font-size: 12px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 760px) {
  :root { --side-pad: 22px; }
  .section { align-items: flex-end; padding-bottom: 14vh; }
  .section--hero { align-items: center; padding-bottom: 0; }
  .panel { padding: 26px 22px; max-width: 100%; }
  .panel--left, .panel--right { margin: 0; }
  .panel--hero { text-align: left; }
  /* Stack stats vertically on mobile */
  .stats { grid-template-columns: 1fr; gap: 22px; }
  .stats li { display: flex; align-items: baseline; gap: 14px; }
  .stat__num { min-width: 90px; }
  .pullquote p { font-size: clamp(20px, 6vw, 28px); }
  /* Exploded section shorter on mobile (parts stack handled in JS) */
  .section--tall { min-height: 260vh; }
  .wordmark { font-size: 11px; letter-spacing: 0.2em; }
}

/* ---------------- Reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  .panel { transition-duration: 0.001s; }
  .scrollcue__line::after { animation: none; }
  .label, .leaders line { transition-duration: 0.001s; }
  html { scroll-behavior: auto; }
}

.webgl-fallback[hidden] { display: none; }
