/* =========================================================================
   ANIMATIONS — Advanced Keyframes & Utilities
   Derived from Loonee Flutter app: AnimatedLiquidBackground, GlowingOrbImagePicker,
   GradientScaffold ambient glows, PetCard depth, GlassContainer shimmer.
   ========================================================================= */

/* ── Existing Foundations ─────────────────────────────────────────────── */

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

.animate-fade-in-up {
    animation: fadeInUp 0.7s ease forwards;
}

@keyframes glowPulse {
    0% { box-shadow: transparent; }
    50% { box-shadow: var(--shadow-orange-glow); }
    100% { box-shadow: transparent; }
}

.animate-glow-pulse {
    animation: glowPulse 2s infinite;
}

.hover-scale {
    transition: transform var(--transition-base);
}

.hover-scale:hover {
    transform: scale(1.04);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

.animate-shake {
    animation: shake 0.4s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

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

@keyframes spinnerFade {
    0% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 1; }
}

/* ── Liquid Blob Orbit (from AnimatedLiquidBackground — 15s loop) ───── */

@keyframes orbitBlob1 {
    0%   { transform: translate(0, 0) scale(1); }
    25%  { transform: translate(50px, -30px) scale(1.05); }
    50%  { transform: translate(-20px, 50px) scale(0.95); }
    75%  { transform: translate(-50px, -20px) scale(1.02); }
    100% { transform: translate(0, 0) scale(1); }
}

@keyframes orbitBlob2 {
    0%   { transform: translate(0, 0) scale(1); }
    25%  { transform: translate(-60px, 40px) scale(0.95); }
    50%  { transform: translate(30px, -50px) scale(1.08); }
    75%  { transform: translate(40px, 30px) scale(0.98); }
    100% { transform: translate(0, 0) scale(1); }
}

@keyframes orbitBlob3 {
    0%   { transform: translate(0, 0) scale(1); }
    25%  { transform: translate(40px, 30px) scale(1.03); }
    50%  { transform: translate(-40px, -40px) scale(0.97); }
    75%  { transform: translate(20px, -50px) scale(1.05); }
    100% { transform: translate(0, 0) scale(1); }
}

/* ── Breathing Glow (from GlowingOrbImagePicker — scale + opacity) ─── */

@keyframes breathe {
    0%, 100% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.08);
        opacity: 1;
    }
}

@keyframes breatheSlow {
    0%, 100% {
        transform: scale(0.95);
        opacity: 0.4;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.7;
    }
}

/* ── Glass Shimmer Border (light streak along card borders) ──────────── */

@keyframes shimmer {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

/* ── Gradient Shift (ambient background color drift) ─────────────────── */

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

/* ── Aurora Rotate (for Legendary tier chip crown glow) ──────────────── */

@keyframes auroraRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ── Icon Ring Rotation (feature card accent rings) ──────────────────── */

@keyframes iconRingSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ── Float Drift (gentle ambient motion) ────────────────────────────── */

@keyframes floatDrift {
    0%, 100% { transform: translateY(0) translateX(0); }
    25% { transform: translateY(-15px) translateX(8px); }
    50% { transform: translateY(-5px) translateX(-5px); }
    75% { transform: translateY(-20px) translateX(3px); }
}

/* ── Scroll Progress Bar ────────────────────────────────────────────── */

@keyframes scrollProgress {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--clr-primary), var(--clr-accent-amber), var(--clr-primary));
    transform-origin: left center;
    z-index: 9999;
    animation: scrollProgress linear;
    animation-timeline: scroll(root);
}

/* ── Text Clip Reveal (word-by-word gradient mask sweep) ─────────────── */

@keyframes textRevealClip {
    from {
        clip-path: inset(0 100% 0 0);
        opacity: 0;
    }
    to {
        clip-path: inset(0 0 0 0);
        opacity: 1;
    }
}

.text-reveal-word {
    display: inline-block;
    animation: textRevealClip 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* Staggered delays for word-by-word reveal */
.text-reveal-word:nth-child(1) { animation-delay: 0.1s; }
.text-reveal-word:nth-child(2) { animation-delay: 0.18s; }
.text-reveal-word:nth-child(3) { animation-delay: 0.26s; }
.text-reveal-word:nth-child(4) { animation-delay: 0.34s; }
.text-reveal-word:nth-child(5) { animation-delay: 0.42s; }
.text-reveal-word:nth-child(6) { animation-delay: 0.50s; }
.text-reveal-word:nth-child(7) { animation-delay: 0.58s; }
.text-reveal-word:nth-child(8) { animation-delay: 0.66s; }
.text-reveal-word:nth-child(9) { animation-delay: 0.74s; }
.text-reveal-word:nth-child(10) { animation-delay: 0.82s; }

/* ── Staggered Cascade (for tier chips, trust pillars, plus cards) ──── */

@keyframes cascadeIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Confetti Burst (paw prints on submit) ───────────────────────────── */

@keyframes confettiBurst {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

@keyframes confetti1 {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translate(-60px, -80px) rotate(-45deg) scale(0.5); opacity: 0; }
}

@keyframes confetti2 {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translate(50px, -90px) rotate(30deg) scale(0.4); opacity: 0; }
}

@keyframes confetti3 {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translate(-30px, -100px) rotate(-60deg) scale(0.6); opacity: 0; }
}

@keyframes confetti4 {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translate(70px, -70px) rotate(50deg) scale(0.3); opacity: 0; }
}

@keyframes confetti5 {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translate(20px, -110px) rotate(-20deg) scale(0.5); opacity: 0; }
}

@keyframes confetti6 {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translate(-50px, -60px) rotate(40deg) scale(0.4); opacity: 0; }
}

/* ── Magnetic Pull (subtle transform for CTA buttons) ────────────────── */

@keyframes magneticPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 var(--clr-primary-glow);
    }
    50% {
        box-shadow: 0 0 20px 4px var(--clr-primary-glow);
    }
}

/* ── Scroll-Driven View Reveals ─────────────────────────────────────── */

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

@keyframes scrollSlideLeft {
    from {
        opacity: 0;
        transform: translateX(-60px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scrollSlideRight {
    from {
        opacity: 0;
        transform: translateX(60px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scrollScaleUp {
    from {
        opacity: 0;
        transform: scale(0.88);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Scroll-driven reveal classes (progressive enhancement) */
@supports (animation-timeline: view()) {
    .scroll-reveal-up {
        animation: scrollFadeUp linear both;
        animation-timeline: view();
        animation-range: entry 0% cover 35%;
    }

    .scroll-reveal-left {
        animation: scrollSlideLeft linear both;
        animation-timeline: view();
        animation-range: entry 0% cover 35%;
    }

    .scroll-reveal-right {
        animation: scrollSlideRight linear both;
        animation-timeline: view();
        animation-range: entry 0% cover 35%;
    }

    .scroll-reveal-scale {
        animation: scrollScaleUp linear both;
        animation-timeline: view();
        animation-range: entry 0% cover 40%;
    }
}

/* ── Accessibility ───────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .scroll-progress {
        display: none;
    }

    .text-reveal-word {
        clip-path: none !important;
        opacity: 1 !important;
        animation: none !important;
    }
}