/* ==========================================================================
   SCROLL STORY — pinned cinematic 3D walk-through (see site.js "Scroll Director")
   Layers: .story (bg + giant words, below model) < floating 3D (z 50) < .story-overlay (text, z 60)
   ========================================================================== */
.story-fade { height: 24vh; margin-top: -1px; pointer-events: none; }
.story-fade--in { background: linear-gradient(180deg, #e8f1fb 0%, #86c4ff 100%); }
.story-fade--out { background: linear-gradient(180deg, #e2edff 0%, #ffffff 100%); }

.story {
  position: relative;
  background: #cfe6ff;
  color: #0b1220;
  overflow: hidden;
}
.story__gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.story__bg.has-gl .story__grid { display: none; }
.story__stage { position: relative; }
.story__bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.story__grid {
  position: absolute; inset: -10%;
  background-image:
    linear-gradient(rgba(120, 180, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 180, 255, 0.07) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 50%, #000 15%, transparent 70%);
  mask-image: radial-gradient(ellipse at 50% 50%, #000 15%, transparent 70%);
}
.story__aura {
  position: absolute; left: 50%; top: 50%;
  width: min(120vw, 1500px); height: min(120vw, 1500px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, var(--aura, rgba(0, 102, 255, 0.35)) 0%, rgba(0, 20, 60, 0) 62%);
  opacity: 0.45;
  mix-blend-mode: screen;
  will-change: opacity, transform;
}

/* Giant outline words sit BEHIND the model for depth */
.story__words { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.story__word {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(120px, 24vw, 400px);
  line-height: 0.9;
  letter-spacing: -0.03em;
  white-space: nowrap;
  color: transparent;
  -webkit-text-stroke: 1.5px rgba(255, 255, 255, 0.75);
  opacity: 0;
  will-change: transform, opacity;
}

/* Text + HUD overlay (moved to <body> by JS so it can sit above the model) */
.story-overlay {
  position: fixed; inset: 0; z-index: 60;
  pointer-events: none;
  opacity: 0; visibility: hidden;
  color: #0b1220;
}
.story-overlay.is-on { visibility: visible; }

.story-ch {
  background: rgba(255, 255, 255, 0.66);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 22px;
  padding: 26px 30px 28px;
  box-shadow: 0 30px 70px -30px rgba(20, 70, 140, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  max-width: 440px;
}
.story-ch__eyebrow {
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.16em;
  color: #0a63e0; margin: 0 0 10px;
}
.story-ch__title {
  font-family: var(--font-sport);
  font-weight: 800;
  font-size: clamp(26px, 3vw, 40px);
  line-height: 1.12;
  margin: 0 0 12px;
  color: #0b1220;
}
.story-ch__text { margin: 0; font-size: 15px; line-height: 1.7; color: rgba(11, 18, 32, 0.74); }
.story-ch__note { margin: 12px 0 0; font-size: 12px; color: rgba(11, 18, 32, 0.5); }

.story-ch__chips { list-style: none; display: flex; gap: 10px; margin: 18px 0 0; padding: 0; flex-wrap: wrap; }
.story-ch__chips li {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 14px; border-radius: 14px;
  background: rgba(0, 110, 255, 0.08);
  border: 1px solid rgba(0, 110, 255, 0.22);
}
.story-ch__chips b { font-family: var(--font-mono); font-size: 18px; color: #0b1220; }
.story-ch__chips span { font-size: 11px; color: rgba(11, 18, 32, 0.6); }

.story-ch__parts { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.story-ch__parts li {
  display: flex; gap: 12px; align-items: baseline;
  font-size: 14px; color: rgba(11, 18, 32, 0.86);
  padding-bottom: 8px; border-bottom: 1px dashed rgba(10, 99, 224, 0.25);
}
.story-ch__parts b { font-family: var(--font-mono); color: #0a63e0; font-size: 12px; }

.story-ch__cta { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; justify-content: center; }
.story-ch__cta .btn-primary { background: linear-gradient(135deg, #0066ff, #00d2ff); box-shadow: 0 14px 40px -12px rgba(0, 150, 255, 0.8); }
.story-ch__ghost { color: #0b1220; border-color: rgba(10, 99, 224, 0.3); background: rgba(255, 255, 255, 0.7); }

/* Equalizer + play button */
.story-eq { display: flex; align-items: flex-end; gap: 3px; height: 48px; margin: 18px 0 14px; }
.story-eq i {
  flex: 1; height: 100%; border-radius: 2px;
  background: linear-gradient(180deg, #00b8ff, #0066ff);
  transform-origin: bottom; transform: scaleY(0.12);
}
.story-play {
  display: inline-flex; align-items: center; gap: 10px;
  border: 0; cursor: pointer;
  padding: 12px 22px; border-radius: 999px;
  font: 700 14px var(--font-sport);
  color: #fff;
  background: linear-gradient(135deg, #0066ff, #00d2ff);
  box-shadow: 0 12px 34px -10px rgba(0, 160, 255, 0.85);
  transition: transform 0.25s ease, box-shadow 0.25s;
}
.story-play:hover { transform: translateY(-2px); }
.story-play:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.story-play__icon {
  width: 0; height: 0;
  border-left: 11px solid #fff; border-top: 7px solid transparent; border-bottom: 7px solid transparent;
}
.story-play.is-playing .story-play__icon {
  width: 12px; height: 14px; border: 0;
  background: linear-gradient(90deg, #fff 0 35%, transparent 35% 65%, #fff 65%);
}

/* Neon mode pills */
.story-pills { list-style: none; display: flex; gap: 8px; margin: 18px 0 0; padding: 0; flex-wrap: wrap; }
.story-pills li {
  padding: 8px 16px; border-radius: 999px; font: 600 13px var(--font-mono);
  color: rgba(11, 18, 32, 0.6);
  border: 1px solid rgba(10, 99, 224, 0.25);
  transition: all 0.3s;
}
.story-pills li.is-on {
  color: #fff; background: #0a63e0; border-color: #0a63e0;
  box-shadow: 0 8px 22px -6px rgba(10, 99, 224, 0.7);
}

/* HUD */
.story__hud {
  position: absolute; left: clamp(20px, 4vw, 64px); bottom: 26px;
  display: flex; align-items: center; gap: 14px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em;
  color: rgba(11, 18, 32, 0.65);
  pointer-events: none;
}
.story__counter b { color: #0b1220; font-size: 15px; }
.story__bar { width: 120px; height: 2px; background: rgba(11, 18, 32, 0.15); border-radius: 2px; overflow: hidden; }
.story__bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #0066ff, #00f0ff); transform-origin: left; transform: scaleX(0); }

/* ---- Cinematic mode (JS adds .is-cinematic) ---- */
.story.is-cinematic .story__stage { height: 100vh; height: 100svh; }
.story-overlay .story-ch {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  will-change: opacity, transform;
}
.story-overlay .story-ch.is-active { pointer-events: auto; }
.story-overlay .story-ch--left {
  left: clamp(20px, 5vw, 88px); top: 50%;
  transform: translateY(calc(-50% + var(--ty, 0px)));
}
.story-overlay .story-ch--right {
  right: clamp(20px, 5vw, 88px); top: 50%;
  transform: translateY(calc(-50% + var(--ty, 0px)));
}
.story-overlay .story-ch--bottom {
  left: 50%; bottom: 9vh;
  transform: translate(-50%, var(--ty, 0px));
  max-width: 660px; width: calc(100% - 40px);
  text-align: center;
}
.story-overlay .story-ch--bottom .story-ch__chips { justify-content: center; }
.story-overlay .story__hud { position: absolute; }

/* ---- Fallback (no JS / reduced motion): plain stacked cards ---- */
.story:not(.is-cinematic) { padding: 72px 0 56px; }
.story:not(.is-cinematic) .story__words,
.story:not(.is-cinematic) .story__hud,
.story:not(.is-cinematic) .story__aura { display: none; }
.story:not(.is-cinematic) .story__chapters {
  position: relative; z-index: 2;
  display: grid; gap: 18px;
  width: min(720px, calc(100% - 40px)); margin: 0 auto;
}
.story:not(.is-cinematic) .story-ch { max-width: none; }

@media (max-width: 760px) {
  .story-fade { height: 14vh; }
  .story__word { font-size: 38vw; }
  .story-overlay .story-ch,
  .story-overlay .story-ch--left,
  .story-overlay .story-ch--right,
  .story-overlay .story-ch--bottom {
    left: 14px; right: 14px; top: auto; bottom: calc(var(--mobile-tabs-height, 64px) + 14px);
    width: auto; max-width: none;
    transform: translateY(var(--ty, 0px));
    padding: 16px 18px 18px;
    border-radius: 18px;
    text-align: left;
  }
  .story-overlay .story-ch--bottom .story-ch__chips,
  .story-overlay .story-ch__cta { justify-content: flex-start; }
  .story-ch__title { font-size: 22px; margin-bottom: 8px; }
  .story-ch__text { font-size: 13px; line-height: 1.55; }
  .story-ch__note, .story-ch__parts li:nth-child(n+3) { display: none; }
  .story-ch__chips { margin-top: 12px; gap: 8px; }
  .story-ch__chips li { padding: 7px 10px; }
  .story-eq { height: 30px; margin: 12px 0 10px; }
  .story-pills { margin-top: 12px; }
  .story__hud { bottom: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .story-play, .story-pills li { transition: none; }
}

/* ---- Real photography layered over the procedural scenes (Unsplash) ---- */
.story__photos { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.story__photo { position: absolute; inset: -4%; opacity: 0; will-change: transform, opacity; }
.story__photo b { position: absolute; inset: 0; background-size: cover; background-repeat: no-repeat; will-change: transform; animation: photoDrift 26s ease-in-out infinite alternate; }
.story__photo--sky b { background-image: url(/images/scenes/sky.webp); background-position: 50% 40%; }
.story__photo--water b { background-image: url(/images/scenes/water.webp); background-position: 55% 0%; }
.story__photo--sunset b { background-image: url(/images/scenes/sunset.webp); background-position: 50% 8%; }
@keyframes photoDrift { from { transform: scale(1.04) translate3d(-1.5%, 0, 0); } to { transform: scale(1.14) translate3d(1.5%, -1.5%, 0); } }
.story__credit { margin-left: 18px; font: 400 10px var(--font-mono); letter-spacing: 0.04em; opacity: 0.55; }
@media (max-width: 760px) { .story__credit { display: none; } }
@media (prefers-reduced-motion: reduce) { .story__photo b { animation: none; } }

/* ==========================================================================
   Opening scene (intro.js) — quiet studio daylight stage for the 3D assembly
   ========================================================================== */
.intro {
  position: fixed; inset: 0; z-index: 200;
  background: radial-gradient(circle at 50% 48%, #ffffff 0%, #f5f8fd 58%, #eaf1fa 100%);
  display: grid; place-items: center;
  transition: opacity 1.05s cubic-bezier(0.22, 1, 0.36, 1), visibility 1.05s;
  /* if scripting dies the overlay still leaves on its own */
  animation: introFailsafe 0.6s ease 20s forwards;
}
.intro.is-closing .intro__brand,
.intro.is-closing .intro__status,
.intro.is-closing .intro__skip {
  opacity: 0 !important;
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1), transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.intro.is-closing .intro__brand { transform: translate(-50%, -8px); }
.intro.is-closing .intro__status { transform: translate(-50%, 8px); }
.intro.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.intro.is-replaying { animation: none; }
@keyframes introFailsafe { to { opacity: 0; visibility: hidden; } }
@keyframes introFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes introRiseIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes introDropIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

html.is-intro { overflow: hidden; }
html.is-intro-settling .viewer-3d--hero.is-floating {
  transition: transform 1.05s cubic-bezier(0.16, 1, 0.3, 1);
}
html.is-intro .viewer-3d--hero.is-floating {
  z-index: 210;
  inset: 0 !important;
  height: 100vh !important;
  height: 100dvh !important;
  transform: translate3d(0, 0, 0) scale(1) !important;
  opacity: 1 !important;
}
html.is-intro .hero-in { animation-play-state: paused; }
html.is-intro .site-header { opacity: 0; transform: translate3d(0, -10px, 0); }
html:not(.is-intro) .site-header {
  transition: opacity 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.12s, transform 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.12s, background var(--dur-med) var(--ease-sport), box-shadow var(--dur-med) var(--ease-sport);
}
html.is-intro .hero3d__editorial-backdrop { opacity: 0; transform: scale(0.97); }
.hero3d__editorial-backdrop {
  transition: opacity 1.1s cubic-bezier(0.16, 1, 0.3, 1) 0.18s, transform 1.2s cubic-bezier(0.16, 1, 0.3, 1) 0.18s;
}
html.is-intro .hero3d__gesture-pill { opacity: 0; transform: translate3d(0, 8px, 0); }
.hero3d__gesture-pill {
  transition: opacity 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.4s, transform 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.4s;
}

.intro__skip {
  position: absolute; top: clamp(22px, 4vh, 36px); right: clamp(20px, 4vw, 44px);
  z-index: 5;
  padding: 6px 10px;
  font: 500 12px var(--font-sport);
  color: rgba(15, 23, 42, 0.42);
  background: transparent;
  border: 0;
  transition: color 0.25s ease;
  animation: introFadeIn 0.8s ease-out 0.7s both;
}
.intro__skip:hover { color: rgba(15, 23, 42, 0.85); }

.intro__brand { position: absolute; top: clamp(28px, 6vh, 56px); left: 50%; transform: translateX(-50%); text-align: center; line-height: 1; animation: introDropIn 0.95s cubic-bezier(0.16, 1, 0.3, 1) 0.06s both; }
.intro__brand b { display: block; font: 800 clamp(22px, 3vw, 32px) var(--font-display); letter-spacing: 0.06em; color: #0f172a; }
.intro__brand span { display: block; margin-top: 6px; font: 500 10px var(--font-mono); letter-spacing: 0.44em; color: rgba(15, 23, 42, 0.45); }

.intro__status { position: absolute; left: 50%; bottom: clamp(32px, 7vh, 68px); transform: translateX(-50%); width: min(68vw, 240px); text-align: center; color: #0f172a; animation: introRiseIn 0.95s cubic-bezier(0.16, 1, 0.3, 1) 0.16s both; }
.intro__bar { height: 2px; border-radius: 99px; background: rgba(15, 23, 42, 0.09); overflow: hidden; }
.intro__bar i { display: block; height: 100%; background: #0f172a; transform-origin: left; transform: scaleX(0); will-change: transform; }
.intro__status b { display: block; margin-top: 10px; font: 500 11px var(--font-mono); letter-spacing: 0.12em; color: rgba(15, 23, 42, 0.45); }

/* Sound button (HUD) */
.story-sound {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 8px;
  margin-left: 14px; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  font: 600 12px var(--font-sport); letter-spacing: 0;
  color: #0b1220; background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(10, 99, 224, 0.25);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: background 0.25s, color 0.25s;
}
.story-sound:focus-visible { outline: 2px solid #0a63e0; outline-offset: 2px; }
.story-sound__icon { width: 14px; height: 14px; background: currentColor; -webkit-mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 10v4h4l5 4V6L7 10H3zm13.5 2A4.5 4.5 0 0 0 14 8v8a4.5 4.5 0 0 0 2.5-4zM14 3.2v2.1a7 7 0 0 1 0 13.4v2.1a9 9 0 0 0 0-17.6z'/%3E%3C/svg%3E"); mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 10v4h4l5 4V6L7 10H3zm13.5 2A4.5 4.5 0 0 0 14 8v8a4.5 4.5 0 0 0 2.5-4zM14 3.2v2.1a7 7 0 0 1 0 13.4v2.1a9 9 0 0 0 0-17.6z'/%3E%3C/svg%3E"); }
.story-sound.is-on { background: #0a63e0; color: #fff; border-color: #0a63e0; }
.story-ch__note--sound { color: #0a63e0; font-weight: 600; }
.story-fade.story-fade--plain.story-fade--out { background: linear-gradient(180deg, #e2edff 0%, #ffffff 100%); }
.story:not(.is-cinematic) .story__hud { display: none; }
@media (max-width: 760px) {
  .story__hud { gap: 8px; }
  .story-sound { margin-left: 0; padding: 6px 11px; font-size: 11px; }
  .story__bar { width: 56px; }
  .story__hint { display: none; }
  .intro__brand { top: calc(env(safe-area-inset-top, 0px) + 22px); }
  .intro__brand b { font-size: 22px; }
  .intro__brand span { font-size: 9px; letter-spacing: 0.32em; }
  .intro__skip { top: calc(env(safe-area-inset-top, 0px) + 20px); right: 16px; font-size: 11px; }
  .intro__status { bottom: calc(env(safe-area-inset-bottom, 0px) + 28px); width: min(62vw, 200px); }
}

html.is-intro .viewer-loading { display: none !important; }

/* Phones: the site's bottom tab bar owns the bottom edge, so the story HUD moves up under the header */
@media (max-width: 760px) {
  .story-overlay .story__hud { bottom: auto; top: 74px; left: auto; right: 14px; }
  .story__counter, .story__bar { display: none; }
}

/* Phones: no continuous full-screen layer animation (battery + GPU); the scroll parallax still moves the photos */
@media (max-width: 760px) { .story__photo b { animation: none; } .story__photo { inset: -2%; } }
@media (max-width: 760px) { body.has-sticky-atc .story-overlay .story-ch { bottom: calc(var(--mobile-tabs-height, 64px) + 98px); } }

/* ==========================================================================
   Mobile hero (3 series): one tidy row of pills, borderless scroll strip for the lens bar
   ========================================================================== */
.series-pill .sp-pre { font-style: normal; }
@media (max-width: 760px) {
  .hero3d__series-capsule { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; border-radius: 22px; }
  .series-pill { flex-direction: column; gap: 2px; padding: 8px 4px; line-height: 1.15; text-align: center; }
  .series-pill .sp-pre, .series-pill small { display: none; }
  .series-pill b { font-size: 0.82rem; }
  .series-pill__dot { margin-bottom: 2px; }
  .hero3d__lens-bar { scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .hero3d__lens-bar::-webkit-scrollbar { display: none; }
  .hero3d__editorial-backdrop { top: 148px; }
}

@media (max-width: 760px) { .hide-m { display: none; } .mini-matrix__row--head { letter-spacing: 0.06em; } }

/* Fallback (reduced motion / no JS): never show the unrendered WebGL canvas or photos behind the stacked cards */
.story__gl { background: #cfe6ff; }
.story:not(.is-cinematic) { background: linear-gradient(180deg, #cfe6ff 0%, #eaf3ff 100%); }
.story:not(.is-cinematic) .story__gl, .story:not(.is-cinematic) .story__photos, .story:not(.is-cinematic) .story__bg { display: none; }
