/* The Keighley — design system
   near-black #0a0a0a · bone white #f4f1ea · film-amber #e8a33d */

:root {
  --black: #0a0a0a;
  --bone: #f4f1ea;
  --bone-dim: rgba(244, 241, 234, 0.62);
  --bone-faint: rgba(244, 241, 234, 0.34);
  --amber: #e8a33d;
  --amber-dim: rgba(232, 163, 61, 0.55);
  --display: 'Oswald', 'Arial Narrow', sans-serif;
  --body: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: auto; }

body {
  margin: 0;
  background: var(--black);
  color: var(--bone);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

/* ---------- fallback ---------- */
#fallback {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--black);
  padding: 2rem;
  text-align: center;
}
#fallback[hidden] { display: none; }
#fallback h1 {
  font-family: var(--display);
  font-size: clamp(2.5rem, 8vw, 5rem);
  letter-spacing: 0.02em;
  margin: 0 0 1rem;
}
#fallback p { color: var(--bone-dim); max-width: 34rem; margin: 0 auto; }

/* ---------- scroll layout ---------- */
#scroll { position: relative; z-index: 2; pointer-events: none; }

.panel { position: relative; }

#s-hero      { height: 130vh; }
#s-format    { height: 220vh; }
#s-exploded  { height: 340vh; }
#s-blimp     { height: 190vh; }
#s-periscope { height: 190vh; }
#s-makingof  { height: 200vh; }
#s-finale    { height: 300vh; }
#s-end       { height: 150vh; }

/* copy is pinned to the viewport while its section is active (.on) —
   sticky inside tall panels scrolls out of range before the section ends */
.copy {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 7vw;
  max-width: 46rem;
}

.copy-left { align-items: flex-start; }
.copy-top { justify-content: flex-start; padding-top: 8vh; min-height: 60vh; }
.copy-wide { max-width: 62rem; }

.copy-hero {
  max-width: none;
  justify-content: flex-end;
  padding-bottom: 10vh;
}

h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(4rem, 12vw, 11rem);
  line-height: 0.92;
  letter-spacing: -0.01em;
  margin: 0;
  text-transform: uppercase;
}

.sub {
  font-size: clamp(1.05rem, 2.2vw, 1.5rem);
  color: var(--bone-dim);
  margin: 1.4rem 0 0;
  max-width: 30rem;
}

.scroll-hint {
  margin-top: 9vh;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--bone-faint);
}

.kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0 0 1.2rem;
}

.body-copy {
  font-size: clamp(1.15rem, 2.4vw, 1.7rem);
  line-height: 1.5;
  font-weight: 500;
  margin: 0;
  max-width: 40rem;
}
.body-copy.small {
  font-size: clamp(0.95rem, 1.6vw, 1.15rem);
  color: var(--bone-dim);
  max-width: 26rem;
}

.pullquote {
  margin: 2.2rem 0 0;
  padding-left: 1.6rem;
  border-left: 2px solid var(--amber);
}
.pullquote p {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.4rem, 2.8vw, 2.1rem);
  line-height: 1.2;
  margin: 0;
  max-width: 44rem;
}
.pullquote cite {
  display: block;
  font-style: normal;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin-top: 1rem;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 3rem;
  margin-top: 2.6rem;
}
.stat { display: flex; flex-direction: column; }
.stat-num {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(2rem, 4.2vw, 3.2rem);
  line-height: 1;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin-top: 0.7rem;
  max-width: 12rem;
}

/* copy visibility is driven from JS via .on */
.copy, .endcard {
  opacity: 0;
  transition: opacity 0.45s ease;
}
.copy.on, .endcard.on { opacity: 1; }

/* ---------- end card ---------- */
#s-end { display: flex; align-items: center; justify-content: center; }
.endcard {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 6vw;
}
.endcard h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(3rem, 11vw, 9rem);
  margin: 0;
  letter-spacing: 0.01em;
}
.memorial {
  color: var(--bone-dim);
  font-size: clamp(0.95rem, 1.8vw, 1.2rem);
  max-width: 32rem;
  margin: 1.6rem 0 0;
}

/* ---------- film strip progress ---------- */
#filmstrip {
  position: fixed;
  left: 1.4rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  pointer-events: none;
}
.strip-track {
  position: relative;
  width: 14px;
  height: 42vh;
  border-left: 1px solid rgba(244, 241, 234, 0.16);
  border-right: 1px solid rgba(244, 241, 234, 0.16);
  /* perforation holes */
  background-image:
    radial-gradient(circle 1.6px at 4px 6px, rgba(244, 241, 234, 0.4) 98%, transparent),
    radial-gradient(circle 1.6px at 10px 6px, rgba(244, 241, 234, 0.4) 98%, transparent);
  background-size: 14px 13px;
  background-repeat: repeat-y;
}
.strip-fill {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 0%;
  background: linear-gradient(var(--amber), var(--amber));
  opacity: 0.28;
}
.strip-marker {
  position: absolute;
  left: -4px;
  width: 20px;
  height: 2px;
  background: var(--amber);
  top: 0%;
  box-shadow: 0 0 8px var(--amber-dim);
}
.strip-caption {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  color: var(--bone-faint);
  writing-mode: vertical-rl;
}

