/* ---------- Scroll-driven video hero (home page) ---------- */
.hero {
  position: relative;
  height: 500vh; /* scroll length: more vh = slower playback */
}
.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}
.stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  transform: scale(var(--zoom, 1.08));
  will-change: transform;
}
.shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(8, 9, 10, 0.6) 0%, rgba(8, 9, 10, 0) 22%),
    linear-gradient(270deg, rgba(8, 9, 10, 0.6) 0%, rgba(8, 9, 10, 0) 24%),
    linear-gradient(90deg, rgba(8, 9, 10, 0.88) 0%, rgba(8, 9, 10, 0.5) 38%, rgba(8, 9, 10, 0) 68%),
    linear-gradient(0deg, rgba(10, 11, 12, 0.85) 0%, rgba(10, 11, 12, 0) 35%);
}
.stage .bp-grid {
  opacity: 0.07;
  mask-image: linear-gradient(90deg, #000 0%, transparent 60%);
  -webkit-mask-image: linear-gradient(90deg, #000 0%, transparent 60%);
}

/* animated corner brackets framing the shot like a viewfinder */
.frame { position: absolute; inset: calc(var(--nav-h) + 12px) var(--gutter) clamp(84px, 11vh, 120px); pointer-events: none; }
.frame i { position: absolute; width: 28px; height: 28px; border: 0 solid var(--accent); opacity: 0.85; }
.frame i:nth-child(1) { left: 0; top: 0; border-width: 2px 0 0 2px; }
.frame i:nth-child(2) { right: 0; top: 0; border-width: 2px 2px 0 0; }
.frame i:nth-child(3) { left: 0; bottom: 0; border-width: 0 0 2px 2px; }
.frame i:nth-child(4) { right: 0; bottom: 0; border-width: 0 2px 2px 0; }
.frame .rec {
  position: absolute; right: 40px; top: 2px;
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.frame .rec::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #ff4b3a; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* captions */
.captions {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: clamp(104px, 15vh, 160px);
  max-width: 720px;
}
.caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}
.caption.is-active { pointer-events: auto; }
.caption h1, .caption h2 {
  font-family: var(--display);
  font-weight: 700;
  text-transform: uppercase;
  font-size: clamp(48px, min(8.4vw, 12vh), 128px);
  line-height: 0.9;
  letter-spacing: -0.005em;
  margin: 20px 0 22px;
}
.caption h1 em, .caption h2 em { font-style: normal; color: var(--accent); }
.caption p {
  color: var(--muted);
  font-size: clamp(16px, 1.3vw, 19px);
  max-width: 48ch;
}
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; list-style: none; }
.tags li {
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 12px;
  border: 1px solid var(--faint);
  background: rgba(11, 12, 13, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.hstats {
  display: flex;
  gap: clamp(20px, 4vw, 48px);
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--faint);
}
.hstats b { display: block; font-family: var(--display); font-size: clamp(32px, 3vw, 44px); font-weight: 700; line-height: 1.1; }
.hstats span { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

/* reveal animation: headline lines slide up out of a mask, other parts fade in */
.line { display: block; overflow: hidden; padding-bottom: 0.06em; margin-bottom: -0.06em; }
.line > span {
  display: block;
  transform: translateY(120%);
  transition: transform 0.9s var(--ease-out);
  transition-delay: calc(var(--i) * 70ms);
}
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.8s var(--ease-out);
  transition-delay: calc(180ms + var(--i, 0) * 60ms);
}
.caption.is-active .line > span { transform: none; }
.caption.is-active .reveal { opacity: 1; transform: none; }
.caption.is-past .line > span { transform: translateY(-120%); transition-duration: 0.5s; transition-delay: 0s; }
.caption:not(.is-active) .line > span { transition-duration: 0.5s; transition-delay: 0s; }
.caption:not(.is-active) .reveal { transition-duration: 0.3s; transition-delay: 0s; }

/* chapter rail */
.rail {
  position: absolute;
  right: var(--gutter);
  top: 50%;
  transform: translateY(-50%);
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 2;
}
.rail button {
  all: unset;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 8px 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
  transition: color 0.3s;
}
.rail button .label { opacity: 0; transform: translateX(8px); transition: opacity 0.3s, transform 0.3s; }
.rail button .tick { width: 16px; height: 2px; background: currentColor; opacity: 0.5; transition: width 0.4s var(--ease-out), background 0.3s, opacity 0.3s; }
.rail button:hover .label, .rail button.is-active .label { opacity: 1; transform: none; }
.rail button.is-active { color: var(--ink); }
.rail button.is-active .tick { width: 40px; background: var(--accent); opacity: 1; }
.rail button:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }

/* bottom bar */
.hud {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: clamp(28px, 5vh, 48px);
  display: flex;
  align-items: center;
  gap: 20px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.hud .count b { color: var(--ink); font-weight: 500; }
.hud .track { flex: 1; height: 2px; background: var(--faint); position: relative; overflow: hidden; }
.hud .fill { position: absolute; inset: 0; background: var(--accent); transform-origin: left; transform: scaleX(0); }
.hud .hint { display: flex; align-items: center; gap: 10px; transition: opacity 0.4s; }
.hud .hint i {
  width: 18px;
  height: 28px;
  border: 1.5px solid var(--muted);
  border-radius: 10px;
  position: relative;
}
.hud .hint i::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 6px;
  width: 2px;
  height: 6px;
  margin-left: -1px;
  background: var(--accent);
  border-radius: 2px;
  animation: wheel 1.6s ease-in-out infinite;
}
@keyframes wheel {
  0% { transform: translateY(0); opacity: 1; }
  80% { transform: translateY(9px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}
.hero.is-scrolled .hint { opacity: 0; }

/* loader */
.loader {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  gap: 14px;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  transition: opacity 0.7s ease, visibility 0.7s;
}
.loader.is-done { opacity: 0; visibility: hidden; }
.loader img { width: min(320px, 70vw); margin-bottom: 18px; }
.loader .bar { width: min(320px, 70vw); height: 2px; background: var(--faint); }
.loader .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

/* short screens: keep the tallest chapter clear of the header */
@media (max-height: 760px) {
  .hstats { display: none; }
  .captions { bottom: 88px; }
  .tags { margin-top: 18px; }
  .frame { display: none; }
}

@media (max-width: 860px) {
  .shade {
    background:
      linear-gradient(180deg, rgba(8, 9, 10, 0.6) 0%, rgba(8, 9, 10, 0) 25%),
      linear-gradient(0deg, rgba(10, 11, 12, 0.96) 0%, rgba(8, 9, 10, 0.6) 48%, rgba(8, 9, 10, 0.1) 80%);
  }
  .stage .bp-grid, .rail, .frame { display: none; }
  .captions { bottom: 92px; }
  .caption p { font-size: 15px; }
  .tags li { font-size: 11px; padding: 6px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .line > span, .reveal { transition: opacity 0.3s; transform: none !important; }
  .caption:not(.is-active) .line > span { opacity: 0; }
  .caption.is-active .line > span { opacity: 1; }
  .stage video { transform: none; }
}
