/* ======== Animations - Inspired by python2/css/animations.css ======== */

/* Keyframe Animations */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px var(--primary), 0 0 10px var(--primary); }
    50% { box-shadow: 0 0 20px var(--primary), 0 0 30px var(--primary); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-15px); }
    60% { transform: translateY(-7px); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInBottom {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideInTop {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Sparkle Animation */
@keyframes sparkle {
    0%, 100% { 
        opacity: 0; 
        transform: scale(0) rotate(0deg); 
    }
    50% { 
        opacity: 1; 
        transform: scale(1) rotate(180deg); 
    }
}

/* Confetti Animation */
@keyframes confetti-fall {
    0% { 
        transform: translateY(-100vh) rotate(0deg); 
        opacity: 1; 
    }
    100% { 
        transform: translateY(100vh) rotate(720deg); 
        opacity: 0; 
    }
}

@keyframes confetti-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(10px); }
    75% { transform: translateX(-10px); }
}

/* Progress Bar Fill Animation */
@keyframes progressFill {
    from { width: 0; }
}

/* Shimmer Effect */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Ripple Effect */
@keyframes ripple {
    0% { 
        transform: scale(0); 
        opacity: 0.5; 
    }
    100% { 
        transform: scale(4); 
        opacity: 0; 
    }
}

/* Particle Float */
@keyframes particleFloat {
    0%, 100% {
        transform: translateY(0) translateX(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) translateX(50px) rotate(360deg);
        opacity: 0;
    }
}

/* Badge Unlock Animation */
@keyframes badgeUnlock {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Card Hover Lift */
@keyframes cardLift {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

/* Icon Bounce */
@keyframes iconBounce {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-5px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(-3px); }
}

/* XP Gain Animation */
@keyframes xpGain {
    0% { 
        transform: translateY(0) scale(1); 
        opacity: 1; 
    }
    100% { 
        transform: translateY(-50px) scale(1.5); 
        opacity: 0; 
    }
}

/* Coin Flip */
@keyframes coinFlip {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}

/* Level Up Animation */
@keyframes levelUp {
    0% { 
        transform: scale(1); 
        filter: brightness(1); 
    }
    50% { 
        transform: scale(1.5); 
        filter: brightness(1.5); 
    }
    100% { 
        transform: scale(1); 
        filter: brightness(1); 
    }
}

/* Rainbow Text */
@keyframes rainbow {
    0% { color: #ff6b6b; }
    14% { color: #feca57; }
    28% { color: #48dbfb; }
    42% { color: #1dd1a1; }
    57% { color: #5f27cd; }
    71% { color: #ff9ff3; }
    85% { color: #54a0ff; }
    100% { color: #ff6b6b; }
}

/* Typing Effect */
@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    0%, 50% { border-color: transparent; }
    51%, 100% { border-color: var(--text); }
}

/* Notification Slide */
@keyframes notificationSlide {
    0% {
        transform: translateX(100%);
        opacity: 0;
    }
    10% {
        transform: translateX(0);
        opacity: 1;
    }
    90% {
        transform: translateX(0);
        opacity: 1;
    }
    100% {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Animation Classes */
.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

.animate-bounce {
    animation: bounce 1s ease infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-fadeIn {
    animation: fadeIn 0.5s ease forwards;
}

.animate-fadeInUp {
    animation: fadeInUp 0.6s ease forwards;
}

.animate-fadeInDown {
    animation: fadeInDown 0.6s ease forwards;
}

.animate-fadeInLeft {
    animation: fadeInLeft 0.6s ease forwards;
}

.animate-fadeInRight {
    animation: fadeInRight 0.6s ease forwards;
}

.animate-scaleIn {
    animation: scaleIn 0.4s ease forwards;
}

.animate-slideInBottom {
    animation: slideInBottom 0.5s ease forwards;
}

.animate-rainbow {
    animation: rainbow 3s linear infinite;
}

/* Staggered Animations for Lists */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }
.stagger-6 { animation-delay: 0.6s; }
.stagger-7 { animation-delay: 0.7s; }
.stagger-8 { animation-delay: 0.8s; }

/* Confetti Container */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confetti-fall 3s linear forwards, confetti-shake 0.5s ease-in-out infinite;
}

/* Sparkle Effect */
.sparkle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: sparkle 1.5s ease-in-out infinite;
    pointer-events: none;
}

.sparkle::before,
.sparkle::after {
    content: '';
    position: absolute;
    background: white;
    border-radius: 50%;
}

.sparkle::before {
    width: 100%;
    height: 100%;
    transform: rotate(45deg);
}

.sparkle::after {
    width: 100%;
    height: 100%;
    transform: rotate(-45deg);
}

/* XP Popup */
.xp-popup {
    position: fixed;
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    color: var(--warning);
    text-shadow: 0 0 10px var(--warning);
    animation: xpGain 1s ease-out forwards;
    pointer-events: none;
    z-index: 9999;
}

/* Notification Toast */
.notification-toast {
    position: fixed;
    top: 100px;
    right: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: notificationSlide 4s ease forwards;
    z-index: 9999;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.notification-toast i {
    font-size: 1.5rem;
}

.notification-toast.success i { color: var(--success); }
.notification-toast.warning i { color: var(--warning); }
.notification-toast.error i { color: var(--danger); }
.notification-toast.info i { color: var(--secondary); }

/* Loading Spinner */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Shimmer Loading Effect */
.shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Ripple Button Effect */
.ripple-effect {
    position: relative;
    overflow: hidden;
}

.ripple-effect::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    transform: scale(0);
    opacity: 0;
    top: 0;
    left: 0;
    pointer-events: none;
}

.ripple-effect:active::after {
    animation: ripple 0.6s ease-out;
}

/* Hover Animations */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 20px var(--primary);
}

.hover-scale {
    transition: transform 0.3s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
