/* Card Animations */

/* Card Deal */
@keyframes cardDeal {
    0% {
        opacity: 0;
        transform: translate(-50%, -200%) rotate(-15deg) scale(0.5);
    }
    60% {
        opacity: 1;
        transform: translate(0, 0) rotate(5deg) scale(1.05);
    }
    100% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
}

.card.deal-animation {
    animation: cardDeal 0.4s ease-out forwards;
}

/* Card Shuffle */
@keyframes cardShuffle {
    0% { transform: translateX(0); }
    25% { transform: translateX(-10px) rotate(-3deg); }
    50% { transform: translateX(10px) rotate(3deg); }
    75% { transform: translateX(-5px) rotate(-1deg); }
    100% { transform: translateX(0) rotate(0deg); }
}

.card.shuffle-animation {
    animation: cardShuffle 0.3s ease;
}

/* Card Flip 3D */
@keyframes cardFlip3D {
    0% {
        transform: perspective(1000px) rotateY(0deg);
    }
    100% {
        transform: perspective(1000px) rotateY(180deg);
    }
}

.card.flip-3d {
    animation: cardFlip3D 0.4s ease-in-out;
    transform-style: preserve-3d;
}

/* Auto Move Animation */
@keyframes autoMove {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.card.auto-move {
    animation: autoMove 0.3s ease;
}

/* Win Celebration - Cards Flying */
@keyframes winCardFly {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate(var(--end-x, 0), var(--end-y, -100vh)) rotate(var(--rotation, 720deg));
        opacity: 0;
    }
}

.card.win-fly {
    animation: winCardFly var(--duration, 2s) ease-out forwards;
    animation-delay: var(--delay, 0s);
}

/* Win Celebration - Bounce */
@keyframes winBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-30px);
    }
    60% {
        transform: translateY(-15px);
    }
}

.card.win-bounce {
    animation: winBounce 1s ease infinite;
}

/* Cascade Animation for dealing */
.card.cascade-deal {
    animation: cascadeDeal 0.3s ease-out forwards;
    animation-delay: var(--cascade-delay, 0s);
    opacity: 0;
}

@keyframes cascadeDeal {
    0% {
        opacity: 0;
        transform: translateY(-50px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fireworks for win screen */
.firework {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.firework:nth-child(1) {
    top: 20%;
    left: 20%;
    animation: firework1 1.5s ease-out infinite;
}

.firework:nth-child(2) {
    top: 30%;
    right: 25%;
    animation: firework2 1.5s ease-out infinite 0.5s;
}

.firework:nth-child(3) {
    top: 15%;
    right: 15%;
    animation: firework3 1.5s ease-out infinite 1s;
}

@keyframes firework1 {
    0% {
        transform: scale(0);
        opacity: 1;
        box-shadow:
            0 0 0 #ff0,
            -20px -20px 0 #f0f,
            20px -20px 0 #0ff,
            20px 20px 0 #f00,
            -20px 20px 0 #0f0;
    }
    50% {
        transform: scale(1);
        opacity: 1;
        box-shadow:
            0 -40px 0 #ff0,
            -40px -40px 0 #f0f,
            40px -40px 0 #0ff,
            40px 40px 0 #f00,
            -40px 40px 0 #0f0;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
        box-shadow:
            0 -60px 0 #ff0,
            -60px -60px 0 #f0f,
            60px -60px 0 #0ff,
            60px 60px 0 #f00,
            -60px 60px 0 #0f0;
    }
}

@keyframes firework2 {
    0% {
        transform: scale(0);
        opacity: 1;
        box-shadow:
            0 0 0 #f90,
            -15px -25px 0 #90f,
            25px -15px 0 #09f,
            15px 25px 0 #f09,
            -25px 15px 0 #9f0;
    }
    50% {
        transform: scale(1);
        opacity: 1;
        box-shadow:
            0 -30px 0 #f90,
            -35px -45px 0 #90f,
            45px -35px 0 #09f,
            35px 45px 0 #f09,
            -45px 35px 0 #9f0;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
        box-shadow:
            0 -50px 0 #f90,
            -55px -65px 0 #90f,
            65px -55px 0 #09f,
            55px 65px 0 #f09,
            -65px 55px 0 #9f0;
    }
}

@keyframes firework3 {
    0% {
        transform: scale(0);
        opacity: 1;
        box-shadow:
            0 0 0 #0ff,
            -25px -15px 0 #ff0,
            15px -25px 0 #f0f,
            25px 15px 0 #0f0,
            -15px 25px 0 #f00;
    }
    50% {
        transform: scale(1);
        opacity: 1;
        box-shadow:
            0 -35px 0 #0ff,
            -45px -35px 0 #ff0,
            35px -45px 0 #f0f,
            45px 35px 0 #0f0,
            -35px 45px 0 #f00;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
        box-shadow:
            0 -55px 0 #0ff,
            -65px -55px 0 #ff0,
            55px -65px 0 #f0f,
            65px 55px 0 #0f0,
            -55px 65px 0 #f00;
    }
}

/* Confetti */
@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg) scale(0.5);
        opacity: 0;
    }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    animation: confettiFall 3s ease-in-out forwards;
}

/* Sparkle animation */
@keyframes sparkleAnim {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.5) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(0) rotate(360deg);
        opacity: 0;
    }
}

/* Flying cards celebration */
@keyframes cardFlyUp {
    0% {
        transform: translateY(0) translateX(0) rotate(0deg) scale(1);
        opacity: 1;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) translateX(var(--end-x, 0)) rotate(var(--rotation, 720deg)) scale(0.5);
        opacity: 0;
    }
}

/* Celebration burst */
@keyframes celebrationBurst {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Star spin */
@keyframes starSpin {
    0% {
        transform: rotate(0deg) scale(0);
        opacity: 1;
    }
    50% {
        transform: rotate(180deg) scale(1.5);
        opacity: 1;
    }
    100% {
        transform: rotate(360deg) scale(0);
        opacity: 0;
    }
}

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

.shake {
    animation: shake 0.5s ease;
}

/* Pulse for hints */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(201, 162, 39, 0.7);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(201, 162, 39, 0);
    }
}

.pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Glow effect */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(201, 162, 39, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(201, 162, 39, 0.8);
    }
}

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

/* Slide in from right (for panels) */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

/* Fade in */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Fade out */
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.fade-out {
    animation: fadeOut 0.3s ease;
}

/* Scale in */
@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.scale-in {
    animation: scaleIn 0.3s ease-out;
}

/* Button press effect */
@keyframes buttonPress {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.button-press {
    animation: buttonPress 0.15s ease;
}

/* Score pop animation */
@keyframes scorePop {
    0% {
        transform: scale(1);
        color: var(--ui-primary);
    }
    50% {
        transform: scale(1.3);
        color: #fff;
    }
    100% {
        transform: scale(1);
        color: var(--ui-primary);
    }
}

.score-pop {
    animation: scorePop 0.3s ease;
}

/* Floating score text */
@keyframes floatScore {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.5);
    }
}

.float-score {
    position: absolute;
    font-size: 20px;
    font-weight: bold;
    color: var(--ui-primary);
    animation: floatScore 1s ease-out forwards;
    pointer-events: none;
}

/* Animation speed classes */
.anim-slow {
    --anim-speed: 0.5s;
}

.anim-normal {
    --anim-speed: 0.3s;
}

.anim-fast {
    --anim-speed: 0.15s;
}

.anim-instant {
    --anim-speed: 0s;
}

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