/* =============================================================================
   Scrollytelling — Scroll-scrubbed cinematic section
   =============================================================================
   Structure:
   .scrollytelling                → tall outer container (sets scroll distance)
     .scrollytelling__sticky      → viewport-pinned inner wrapper
       .scrollytelling__canvas    → full-bleed canvas for frame rendering
       .scrollytelling__overlay   → gradient + text container
         .scrollytelling__text-block → individual copy block
       .scrollytelling__progress  → thin progress bar at bottom
     .scrollytelling__poster      → static fallback for no-JS / reduced-motion
   ============================================================================= */

/* ── Container: sets the scroll distance ─────────────────────────────── */
.scrollytelling {
  position: relative;
  height: 420vh; /* Total scroll distance — adjust for pacing */
  background: var(--color-bg-dark, #0f1117);
}

/* ── Sticky wrapper: stays pinned during scroll ──────────────────────── */
.scrollytelling__sticky {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* ── Canvas: full-viewport frame rendering ───────────────────────────── */
.scrollytelling__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.scrollytelling--ready .scrollytelling__canvas {
  opacity: 1;
}

/* Grey tint over video for contrast */
.scrollytelling__sticky::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 23, 0.35);
  z-index: 1;
  pointer-events: none;
}

/* ── Overlay: gradient + text on top of video ────────────────────────── */
.scrollytelling__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: clamp(2rem, 6vw, 8rem);
  /* Centered vignette gradient for text legibility */
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.3) 50%,
    rgba(0, 0, 0, 0.1) 100%
  );
  z-index: 2;
  pointer-events: none;
}

/* ── Text blocks: copy that fades in/out ─────────────────────────────── */
.scrollytelling__text-block {
  position: absolute;
  max-width: 680px;
  width: 100%;
  opacity: 0;
  transform: translateY(20px);
  will-change: opacity, transform;
  pointer-events: auto;
  /* Ensure all children centre within the block */
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Eyebrow */
.scrollytelling__eyebrow {
  display: block;
  font-size: clamp(0.8rem, 1.2vw, 1rem);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-brand-secondary, #f59e0b);
  margin-bottom: 1rem;
}

/* Headline */
.scrollytelling__headline {
  font-size: clamp(2.2rem, 4.5vw, 3.8rem);
  font-weight: 700;
  line-height: 1.1;
  color: #fff;
  margin: 0 0 1.25rem;
  letter-spacing: -0.025em;
}

/* Body */
.scrollytelling__body {
  font-size: clamp(1rem, 1.4vw, 1.25rem);
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.88);
  margin: 0;
  max-width: 540px;
}

/* ── Progress bar ────────────────────────────────────────────────────── */
.scrollytelling__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--color-brand-primary, #2563eb);
  transform-origin: left center;
  transform: scaleX(0);
  z-index: 3;
  will-change: transform;
}

/* ── Static poster fallback ──────────────────────────────────────────── */
.scrollytelling__poster {
  display: none;
}

/* No-JS fallback: show poster, hide canvas */
.no-js .scrollytelling__canvas,
.scrollytelling--reduced-motion .scrollytelling__canvas {
  display: none;
}

.no-js .scrollytelling__poster,
.scrollytelling--reduced-motion .scrollytelling__poster {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Reduced motion: shorter scroll, show all text statically */
.scrollytelling--reduced-motion {
  height: auto;
}

.scrollytelling--reduced-motion .scrollytelling__sticky {
  position: relative;
  height: auto;
}

.scrollytelling--reduced-motion .scrollytelling__overlay {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2xl, 4rem);
  padding: var(--space-3xl, 6rem) var(--space-xl, 2rem);
  background: var(--color-bg-dark, #0f1117);
}

.scrollytelling--reduced-motion .scrollytelling__text-block {
  position: relative;
  opacity: 1;
  transform: none;
  max-width: 640px;
}

.scrollytelling--reduced-motion .scrollytelling__progress {
  display: none;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .scrollytelling {
    height: 350vh;
  }

  .scrollytelling__overlay {
    padding: 1.5rem;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: radial-gradient(
      ellipse at center,
      rgba(0, 0, 0, 0.6) 0%,
      rgba(0, 0, 0, 0.35) 50%,
      rgba(0, 0, 0, 0.1) 100%
    );
  }

  .scrollytelling__text-block {
    max-width: 100%;
  }

  .scrollytelling__headline {
    font-size: clamp(1.6rem, 6vw, 2.4rem);
  }

  .scrollytelling__body {
    font-size: clamp(0.95rem, 3vw, 1.1rem);
  }
}

/* ── Loading state ───────────────────────────────────────────────────── */
.scrollytelling:not(.scrollytelling--ready) .scrollytelling__overlay {
  opacity: 0;
}

.scrollytelling--ready .scrollytelling__overlay {
  opacity: 1;
  transition: opacity 0.4s ease 0.2s;
}

/* ── Scroll hint ─────────────────────────────────────────────────────── */
.scrollytelling__scroll-hint {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  color: rgba(255, 255, 255, 0.6);
  font-size: var(--text-xs, 0.75rem);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  animation: scrollHintPulse 2s ease-in-out infinite;
  pointer-events: none;
}

.scrollytelling__scroll-hint::after {
  content: '';
  display: block;
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.4);
  margin: 0.5rem auto 0;
  animation: scrollHintLine 2s ease-in-out infinite;
}

@keyframes scrollHintPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@keyframes scrollHintLine {
  0% { transform: scaleY(0); transform-origin: top; }
  50% { transform: scaleY(1); transform-origin: top; }
  51% { transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; }
}

/* Hide scroll hint after user starts scrolling */
.scrollytelling--ready.scrollytelling--loaded .scrollytelling__scroll-hint {
  transition: opacity 0.3s ease;
}
