/* Custom animation styles for GSAP-driven animations */

/* ==========================================================================
   LENIS SMOOTH SCROLL
   ========================================================================== */

/**
 * Required CSS for Lenis smooth scrolling to work.
 * Without these styles, Lenis initializes but the effect doesn't apply.
 */

/* Reset browser's native smooth scroll - conflicts with Lenis */
html, body {
  scroll-behavior: auto !important;
}

/* Lenis active state */
html.lenis,
html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

.lenis.lenis-scrolling iframe {
  pointer-events: none;
}

/* ==========================================================================
   SCROLL-TRIGGERED ANIMATIONS
   ========================================================================== */

/* Initial states for animated elements (before GSAP takes over).
   Applies to both data-animate (animations_controller) and
   data-how-it-works-target="stepNode" (how_it_works_controller).
   Without CSS pre-hide, fromTo() would flash: visible → opacity:0 → animate in. */
[data-animate],
[data-how-it-works-target="stepNode"]:not([data-animated="true"]) {
  opacity: 0;
}

/* CSS safety net: elements that have already completed their entrance animation
   must never flash back to opacity 0 — even if CSS re-applies (Turbo page swap,
   DOM mutation, controller reconnect). This rule wins over the bare [data-animate]
   because it has higher specificity. */
[data-animate][data-animated="true"],
[data-how-it-works-target="stepNode"][data-animated="true"] {
  opacity: 1;
}

/* Hero child elements start hidden to prevent flash between body swap
   and GSAP animation initialization. During Turbo navigation, the hero
   container gets data-animated="true" (via turbo:before-render), but on
   cold loads children would be fully visible from raw HTML for 1-3 frames
   before heroEntrance() can set their fromTo "from" state. These rules
   ensure children start hidden, matching the GSAP "from" state.
   The :not([data-animated="true"]) selector lifts the hiding after
   animation completes. */
[data-animate="hero"]:not([data-animated="true"]) h1,
[data-animate="hero"]:not([data-animated="true"]) .hero-headline,
[data-animate="hero"]:not([data-animated="true"]) .hero-preamble,
[data-animate="hero"]:not([data-animated="true"]) .hero-subheadline,
[data-animate="hero"]:not([data-animated="true"]) .hero-cta,
[data-animate="hero"]:not([data-animated="true"]) .hero-image {
  opacity: 0;
}

/* Ensure smooth transitions */
.animate-in {
  opacity: 1;
  transform: none;
}

/* Custom animation keyframes (for non-GSAP fallbacks) */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Sticky scroll effects (for advanced GSAP animations) */
.sticky-section {
  position: sticky;
  top: 0;
}

/* Card stack animation helpers */
.card-stack {
  perspective: 1000px;
}

.card-stack-item {
  transform-origin: top center;
}

/* Parallax helper classes.
   will-change removed: static hints promote persistent compositor layers even when the
   element is off-screen or the user has not started scrolling. The browser auto-promotes
   during active GSAP animation — no static hint needed. */
.parallax-slow,
.parallax-fast {
  /* Intentionally empty — layer promotion happens automatically during animation */
}

/* Text reveal animation helpers */
.text-reveal {
  overflow: hidden;
}

.text-reveal-line {
  display: block;
  transform: translateY(100%);
}

/* Horizontal scroll section */
.horizontal-scroll {
  display: flex;
  flex-wrap: nowrap;
}

.horizontal-scroll-item {
  flex-shrink: 0;
}
