/* animations.css - 所有@keyframes和动画类 */

@keyframes syncPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.word-card.animate-enter {
    animation: cardEnter 0.4s var(--ease-out-quart) forwards;
    opacity: 0;
}

@keyframes masteryCelebrate {
    0% { transform: scale(1); }
    30% { transform: scale(1.3) rotate(10deg); }
    60% { transform: scale(1.2) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes greenGlow {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    45% { transform: translate3d(0, -5px, 0) scale(1.012); }
    100% { transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes checkmarkPop {
    0% { transform: scale(0) rotate(-45deg); }
    50% { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes greenPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.08); opacity: 0.92; }
    100% { transform: scale(1); opacity: 1; }
}

.word-card.celebrating {
    animation: greenGlow 0.34s var(--ease-out-quart);
}

.mastery-checkbox-custom.celebrating {
    animation: checkmarkPop 0.32s var(--ease-out-quart), greenPulse 0.2s var(--ease-out-expo);
}

.toast-notification,
.combo-toast {
    position: fixed;
    top: 76px;
    left: 50%;
    transform: translate(-50%, 0) scale(0.96);
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.14);
    padding: 10px 14px;
    border-radius: 999px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.22);
    max-width: min(92vw, 560px);
    width: fit-content;
    z-index: 9999;
    pointer-events: none;
    animation: comboPopIn 0.8s var(--ease-out-expo) forwards;
    display: flex;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
}

.toast-notification.toast-singleline .toast-message,
.combo-toast {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toast-notification.toast-multiline {
    align-items: flex-start;
}

.toast-notification.toast-multiline .toast-message {
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.35;
    max-height: calc(1.35em * 2);
}

.toast-notification.toast-info {
    border-color: rgba(96, 165, 250, 0.38);
}

.toast-notification.toast-warning {
    border-color: rgba(251, 191, 36, 0.42);
}

.toast-notification.toast-error {
    border-color: rgba(251, 113, 133, 0.42);
}

@keyframes comboPopIn {
    0% { transform: translate(-50%, 0) scale(0.9); opacity: 0; }
    60% { transform: translate(-50%, 0) scale(1.03); opacity: 1; }
    100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

.toast-notification.out,
.combo-toast.out {
    animation: comboOut 220ms ease forwards;
}

@keyframes comboOut {
    from { opacity: 1; transform: translate(-50%, 0) scale(1); }
    to { opacity: 0; transform: translate(-50%, -6px) scale(0.98); }
}

/* --- 3. 按钮交互反馈 --- */
.btn {
    transition: transform 0.15s var(--ease-out-quart), 
                box-shadow 0.15s ease,
                background-position 0.3s ease;
}

.btn:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: scale(0.97);
}

/* 加载状态 - 渐变流动 */
.btn.loading {
    background: linear-gradient(90deg, #1e293b 0%, #334155 50%, #1e293b 100%);
    background-size: 200% 100%;
    animation: gradientFlow 1.5s ease infinite;
    pointer-events: none;
}

@keyframes gradientFlow {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* --- 4. 语音播放视觉联动 --- */
@keyframes audioRipple {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

@keyframes audioPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

.btn-audio.playing {
    animation: audioPulse 0.6s ease-in-out infinite;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

.btn-audio .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.3);
    animation: audioRipple 0.8s ease-out forwards;
    pointer-events: none;
}

/* --- 5. 统计数字动画 --- */
@keyframes numberFlash {
    0% { color: inherit; }
    50% { color: #f59e0b; text-shadow: 0 0 8px rgba(245, 158, 11, 0.5); }
    100% { color: inherit; }
}

.stats-bar .flash {
    animation: numberFlash 0.5s ease;
}

/* 数字滚动容器 */
.stat-number {
    display: inline-block;
    transition: transform 0.3s var(--ease-out-quart);
}

/* --- 6. 新批次加载过渡 --- */
@keyframes cardExit {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-15px);
    }
}

.word-card.animate-exit {
    animation: cardExit 0.25s var(--ease-out-quart) forwards;
}

/* 加载进度条 */
.loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #2563eb, #16a34a);
    z-index: 10001;
    animation: loadingProgress 1s ease-in-out;
}

@keyframes loadingProgress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; opacity: 0; }
}

/* --- 7. 激活成功庆祝 --- */
@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: 0;
    z-index: 10000;
    pointer-events: none;
    animation: confettiFall 3s ease-in-out forwards;
}

@keyframes successTextPop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.success-message {
    animation: successTextPop 0.5s var(--ease-out-expo);
}

/* --- 无障碍：尊重减少动画偏好 --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
