/* Animations - Dao of the Endless Sky */
/* PROMPT 15: Comprehensive Animation System & Polish */

/* ========== CORE ANIMATIONS ========== */

/* Fade In */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease;
}

#tab-content {
    animation: fadeIn 0.4s ease;
}

/* Button pulse on click */
@keyframes pulse {
    0%, 100% { 
        transform: scale(1); 
    }
    50% { 
        transform: scale(1.08); 
        box-shadow: 0 0 25px rgba(255, 215, 0, 0.8); 
    }
}

.btn:active,
.btn-primary:active,
.btn-cultivate:active,
.btn-train-skill:active,
.btn-craft:active,
.btn-gather:active {
    animation: pulse 0.3s ease;
}

/* Floating numbers */
@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    50% {
        opacity: 1;
        transform: translateY(-30px) scale(1.2);
    }
    100% {
        transform: translateY(-80px) scale(0.8);
        opacity: 0;
    }
}

.floating-number {
    position: fixed;
    font-size: 1.5em;
    font-weight: bold;
    pointer-events: none;
    animation: floatUp 1.5s ease-out forwards;
    z-index: 10000;
    text-shadow: 
        0 0 10px currentColor,
        0 2px 6px rgba(0, 0, 0, 1);
}

.floating-number.exp { 
    color: #b370c9;
    text-shadow: 
        0 0 10px rgba(179, 112, 201, 0.8),
        0 0 20px rgba(179, 112, 201, 0.4),
        0 2px 6px rgba(0, 0, 0, 1);
}
.floating-number.damage { 
    color: #ff4444;
    text-shadow: 
        0 0 10px rgba(255, 68, 68, 0.8),
        0 2px 6px rgba(0, 0, 0, 1);
}
.floating-number.heal { 
    color: #66ff66;
    text-shadow: 
        0 0 10px rgba(102, 255, 102, 0.8),
        0 2px 6px rgba(0, 0, 0, 1);
}
.floating-number.gold { 
    color: #f39c12;
    text-shadow: 
        0 0 10px rgba(243, 156, 18, 0.8),
        0 0 20px rgba(243, 156, 18, 0.4),
        0 2px 6px rgba(0, 0, 0, 1);
}

/* Level up flash */
@keyframes levelUpFlash {
    0%, 100% { 
        background-color: rgba(255, 215, 0, 0); 
    }
    50% { 
        background-color: rgba(255, 215, 0, 0.6); 
    }
}

body.level-up-flash::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 215, 0, 0.6);
    pointer-events: none;
    z-index: 9999;
    animation: levelUpFlash 0.6s ease 2;
}

/* Progress bar glow when near full */
@keyframes barGlow {
    0%, 100% { 
        box-shadow: 0 0 8px rgba(255, 215, 0, 0.4); 
    }
    50% { 
        box-shadow: 0 0 25px rgba(255, 215, 0, 1),
                    0 0 40px rgba(255, 215, 0, 0.6); 
    }
}

.bar-fill.glowing,
.progress-fill.glowing {
    animation: barGlow 1.5s infinite;
}

/* Skill card level up shimmer */
@keyframes shimmer {
    0% { 
        background-position: -1000px 0; 
    }
    100% { 
        background-position: 1000px 0; 
    }
}

.skill-card.level-up {
    position: relative;
    overflow: hidden;
}

.skill-card.level-up::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 215, 0, 0.4) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shimmer 1.5s ease forwards;
    pointer-events: none;
}

/* Equipment glow by tier */
@keyframes tierGlowRare {
    0%, 100% { 
        box-shadow: 0 0 5px rgba(65, 105, 225, 0.5); 
    }
    50% { 
        box-shadow: 0 0 20px rgba(65, 105, 225, 1),
                    0 0 30px rgba(65, 105, 225, 0.5); 
    }
}

@keyframes tierGlowEpic {
    0%, 100% { 
        box-shadow: 0 0 5px rgba(147, 112, 219, 0.5); 
    }
    50% { 
        box-shadow: 0 0 25px rgba(147, 112, 219, 1),
                    0 0 35px rgba(147, 112, 219, 0.5); 
    }
}

