/* ==================== 青云小墨 v2.0 - 电子宠物样式（增强版） ==================== */

/* 容器定位 */
#ai-mascot-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
}

#ai-mascot-container.minimized {
    transform: scale(0.3);
    opacity: 0;
    pointer-events: none;
}

#ai-mascot-container.minimized .mascot-body {
    animation: none !important;
}

/* 宠物本体 */
.mascot-body {
    position: relative;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 8px 20px rgba(16, 185, 129, 0.35));
    transition: filter 0.3s ease;
}

.mascot-body:hover {
    filter: drop-shadow(0 12px 30px rgba(16, 185, 129, 0.5));
}

/* 身体主体样式 */
.mascot-body-circle {
    fill: #10B981;
    stroke: #059669;
    transition: fill 0.5s ease, stroke 0.5s ease;
}

/* 浮动动画 */
@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-8px) rotate(1deg); }
    50% { transform: translateY(-12px) rotate(0deg); }
    75% { transform: translateY(-8px) rotate(-1deg); }
}

/* 忙碌旋转动画 */
.mascot-body.busy {
    animation: spin 1.2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 开心跳跃动画 */
.mascot-body.happy {
    animation: bounce 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97) 3;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    30% { transform: translateY(-30px) scale(1.1); }
    50% { transform: translateY(-15px) scale(1.05); }
    70% { transform: translateY(-5px) scale(1); }
}

/* 睡眠呼吸动画 */
@keyframes sleepBreathe {
    0%, 100% { transform: scale(1) translateY(0); }
    50% { transform: scale(0.95) translateY(5px); }
}

/* 随机跳跃动画 */
.mascot-body.jumping {
    animation: jump 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes jump {
    0%, 100% { transform: translateY(0) scale(1); }
    20% { transform: translateY(5px) scale(1.1, 0.9); }
    50% { transform: translateY(-25px) scale(0.9, 1.1); }
    80% { transform: translateY(0) scale(1.05, 0.95); }
}

/* 放屁抖动动画 */
.mascot-body.farting {
    animation: fartShake 0.5s ease-in-out;
}

@keyframes fartShake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-5px) rotate(-2deg); }
    20% { transform: translateX(5px) rotate(2deg); }
    30% { transform: translateX(-5px) rotate(-1deg); }
    40% { transform: translateX(5px) rotate(1deg); }
    50% { transform: translateX(-3px); }
    60% { transform: translateX(3px); }
    70% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
    90% { transform: translateX(-1px); }
}

/* 弹弓发射状态 */
.mascot-body.launched {
    filter: drop-shadow(0 0 15px rgba(255, 107, 107, 0.8)) brightness(1.1);
    animation: launchSpin 0.3s linear infinite;
}

@keyframes launchSpin {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(10deg); }
    50% { transform: rotate(0deg); }
    75% { transform: rotate(-10deg); }
    100% { transform: rotate(0deg); }
}

/* 碰撞抖动 */
.mascot-body.bouncing {
    animation: bounceShake 0.2s ease-out;
}

