/* 99 Nights in the Forest - Custom Animations & Styles */

/* ========================================
   ANIMATED BACKGROUND ELEMENTS
   ======================================== */

/* Twinkling stars background */
.stars {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20px 30px, #fff, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(2px 2px at 130px 80px, rgba(255,255,255,0.6), transparent),
        radial-gradient(1px 1px at 160px 120px, #fff, transparent),
        radial-gradient(2px 2px at 200px 50px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 250px 160px, #fff, transparent),
        radial-gradient(2px 2px at 300px 90px, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 350px 200px, #fff, transparent),
        radial-gradient(2px 2px at 400px 30px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 450px 150px, #fff, transparent),
        radial-gradient(2px 2px at 500px 70px, rgba(255,255,255,0.6), transparent),
        radial-gradient(1px 1px at 550px 180px, #fff, transparent),
        radial-gradient(2px 2px at 600px 100px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 650px 220px, #fff, transparent),
        radial-gradient(2px 2px at 700px 50px, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 750px 130px, #fff, transparent),
        radial-gradient(2px 2px at 800px 80px, rgba(255,255,255,0.8), transparent);
    background-size: 800px 250px;
    animation: twinkle 8s ease-in-out infinite;
}

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

/* Floating fireflies */
.firefly {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #a3e635;
    border-radius: 50%;
    box-shadow:
        0 0 10px 3px rgba(163, 230, 53, 0.8),
        0 0 20px 6px rgba(163, 230, 53, 0.4),
        0 0 30px 9px rgba(163, 230, 53, 0.2);
    animation: firefly-float 6s ease-in-out infinite, firefly-glow 2s ease-in-out infinite;
}

@keyframes firefly-float {
    0% {
        transform: translate(0, 100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translate(20px, 80vh) scale(1);
    }
    30% {
        transform: translate(-15px, 50vh) scale(0.8);
    }
    50% {
        transform: translate(25px, 30vh) scale(1);
    }
    70% {
        transform: translate(-10px, 20vh) scale(0.9);
    }
    90% {
        opacity: 1;
        transform: translate(15px, 10vh) scale(0.7);
    }
    100% {
        transform: translate(0, -10vh) scale(0);
        opacity: 0;
    }
}

@keyframes firefly-glow {
    0%, 100% {
        box-shadow:
            0 0 10px 3px rgba(163, 230, 53, 0.8),
            0 0 20px 6px rgba(163, 230, 53, 0.4),
            0 0 30px 9px rgba(163, 230, 53, 0.2);
    }
    50% {
        box-shadow:
            0 0 15px 5px rgba(163, 230, 53, 1),
            0 0 30px 10px rgba(163, 230, 53, 0.6),
            0 0 45px 15px rgba(163, 230, 53, 0.3);
    }
}

/* ========================================
   FLOATING ANIMATIONS
   ======================================== */

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

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

/* Slow pulse for title */
.animate-pulse-slow {
    animation: pulse-slow 4s ease-in-out infinite;
}

@keyframes pulse-slow {
    0%, 100% {
        opacity: 1;
        filter: brightness(1);
    }
    50% {
        opacity: 0.8;
        filter: brightness(1.2);
    }
}

/* ========================================
   CARD GAME ANIMATIONS
   ======================================== */

/* Card shake animation for wrong answers */
.shake {
    animation: shake 0.5s ease-in-out;
}

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

/* Card hover scale */
.hover\:scale-102:hover {
    transform: scale(1.02);
}

/* Connection line animation */
.connection-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: draw-line 0.5s ease-out forwards;
}

@keyframes draw-line {
    to {
        stroke-dashoffset: 0;
    }
}

/* ========================================
   PARTICLE EFFECTS
   ======================================== */

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    animation: particle-explode 1s ease-out forwards;
}

@keyframes particle-explode {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--vx, 100px), var(--vy, -100px)) scale(0);
    }
}

/* ========================================
   BUTTON & INTERACTIVE ELEMENTS
   ======================================== */

/* Glowing border animation */
.glow-border {
    animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
    }
    50% {
        box-shadow: 0 0 30px rgba(168, 85, 247, 0.6);
    }
}

/* Word option hover state */
.word-option:hover {
    transform: scale(1.05);
}

.word-option:active {
    transform: scale(0.98);
}

/* ========================================
   PROGRESS BAR ANIMATIONS
   ======================================== */

/* Magic wand tip glow */
.wand-tip {
    animation: wand-glow 1.5s ease-in-out infinite;
}

@keyframes wand-glow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 255, 255, 1), 0 0 30px rgba(168, 85, 247, 0.5);
    }
}

/* ========================================
   MODAL ANIMATIONS
   ======================================== */

/* Modal fade in */
.modal-enter {
    animation: modal-fade-in 0.3s ease-out forwards;
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Victory bounce */
.animate-bounce {
    animation: bounce 1s ease-in-out infinite;
}

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

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
    .firefly {
        width: 6px;
        height: 6px;
    }

    .stars {
        background-size: 400px 200px;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

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

    .firefly,
    .stars,
    .animate-float,
    .animate-pulse-slow {
        animation: none;
    }
}

/* ========================================
   GAME-SPECIFIC STYLES
   ======================================== */

/* Phaser game container */
#game-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container canvas {
    max-width: 100%;
    height: auto;
}

/* Current ammo pulse effect */
#current-ammo {
    animation: ammo-pulse 2s ease-in-out infinite;
}

@keyframes ammo-pulse {
    0%, 100% {
        text-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
    }
    50% {
        text-shadow: 0 0 20px rgba(168, 85, 247, 0.8), 0 0 30px rgba(168, 85, 247, 0.4);
    }
}

/* Score display glow */
#score-display {
    text-shadow: 0 0 10px rgba(163, 230, 53, 0.6);
}
