/* ============ THE KEIGHLEY — design system ============ */
:root {
  --ink: #0a0a0a;
  --bone: #f4f1ea;
  --amber: #e8a33d;
  --grey: #8d8a84;
  --display: "Archivo", "Arial Narrow", sans-serif;
  --body: "Inter", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

html { background: var(--ink); }
html, body { overscroll-behavior-y: none; }

body {
  -webkit-user-select: none;
  user-select: none;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

/* ---------- canvas + scroll track ---------- */
#gl {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  z-index: 0;
  touch-action: pan-y;
}
#gl.grabbing { cursor: grabbing; }
#gl.interactive { cursor: grab; touch-action: none; }

#track { height: 1750vh; position: relative; z-index: -1; pointer-events: none; }
body.reduced #track { height: 0; }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 60;
  background: var(--ink);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .8s ease .15s; opacity: 1;
}
#loader.done { opacity: 0; pointer-events: none; }
.loader-mark { text-align: center; }
.loader-film {
  width: 180px; height: 26px; margin: 0 auto 14px;
  border: 1px solid #2c2a26; position: relative; overflow: hidden;
  background:
    repeating-linear-gradient(90deg, transparent 0 8px, #1b1916 8px 10px, transparent 10px 12px) 0 0 / 12px 4px repeat-x,
    repeating-linear-gradient(90deg, transparent 0 8px, #1b1916 8px 10px, transparent 10px 12px) 0 100% / 12px 4px repeat-x;
  background-repeat: repeat-x;
}
.loader-film span {
  position: absolute; top: 4px; bottom: 4px; left: 0; width: 0%;
  background: linear-gradient(90deg, rgba(232,163,61,.25), var(--amber));
  transition: width .2s ease;
}
.loader-text {
  font-family: var(--mono); font-size: 10px; letter-spacing: .35em;
  color: var(--grey);
}

/* ---------- fallback ---------- */
#fallback {
  position: fixed; inset: 0; z-index: 70; background: var(--ink);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#fallback[hidden] { display: none; }
.fallback-inner { max-width: 560px; }
.fallback-inner h1 { font-family: var(--display); font-stretch: 66%; font-weight: 800; font-size: 64px; margin-bottom: 18px; }
.fallback-inner p { color: var(--grey); }

/* ---------- film rail (scroll progress) ---------- */
#film-rail {
  position: fixed; top: 0; right: 14px; bottom: 0; width: 14px; z-index: 40;
  pointer-events: none;
}
.rail-strip {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(180deg, transparent 0 5px, #24211d 5px 9px, transparent 9px 14px) 0 0 / 3px 14px repeat-y,
    repeating-linear-gradient(180deg, transparent 0 5px, #24211d 5px 9px, transparent 9px 14px) 100% 0 / 3px 14px repeat-y,
    linear-gradient(180deg, #14120f, #14120f);
  background-repeat: repeat-y;
  opacity: .9;
}
.rail-cursor {
  position: absolute; left: 0; right: 0; top: 0; height: 34px;
  background: linear-gradient(180deg, rgba(232,163,61,.0), rgba(232,163,61,.85) 30%, rgba(232,163,61,.85) 70%, rgba(232,163,61,0));
  box-shadow: 0 0 12px rgba(232,163,61,.35);
  mix-blend-mode: screen;
}

/* ---------- leader lines svg ---------- */
#leaders {
  position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 20;
  pointer-events: none;
}
#leaders line { stroke: var(--amber); stroke-width: 1; opacity: 0; }
#leaders circle { fill: var(--amber); opacity: 0; }

/* ---------- overlay panels ---------- */
#overlay { position: fixed; inset: 0; z-index: 25; pointer-events: none; }
.panel {
  position: absolute; inset: 0; display: flex; align-items: center;
  opacity: 0; visibility: hidden;
  padding: 0 7vw;
}
.panel.on { opacity: 1; visibility: visible; }

.kicker {
  font-family: var(--mono); font-size: 11px; letter-spacing: .38em;
  color: var(--amber); margin-bottom: 18px;
}
.display {
  font-family: var(--display); font-stretch: 63%; font-weight: 800;
  font-size: clamp(64px, 13.5vw, 176px); line-height: .88; letter-spacing: .005em;
}
.display-2 {
  font-family: var(--display); font-stretch: 63%; font-weight: 800;
  font-size: clamp(40px, 5.6vw, 84px); line-height: .92;
  margin-bottom: 22px;
}
.body {
  color: #c9c5bc; max-width: 430px; font-size: 15.5px;
}
.body.wide { max-width: 560px; }

.hero-block { max-width: 900px; }
.hero-block .sub {
  margin-top: 26px; color: #c9c5bc; font-size: clamp(15px, 1.6vw, 19px);
  max-width: 420px;
}
.scroll-hint {
  margin-top: 7vh; font-family: var(--mono); font-size: 10px;
  letter-spacing: .4em; color: var(--grey); display: flex; align-items: center; gap: 14px;
}
.hint-line { display: inline-block; width: 1px; height: 44px; background: linear-gradient(180deg, var(--amber), transparent); animation: hint 2s ease-in-out infinite; }
@keyframes hint { 0%,100% { transform: scaleY(.4); opacity:.4 } 50% { transform: scaleY(1); opacity:1 } }

.copy-block { max-width: 520px; }
.copy-block.right { margin-left: auto; }
.copy-block.top-left { align-self: flex-start; margin-top: 12vh; }
.copy-block.slim .body { max-width: 380px; }

.spec-row { display: flex; gap: 40px; margin-top: 34px; flex-wrap: wrap; }
.spec-num {
  display: block; font-family: var(--display); font-stretch: 66%;
  font-weight: 700; font-size: 38px; line-height: 1; color: var(--bone);
}
.spec-label {
  display: block; margin-top: 6px; font-family: var(--mono);
  font-size: 10px; letter-spacing: .18em; color: var(--grey); text-transform: uppercase;
}

/* making-of */
.making-block { max-width: 860px; margin: 0 auto; text-align: center; }
.making-block .body { margin: 0 auto; }
.quote {
  font-family: var(--display); font-stretch: 72%; font-weight: 600;
  font-size: clamp(26px, 3.6vw, 48px); line-height: 1.12;
  margin: 5vh auto 6vh; max-width: 780px; color: var(--bone);
}
.quote cite {
  display: block; margin-top: 18px; font-family: var(--mono); font-style: normal;
  font-size: 11px; letter-spacing: .3em; color: var(--amber);
}
.stat-row { display: flex; justify-content: center; gap: 7vw; flex-wrap: wrap; }
.stat-num {
  display: block; font-family: var(--display); font-stretch: 63%; font-weight: 800;
  font-size: clamp(40px, 5.5vw, 76px); line-height: 1; color: var(--amber);
  font-variant-numeric: tabular-nums;
}
.stat-label { display: block; margin-top: 8px; font-family: var(--mono); font-size: 10px; letter-spacing: .2em; color: var(--grey); text-transform: uppercase; }

/* end card */
#p-end { justify-content: center; text-align: center; }
.end-block .display { font-size: clamp(64px, 11vw, 150px); }
.memorial {
  margin-top: 4vh; color: var(--grey); font-size: 14px; max-width: 420px;
  margin-left: auto; margin-right: auto;
}

/* ---------- exploded part labels ---------- */
#labels { position: fixed; inset: 0; z-index: 22; pointer-events: none; }
.part-label {
  position: absolute; transform: translate(-0%, -50%);
  opacity: 0; transition: opacity .25s ease;
  max-width: 250px; pointer-events: none;
}
.part-label.show { opacity: 1; }
.part-label .pl-name {
  font-family: var(--display); font-stretch: 70%; font-weight: 700;
  font-size: 17px; letter-spacing: .04em; text-transform: uppercase; color: var(--bone);
}
.part-label .pl-spec {
  font-family: var(--mono); font-size: 10.5px; line-height: 1.6;
  color: var(--grey); letter-spacing: .04em; margin-top: 4px;
}
.part-label.hot .pl-name { color: var(--amber); }
.part-label.hot .pl-spec { color: #b9b4a9; }

/* ---------- operator UI (finale) ---------- */
#operator { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
#operator[hidden] { display: none; }

#viewfinder {
  position: absolute; top: 20px; left: 34px;
  width: min(340px, 34vw);
  opacity: 0; transition: opacity .5s ease;
}
#operator.live #viewfinder { opacity: 1; }
.vf-frame {
  position: relative; aspect-ratio: 1.43 / 1;
  border: 1px solid rgba(244,241,234,.4);
  box-shadow: 0 0 0 1px rgba(10,10,10,.6), 0 12px 40px rgba(0,0,0,.5);
  overflow: hidden;
}
.vf-mask { position: absolute; background: rgba(4,4,4,.78); z-index: 2; transition: all .45s cubic-bezier(.6,0,.2,1); }
.vf-mask-l { left: 0; top: 0; bottom: 0; width: 0; }
.vf-mask-r { right: 0; top: 0; bottom: 0; width: 0; }
.vf-mask-t { top: 0; left: 0; right: 0; height: 0; }
.vf-mask-b { bottom: 0; left: 0; right: 0; height: 0; }
#viewfinder.fmt-std .vf-mask-t { height: 29.1%; }
#viewfinder.fmt-std .vf-mask-b { height: 29.1%; }
.vf-reticle { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.vf-reticle span { position: absolute; background: rgba(244,241,234,.55); }
.vf-reticle span:first-child { left: 50%; top: 46%; width: 1px; height: 8%; }
.vf-reticle span:last-child { top: 50%; left: 46.5%; height: 1px; width: 7%; }
.vf-level {
  position: absolute; bottom: 9%; left: 50%; transform: translateX(-50%);
  width: 34%; height: 4px; border: 1px solid rgba(244,241,234,.3); z-index: 3;
}
.vf-bubble {
  position: absolute; top: 0; bottom: 0; width: 22%; left: 39%;
  background: var(--amber); opacity: .8; transition: left .1s linear;
}
.vf-info {
  position: absolute; left: 0; right: 0; bottom: -26px;
  display: flex; justify-content: space-between; gap: 8px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em; color: var(--grey);
}
.vf-rec { color: #ff4b3a; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .15; } }

#controls {
  position: absolute; left: 50%; bottom: 34px; transform: translate(-50%, 20px);
  display: flex; align-items: flex-end; gap: 34px;
  pointer-events: auto; opacity: 0; transition: opacity .5s ease, transform .5s ease;
  background: rgba(10,10,10,.55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid #23211d;
  padding: 16px 26px 18px;
}
#operator.live #controls { opacity: 1; transform: translate(-50%, 0); }
.ctl label {
  display: block; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: .3em; color: var(--grey); margin-bottom: 10px;
}
.ctl-focus { width: min(300px, 38vw); }
#focus-slider {
  width: 100%; appearance: none; -webkit-appearance: none; height: 2px;
  background: linear-gradient(90deg, #3a372f, #3a372f); outline: none;
}
#focus-slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 16px; height: 26px;
  background: var(--bone); border: none; cursor: ew-resize;
  clip-path: polygon(0 20%, 100% 20%, 100% 80%, 0 80%);
  box-shadow: inset 3px 0 0 var(--amber);
}
#focus-slider::-moz-range-thumb {
  width: 14px; height: 22px; background: var(--bone); border: none; cursor: ew-resize;
}
.focus-marks { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 9px; color: #58554e; margin-top: 6px; }

#format-toggle {
  display: flex; border: 1px solid #34312b; background: #111009;
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
  cursor: pointer; padding: 0; color: var(--grey);
}
#format-toggle .fmt { padding: 9px 14px; transition: all .25s ease; }
#format-toggle .fmt.on { background: var(--amber); color: var(--ink); font-weight: 500; }

#roll-btn {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .28em;
  color: var(--bone); background: #16140f; border: 1px solid #3a372f;
  padding: 12px 22px; cursor: pointer; transition: all .2s ease;
}
#roll-btn:hover { border-color: var(--amber); }
#roll-btn .roll-dot { width: 10px; height: 10px; border-radius: 50%; background: #58221c; transition: all .2s ease; }
#roll-btn.rec { border-color: #ff4b3a; color: #ff4b3a; }
#roll-btn.rec .roll-dot { background: #ff4b3a; box-shadow: 0 0 12px rgba(255,75,58,.8); animation: blink 1s steps(2) infinite; }

#op-hint {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  font-family: var(--mono); font-size: 9px; letter-spacing: .18em; color: #4c4943;
  white-space: nowrap; opacity: 0; transition: opacity .5s ease 1.2s;
}
#operator.live #op-hint { opacity: 1; }

/* ---------- sound toggle ---------- */
#sound-toggle {
  position: fixed; left: 22px; bottom: 20px; z-index: 45;
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  background: rgba(10,10,10,.5); border: 1px solid #23211d; color: var(--grey);
  cursor: pointer; transition: color .2s ease, border-color .2s ease;
}
#sound-toggle:hover { color: var(--bone); border-color: #3a372f; }
#sound-toggle .wave { display: none; }
#sound-toggle.on .wave { display: block; }
#sound-toggle.on .mute { display: none; }
#sound-toggle.on { color: var(--amber); }