@keyframes bounceShake {
    0% { transform: scale(1); }
    25% { transform: scale(1.2) rotate(5deg); }
    50% { transform: scale(0.9) rotate(-5deg); }
    75% { transform: scale(1.1) rotate(3deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* 发射状态指示器 */
#ai-mascot-container.launched-mode .mascot-status {
    background: linear-gradient(135deg, #FF6B6B, #FF1493);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
    animation: launchPulse 0.5s ease-in-out infinite;
}

@keyframes launchPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* 眨眼动画 */
.mascot-body.blink .eye ellipse:first-child {
    ry: 1;
    transition: ry 0.15s ease;
}

/* 光晕效果 */
.glow-effect {
    animation: glow 2s ease-in-out infinite;
    transition: fill 0.5s ease;
}

@keyframes glow {
    0%, 100% { opacity: 0.3; r: 75; }
    50% { opacity: 0.5; r: 78; }
}

/* 眼睛跟随过渡 */
.pupil {
    transition: transform 0.15s ease-out;
}

/* 嘴巴动画 */
.mouth {
    transition: d 0.3s ease;
}

/* ==================== 四肢样式 ==================== */
.arm, .leg {
    transition: color 0.5s ease;
}

.arm-left, .arm-right {
    transform-origin: 100px 100px;
}

.leg-left, .leg-right {
    transform-origin: 100px 100px;
}

/* 爬行时四肢动画 */
.mascot-body.crawling .arm-left {
    animation: crawlArmLeft 0.3s ease-in-out infinite;
}

.mascot-body.crawling .arm-right {
    animation: crawlArmRight 0.3s ease-in-out infinite;
}

.mascot-body.crawling .leg-left {
    animation: crawlLegLeft 0.3s ease-in-out infinite;
}

.mascot-body.crawling .leg-right {
    animation: crawlLegRight 0.3s ease-in-out infinite;
}

@keyframes crawlArmLeft {
    0%, 100% { transform: rotate(-30deg); }
    50% { transform: rotate(30deg); }
}

@keyframes crawlArmRight {
    0%, 100% { transform: rotate(30deg); }
    50% { transform: rotate(-20deg); }
}

@keyframes crawlLegLeft {
    0%, 100% { transform: rotate(15deg); }
    50% { transform: rotate(-15deg); }
}

@keyframes crawlLegRight {
    0%, 100% { transform: rotate(-15deg); }
    50% { transform: rotate(15deg); }
}

/* ==================== 对话气泡 ==================== */
.mascot-bubble {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: white;
    padding: 12px 18px;
    border-radius: 16px;
    margin-bottom: 15px;
    font-size: 14px;
    color: #064E3B;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    border: 1px solid #A7F3D0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 300px;
    white-space: normal;
    text-align: center;
    font-weight: 500;
    letter-spacing: 0.3px;
    direction: ltr; /* 确保文字始终正向显示 */
    writing-mode: horizontal-tb; /* 确保文字水平显示 */
}

.mascot-bubble.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.bubble-tail {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.05));
}

/* ==================== 状态指示器 ==================== */
.mascot-status {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 12px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    font-weight: 600;
    direction: ltr; /* 确保文字始终正向显示 */
    writing-mode: horizontal-tb; /* 确保文字水平显示 */
}

.mascot-status.show {
    opacity: 1;
    transform: scale(1);
}

/* 跑动状态特殊样式 */
#ai-mascot-container.crawling-mode .mascot-status {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    animation: statusPulse 1s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3); }
    50% { box-shadow: 0 4px 20px rgba(245, 158, 11, 0.5); }
}

/* ==================== 控制按钮 ==================== */
.mascot-controls {
    position: absolute;
    top: -5px;
    right: -5px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

#ai-mascot-container:hover .mascot-controls {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.mascot-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: white;
    color: #064E3B;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    padding: 0;
}

.mascot-btn:hover {
    background: #E6FFFA;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.mascot-btn:active {
    transform: scale(0.95);
}

/* 按钮颜色主题 */
.mascot-btn-color:hover {
    background: linear-gradient(135deg, #ff6b6b, #ffd93d, #6bcb77, #4d96ff);
    color: white;
}

.mascot-btn-crawl:hover {
    background: #dcfce7;
    color: #16a34a;
    animation: pulse 0.5s ease-in-out;
}

/* 跑动时按钮特殊样式 */
#ai-mascot-container.crawling-mode .mascot-btn-crawl {
    background: #FCD34D;
    color: #92400E;
    animation: spin 2s linear infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1.1); }
    50% { transform: scale(1.2); }
}

.mascot-btn-firework:hover {
    background: #fef3c7;
    color: #d97706;
}

.mascot-btn-fart:hover {
    background: #fef2f2;
    color: #dc2626;
}

.mascot-btn-launch:hover {
    background: #fce7f3;
    color: #ec4899;
    animation: launchBtnPulse 0.5s ease-in-out;
}

@keyframes launchBtnPulse {
    0%, 100% { transform: scale(1.1); }
    50% { transform: scale(1.3) rotate(15deg); }
}

/* ==================== 睡眠状态样式 ==================== */
.mascot-body.sleeping {
    filter: drop-shadow(0 8px 20px rgba(16, 185, 129, 0.2)) brightness(0.9);
}

.mascot-body.sleeping .eye ellipse:first-child {
    ry: 1;
}

