/*
 * animations.css — Scroll-driven reveal animations (CSS progressive enhancement)
 *
 * Modern browsers (Chrome 115+, Firefox 110+, Safari 18+) get GPU-composited scroll
 * reveals via animation-timeline: view(). Older browsers fall back to the JS/GSAP
 * IntersectionObserver path in global.js (window.FI.runAnimations).
 *
 * The @supports guard ensures unsupported browsers see elements as fully visible
 * from the start — no invisible/stuck elements, just no animation.
 *
 * Selectors here must match the window.FI.animations queue in global.js so the two
 * paths stay in sync. When adding a new animated element, add it to BOTH places.
 */

/* ── Keyframes ────────────────────────────────────────────────────────────────── */
@keyframes fi-fade-in-up {
    from { opacity: 0; transform: translate3d(0, 30px, 0); }
    to   { opacity: 1; transform: none; }
}

@keyframes fi-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Scroll-driven reveals (below-fold) ─────────────────────────────────────────
   animation-range: entry 0% entry 25% means the animation plays over the first 25%
   of the element's entry into the viewport. Feels natural without being too slow.
   animation-fill-mode: both keeps elements at opacity:0 until they enter.        */
@supports (animation-timeline: view()) {

    section:not(.section-hero-home) .heading,
    section .paragraph,
    section .buttons,
    .avatars .avatar,
    .blog-post,
    .logos,
    .mini-cases,
    .shared-heading,
    .featured-case,
    .platform-feature-section .loop,
    .feature-slider,
    .interactive-cta,
    .call-to-action,
    .leave-an-impression-section .blurb,
    .full-height-hero .content .title,
    /* about.js additions */
    .about-story-section .text,
    /* experience-generator.js additions */
    .cases-results .actions,
    .case-card,
    .form-experience-generator,
    .spinning-badge {
        animation: fi-fade-in-up 0.8s ease-out both;
        animation-timeline: view();
        animation-range: entry 0% entry 25%;
    }

    .full-height-hero .background {
        animation: fi-fade-in 0.8s ease-out both;
        animation-timeline: view();
        animation-range: entry 0% entry 25%;
    }

    /* LCP element — explicitly excluded. Must never be animated in.
       The hero heading is visible in cream before the bg image loads;
       animating it delays LCP. Handled separately via bg-loaded class in index.php. */
    .section-hero-home .hero-content .heading {
        animation: none;
        opacity: 1;
        transform: none;
    }

    /* Case-study spinning badges have their own CSS/JS positioning.
       The fi-fade-in-up keyframe would override transform:translate(-50%,-50%)
       and visually displace both badges before they scroll into view. */
    .case-study-cover .spinning-badge,
    .case-study-video .spinning-badge,
    .case-study-layout > .spinning-badge {
        animation: none;
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}
