/* ═══════════════════════════════════════════════════════════════════
   BUILD STORY — cinematic construction timeline overlay
   Loaded by index.html. Sits above the lightbox (z 2100 > 2000).
   ═══════════════════════════════════════════════════════════════════ */

.story {
  position: fixed; inset: 0;
  z-index: 2100;
  display: none;
  background: #050d16;
  color: #f6f8fb;
  overflow: hidden;
  opacity: 0;
  transition: opacity .45s ease;
  font-family: "Manrope", ui-sans-serif, system-ui, sans-serif;
}
.story.is-open { display: block; opacity: 1; }
body.has-story { overflow: hidden; }

/* ── Media layers: two <img> for crossfade + one <video> ─────────── */
.story__media { position: absolute; inset: 0; background: #050d16; }
.story__img,
.story__video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 40%;
  opacity: 0;
  transition: opacity 1.1s ease;
  will-change: transform, opacity;
  background: #050d16;
}
.story__img.is-active,
.story__video.is-active { opacity: 1; }
/* Ken Burns lives on .is-ken (NOT .is-active) so the outgoing frame keeps its
   drift while it fades out instead of snapping back to un-zoomed. */
.story__img.is-ken { animation: storyKen var(--story-ken, 8.5s) linear forwards; }
.story__img.is-ken.is-alt { animation-name: storyKenAlt; }
@keyframes storyKen {
  from { transform: scale(1.02) translate(0, 0); }
  to   { transform: scale(1.15) translate(-1.6%, -1.1%); }
}
@keyframes storyKenAlt {
  from { transform: scale(1.14) translate(1.4%, 1%); }
  to   { transform: scale(1.02) translate(0, 0); }
}
.story.is-paused .story__img.is-ken { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  .story__img.is-ken { animation: none; transform: scale(1.04); }
}

/* ── Legibility gradients ─────────────────────────────────────────── */
.story__vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(5,13,22,.6) 0%, rgba(5,13,22,0) 26%, rgba(5,13,22,0) 52%, rgba(5,13,22,.88) 100%),
    radial-gradient(ellipse at center, transparent 40%, rgba(5,13,22,.5) 100%);
}

