/* ============ CAPTAIN — main.css ============ */
/* Palette: indigo shadows / cyan mid-lights / warm amber accents */
:root {
  --ink: #05060e;
  --ink-2: #0a0e1e;
  --indigo: #131b3a;
  --cyan: #7fd8ff;
  --cyan-hot: #46c8ff;
  --amber: #ffb45e;
  --text: #e8ecf6;
  --dim: #8a93ad;
  --line: rgba(127, 216, 255, 0.22);
  --grotesk: 'Space Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --fa: 'Vazirmatn', system-ui, sans-serif;
}

@font-face { font-family: 'Space Grotesk'; src: url('../fonts/space-grotesk-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Space Grotesk'; src: url('../fonts/space-grotesk-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Space Grotesk'; src: url('../fonts/space-grotesk-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../fonts/jetbrains-mono-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../fonts/jetbrains-mono-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/vazirmatn-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/vazirmatn-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { background: var(--ink); scrollbar-color: var(--indigo) var(--ink); }
html.no-scroll, html.no-scroll body { overflow: hidden; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--grotesk);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body.locked { overflow: hidden; height: 100vh; }
html[lang="fa"] body { font-family: var(--fa); }
html[lang="fa"] .ov-body, html[lang="fa"] .panel p, html[lang="fa"] .panel h3 { letter-spacing: 0; }

.mono { font-family: var(--mono); letter-spacing: 0.14em; }
button { background: none; border: none; color: inherit; cursor: pointer; font: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 1.5px solid var(--cyan); outline-offset: 3px; }

/* ============ PRELOADER ============ */
#preloader {
  position: fixed; inset: 0; z-index: 100;
  background: var(--ink);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 1.1s ease, filter 1.1s ease, visibility 1.1s;
}
#preloader.done { opacity: 0; visibility: hidden; pointer-events: none; }
@keyframes pre-pulse { 50% { opacity: 0.45; } }

/* name + tagline sit quietly in the top-left */
.pre-meta {
  position: absolute; top: clamp(24px, 4vh, 44px); inset-inline-start: clamp(22px, 4vw, 48px);
  display: flex; flex-direction: column; gap: 7px;
}
.pre-name { font-size: 11px; color: var(--text); letter-spacing: .34em; }
.pre-title { font-size: 9px; color: var(--dim); letter-spacing: .34em; }

/* rolling odometer — bottom-left, oversized, Lusion-style */
.odo {
  position: absolute; bottom: clamp(18px, 4vh, 46px); inset-inline-start: clamp(18px, 4vw, 44px);
  display: flex; align-items: flex-end;
  font-family: var(--grotesk); font-weight: 700;
  font-size: clamp(64px, 15vw, 190px); line-height: .82;
  color: var(--text); letter-spacing: -.03em;
}
.odo-col { display: block; height: 1em; overflow: hidden; }
.odo-strip {
  display: flex; flex-direction: column; will-change: transform;
}
.odo-strip { white-space: pre-wrap; word-break: break-all; width: .62em; }
.pre-line {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 1px; background: rgba(127,216,255,.12);
}
#pre-bar { display: block; width: 0%; height: 100%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan-hot); }

/* ============ CUSTOM CURSOR ============ */
html.has-cursor, html.has-cursor * { cursor: none !important; }
#cursor { position: fixed; inset: 0; z-index: 95; pointer-events: none; }
#cursor span { position: absolute; top: 0; left: 0; will-change: transform; }
.cur-dot {
  width: 4px; height: 4px; border-radius: 50%; background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-hot);
}
.cur-ring {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid rgba(127,216,255,.55);
  transition: border-color .3s ease, background .3s ease;
}
#cursor.on-target .cur-ring { border-color: var(--amber); background: rgba(255,180,94,.07); }
/* the slow trailing light that follows the pointer across the text zone */
.cur-glow {
  width: 340px; height: 340px; border-radius: 50%;
  background: radial-gradient(circle, rgba(127,216,255,.055), transparent 68%);
  mix-blend-mode: screen;
}

/* ============ HEADER ============ */
#hdr {
  position: fixed; z-index: 40; inset-block-start: 0; inset-inline: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px clamp(20px, 4vw, 48px);
  mix-blend-mode: screen;
  opacity: 0; transition: opacity .8s ease .3s;
}
body.ready #hdr { opacity: 1; }
#hdr-name { font-size: 12px; letter-spacing: .28em; color: var(--text); }
#hdr-name .hdr-full { color: var(--dim); }
.hdr-right { display: flex; align-items: center; gap: clamp(14px, 2.4vw, 30px); }
.hdr-right button { font-size: 10px; letter-spacing: .24em; color: var(--dim); display: inline-flex; align-items: center; gap: 7px; transition: color .3s; }
.hdr-right button:hover { color: var(--cyan); }
#sound-toggle[aria-pressed="true"] { color: var(--amber); }
#sound-toggle[aria-pressed="false"] .snd-waves { opacity: .25; }
/* fullscreen: show "expand" arrows normally, "collapse" while fullscreen */
#fs-toggle { padding: 2px; }
#fs-toggle .fs-out { display: none; }
#fs-toggle[aria-pressed="true"] { color: var(--amber); }
#fs-toggle[aria-pressed="true"] .fs-in { display: none; }
#fs-toggle[aria-pressed="true"] .fs-out { display: block; }

/* ============ NUMBERED INDEX RAIL ============ */
#rail {
  position: fixed; z-index: 40;
  inset-inline-end: clamp(16px, 2.6vw, 40px);
  top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 14px;
  opacity: 0; transition: opacity .8s ease .5s;
}
body.ready #rail { opacity: 1; }
.ri {
  position: relative; display: flex; align-items: center; gap: 9px;
  justify-content: flex-end; height: 16px;
  color: var(--dim); transition: color .35s ease;
}
.ri-num { font-size: 9px; letter-spacing: .18em; opacity: .55; transition: opacity .35s, color .35s; }
.ri-label {
  font-size: 8.5px; letter-spacing: .2em; color: var(--cyan); white-space: nowrap;
  max-width: 0; overflow: hidden; opacity: 0;
  transition: max-width .4s ease, opacity .3s ease;
}
.ri:hover .ri-label, .ri:focus-visible .ri-label { max-width: 160px; opacity: 1; }
.ri-tick {
  position: relative; width: 18px; height: 1px; background: rgba(127,216,255,.18);
  overflow: hidden; flex: none;
}
.ri-tick::after {
  content: ''; position: absolute; inset: 0; transform-origin: left center;
  transform: scaleX(0); background: var(--cyan); box-shadow: 0 0 8px var(--cyan-hot);
}
.ri.active { color: var(--cyan); }
.ri.active .ri-num { opacity: 1; color: var(--amber); }
.ri.active .ri-label { max-width: 160px; opacity: 1; }
.ri.active .ri-tick { height: 2px; }
.ri.active .ri-tick::after { transform: scaleX(var(--sp, 0)); }
.ri.loading .ri-num { animation: pre-pulse 1.2s ease-in-out infinite; }
.ri.flick { animation: ri-flick .5s steps(1) 1; }
@keyframes ri-flick { 0%,100%{opacity:1} 20%{opacity:.2} 40%{opacity:1} 60%{opacity:.35} 80%{opacity:1} }
html[lang="fa"] .ri-tick::after { transform-origin: right center; }

