/* ===== 动画系统 ===== */

/* 脉冲呼吸 */
@keyframes dp-pulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(108,92,231,0.35); }
    50% { box-shadow: 0 4px 24px rgba(108,92,231,0.55); }
}

/* 弹出 */
@keyframes dp-pop {
    0% { transform: scale(0.8); opacity: 0; }
    60% { transform: scale(1.08); }
    100% { transform: scale(1); opacity: 1; }
}

/* 卡片翻转 */
@keyframes dp-card-flip {
    0% { transform: translateY(16px) scale(0.9); opacity: 0; }
    60% { transform: translateY(-4px) scale(1.02); }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* 麦克风录音脉冲 */
@keyframes dp-mic-pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* 向上滑入 */
@keyframes dp-slide-up {
    from { transform: translateY(24px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* 逐字淡入 */
@keyframes dp-char-fade {
    0% { opacity: 0; transform: translateY(8px); }
    60% { transform: translateY(-2px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* 连击闪烁 */
@keyframes dp-combo-flash {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* 升级光弧 */
@keyframes dp-levelup-glow {
    0% { box-shadow: 0 0 0 0 rgba(255,215,0,0.5); }
    50% { box-shadow: 0 0 40px 16px rgba(255,215,0,0.25); }
    100% { box-shadow: 0 0 0 0 rgba(255,215,0,0); }
}

/* 评级字母出现 */
@keyframes dp-rating-appear {
    0% { transform: scale(0) rotate(-15deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(3deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* 护眼模式动画降级 */
[data-theme="eye"] .dp-mic-btn.recording .dp-mic-ring {
    animation: none;
    opacity: 0.4;
}
[data-theme="eye"] .dp-dot.active {
    animation: none;
}
[data-theme="eye"] .dp-start-btn::after {
    animation: none;
    display: none;
}
[data-theme="eye"] .dp-rating-badge.SSS {
    animation: dp-rating-appear 0.5s ease;
}
/* ===== 浮动小精灵 ===== */
.dp-mascot-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 50;
    pointer-events: none;
    width: 60px;
    height: 60px;
    opacity: 1;
}
.dp-mascot-container.visible {
    opacity: 1;
}
.dp-mascot-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* 3D 猫 canvas 适配 */
.dp-mascot-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    /* drop-shadow removed: caused ghost */
}
.mascot-panda-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(0,0,0,0.15));
    transform-origin: center;
    animation: mascot-float 4s ease-in-out infinite;
    transition: transform 0.3s ease, filter 0.3s ease;
}
@keyframes mascot-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}
/* 情绪状态 */
.dp-mascot-happy .mascot-panda-img {
    animation: mascot-jump 0.5s ease, mascot-float 4s ease-in-out infinite;
    filter: drop-shadow(0 0 12px rgba(34,197,94,0.3));
}
.dp-mascot-sad .mascot-panda-img {
    transform: rotate(-4deg) scale(0.95);
    filter: drop-shadow(0 0 8px rgba(0,0,0,0.15)) brightness(0.85);
    animation: mascot-shake 0.4s ease;
}
/* 小精灵情绪动画 */
@keyframes mascot-jump {
    0% { transform: translateY(0) scale(1); }
    30% { transform: translateY(-16px) scale(1.1); }
    50% { transform: translateY(-18px) scale(1.05); }
    70% { transform: translateY(-8px) scale(0.98); }
    100% { transform: translateY(0) scale(1); }
}
@keyframes mascot-shake {
    0%, 100% { transform: translateX(0) rotate(-4deg); }
    20% { transform: translateX(-5px) rotate(-8deg); }
    40% { transform: translateX(5px) rotate(0deg); }
    60% { transform: translateX(-3px) rotate(-6deg); }
    80% { transform: translateX(3px) rotate(-2deg); }
}
@keyframes mascot-pop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.3); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}
.dp-mascot-pop { animation: mascot-pop 0.3s ease forwards; }

/* ===== 题目过渡动画 ===== */
.dp-question-area {
    transition: opacity 0s;
}
.dp-question-area.exit-left {
    animation: q-exit-left 0.25s ease forwards;
}
.dp-question-area.exit-right {
    animation: q-exit-right 0.25s ease forwards;
}
.dp-question-area.enter-left {
    animation: q-enter-left 0.3s ease forwards;
}
.dp-question-area.enter-right {
    animation: q-enter-right 0.3s ease forwards;
}
@keyframes q-exit-left {
    0% { opacity: 1; transform: translateX(0) scale(1); }
    100% { opacity: 0; transform: translateX(-40px) scale(0.95); }
}
@keyframes q-exit-right {
    0% { opacity: 1; transform: translateX(0) scale(1); }
    100% { opacity: 0; transform: translateX(40px) scale(0.95); }
}
@keyframes q-enter-left {
    0% { opacity: 0; transform: translateX(-40px) scale(0.95); }
    60% { opacity: 1; transform: translateX(4px) scale(1.01); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes q-enter-right {
    0% { opacity: 0; transform: translateX(40px) scale(0.95); }
    60% { opacity: 1; transform: translateX(-4px) scale(1.01); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}

/* ===== 关卡进度环 ===== */
.dp-level-ring-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
    position: relative;
}
.dp-level-ring {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}
.dp-level-ring .ring-bg {
    fill: none;
    stroke: rgba(255,255,255,0.08);
    stroke-width: 3;
}
.dp-level-ring .ring-fg {
    fill: none;
    stroke: var(--accent-purple);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 88; /* circumference = 2*pi*14 ≈ 88 */
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke-dashoffset 0.6s ease;
}
.dp-level-ring .ring-text {
    font-size: 10px;
    font-weight: 700;
    fill: var(--text-primary);
    dominant-baseline: central;
    text-anchor: middle;
}
/* 升级流光 */
.dp-level-ring.level-up .ring-fg {
    filter: url(#glow);
    animation: ring-levelup 0.8s ease;
}
@keyframes ring-levelup {
    0% { stroke-dashoffset: 88; }
    50% { stroke: #f59e0b; }
    100% { stroke-dashoffset: var(--target-offset, 0); }
}

/* ===== 分数弹出粒子 ===== */
.dp-score-burst {
    position: fixed;
    pointer-events: none;
    z-index: 9998;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-green);
    animation: score-burst 0.8s ease forwards;
}
.dp-score-burst.burst-low {
    color: var(--accent-orange);
}
@keyframes score-burst {
    0% { opacity: 1; transform: translateY(0) scale(0.5); }
    50% { opacity: 1; transform: translateY(-40px) scale(1.2); }
    100% { opacity: 0; transform: translateY(-80px) scale(0.8); }
}

/* 评级大徽章 */
.dp-big-badge {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 9997;
    width: 120px;
    height: 120px;
    pointer-events: none;
    opacity: 0;
}
.dp-big-badge.show {
    animation: badge-appear 0.6s ease forwards;
}
@keyframes badge-appear {
    0% { transform: translate(-50%, -50%) scale(0) rotate(-15deg); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.15) rotate(3deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 0.9; }
}
.dp-big-badge-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 40%, var(--badge-glow) 0%, transparent 65%),
                conic-gradient(from 0deg, var(--badge-color) 0%, var(--badge-color) 100%);
    box-shadow: 0 0 40px var(--badge-glow), inset 0 0 20px rgba(255,255,255,0.3);
    animation: badge-ring-spin 4s linear infinite;
}
@keyframes badge-ring-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.dp-big-badge-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-align: center;
    z-index: 2;
}
.dp-big-badge-label {
    font-size: 42px;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 2px 8px rgba(0,0,0,0.4), 0 0 12px var(--badge-glow);
    letter-spacing: 1px;
}
.dp-big-badge-text {
    font-size: 13px;
    font-weight: 700;
    margin-top: 4px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
    opacity: 0.95;
}
@media (max-width: 480px) {
    .dp-big-badge-label { font-size: 32px; }
    .dp-big-badge-text { font-size: 11px; }
}

/* 连击火焰效果增强 */
.dp-combo.fire {
    animation: combo-fire 0.5s ease;
}
@keyframes combo-fire {
    0% { box-shadow: 0 0 0 rgba(255,165,0,0); }
    50% { box-shadow: 0 0 30px 8px rgba(255,165,0,0.3); }
    100% { box-shadow: 0 0 0 rgba(255,165,0,0); }
}

/* 移动端调整 */
@media (max-width: 480px) {
    .dp-mascot-container {
        bottom: 16px;
        right: 16px;
        width: 46px;
        height: 46px;
    }
    .dp-level-ring {
        width: 30px;
        height: 30px;
    }
    .dp-big-badge {
        width: 90px;
        height: 90px;
    }
}

/* 3D精灵容器覆盖 - 桌面端 */
.dp-mascot-container {
    bottom: 6px;
    right: 6px;
    width: 200px;
    height: 200px;
}
.dp-mascot-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}
/* 移动端 */
@media (max-width: 480px) {
    .dp-mascot-container {
        bottom: 6px;
        right: 6px;
        width: 150px;
        height: 150px;
    }
}