/* ── Blueprint grid — bursts outward from centre on each phase ───── */
.story__grid {
  position: absolute; inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(125,200,236,.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125,200,236,.16) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(circle at center, #000 0%, transparent 68%);
          mask-image: radial-gradient(circle at center, #000 0%, transparent 68%);
  opacity: 0;
  transform: scale(.55);
  transition: opacity 1s ease, transform 1.4s cubic-bezier(.2,.7,.2,1);
}
.story.is-phasing .story__grid { opacity: .85; transform: scale(1.4); }

/* ── Cyan flash on transition ─────────────────────────────────────── */
.story__flash {
  position: absolute; inset: 0;
  pointer-events: none;
  background: #5fb4dc;
  opacity: 0;
}
.story.is-phasing .story__flash { animation: storyFlash .6s ease-out; }
@keyframes storyFlash { 0% { opacity: 0; } 16% { opacity: .2; } 100% { opacity: 0; } }

/* ── Corner brackets ──────────────────────────────────────────────── */
.story__corner {
  position: absolute;
  width: clamp(28px, 4vw, 58px); height: clamp(28px, 4vw, 58px);
  border: 1.5px solid #7dc8ec;
  opacity: 0;
  transform: scale(.65);
  transition: opacity .7s ease .2s, transform .8s cubic-bezier(.2,.7,.2,1) .2s;
  pointer-events: none;
  z-index: 4;
}
.story__corner.tl { top: clamp(20px,3vw,48px);    left: clamp(20px,3vw,48px);  border-right: 0; border-bottom: 0; }
.story__corner.tr { top: clamp(20px,3vw,48px);    right: clamp(20px,3vw,48px); border-left: 0;  border-bottom: 0; }
.story__corner.bl { bottom: clamp(20px,3vw,48px); left: clamp(20px,3vw,48px);  border-right: 0; border-top: 0; }
.story__corner.br { bottom: clamp(20px,3vw,48px); right: clamp(20px,3vw,48px); border-left: 0;  border-top: 0; }
.story.is-open .story__corner { opacity: .9; transform: scale(1); }

/* ── Header ──────────────────────────────────────────────────────── */
.story__head {
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 6;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: clamp(22px,3.2vw,44px) clamp(24px,4vw,64px);
  gap: 20px;
}
.story__eyebrow {
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 10px; letter-spacing: .32em; text-transform: uppercase;
  color: #7dc8ec;
  display: inline-flex; align-items: center; gap: 12px;
  margin-bottom: 8px;
}
.story__eyebrow::before { content: ''; width: 26px; height: 1px; background: #7dc8ec; }
.story__eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%; background: #5fb4dc;
  animation: storyPulse 1.8s ease-in-out infinite;
}
@keyframes storyPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(95,180,220,.55); }
  60%      { box-shadow: 0 0 0 8px rgba(95,180,220,0); }
}
.story__title {
  font-family: "Fraunces", "Cormorant Garamond", Georgia, serif;
  font-weight: 400;
  font-size: clamp(20px, 2.2vw, 30px);
  line-height: 1.05;
  margin: 0;
  letter-spacing: -.01em;
  font-variation-settings: "opsz" 72;
}
.story__title em { font-style: italic; color: #5fb4dc; }

.story__controls { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.story__btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border: 1px solid rgba(125,200,236,.38);
  border-radius: 999px;
  background: rgba(5,13,22,.58);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #f6f8fb;
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 10px; letter-spacing: .22em; text-transform: uppercase;
  cursor: pointer;
  transition: background .25s ease, border-color .25s ease;
}
.story__btn:hover { background: rgba(125,200,236,.15); border-color: #5fb4dc; }
.story__btn--icon { width: 42px; height: 42px; padding: 0; justify-content: center; }
.story__btn--icon svg { width: 16px; height: 16px; }

/* ── Body: phase text (bottom-left) ───────────────────────────────── */
.story__body {
  position: absolute; left: 0; right: 0; bottom: 0;
  z-index: 6;
  padding: 0 clamp(24px,4vw,64px) clamp(60px,7.5vw,104px);
  max-width: 960px;
  pointer-events: none;
}
.story__body > * { pointer-events: auto; }
.story__num {
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 11px; letter-spacing: .3em; text-transform: uppercase;
  color: #7dc8ec;
  display: inline-flex; align-items: center; gap: 14px;
  margin-bottom: 14px;
}
.story__num::after { content: ''; width: 40px; height: 1px; background: rgba(125,200,236,.6); }
.story__date {
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 11px; letter-spacing: .26em; text-transform: uppercase;
  color: rgba(246,248,251,.72);
}
.story__phase {
  font-family: "Fraunces", "Cormorant Garamond", Georgia, serif;
  font-weight: 400;
  font-size: clamp(38px, 6.2vw, 88px);
  line-height: .96;
  letter-spacing: -.02em;
  margin: 0 0 16px;
  font-variation-settings: "opsz" 144;
  text-shadow: 0 2px 30px rgba(5,13,22,.6);
}
.story__phase em { font-style: italic; color: #5fb4dc; }
.story__note {
  font-weight: 300;
  font-size: clamp(14px, 1.15vw, 17px);
  line-height: 1.65;
  color: rgba(246,248,251,.88);
  max-width: 54ch;
  margin: 0;
}
/* Staggered slide-up on each phase */
.story__num, .story__phase, .story__note, .story__cta-wrap {
  opacity: 0; transform: translateY(20px);
  transition: opacity .75s ease, transform .85s cubic-bezier(.2,.7,.2,1);
}
.story.is-textin .story__num      { opacity: 1; transform: none; transition-delay: .06s; }
.story.is-textin .story__phase    { opacity: 1; transform: none; transition-delay: .18s; }
.story.is-textin .story__note     { opacity: 1; transform: none; transition-delay: .3s; }
.story.is-textin .story__cta-wrap { opacity: 1; transform: none; transition-delay: .46s; }

/* ── Film chapters ───────────────────────────────────────────────────
   A film phase swaps its caption mid-play. The date/phase/note dip out
   quickly (no stagger), the JS swaps the text, then .is-textin brings it
   back with the usual stagger. Declared AFTER .is-textin so it wins. */
.story__date { transition: opacity .3s ease, transform .3s ease; }
.story.is-chaptering .story__date,
.story.is-chaptering .story__phase,
.story.is-chaptering .story__note {
  opacity: 0; transform: translateY(12px);
  transition: opacity .3s ease, transform .3s ease; transition-delay: 0s;
}
/* "AI reconstruction" pill — an honest label, in the brand's mono voice */
.story__tag {
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 9.5px; letter-spacing: .22em; text-transform: uppercase;
  color: #7dc8ec;
  border: 1px solid rgba(125,200,236,.45);
  border-radius: 999px;
  padding: 4px 10px 3px;
  background: rgba(5,13,22,.35);
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
.story__tag[hidden] { display: none; }

/* ── Final-phase CTA ─────────────────────────────────────────────── */
.story__cta-wrap { margin-top: 28px; display: none; }
.story.is-final .story__cta-wrap { display: flex; gap: 12px; flex-wrap: wrap; }
.story__cta {
  display: inline-flex; align-items: center; gap: 14px;
  padding: 14px 26px;
  background: #f6f8fb;
  color: #0a1b2e;
  border: 0; border-radius: 999px;
  font-family: "Manrope", ui-sans-serif, sans-serif;
  font-weight: 600;
  font-size: 13px; letter-spacing: .05em;
  cursor: pointer;
  transition: transform .25s ease, background .25s ease;
}
.story__cta:hover { transform: translateY(-2px); background: #fff; }
.story__cta .arr { transition: transform .3s ease; }
.story__cta:hover .arr { transform: translateX(4px); }
.story__cta--ghost {
  background: transparent; color: #f6f8fb;
  border: 1px solid rgba(246,248,251,.35);
}
.story__cta--ghost:hover { background: rgba(246,248,251,.08); }

/* ── Segmented timeline progress bar ──────────────────────────────── */
.story__progress {
  position: absolute;
  left: clamp(24px,4vw,64px); right: clamp(24px,4vw,64px);
  bottom: clamp(22px,3vw,38px);
  z-index: 6;
  display: flex; gap: 6px;
}
.story__seg {
  flex: 1; height: 2px;
  background: rgba(246,248,251,.22);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}
.story__seg::after {
  content: '';
  position: absolute; inset: 0;
  background: #5fb4dc;
  transform: scaleX(0);
  transform-origin: left;
}
.story__seg.is-done::after   { transform: scaleX(1); }
.story__seg.is-active::after { animation: storySeg var(--story-dur, 6.5s) linear forwards; }
.story.is-paused .story__seg.is-active::after { animation-play-state: paused; }
@keyframes storySeg { from { transform: scaleX(0); } to { transform: scaleX(1); } }
/* A film's segment follows the video clock (JS sets --story-fill on timeupdate),
   so buffering stalls and pauses never desync the bar from the picture. */
.story__seg.is-video::after {
  animation: none;
  transform: scaleX(var(--story-fill, 0));
  transition: transform .3s linear;
}
/* The film segment gets more room in the bar — it carries most of the story. */
.story__seg.is-film { flex: 3; }

/* ── Next arrow (bottom-right) ─────────────────────────────────────── */
.story__next {
  position: absolute;
  right: clamp(24px,4vw,64px);
  bottom: clamp(60px,7.5vw,104px);
  z-index: 7;
  width: 58px; height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(125,200,236,.42);
  background: rgba(5,13,22,.52);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #f6f8fb;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background .25s ease, border-color .25s ease, transform .25s ease;
}
.story__next:hover { background: rgba(125,200,236,.16); border-color: #5fb4dc; transform: translateX(3px); }
.story.is-final .story__next { display: none; }

/* ── Whole overlay is click-to-advance (controls stop propagation) ── */
.story { cursor: pointer; }
.story__controls, .story__cta-wrap, .story__next, .story__progress { cursor: default; }

/* ── Paused indicator ─────────────────────────────────────────────── */
.story__paused {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 7;
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 10px; letter-spacing: .32em; text-transform: uppercase;
  color: rgba(246,248,251,.8);
  padding: 10px 18px;
  border: 1px solid rgba(246,248,251,.28);
  border-radius: 999px;
  background: rgba(5,13,22,.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
.story.is-paused .story__paused { opacity: 1; }

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .story__head { padding: 18px 20px; }
  .story__title { font-size: 17px; }
  .story__btn { padding: 8px 12px; font-size: 9px; }
  .story__btn .lbl { display: none; }
  .story__body { padding: 0 20px 76px; }
  .story__phase { font-size: clamp(30px, 9.5vw, 46px); }
  .story__note { font-size: 13px; }
  .story__next { width: 46px; height: 46px; right: 18px; bottom: 76px; }
  .story__progress { left: 20px; right: 20px; bottom: 18px; }
  .story__corner { display: none; }
  .story__img, .story__video { object-position: center; }
}