@keyframes tierGlowLegendary {
    0%, 100% { 
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.6); 
    }
    50% { 
        box-shadow: 0 0 30px rgba(255, 215, 0, 1),
                    0 0 50px rgba(255, 215, 0, 0.6); 
    }
}

.equipment-item.tier-rare { 
    animation: tierGlowRare 2s infinite; 
}

.equipment-item.tier-epic { 
    animation: tierGlowEpic 2s infinite; 
}

.equipment-item.tier-legendary { 
    animation: tierGlowLegendary 2s infinite; 
}

.equipped-item.tier-rare {
    animation: tierGlowRare 2s infinite;
}

.equipped-item.tier-epic {
    animation: tierGlowEpic 2s infinite;
}

.equipped-item.tier-legendary {
    animation: tierGlowLegendary 2s infinite;
}

/* Button hover lift */
.btn,
.btn-primary,
.btn-secondary,
.btn-train-skill,
.btn-craft,
.btn-gather,
.btn-attack,
.btn-breakthrough,
.btn-equip-item,
.btn-cultivate {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:hover:not(:disabled),
.btn-primary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled),
.btn-train-skill:hover:not(:disabled),
.btn-craft:hover:not(:disabled),
.btn-gather:hover:not(:disabled),
.btn-attack:hover:not(:disabled),
.btn-breakthrough:hover:not(:disabled),
.btn-equip-item:hover:not(:disabled),
.btn-cultivate:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.5);
}

/* Loading spinner */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffd700;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* Shake on error */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.shake {
    animation: shake 0.4s ease;
}

/* Bounce effect */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.bounce {
    animation: bounce 0.5s ease;
}

/* Resource gain pulse */
@keyframes resourcePulse {
    0%, 100% { 
        transform: scale(1); 
        color: inherit;
    }
    50% { 
        transform: scale(1.2); 
        color: #00ff00; 
    }
}

.resource-value.gain,
.resource-counter.gain {
    animation: resourcePulse 0.5s ease;
}

/* Item sparkle */
@keyframes sparkle {
    0%, 100% { 
        opacity: 0; 
        transform: scale(0.5) rotate(0deg); 
    }
    50% { 
        opacity: 1; 
        transform: scale(1.2) rotate(180deg); 
    }
}

.item-sparkle::after {
    content: '✨';
    position: absolute;
    top: -5px;
    right: -5px;
    animation: sparkle 1.5s infinite;
    pointer-events: none;
}

/* Hit flash */
@keyframes hitFlash {
    0%, 100% { 
        filter: brightness(1); 
    }
    50% { 
        filter: brightness(2) drop-shadow(0 0 15px red); 
    }
}

.hit,
.enemy-display.hit {
    animation: hitFlash 0.3s ease;
}

/* Card flip animation */
@keyframes cardFlipIn {
    0% {
        transform: perspective(1000px) rotateY(90deg);
        opacity: 0;
    }
    100% {
        transform: perspective(1000px) rotateY(0);
        opacity: 1;
    }
}

.skill-card.new-unlock,
.new-unlock {
    animation: cardFlipIn 0.6s ease;
}

/* Achievement slide */
@keyframes slideInRight {
    from { 
        transform: translateX(400px); 
        opacity: 0; 
    }
    to { 
        transform: translateX(0); 
        opacity: 1; 
    }
}

@keyframes slideOutRight {
    from { 
        transform: translateX(0); 
        opacity: 1; 
    }
    to { 
        transform: translateX(400px); 
        opacity: 0; 
    }
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

.slide-out-right {
    animation: slideOutRight 0.5s ease-out forwards;
}

/* Crafting progress */
@keyframes craftingProgress {
    from { width: 0%; }
    to { width: 100%; }
}

.crafting-progress-bar {
    height: 4px;
    background: linear-gradient(90deg, #4CAF50, #2196F3);
    border-radius: 2px;
    animation: craftingProgress var(--craft-time, 2s) linear;
}

/* 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;
    }
}
