/* Stream-AI Workout Assistant - Animations */

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

/* Elements start hidden before scrolling into view */
.scroll-animate {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Stagger children */
.scroll-animate.stagger-1 { transition-delay: 0.1s; }
.scroll-animate.stagger-2 { transition-delay: 0.2s; }
.scroll-animate.stagger-3 { transition-delay: 0.3s; }
.scroll-animate.stagger-4 { transition-delay: 0.4s; }

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

.scroll-animate.slide-left.visible {
    opacity: 1;
    transform: translateX(0);
}

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

.scroll-animate.slide-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.scroll-animate.scale-in {
    opacity: 0;
    transform: scale(0.9);
}

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

/* ============================================
   HERO ANIMATIONS
   ============================================ */
.hero-fade-in {
    animation: heroFadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.hero-fade-in-delayed {
    opacity: 0;
    animation: heroFadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.2s forwards;
}

.hero-fade-in-delayed-2 {
    opacity: 0;
    animation: heroFadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.4s forwards;
}

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

/* ============================================
   GLOW PULSE (for accent elements)
   ============================================ */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    }
    50% {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    }
}

.glow-pulse {
    animation: glowPulse 3s ease-in-out infinite;
}

/* ============================================
   COUNTER ANIMATION (for stat numbers)
   ============================================ */
@keyframes countUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.count-animate {
    animation: countUp 0.5s ease forwards;
}

/* ============================================
   SHIMMER LOADING EFFECT
   ============================================ */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.shimmer {
    background: linear-gradient(
        90deg,
        hsla(var(--accent-hsl), 0.03) 25%,
        hsla(var(--accent-hsl), 0.08) 50%,
        hsla(var(--accent-hsl), 0.03) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 2s ease-in-out infinite;
}

/* ============================================
   FLOATING ANIMATION
   ============================================ */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

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

/* ============================================
   ICON SPIN (for loading states)
   ============================================ */
@keyframes iconSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.icon-spin {
    animation: iconSpin 1.5s linear infinite;
}

/* ============================================
   BUTTON RIPPLE EFFECT
   ============================================ */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease, opacity 0.6s ease;
    opacity: 0;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
    opacity: 0;
    transition: 0s;
    opacity: 1;
}

/* ============================================
   NAVBAR SCROLL EFFECT
   ============================================ */
.navbar.scrolled {
    /* Do NOT change padding here. The navbar is sticky-top and lives in the
       document flow, so shrinking it changes total page height and nudges
       scrollY. Right at the scrollY>50 threshold that caused a feedback
       oscillation (shrink → page shorter → scrollY<50 → grow → repeat),
       which showed up as the top of the screen "glitching" while scrolling.
       Only the paint-only box-shadow toggles now — height stays constant. */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* ============================================
   CARD HOVER ACCENT LINE
   ============================================ */
.card-hover-line {
    position: relative;
    overflow: hidden;
}

.card-hover-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-gradient);
    transform: scaleX(0);
    transition: transform 0.3s ease;
    z-index: 1;
}

.card-hover-line:hover::before {
    transform: scaleX(1);
}

/* ============================================
   REDUCE MOTION - Accessibility
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .scroll-animate {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .hero-fade-in,
    .hero-fade-in-delayed,
    .hero-fade-in-delayed-2 {
        animation: none;
        opacity: 1;
    }

    .glow-pulse,
    .float-animate,
    .icon-spin {
        animation: none;
    }

    .shimmer {
        animation: none;
        background: transparent;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
