/* ==========================================================================
   Game Animations - GoWort Interactive Games
   ========================================================================== */

/* Particle explosion on correct answer */
@keyframes particle-burst {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}
.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    animation: particle-burst 0.7s ease-out forwards;
}

/* Screen shake on wrong answer */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-10px) rotate(-1deg); }
    30% { transform: translateX(10px) rotate(1deg); }
    45% { transform: translateX(-6px); }
    60% { transform: translateX(6px); }
    75% { transform: translateX(-2px); }
}
.shake { animation: shake 0.5s ease-in-out; }

/* Floating +XP text */
@keyframes float-up {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    50% { transform: translateY(-30px) scale(1.2); opacity: 0.8; }
    100% { transform: translateY(-70px) scale(0.8); opacity: 0; }
}
.float-xp {
    position: absolute;
    font-weight: 800;
    font-size: 1.25rem;
    pointer-events: none;
    animation: float-up 1s ease-out forwards;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Card flip 3D (for Memory Match) */
.card-container {
    perspective: 800px;
}
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}
.card-flipped .card-inner {
    transform: rotateY(180deg);
}
.card-matched .card-inner {
    transform: rotateY(180deg);
}
.card-front, .card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.card-back {
    transform: rotateY(180deg);
}

/* Card match glow */
@keyframes match-glow {
    0% { box-shadow: 0 0 0 rgba(34, 197, 94, 0); }
    50% { box-shadow: 0 0 20px rgba(34, 197, 94, 0.6); }
    100% { box-shadow: 0 0 5px rgba(34, 197, 94, 0.3); }
}
.card-matched {
    animation: match-glow 0.6s ease-out;
}

/* Falling word animation (for Word Cascade) */
@keyframes fall-down {
    from { transform: translateY(0); }
    to { transform: translateY(var(--fall-distance, 500px)); }
}
.falling-word {
    position: absolute;
    animation: fall-down var(--fall-duration, 6s) linear forwards;
    will-change: transform;
}

/* Combo fire glow */
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 165, 0, 0.4); }
    50% { box-shadow: 0 0 25px rgba(255, 165, 0, 0.8), 0 0 50px rgba(255, 69, 0, 0.3); }
}
.combo-glow { animation: pulse-glow 0.8s ease-in-out infinite; }

/* Combo text pulse */
@keyframes combo-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}
.combo-pulse { animation: combo-pulse 0.3s ease-out; }

/* Slide in from bottom */
@keyframes slide-up {
    0% { transform: translateY(30px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}
.slide-up { animation: slide-up 0.4s ease-out; }

/* Scale pop */
@keyframes pop-in {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}
.pop-in { animation: pop-in 0.35s ease-out; }

/* Pop out (for removed elements) */
@keyframes pop-out {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.3); opacity: 0; }
}
.pop-out { animation: pop-out 0.3s ease-in forwards; }

/* Correct flash - green pulse on game area */
@keyframes correct-flash {
    0% { background-color: transparent; }
    30% { background-color: rgba(34, 197, 94, 0.15); }
    100% { background-color: transparent; }
}
.correct-flash { animation: correct-flash 0.5s ease-out; }

/* Wrong flash - red pulse */
@keyframes wrong-flash {
    0% { background-color: transparent; }
    30% { background-color: rgba(239, 68, 68, 0.15); }
    100% { background-color: transparent; }
}
.wrong-flash { animation: wrong-flash 0.5s ease-out; }

/* Heart loss animation */
@keyframes heart-break {
    0% { transform: scale(1); opacity: 1; }
    30% { transform: scale(1.3); color: #ef4444; }
    100% { transform: scale(0) rotate(45deg); opacity: 0; }
}
.heart-break { animation: heart-break 0.5s ease-in forwards; }

/* Timer pulse when low */
@keyframes timer-pulse {
    0%, 100% { color: #ef4444; transform: scale(1); }
    50% { color: #dc2626; transform: scale(1.15); }
}
.timer-critical { animation: timer-pulse 0.5s ease-in-out infinite; }

/* Word tile hover/selected */
.word-tile {
    transition: all 0.15s ease;
    cursor: pointer;
}
.word-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.word-tile:active {
    transform: translateY(0);
}
.word-tile-placed {
    background-color: #fef3c7 !important;
    border-color: #f59e0b !important;
}

/* Score counter roll */
@keyframes score-bump {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
.score-bump { animation: score-bump 0.25s ease-out; }

/* Game over overlay */
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
.fade-in { animation: fade-in 0.5s ease-out; }

/* Stars rating on results screen */
@keyframes star-pop {
    0% { transform: scale(0) rotate(-30deg); opacity: 0; }
    60% { transform: scale(1.3) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.star-pop {
    display: inline-block;
    animation: star-pop 0.4s ease-out forwards;
    opacity: 0;
}
.star-pop:nth-child(1) { animation-delay: 0.2s; }
.star-pop:nth-child(2) { animation-delay: 0.4s; }
.star-pop:nth-child(3) { animation-delay: 0.6s; }

/* Ripple effect on button press */
@keyframes ripple {
    0% { transform: scale(0); opacity: 0.5; }
    100% { transform: scale(4); opacity: 0; }
}
.btn-ripple {
    position: relative;
    overflow: hidden;
}
.btn-ripple::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    transform: scale(0);
    opacity: 0;
}
.btn-ripple:active::after {
    animation: ripple 0.5s ease-out;
}

/* Progress bar fill animation */
@keyframes fill-bar {
    from { width: 0%; }
    to { width: var(--fill-width, 0%); }
}
.fill-bar {
    animation: fill-bar 1s ease-out forwards;
}
