/* ==================== Keyframe Animations ==================== */

/* ==================== Candy Crush Jelly Effects ==================== */

/* Jelly wobble - like tapping a candy */
@keyframes jelly-wobble {
    0% { transform: scale(1, 1); }
    15% { transform: scale(1.15, 0.85); }
    30% { transform: scale(0.9, 1.1); }
    45% { transform: scale(1.08, 0.92); }
    60% { transform: scale(0.95, 1.05); }
    75% { transform: scale(1.03, 0.97); }
    100% { transform: scale(1, 1); }
}

/* Jelly bounce - bouncy landing */
@keyframes jelly-bounce {
    0% { transform: translateY(-20px) scale(1, 1); opacity: 0; }
    30% { transform: translateY(0) scale(1.1, 0.9); opacity: 1; }
    50% { transform: translateY(-8px) scale(0.95, 1.05); }
    70% { transform: translateY(0) scale(1.03, 0.97); }
    85% { transform: translateY(-3px) scale(0.99, 1.01); }
    100% { transform: translateY(0) scale(1, 1); }
}

/* Candy shimmer - sparkle effect */
@keyframes candy-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Rainbow candy pulse */
@keyframes rainbow-pulse {
    0% { filter: hue-rotate(0deg) brightness(1) saturate(1.2); }
    25% { filter: hue-rotate(90deg) brightness(1.1) saturate(1.3); }
    50% { filter: hue-rotate(180deg) brightness(1.2) saturate(1.4); }
    75% { filter: hue-rotate(270deg) brightness(1.1) saturate(1.3); }
    100% { filter: hue-rotate(360deg) brightness(1) saturate(1.2); }
}

/* Candy glow pulse - bright neon glow */
@keyframes candy-glow {
    0%, 100% {
        box-shadow:
            0 0 10px currentColor,
            0 0 20px currentColor,
            inset 0 0 10px rgba(255,255,255,0.2);
    }
    50% {
        box-shadow:
            0 0 20px currentColor,
            0 0 40px currentColor,
            0 0 60px currentColor,
            inset 0 0 20px rgba(255,255,255,0.3);
    }
}

/* Sparkle star twinkle */
@keyframes sparkle-twinkle {
    0%, 100% { opacity: 0; transform: scale(0) rotate(0deg); }
    50% { opacity: 1; transform: scale(1) rotate(180deg); }
}

/* Sugar rush - intense screen shake */
@keyframes sugar-rush {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-3px, -3px) rotate(-1deg); }
    20% { transform: translate(3px, -3px) rotate(1deg); }
    30% { transform: translate(-3px, 3px) rotate(-1deg); }
    40% { transform: translate(3px, 3px) rotate(1deg); }
    50% { transform: translate(-2px, -2px) rotate(-0.5deg); }
    60% { transform: translate(2px, -2px) rotate(0.5deg); }
    70% { transform: translate(-2px, 2px) rotate(-0.5deg); }
    80% { transform: translate(2px, 2px) rotate(0.5deg); }
    90% { transform: translate(-1px, -1px) rotate(0deg); }
}

/* Candy pop - satisfying pop */
@keyframes candy-pop {
    0% { transform: scale(1); }
    20% { transform: scale(1.3); }
    40% { transform: scale(0.9); }
    60% { transform: scale(1.1); }
    80% { transform: scale(0.97); }
    100% { transform: scale(1); }
}

/* Jelly idle float */
@keyframes jelly-float {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    25% { transform: translateY(-5px) rotate(1deg); }
    50% { transform: translateY(0) rotate(-0.5deg); }
    75% { transform: translateY(-3px) rotate(0.5deg); }
}

/* Candy stripe rotation */
@keyframes candy-stripe {
    0% { background-position: 0 0; }
    100% { background-position: 50px 50px; }
}