/* ============ STAGE / FILM ============ */
#stage { position: fixed; inset: 0; z-index: 1; overflow: hidden; }
#film { position: absolute; inset: 0; background: var(--ink); }
html.fa-mirror #film { transform: scaleX(-1); }
/* (the full-viewport blur from the removed carousel is gone — nothing filters
   the video any more, which is also why the background never flickers) */
#film video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 50%;
  display: none; pointer-events: none;
}
#film video.warm { display: block; }
#film video.top { z-index: 3; }
#vignette {
  position: absolute; inset: 0; z-index: 6; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(5,6,14,.55) 100%);
}
/* optional boundary pulse — OFF by default (re-enableable via tuning panel).
   No will-change: a permanent compositing layer here made the video re-render
   (brief blur/unblur) when scroll settled. */
#pulse {
  position: absolute; inset: 0; z-index: 7; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at 50% 50%, rgba(255,255,255,.85), rgba(127,216,255,.4) 42%, transparent 72%);
  mix-blend-mode: screen;
}
/* black hold while an out-scrolled clip finishes loading */
#hold {
  position: absolute; inset: 0; z-index: 8; pointer-events: none; opacity: 0;
  background: var(--ink);
}
/* ============ PHONE: give the film a band, not a keyhole ============ */
/* A 16:9 frame inside a 0.46-aspect phone viewport loses ~74% of its width to
   cover-cropping — the compositions (subject small in a wide room, empty third
   for text) simply stop reading. Constraining the film to a band roughly doubles
   the visible frame and gives the text its own ground underneath. */
@media (max-width: 560px) {
  #film { inset: 0 0 auto 0; height: 47vh; }
  #film video { height: 100%; }
  /* soften the bottom edge so the band doesn't read as a hard seam */
  #film::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 26%;
    background: linear-gradient(to bottom, transparent, var(--ink) 92%);
    pointer-events: none; z-index: 7;
  }
  #vignette { background: radial-gradient(ellipse at center, transparent 58%, rgba(5,6,14,.42) 100%); }
}

/* motion-graphics instruments — above film, below text */
#gfx {
  position: absolute; inset: 0; z-index: 8; pointer-events: none;
  width: 100%; height: 100%;
}
/* fiber streak canvas — above film, below text overlays */
#fiberfx {
  position: absolute; inset: 0; z-index: 9; pointer-events: none;
  width: 100%; height: 100%;
}

/* ============ TELEMETRY STRIP ============ */
#telemetry {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding: 9px clamp(18px, 3vw, 40px);
  font-size: 8.5px; letter-spacing: .2em; color: var(--dim);
  background: linear-gradient(transparent, rgba(5,6,14,.55));
  opacity: 0; transition: opacity .8s ease .6s; pointer-events: none;
  direction: ltr;
}
body.ready #telemetry { opacity: 1; }
body.no-telemetry #telemetry { display: none; }
.tm-b { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.tm-b i { font-style: normal; color: rgba(127,216,255,.5); }
.tm-b b { font-weight: 400; color: var(--cyan); }
@media (max-width: 820px) {
  #telemetry { font-size: 7.5px; gap: 10px; padding: 7px 14px; }
  #telemetry .tm-b:nth-child(3) { display: none; }
}

/* ============ TRACKS ============ */
#tracks { position: relative; z-index: 0; visibility: hidden; }
/* taller now that each section carries headline + detail before the film */
.track { height: 550vh; }
/* last 100vh so section 7 can complete its range (contact CTAs + hold) */
#tail { height: 100vh; }
body.reduced #tail { display: none; }

/* Reduced-motion / no-video fallback re-uses tracks as real content */
body.reduced #stage { display: none; }
body.reduced #tracks { visibility: visible; }
body.reduced .track {
  height: auto; min-height: 100vh;
  display: flex; align-items: center;
  background-size: cover; background-position: center;
  position: relative;
}
body.reduced .track::before { content: ''; position: absolute; inset: 0; background: rgba(5,6,14,.45); }