/* ---------- leader lines + part labels ---------- */
#leaders {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
}
#leaders line {
  stroke: var(--amber);
  stroke-width: 1;
  opacity: 0.85;
}
#leaders circle { fill: var(--amber); }

#part-labels {
  position: fixed;
  inset: 0;
  z-index: 11;
  pointer-events: none;
}
.part-label {
  position: absolute;
  transform: translateY(-50%);
  border-left: 2px solid var(--amber);
  padding: 0.15rem 0 0.15rem 0.7rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  max-width: 15rem;
}
.part-label.visible { opacity: 1; }
.part-label.emph .pl-name { color: var(--amber); }
.pl-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  transition: color 0.2s ease;
}
.pl-spec {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  color: var(--bone-dim);
  display: block;
  margin-top: 0.2rem;
  line-height: 1.5;
}

/* ---------- finale UI ---------- */
#finale-ui {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
#finale-ui.on { opacity: 1; }

.reticle { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.reticle-ring {
  width: 76px; height: 76px;
  border: 1px solid rgba(244, 241, 234, 0.35);
  border-radius: 50%;
}
.reticle-cross-h, .reticle-cross-v {
  position: absolute;
  background: rgba(244, 241, 234, 0.35);
}
.reticle-cross-h { width: 120px; height: 1px; left: -22px; top: 38px; }
.reticle-cross-v { width: 1px; height: 120px; left: 38px; top: -22px; }

.level {
  position: absolute;
  left: 50%;
  bottom: 18vh;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.level-line {
  width: 90px;
  height: 1px;
  background: var(--amber-dim);
  transform-origin: center;
}
.level-readout {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--bone-dim);
  min-width: 3.4rem;
}

.frame-mask { position: absolute; inset: 0; }
.frame-rect {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  border: 1px solid var(--amber-dim);
  box-shadow: 0 0 0 4000px rgba(10, 10, 10, 0.0);
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1),
              height 0.45s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.45s ease;
}
.frame-rect.cropped { box-shadow: 0 0 0 4000px rgba(10, 10, 10, 0.62); }
.frame-tag {
  position: absolute;
  bottom: -1.5rem;
  left: 0;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  color: var(--amber);
  white-space: nowrap;
}

.controls {
  position: absolute;
  left: 50%;
  bottom: max(2rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 2.2rem;
  pointer-events: auto;
  background: rgba(10, 10, 10, 0.72);
  border: 1px solid rgba(244, 241, 234, 0.12);
  padding: 0.9rem 1.4rem;
}
.ctl { display: flex; flex-direction: column; gap: 0.45rem; }
.ctl label {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--bone-dim);
}
.ctl-hint {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--bone-faint);
}

#focus-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 180px;
  height: 2px;
  background: rgba(244, 241, 234, 0.25);
  outline: none;
}
#focus-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--amber);
  cursor: pointer;
}
#focus-slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--amber);
  cursor: pointer;
}

.ctl-format { flex-direction: row; gap: 0; border: 1px solid rgba(244, 241, 234, 0.2); }
.fmt-btn {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: transparent;
  color: var(--bone-dim);
  border: none;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
}
.fmt-btn.active { background: var(--amber); color: var(--black); }

.ctl-run { flex-direction: row; gap: 0.6rem; align-items: center; }
#rec-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  background: transparent;
  color: var(--bone);
  border: 1px solid rgba(244, 241, 234, 0.25);
  padding: 0.55rem 1rem;
  cursor: pointer;
}
#rec-btn .rec-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: rgba(244, 241, 234, 0.3);
}
#rec-btn.rolling { border-color: #d83a2e; color: #ff6b5e; }
#rec-btn.rolling .rec-dot { background: #d83a2e; box-shadow: 0 0 10px #d83a2e; }
#mute-btn {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: transparent;
  color: var(--bone-dim);
  border: 1px solid rgba(244, 241, 234, 0.18);
  padding: 0.55rem 0.8rem;
  cursor: pointer;
}
.drag-hint {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--bone-faint);
  margin: 0;
}

/* scene fade used around the end card */
#vignette-fade {
  position: fixed;
  inset: 0;
  z-index: 1; /* below #scroll so the end card stays readable */
  background: var(--black);
  opacity: 0;
  pointer-events: none;
}

/* ---------- responsive ---------- */
@media (max-width: 768px) {
  .copy { padding: 0 8vw; }
  .copy-top { padding-top: 10vh; }
  #filmstrip { left: 0.7rem; }
  .strip-track { height: 34vh; }

  .part-label { max-width: 10.5rem; }
  .pl-name { font-size: 0.8rem; }
  .pl-spec { font-size: 0.58rem; }

  .controls {
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem 1.4rem;
    width: calc(100vw - 2rem);
    padding: 0.8rem 1rem;
  }
  #focus-slider { width: 140px; }
  .drag-hint { display: none; }
  .stats { gap: 2rem; }
  .level { bottom: 38vh; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .copy, .endcard, .part-label, .frame-rect, #finale-ui { transition: none; }
}

/* shot-mode (?shot=...) hides every DOM overlay */
body.shot-mode #scroll,
body.shot-mode #filmstrip,
body.shot-mode #finale-ui,
body.shot-mode #part-labels,
body.shot-mode #leaders,
body.shot-mode #vignette-fade { display: none; }