/* Micro Interactions */
@keyframes pulse-micro {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes squish {
    0% { transform: scale(1, 1); }
    30% { transform: scale(1.15, 0.85); }
    50% { transform: scale(0.9, 1.1); }
    70% { transform: scale(1.05, 0.95); }
    100% { transform: scale(1, 1); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Celebrations */
@keyframes celebrate {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-2deg); }
    50% { transform: scale(1.15) rotate(2deg); }
    75% { transform: scale(1.05) rotate(-1deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes pop-in {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes pop-out {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0); opacity: 0; }
}

/* Progress & Growth */
@keyframes number-bump {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

@keyframes number-tick {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes progress-shine {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes glow-pulse {
    0%, 100% {
        box-shadow: 0 0 5px var(--x-blue);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 20px var(--x-blue), 0 0 40px rgba(29, 155, 240, 0.3);
        transform: scale(1.02);
    }
}

@keyframes glow-pulse-gold {
    0%, 100% {
        box-shadow: 0 0 5px var(--x-premium-gold);
    }
    50% {
        box-shadow: 0 0 20px var(--x-premium-gold), 0 0 40px rgba(255, 215, 0, 0.3);
    }
}

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

@keyframes float-up-fade {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-80px) scale(0.8);
    }
}

@keyframes float-up-fade-fast {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
}

/* Entrances */
@keyframes slide-in-right {
    0% { transform: translateX(100%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

@keyframes slide-in-bottom {
    0% { transform: translateY(100%); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes slide-in-bounce {
    0% { transform: translateY(100%); opacity: 0; }
    60% { transform: translateY(-10%); opacity: 1; }
    80% { transform: translateY(5%); }
    100% { transform: translateY(0); }
}

@keyframes fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Exits */
@keyframes shrink-out {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0); opacity: 0; }
}

@keyframes fade-out {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Special Effects */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes shake-intense {
    0%, 100% { transform: translate(0, 0); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-8px, -2px); }
    20%, 40%, 60%, 80% { transform: translate(8px, 2px); }
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes rainbow {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

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

/* Typing Specific */
@keyframes char-typed {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); color: var(--success-green); }
    100% { transform: scale(1); }
}

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

/* Combo Specific */
@keyframes combo-increment {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); text-shadow: 0 0 20px currentColor; }
    100% { transform: scale(1); }
}

@keyframes on-fire {
    0%, 100% {
        filter: brightness(1) saturate(1);
        text-shadow: 0 0 10px var(--accent-coral);
    }
    50% {
        filter: brightness(1.2) saturate(1.5);
        text-shadow: 0 0 30px var(--accent-coral), 0 0 60px var(--highlight-yellow);
    }
}

/* Viral Effects */
@keyframes viral-burst {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(2);
        opacity: 0.8;
    }
    100% {
        transform: scale(3);
        opacity: 0;
    }
}

@keyframes main-character {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }
    25% {
        transform: scale(1.1) rotate(-2deg);
        filter: brightness(1.3);
    }
    50% {
        transform: scale(1.15) rotate(2deg);
        filter: brightness(1.5);
    }
    75% {
        transform: scale(1.1) rotate(-1deg);
        filter: brightness(1.3);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

/* ==================== Animation Utility Classes ==================== */

/* Apply Animations */
.animate-pulse {
    animation: pulse-micro 0.3s ease;
}

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

.animate-bounce {
    animation: bounce 0.5s ease;
}

.animate-celebrate {
    animation: celebrate 0.6s ease;
}

.animate-pop-in {
    animation: pop-in 0.3s ease forwards;
}

.animate-pop-out {
    animation: pop-out 0.2s ease forwards;
}

.animate-number-bump {
    animation: number-bump 0.3s ease;
}

.animate-number-tick {
    animation: number-tick 0.15s ease;
}

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

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

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

.animate-float-up {
    animation: float-up-fade 1s ease-out forwards;
}

.animate-float-up-fast {
    animation: float-up-fade-fast 0.6s ease-out forwards;
}

.animate-slide-in-right {
    animation: slide-in-right 0.3s ease forwards;
}

.animate-slide-in-bottom {
    animation: slide-in-bottom 0.3s ease forwards;
}

.animate-slide-in-bounce {
    animation: slide-in-bounce 0.5s ease forwards;
}

.animate-fade-in {
    animation: fade-in 0.2s ease forwards;
}

.animate-fade-out {
    animation: fade-out 0.2s ease forwards;
}

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

.animate-shake-intense {
    animation: shake-intense 0.5s ease;
}

.animate-flash {
    animation: flash 0.2s ease;
}

.animate-rainbow {
    animation: rainbow 2s linear infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-char-typed {
    animation: char-typed 0.2s ease;
}

.animate-char-error {
    animation: char-error 0.3s ease;
}

.animate-combo-increment {
    animation: combo-increment 0.3s ease;
}

.animate-on-fire {
    animation: on-fire 0.5s ease-in-out infinite;
}

.animate-viral-burst {
    animation: viral-burst 0.8s ease-out forwards;
}

.animate-main-character {
    animation: main-character 1s ease-in-out infinite;
}

/* Progress Bar Shine */
#progress-fill.shining {
    background: linear-gradient(
        90deg,
        var(--x-blue),
        var(--success-green),
        var(--highlight-yellow),
        var(--success-green),
        var(--x-blue)
    );
    background-size: 200% 100%;
    animation: progress-shine 1.5s linear infinite;
}

/* Screen Flash Overlay */
.screen-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    animation: fade-out 0.3s ease forwards;
}

.screen-flash.gold {
    background: radial-gradient(circle, rgba(255, 215, 0, 0.4) 0%, transparent 70%);
}

.screen-flash.blue {
    background: radial-gradient(circle, rgba(29, 155, 240, 0.4) 0%, transparent 70%);
}

.screen-flash.coral {
    background: radial-gradient(circle, rgba(255, 107, 107, 0.4) 0%, transparent 70%);
}

.screen-flash.green {
    background: radial-gradient(circle, rgba(0, 186, 124, 0.4) 0%, transparent 70%);
}

.screen-flash.pink {
    background: radial-gradient(circle, rgba(255, 20, 147, 0.5) 0%, transparent 70%);
}

.screen-flash.purple {
    background: radial-gradient(circle, rgba(155, 89, 255, 0.5) 0%, transparent 70%);
}

.screen-flash.cyan {
    background: radial-gradient(circle, rgba(0, 255, 255, 0.5) 0%, transparent 70%);
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
