/* ============================================================
   cinematic.css — core cinematic engine styles
   Layered architecture:
     video layer < visual-effects < HTML content layer
   Only decorative layers get pointer-events:none.
   ============================================================ */

:root {
  --bg: #070b14;
  --bg-2: #0c1322;
  --ink: #f2f5fb;
  --ink-dim: rgba(242, 245, 251, 0.72);
  --accent: #5eead4;
  --accent-2: #7aa2ff;
  --card: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.12);
  --radius: 16px;
  --nav-h: 64px;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Skip link */
.skip-link {
  position: fixed;
  top: -60px;
  left: 12px;
  z-index: 200;
  background: var(--accent);
  color: #04211c;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 12px; }

/* ============ STORY / STAGE ============ */

.cinematic-page {
  position: relative;
}

/* Journey length: tall scroll track pins the stage via sticky */
.cinematic-story {
  position: relative;
  height: 800vh; /* total journey length; tuned per breakpoint */
}

.cinematic-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: grid;
  isolation: isolate;
}

/* ---- Video layer (decorative, never interactive) ---- */
.video-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.journey-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(1.05) contrast(1.05);
}

/* Gradient fallback shown until/without video */
.video-fallback {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(122, 162, 255, 0.35), transparent 60%),
    radial-gradient(1000px 700px at 10% 110%, rgba(94, 234, 212, 0.22), transparent 60%),
    linear-gradient(180deg, #0a1120 0%, #070b14 55%, #04070e 100%);
}
.journey-video[data-ready="true"] + .video-fallback { display: none; }

/* ---- Visual effects layer (decorative only) ---- */
.visual-effects {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.fx-gradient { position: absolute; inset: 0; }
.fx-top { background: linear-gradient(180deg, rgba(4, 7, 14, 0.86) 0%, transparent 30%); }
.fx-bottom { background: linear-gradient(0deg, rgba(4, 7, 14, 0.92) 0%, transparent 38%); }
/* All scene copy is left-aligned, so a side scrim buys the most
   contrast per pixel drawn. Tied to progress by the engine
   (--video-dim) so it can ease in only when footage is present. */
.fx-left {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(4, 7, 14, 0.88) 0%, rgba(4, 7, 14, 0.55) 38%, transparent 68%);
}
.fx-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 45%, transparent 45%, rgba(0, 0, 0, 0.72) 100%);
}
.fx-grain {
  position: absolute; inset: 0;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}
.fx-glow {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(94, 234, 212, 0.10) 0%, transparent 60%);
  will-change: transform, opacity;
}

/* ---- HTML content layer (REAL interactive DOM) ---- */
.story-content {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: calc(var(--nav-h) + 8px) 24px 24px;
  display: grid;
}

/* Scenes stack on top of each other; engine drives visibility.
   Inactive scenes are non-interactive; the active scene is. */
.story-scene {
  grid-area: 1 / 1;
  align-self: start;
  max-width: 640px;
  max-height: 100%;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transform: translate3d(0, 40px, 0) scale(var(--scene-fit, 1));
  transform-origin: top center;
}

/* Compositor layers only while a scene is mounted/animating —
   seven permanent fullscreen layers would waste GPU memory. */
.story-scene.is-active {
  will-change: transform, opacity;
}

/* .is-active = mounted/visible (several can coexist mid-dissolve).
   .is-dominant = highest visibility; ONLY the dominant scene receives
   pointer events, so a fading-out scene can never block clicks on the
   scene fading in over it. */
.story-scene.is-active {
  visibility: visible;
}

.story-scene.is-dominant {
  pointer-events: auto;
}

.story-scene.is-dominant a,
.story-scene.is-dominant button,
.story-scene.is-dominant input,
.story-scene.is-dominant textarea,
.story-scene.is-dominant .card {
  pointer-events: auto;
}

/* Scroll track markers: define journey length only */
.story-timeline { position: absolute; inset: 0; pointer-events: none; }
.timeline-marker { height: 14.2857%; } /* 7 scenes share the track */

/* ---- Footer (after the journey) ---- */
.site-footer {
  position: relative;
  z-index: 3;
  background: #04070e;
  border-top: 1px solid var(--line);
}
.footer-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 48px 24px;
  display: grid;
  gap: 20px;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.site-footer a { color: var(--ink-dim); text-decoration: none; }
.site-footer a:hover, .site-footer a:focus-visible { color: var(--ink); }
.copyright { color: var(--ink-dim); font-size: 0.875rem; margin: 0; }
.footer-brand { display: grid; gap: 8px; justify-items: start; }
.footer-brand p { margin: 0; color: var(--ink-dim); }

/* ---- Debug panel ---- */
.debug-panel {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 300;
  background: rgba(0, 0, 0, 0.78);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  color: #9df0e0;
}
.debug-panel b { color: #fff; }
/* Separator between story state and device diagnostics. */
.debug-panel hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  margin: 6px 0;
}

/* ---- Reduced motion: static readable content ----
   Applied via media query AND via body.is-reduced-motion (set by the
   engine when it detects the preference, so JS-set inline styles can
   never hide content). Both paths make every scene fully interactive. */
body.is-reduced-motion .cinematic-story { height: auto; }
body.is-reduced-motion .cinematic-stage {
  position: static;
  height: auto;
  overflow: visible;
  display: block;
}
body.is-reduced-motion .video-layer,
body.is-reduced-motion .visual-effects,
body.is-reduced-motion .story-timeline { display: none; }
body.is-reduced-motion .story-content { display: block; padding-top: calc(var(--nav-h) + 16px); }
body.is-reduced-motion .story-scene {
  visibility: visible !important;
  opacity: 1 !important;
  transform: none !important;
  pointer-events: auto !important;
  padding: 56px 0;
  border-top: 1px solid var(--line);
}
body.is-reduced-motion .story-scene [data-stagger],
body.is-reduced-motion .story-scene [data-drift] {
  opacity: 1 !important;
  translate: none !important;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cinematic-story { height: auto; }
  .cinematic-stage {
    position: static;
    height: auto;
    overflow: visible;
    display: block;
  }
  .video-layer, .visual-effects { display: none; }
  .story-content { display: block; padding-top: calc(var(--nav-h) + 16px); }
  .story-scene {
    visibility: visible;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    padding: 56px 0;
    border-top: 1px solid var(--line);
  }
  .story-timeline { display: none; }
}