/* ==================== 跑动状态样式 ==================== */
#ai-mascot-container.crawling-mode {
    transition: left 0.03s linear, top 0.03s linear, transform 0.2s ease;
    cursor: grab;
}

#ai-mascot-container.crawling-mode:active {
    cursor: grabbing;
}

/* ==================== 弓箭模式样式 ==================== */
#ai-mascot-container.slingshot-mode {
    transition: left 0.03s linear, top 0.03s linear;
    cursor: grab;
    z-index: 10002;
}

#ai-mascot-container.slingshot-mode:active {
    cursor: grabbing;
}

#ai-mascot-container.slingshot-mode .mascot-body {
    animation: bowPulse 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 15px rgba(255, 165, 0, 0.6));
}

@keyframes bowPulse {
    0%, 100% { 
        transform: scale(1);
        filter: drop-shadow(0 0 15px rgba(255, 165, 0, 0.6));
    }
    25% {
        transform: scale(1.02) rotate(1deg);
        filter: drop-shadow(0 0 20px rgba(255, 100, 0, 0.7));
    }
    50% { 
        transform: scale(1.05);
        filter: drop-shadow(0 0 25px rgba(255, 50, 0, 0.8));
    }
    75% {
        transform: scale(1.02) rotate(-1deg);
        filter: drop-shadow(0 0 20px rgba(255, 100, 0, 0.7));
    }
}

#ai-mascot-container.slingshot-mode .mascot-status {
    background: linear-gradient(135deg, #D4A574, #8B4513, #D2691E);
    background-size: 300% 300%;
    animation: bowStatusShift 3s ease infinite;
    color: #FFF8DC;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 215, 0, 0.5);
}

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

/* 弓箭模式下的气泡样式 */
#ai-mascot-container.slingshot-mode .mascot-bubble {
    border-color: #D4A574;
    box-shadow: 0 8px 30px rgba(139, 69, 19, 0.3);
}

/* 弓箭模式下的按钮样式 */
#ai-mascot-container.slingshot-mode .mascot-btn {
    opacity: 0.5;
    pointer-events: none;
}

/* ==================== 粒子画布 ==================== */
#mascot-particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10000;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    #ai-mascot-container {
        bottom: 20px;
        right: 20px;
    }
    
    .mascot-body svg {
        width: 80px;
        height: 80px;
    }
    
    .mascot-bubble {
        font-size: 13px;
        padding: 10px 14px;
        max-width: 250px;
    }
    
    .mascot-controls {
        top: -3px;
        right: -3px;
    }
    
    .mascot-btn {
        width: 24px;
        height: 24px;
    }
    
    .mascot-btn svg {
        width: 12px;
        height: 12px;
    }
}

@media (max-width: 480px) {
    #ai-mascot-container {
        bottom: 15px;
        right: 15px;
    }
    
    .mascot-body svg {
        width: 70px;
        height: 70px;
    }
    
    .mascot-bubble {
        font-size: 12px;
        padding: 8px 12px;
        max-width: 200px;
    }
}

/* ==================== 深色模式适配 ==================== */
@media (prefers-color-scheme: dark) {
    .mascot-bubble {
        background: #1E293B;
        color: #E2E8F0;
        border-color: #334155;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    }
    
    .bubble-tail {
        border-top-color: #1E293B;
    }
    
    .mascot-btn {
        background: #334155;
        color: #E2E8F0;
    }
    
    .mascot-btn:hover {
        background: #475569;
    }
}

/* ==================== 动画性能优化 ==================== */
@media (prefers-reduced-motion: reduce) {
    .mascot-body,
    .mascot-body.crawling .arm-left,
    .mascot-body.crawling .arm-right,
    .mascot-body.crawling .leg-left,
    .mascot-body.crawling .leg-right {
        animation: none !important;
    }
    
    .mascot-bubble,
    .mascot-status {
        transition: opacity 0.2s ease !important;
    }
    
    .arm, .leg {
        transition: none !important;
    }
}

/* ==================== 打印时隐藏 ==================== */
@media print {
    #ai-mascot-container,
    #mascot-particle-canvas {
        display: none !important;
    }
}
