/* 全局学习助手样式 */
.learning-assistant {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 100px;
    height: 100px;
    cursor: grab;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(255, 94, 98, 0.4);
    transition: box-shadow 0.3s ease, transform 0.15s ease;
    animation: float 3s ease-in-out infinite;
    border-radius: 50%;
    display: none;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.learning-assistant.dragging {
    cursor: grabbing;
    animation: none;
    transition: none;
    opacity: 0.9;
    box-shadow: 0 8px 32px rgba(255, 94, 98, 0.55);
}

.learning-assistant:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(255, 94, 98, 0.6);
}

.learning-assistant.dragging:hover {
    transform: none;
}

/* ===== Mode Styles ===== */
.learning-assistant.mode-study {
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4);
    animation: floatStudy 3s ease-in-out infinite;
}
.learning-assistant.mode-study:hover {
    box-shadow: 0 6px 25px rgba(0, 212, 255, 0.6);
}
.learning-assistant.mode-study.dragging {
    box-shadow: 0 8px 32px rgba(0, 212, 255, 0.55);
}

.learning-assistant.mode-game {
    box-shadow: 0 4px 20px rgba(255, 107, 53, 0.4);
    animation: floatGame 1.5s ease-in-out infinite;
}
.learning-assistant.mode-game:hover {
    box-shadow: 0 6px 25px rgba(255, 107, 53, 0.6);
}
.learning-assistant.mode-game.dragging {
    box-shadow: 0 8px 32px rgba(255, 107, 53, 0.55);
}

.learning-assistant.mode-music {
    box-shadow: 0 4px 20px rgba(168, 85, 247, 0.4);
}
.learning-assistant.mode-music:hover {
    box-shadow: 0 6px 25px rgba(168, 85, 247, 0.6);
}
.learning-assistant.mode-music.dragging {
    box-shadow: 0 8px 32px rgba(168, 85, 247, 0.55);
}

.assistant-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

/* 添加助手昵称样式 */
.assistant-name {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 200, 255, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    z-index: 10000;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    height: 32px; /* 增加高度 */
    box-sizing: border-box;
    border: 2px solid rgba(255, 255, 255, 0.3); /* 添加白色边框增强视觉效果 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* 添加阴影增强立体感 */
    backdrop-filter: blur(5px); /* 毛玻璃效果 */
    transition: all 0.3s ease; /* 添加过渡动画 */
}

/* 鼠标悬停效果 */
.assistant-name:hover {
    background: rgba(0, 162, 255, 0.9);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.assistant-speech-bubble {
    position: fixed;
    background: white;
    color: #333;
    padding: 15px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    max-width: 200px;
    font-size: 16px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    display: none;
}

/* 默认箭头在气泡右侧（气泡在助手左侧） */
.assistant-speech-bubble::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: -8px;
    border-width: 8px 0 8px 8px;
    border-style: solid;
    border-color: transparent transparent transparent white;
}

/* 箭头在气泡左侧（气泡在助手右侧） */
.assistant-speech-bubble[data-arrow="left"]::after {
    right: auto;
    left: -8px;
    border-width: 8px 8px 8px 0;
    border-color: transparent white transparent transparent;
}

/* 箭头在气泡顶部（气泡在助手下方） */
.assistant-speech-bubble[data-arrow="top"]::after {
    top: -8px;
    right: auto;
    left: 20px;
    transform: none;
    border-width: 0 8px 8px 8px;
    border-color: transparent transparent white transparent;
}

.assistant-speech-bubble.show {
    opacity: 1;
    transform: translateY(0);
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes floatStudy {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

@keyframes floatGame {
    0%, 100% { transform: translateY(0px) scale(1); }
    50% { transform: translateY(-6px) scale(1.05); }
}

/* 音乐节拍跳动 */
@keyframes musicBounce {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    15% {
        transform: translateY(-18px) scale(1.15);
    }
    30% {
        transform: translateY(0) scale(1);
    }
}

/* 音乐粒子 */
.music-note-particle {
    position: fixed;
    font-size: 20px;
    pointer-events: none;
    z-index: 10002;
    animation: noteFloat 1.5s ease-out forwards;
}

@keyframes noteFloat {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(0.5) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translate(var(--nx), var(--ny)) scale(1.2) rotate(var(--nr));
    }
}

/* 学习助手设置页面样式 */
.animal-selection {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 10px;
}

.animal-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(0, 0, 0, 0.1);
}

.animal-option:hover {
    border-color: var(--primary);
    background: rgba(0, 247, 255, 0.1);
    transform: translateY(-2px);
}

