/* Animations - 动画效果 */

/* ============ 淡入动画 ============ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

.fade-in {
    animation: fadeIn var(--transition-base) ease-out;
}

.fade-out {
    animation: fadeOut var(--transition-base) ease-out;
}

/* ============ 5星特效 ============ */
@keyframes goldShine {
    0%, 100% {
        box-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(251, 191, 36, 0.6), 0 0 60px rgba(251, 191, 36, 0.4);
    }
}

.result-item.rarity-5 {
    animation: goldShine 2s ease-in-out infinite;
}

/* ============ 4星特效 ============ */
@keyframes purpleGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
    }
    50% {
        box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
    }
}

.result-item.rarity-4 {
    animation: purpleGlow 2s ease-in-out infinite;
}

/* ============ 卡片翻转动画 ============ */
@keyframes cardFlip {
    0% {
        transform: rotateY(0deg) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: rotateY(90deg) scale(1);
        opacity: 0.5;
    }
    100% {
        transform: rotateY(0deg) scale(1);
        opacity: 1;
    }
}

.result-item.new {
    animation: cardFlip 0.6s ease-out;
}

/* ============ 按钮点击反馈 ============ */
@keyframes buttonPress {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

.gacha-btn:active:not(:disabled) {
    animation: buttonPress 0.2s ease-out;
}

/* ============ 保底进度条动画 ============ */
.pity-progress {
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ 加载动画 ============ */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============ 页面切换动画 ============ */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.page.active {
    animation: slideIn 0.3s ease-out;
}

/* ============ Toast 动画 ============ */
.toast.show {
    animation: toastIn 0.3s ease-out;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(100px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ============ 数据卡片数字滚动 ============ */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-value.updating {
    animation: countUp 0.4s ease-out;
}

/* ============ 脉冲效果 ============ */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

.pulse {
    animation: pulse 1s ease-in-out infinite;
}

/* ============ 摇晃效果 ============ */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.3s ease-in-out;
}

/* ============ 减少动画(用户偏好) ============ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
