/* ============================================================
   Scroll-driven animations — IntersectionObserver powered
   ============================================================ */

/* Base hidden state for animated elements */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(32px);
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Directional variants */
.animate-on-scroll.slide-left {
    transform: translateX(-40px);
}
.animate-on-scroll.slide-left.visible {
    transform: translateX(0);
}

.animate-on-scroll.slide-right {
    transform: translateX(40px);
}
.animate-on-scroll.slide-right.visible {
    transform: translateX(0);
}

.animate-on-scroll.scale-in {
    transform: scale(0.92);
}
.animate-on-scroll.scale-in.visible {
    transform: scale(1);
}

/* Stagger children — add stagger-children to parent */
.stagger-children > .animate-on-scroll:nth-child(1) { transition-delay: 0ms; }
.stagger-children > .animate-on-scroll:nth-child(2) { transition-delay: 80ms; }
.stagger-children > .animate-on-scroll:nth-child(3) { transition-delay: 160ms; }
.stagger-children > .animate-on-scroll:nth-child(4) { transition-delay: 240ms; }
.stagger-children > .animate-on-scroll:nth-child(5) { transition-delay: 320ms; }
.stagger-children > .animate-on-scroll:nth-child(6) { transition-delay: 400ms; }

/* Hero-specific entrance */
.hero-animate {
    opacity: 0;
    transform: translateY(24px);
    animation: heroEntrance 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.hero-animate:nth-child(1) { animation-delay: 0.1s; }
.hero-animate:nth-child(2) { animation-delay: 0.2s; }
.hero-animate:nth-child(3) { animation-delay: 0.35s; }
.hero-animate:nth-child(4) { animation-delay: 0.5s; }

@keyframes heroEntrance {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Gradient text shimmer */
.gradient-text {
    animation: gradientShift 6s ease-in-out infinite;
    background-size: 200% 100%;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Subtle float for decorative elements */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.float { animation: float 4s ease-in-out infinite; }

/* Pulse ring for icons */
@keyframes pulseRing {
    0% { box-shadow: 0 0 0 0 rgba(var(--color-primary-rgb), 0.4); }
    100% { box-shadow: 0 0 0 16px rgba(var(--color-primary-rgb), 0); }
}

.pulse-ring { animation: pulseRing 2s ease-in-out infinite; }

/* Smooth section transitions via scroll-driven (progressive enhancement) */
@supports (animation-timeline: scroll()) {
    .scroll-reveal {
        animation: scrollFadeIn linear both;
        animation-timeline: view();
        animation-range: entry 0% entry 30%;
    }

    @keyframes scrollFadeIn {
        from { opacity: 0; transform: translateY(40px); }
        to { opacity: 1; transform: translateY(0); }
    }
}

/* Loading skeleton */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg,
        var(--color-border) 25%,
        var(--color-border-hover) 50%,
        var(--color-border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* Page entrance */
main {
    animation: pageIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Accessibility — respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
    .animate-on-scroll,
    .hero-animate {
        animation: none !important;
        transition: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}