.animal-option.selected {
    border-color: var(--primary);
    background: rgba(0, 247, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 247, 255, 0.3);
}

.animal-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
}

.animal-icon.placeholder {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.animal-option span {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

/* 庆祝旋转跳跃动画 */
@keyframes celebrateJump {
    0% {
        transform: rotate(0deg) scale(1) translateY(0);
    }
    30% {
        transform: rotate(180deg) scale(1.3) translateY(-20px);
    }
    60% {
        transform: rotate(360deg) scale(1.1) translateY(-10px);
    }
    100% {
        transform: rotate(360deg) scale(1) translateY(0);
    }
}

.learning-assistant.celebrating {
    animation: var(--celebrate-anim, celebrateJump) 0.6s ease-out;
    pointer-events: none;
}

.learning-assistant.celebrating:hover {
    transform: none;
}

/* 环形进度条 */
.assistant-progress-ring {
    position: absolute;
    top: -6px;
    left: -6px;
    width: calc(100% + 12px);
    height: calc(100% + 12px);
    pointer-events: none;
    z-index: 2;
    transform: rotate(90deg);
    display: none;
}

.assistant-progress-ring.show {
    display: block;
}

.progress-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 2.5;
}

.light-theme .progress-ring-bg {
    stroke: rgba(0, 0, 0, 0.06);
}

.progress-ring-fill {
    fill: none;
    stroke: url(#progressGradient);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-dasharray: 276.46;
    stroke-dashoffset: 276.46;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 0 4px rgba(0, 247, 255, 0.4));
}

.progress-ring-fill.complete {
    filter: drop-shadow(0 0 8px rgba(0, 247, 255, 0.5))
            drop-shadow(0 0 20px rgba(0, 247, 255, 0.3));
    animation: ringPulse 2s ease-in-out infinite;
}

@keyframes ringPulse {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(0, 247, 255, 0.5))
                drop-shadow(0 0 20px rgba(0, 247, 255, 0.3));
    }
    50% {
        filter: drop-shadow(0 0 14px rgba(0, 247, 255, 0.7))
                drop-shadow(0 0 32px rgba(0, 247, 255, 0.45))
                drop-shadow(0 0 48px rgba(128, 0, 255, 0.25));
    }
}

/* 庆祝粒子 */
.celebrate-particle {
    position: fixed;
    font-size: 24px;
    pointer-events: none;
    z-index: 10001;
    animation: particleFly 1s ease-out forwards;
}

@keyframes particleFly {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--dx), var(--dy)) scale(0);
    }
}

/* 上下弹跳3次 */
@keyframes celebrateBounce {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    16% {
        transform: translateY(-20px) scale(1.15);
    }
    33% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-15px) scale(1.1);
    }
    66% {
        transform: translateY(0) scale(1);
    }
    83% {
        transform: translateY(-8px) scale(1.05);
    }
}

/* 左右翻转 */
@keyframes celebrateFlip {
    0% {
        transform: rotateY(0deg) scale(1);
    }
    30% {
        transform: rotateY(180deg) scale(1.2);
    }
    100% {
        transform: rotateY(360deg) scale(1);
    }
}

/* 金币飞行动画 */
.coin-particle {
    position: fixed;
    font-size: 28px;
    pointer-events: none;
    z-index: 10002;
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.8));
    animation: coinFly 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes coinFly {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(0.4) rotate(0deg);
    }
    40% {
        opacity: 1;
        transform: translate(var(--coin-mx), var(--coin-my)) scale(1.2) rotate(var(--coin-rot));
    }
    100% {
        opacity: 0;
        transform: translate(var(--coin-ex), var(--coin-ey)) scale(0.1) rotate(var(--coin-rot-end));
    }
}

.coin-spark {
    position: fixed;
    pointer-events: none;
    z-index: 10003;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ffd700;
    animation: sparkFade 0.6s ease-out forwards;
    box-shadow: 0 0 6px #ffd700, 0 0 12px #ffaa00;
}

@keyframes sparkFade {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--sdx), var(--sdy)) scale(0);
    }
}

/* 左右振动3次 */
@keyframes celebrateShake {
    0%, 100% {
        transform: translateX(0);
    }
    12% {
        transform: translateX(-12px);
    }
    25% {
        transform: translateX(12px);
    }
    37% {
        transform: translateX(-8px);
    }
    50% {
        transform: translateX(8px);
    }
    62% {
        transform: translateX(-4px);
    }
    75% {
        transform: translateX(4px);
    }
    87% {
        transform: translateX(-2px);
    }
}
