/* ===================================
   Advanced Animations & Effects
   =================================== */

/* Coin Collection Animation */
@keyframes coinCollect {
    0% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }

    50% {
        transform: scale(1.5) translateY(-20px);
        opacity: 0.8;
    }

    100% {
        transform: scale(0) translateY(-40px);
        opacity: 0;
    }
}

.coin-collect-animation {
    animation: coinCollect 0.8s ease-out forwards;
}

/* Resource Production Pulse */
@keyframes resourcePulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.resource-pulse {
    animation: resourcePulse 2s ease-in-out infinite;
}

/* Building Construction Animation */
@keyframes buildingConstruct {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }

    50% {
        transform: scale(1.2) rotate(10deg);
    }

    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

.building-construct {
    animation: buildingConstruct 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Level Up Animation */
@keyframes levelUp {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }

    25% {
        transform: scale(1.2);
        filter: brightness(1.5);
    }

    50% {
        transform: scale(0.9) rotate(5deg);
        filter: brightness(2);
    }

    75% {
        transform: scale(1.1) rotate(-5deg);
        filter: brightness(1.5);
    }

    100% {
        transform: scale(1) rotate(0);
        filter: brightness(1);
    }
}

.level-up-animation {
    animation: levelUp 0.8s ease-out;
}

/* Shimmer Effect */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

.shimmer {
    background: linear-gradient(90deg,
            transparent 0%,
            hsla(0, 0%, 100%, 0.1) 50%,
            transparent 100%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* Shake Animation (for errors) */
@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;
}

/* Bounce Animation */
@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.bounce {
    animation: bounce 0.6s ease-in-out;
}

/* Glow Pulse */
@keyframes glowPulse {

    0%,
    100% {
        box-shadow: 0 0 5px var(--color-primary),
            0 0 10px var(--color-primary);
    }

    50% {
        box-shadow: 0 0 10px var(--color-primary),
            0 0 20px var(--color-primary),
            0 0 30px var(--color-primary);
    }
}

.glow-pulse {
    animation: glowPulse 2s ease-in-out infinite;
}

/* Rotate Animation */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.rotate {
    animation: rotate 2s linear infinite;
}

/* Fade In Up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.5s ease-out;
}

/* Fade In Down */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-down {
    animation: fadeInDown 0.5s ease-out;
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.scale-in {
    animation: scaleIn 0.3s ease-out;
}

/* Slide In Right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.4s ease-out;
}

/* Slide In Left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-left {
    animation: slideInLeft 0.4s ease-out;
}

/* Number Counter Animation */
@keyframes numberCount {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.number-count {
    animation: numberCount 0.3s ease-out;
}

/* Confetti Effect (for rewards) */
@keyframes confetti {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti {
    animation: confetti 3s ease-out forwards;
}

/* Ripple Effect */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }

    100% {
        transform: scale(4);
        opacity: 0;
    }
}

.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: hsla(0, 0%, 100%, 0.5);
    transform: translate(-50%, -50%);
    animation: ripple 0.6s ease-out;
}

/* Progress Bar Fill Animation */
@keyframes progressFill {
    from {
        width: 0%;
    }
}

.progress-fill-animate {
    animation: progressFill 1s ease-out;
}

/* Notification Slide In */
@keyframes notificationSlide {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification-slide {
    animation: notificationSlide 0.4s ease-out;
}

/* Modal Backdrop Fade */
@keyframes backdropFade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.backdrop-fade {
    animation: backdropFade 0.3s ease-out;
}

/* Hover Effects */
.hover-lift {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.hover-glow {
    transition: box-shadow var(--transition-base);
}

.hover-glow:hover {
    box-shadow: var(--shadow-glow);
}

.hover-scale {
    transition: transform var(--transition-base);
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* Loading Spinner */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Skeleton Loading */
@keyframes skeleton {
    0% {
        background-position: -200px 0;
    }

    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.skeleton {
    background: linear-gradient(90deg,
            var(--bg-tertiary) 0px,
            var(--bg-elevated) 40px,
            var(--bg-tertiary) 80px);
    background-size: 200px 100%;
    animation: skeleton 1.5s infinite;
}

/* Particle Effect */
@keyframes particle {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

.particle {
    animation: particle 1s ease-out forwards;
}

/* Success Checkmark Animation */
@keyframes checkmark {
    0% {
        stroke-dashoffset: 100;
    }

    100% {
        stroke-dashoffset: 0;
    }
}

.checkmark {
    stroke-dasharray: 100;
    animation: checkmark 0.6s ease-out forwards;
}

/* Stagger Animation Delays */
.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;
}

/* Utility Animation Classes */
.animate-once {
    animation-iteration-count: 1;
}

.animate-infinite {
    animation-iteration-count: infinite;
}

.animate-fast {
    animation-duration: 0.3s;
}

.animate-slow {
    animation-duration: 1s;
}

/* 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;
    }
}