/* =============================================================================
   Scroll Animations — Babiboo Theme

   Usage: Add data-animate="<type>" to any element.
   Optional: data-delay="<ms>" for stagger/delay.

   The JS (scroll-animations.js) adds class .is-visible via IntersectionObserver.
   All animation logic lives here — change timings, easings, or effects
   without touching any other file.
============================================================================= */

/* --- Base: hidden state for all animated elements --- */

[data-animate] {
    opacity: 0;
    will-change: opacity, transform;
    transition:
        opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
    [data-animate] {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
        animation: none !important;
    }
}

/* --- Visible state (applied by JS) --- */

[data-animate].is-visible {
    opacity: 1;
    transform: none;
}

/* =============================================================================
   Animation Types — Initial (hidden) states
   The visible state is always opacity:1 + transform:none (defined above)
============================================================================= */

/* Fade Up — content rises into place */
[data-animate="fade-up"] {
    transform: translateY(40px);
}

/* Fade Down */
[data-animate="fade-down"] {
    transform: translateY(-40px);
}

/* Fade Left — slides in from the left */
[data-animate="fade-left"] {
    transform: translateX(-50px);
}

/* Fade Right — slides in from the right */
[data-animate="fade-right"] {
    transform: translateX(50px);
}

/* Scale Up — grows into view, playful feel */
[data-animate="scale-up"] {
    transform: scale(0.85);
}

/* Pop — bouncy entrance for badges, icons, CTAs */
[data-animate="pop"] {
    transform: scale(0.6);
    transition:
        opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Bounce In — stronger bounce for playful elements */
[data-animate="bounce-in"] {
    transform: scale(0.3);
    transition:
        opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.7s cubic-bezier(0.34, 1.8, 0.64, 1);
}

/* Flip Up — subtle 3D card flip */
[data-animate="flip-up"] {
    transform: perspective(800px) rotateX(15deg) translateY(30px);
}

/* Wiggle In — fun entrance with a little shake */
[data-animate="wiggle-in"] {
    transform: translateY(30px) rotate(-3deg);
    transition:
        opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.6s cubic-bezier(0.34, 1.4, 0.64, 1);
}

/* Zoom Fade — zoom out while fading in */
[data-animate="zoom-fade"] {
    transform: scale(1.1);
    transition:
        opacity 0.8s ease-out,
        transform 0.8s ease-out;
}

/* Slide Up Bounce — playful rise with overshoot */
[data-animate="slide-up-bounce"] {
    transform: translateY(60px);
    transition:
        opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* =============================================================================
   Stagger — children animated one by one
   Add data-animate="stagger" to the PARENT.
   Children get animated automatically with incremental delays.
============================================================================= */

[data-animate="stagger"] {
    opacity: 1;
    transform: none;
}

[data-animate="stagger"] > * {
    opacity: 0;
    transform: translateY(30px);
    transition:
        opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.5s cubic-bezier(0.34, 1.4, 0.64, 1);
}

[data-animate="stagger"].is-visible > * {
    opacity: 1;
    transform: none;
}

/* Stagger delays for up to 12 children */
[data-animate="stagger"].is-visible > *:nth-child(1)  { transition-delay: 0ms; }
[data-animate="stagger"].is-visible > *:nth-child(2)  { transition-delay: 80ms; }
[data-animate="stagger"].is-visible > *:nth-child(3)  { transition-delay: 160ms; }
[data-animate="stagger"].is-visible > *:nth-child(4)  { transition-delay: 240ms; }
[data-animate="stagger"].is-visible > *:nth-child(5)  { transition-delay: 320ms; }
[data-animate="stagger"].is-visible > *:nth-child(6)  { transition-delay: 400ms; }
[data-animate="stagger"].is-visible > *:nth-child(7)  { transition-delay: 480ms; }
[data-animate="stagger"].is-visible > *:nth-child(8)  { transition-delay: 560ms; }
[data-animate="stagger"].is-visible > *:nth-child(9)  { transition-delay: 640ms; }
[data-animate="stagger"].is-visible > *:nth-child(10) { transition-delay: 720ms; }
[data-animate="stagger"].is-visible > *:nth-child(11) { transition-delay: 800ms; }
[data-animate="stagger"].is-visible > *:nth-child(12) { transition-delay: 880ms; }
