/* ===== 动画效果 ===== */

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes modalIn {
    from {
        transform: scale(0.9) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(88,166,255,0.3); }
    50% { box-shadow: 0 0 20px rgba(88,166,255,0.6); }
}

@keyframes floatUp {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-40px); opacity: 0; }
}

@keyframes levelUp {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

@keyframes starSpin {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.2); }
    100% { transform: rotate(360deg) scale(1); }
}

/* ===== 应用动画的类 ===== */
.animate-fade-in {
    animation: fadeIn 0.3s ease forwards;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-bounce {
    animation: bounce 1s ease-in-out infinite;
}

.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

.animate-level-up {
    animation: levelUp 0.5s ease;
}

/* ===== 宠物卡片动画 ===== */
.pet-card {
    animation: fadeIn 0.3s ease forwards;
}

.pet-card:nth-child(1) { animation-delay: 0.05s; }
.pet-card:nth-child(2) { animation-delay: 0.1s; }
.pet-card:nth-child(3) { animation-delay: 0.15s; }
.pet-card:nth-child(4) { animation-delay: 0.2s; }
.pet-card:nth-child(5) { animation-delay: 0.25s; }

/* ===== 稀有度光效 ===== */
.rarity-legendary .pet-avatar {
    animation: starSpin 3s ease-in-out infinite;
    filter: drop-shadow(0 0 8px rgba(255,166,87,0.8));
}

.rarity-epic .pet-avatar {
    filter: drop-shadow(0 0 6px rgba(188,140,255,0.6));
}

.rarity-rare .pet-avatar {
    filter: drop-shadow(0 0 4px rgba(88,166,255,0.5));
}

/* ===== 进度条动画 ===== */
.progress-fill {
    animation: none;
}

.progress-fill.active {
    background: linear-gradient(90deg, 
        var(--accent-green) 0%, 
        #4ade80 50%, 
        var(--accent-green) 100%);
    background-size: 200% 100%;
    animation: shimmer 2s linear infinite;
}

/* ===== 战斗动画 ===== */
.battle-hit {
    animation: pulse 0.3s ease;
}

.battle-victory {
    animation: bounce 0.5s ease;
}

/* ===== 科技节点动画 ===== */
.tech-node.available {
    animation: glow 2s ease-in-out infinite;
}

.tech-node.researched .tech-node-icon {
    animation: none;
}

/* ===== 通知动画 ===== */
.notification.removing {
    animation: slideOutRight 0.3s ease forwards;
}

/* ===== 浮动数字 ===== */
.float-number {
    position: fixed;
    font-size: 16px;
    font-weight: 700;
    pointer-events: none;
    z-index: 9999;
    animation: floatUp 1.5s ease forwards;
}

.float-number.positive { color: var(--accent-green); }
.float-number.negative { color: var(--accent-red); }
.float-number.exp { color: var(--accent-blue); }
.float-number.gold { color: var(--accent-yellow); }

/* ===== 建筑建造动画 ===== */
.building-card.building {
    animation: pulse 1s ease-in-out infinite;
}

/* ===== 探索动画 ===== */
.explore-card.exploring .explore-icon {
    animation: bounce 1s ease-in-out infinite;
}

/* ===== 繁衍动画 ===== */
.breed-heart {
    animation: heartbeat 1.5s ease-in-out infinite;
}

.breed-heart.active {
    animation: heartbeat 0.5s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(255,100,150,0.8));
}

/* ===== 成就解锁动画 ===== */
.achievement-card.just-unlocked {
    animation: glow 0.5s ease 3;
    border-color: var(--accent-yellow);
}

/* ===== 资源变化动画 ===== */
.resource.changed {
    animation: pulse 0.5s ease;
}

/* ===== 加载动画 ===== */
.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

/* ===== 工具提示 ===== */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius);
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    box-shadow: var(--shadow);
}

/* ===== 粒子效果容器 ===== */
.particle-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
    overflow: hidden;
}

.particle {
    position: absolute;
    font-size: 20px;
    animation: floatUp 2s ease forwards;
    pointer-events: none;
}

/* ===== Modal slide-up animation for mobile ===== */
@keyframes modalSlideUp {
    from {
        transform: translateY(100%);
        opacity: 0.5;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===== Disable animations when user opts out ===== */
body.no-animations *,
body.no-animations *::before,
body.no-animations *::after {
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
}
