/* ============================================
   DRIVE MAD - Animations & Keyframes
   ============================================ */

/* ============================================
   KEYFRAMES
   ============================================ */

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-8px) rotate(-2deg); }
    20% { transform: translateX(8px) rotate(2deg); }
    30% { transform: translateX(-6px) rotate(-1deg); }
    40% { transform: translateX(6px) rotate(1deg); }
    50% { transform: translateX(-4px); }
    60% { transform: translateX(4px); }
    70% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
    90% { transform: translateX(-1px); }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.7);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
    70% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes starPop {
    0% {
        transform: scale(0) rotate(-30deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.3) rotate(10deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(255,107,53,0.3);
    }
    50% {
        box-shadow: 0 0 25px rgba(255,107,53,0.7), 0 0 50px rgba(255,107,53,0.3);
    }
}

@keyframes glowAccent {
    0%, 100% {
        box-shadow: 0 0 10px rgba(6,214,160,0.3);
    }
    50% {
        box-shadow: 0 0 25px rgba(6,214,160,0.7), 0 0 50px rgba(6,214,160,0.3);
    }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes confettiFall {
    0% {
        transform: translateY(-20px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

@keyframes crashShake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-5px, -3px) rotate(-1deg); }
    20% { transform: translate(5px, 3px) rotate(1deg); }
    30% { transform: translate(-4px, 2px) rotate(-0.5deg); }
    40% { transform: translate(4px, -2px) rotate(0.5deg); }
    50% { transform: translate(-3px, 1px); }
    60% { transform: translate(3px, -1px); }
    70% { transform: translate(-2px, 0); }
    80% { transform: translate(2px, 0); }
    90% { transform: translate(-1px, 0); }
}

@keyframes levelCompleteFlash {
    0%, 100% { background: rgba(6,214,160,0); }
    50% { background: rgba(6,214,160,0.15); }
}

@keyframes roadStripe {
    from { background-position: 0 0; }
    to { background-position: 60px 0; }
}

@keyframes bgScroll {
    from { background-position: 0 0; }
    to { background-position: -200px 0; }
}

/* ============================================
   ANIMATION UTILITY CLASSES
   ============================================ */

.anim-fade-in {
    animation: fadeIn 0.3s ease forwards;
}

.anim-scale-in {
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.anim-bounce-in {
    animation: bounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.anim-slide-up {
    animation: slideUp 0.4s ease forwards;
}

.anim-shake {
    animation: shake 0.5s ease;
}

.anim-glow {
    animation: glow 2s ease-in-out infinite;
}

.anim-float {
    animation: float 3s ease-in-out infinite;
}

/* ============================================
   STAR ANIMATION (level complete)
   ============================================ */

.star.earned {
    animation: starPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.star:nth-child(1).earned { animation-delay: 0.1s; }
.star:nth-child(2).earned { animation-delay: 0.3s; }
.star:nth-child(3).earned { animation-delay: 0.5s; }

/* ============================================
   OVERLAY ENTRANCE ANIMATIONS
   ============================================ */

.overlay-screen .overlay-content {
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ============================================
   MENU BUTTON HOVER EFFECTS
   ============================================ */

.menu-btn.primary-btn {
    animation: glow 3s ease-in-out infinite;
}

/* ============================================
   LOADING BAR SHIMMER
   ============================================ */

.loading-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    from { left: -100%; }
    to { left: 100%; }
}

.loading-bar {
    position: relative;
    overflow: hidden;
}

/* ============================================
   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;
    }
}

/* JS-controlled reduced motion class */
body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

/* ============================================
   CONFETTI PARTICLES (JS-generated)
   ============================================ */

.confetti-particle {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 9999;
    animation: confettiFall linear forwards;
}

/* ============================================
   LEVEL CARD HOVER ANIMATION
   ============================================ */

.level-card:not(.locked):hover {
    animation: glowAccent 1s ease-in-out infinite;
}

/* ============================================
   CHECKPOINT FLASH
   ============================================ */

.checkpoint-flash {
    animation: levelCompleteFlash 0.5s ease;
}

/* ============================================
   CRASH SCREEN ENTRANCE
   ============================================ */

#crash-screen .crash-icon {
    animation: bounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#crash-screen .crash-title {
    animation: slideUp 0.4s ease 0.2s both;
}

/* ============================================
   COMPLETE SCREEN ENTRANCE
   ============================================ */

#level-complete .complete-flag {
    animation: bounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#level-complete .overlay-title {
    animation: slideUp 0.4s ease 0.15s both;
}

#level-complete .complete-stats {
    animation: slideUp 0.4s ease 0.25s both;
}

#level-complete .star-rating {
    animation: slideUp 0.4s ease 0.35s both;
}

#level-complete .overlay-buttons {
    animation: slideUp 0.4s ease 0.45s both;
}