/* ---------- reduced motion: static article ---------- */
body.reduced #overlay { position: static; pointer-events: auto; }
body.reduced .panel {
  position: relative; opacity: 1; visibility: visible; min-height: 60vh;
  padding: 12vh 7vw;
}
body.reduced #gl { position: fixed; }
body.reduced #film-rail, body.reduced #labels, body.reduced #leaders { display: none; }
body.reduced .copy-block.right { margin-left: 0; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .panel { padding: 0 6vw; align-items: flex-end; }
  .panel .copy-block, .panel .hero-block { margin-bottom: 9vh; }
  .copy-block.top-left { align-self: flex-end; margin-top: 0; }
  #p-hero { align-items: center; }
  .hero-block { margin-bottom: 0; }
  .body { font-size: 14px; max-width: 100%; }
  .spec-row { gap: 24px; margin-top: 22px; }
  .spec-num { font-size: 28px; }
  #film-rail { right: 4px; width: 10px; }
  #viewfinder { top: 12px; right: 12px; left: 12px; width: auto; max-width: 300px; margin-right: auto; }
  #controls {
    left: 12px; right: 12px; transform: translate(0, 20px); bottom: 20px;
    width: auto; flex-wrap: wrap; gap: 16px; padding: 14px 16px; justify-content: space-between;
  }
  #operator.live #controls { transform: translate(0, 0); }
  .ctl-focus { width: 100%; order: 3; }
  #op-hint { display: none; }
  .part-label { max-width: 170px; }
  .part-label .pl-name { font-size: 14px; }
  .part-label .pl-spec { font-size: 9.5px; }
  #sound-toggle { left: auto; right: 12px; top: 12px; bottom: auto; width: 34px; height: 34px; }
}
