/**
 * AI宠物系统 · 动画样式 - v15.1 (修复版)
 * 与现有app.js的HTML类名对齐
 */

/* ==================== 基础变量 ==================== */
:root {
  --pet-area-ratio: 55-60%;
  --pet-bg-happy: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --pet-bg-normal: linear-gradient(135deg, #8B9CF7 0%, #A78BFA 100%);
  --pet-bg-sad: linear-gradient(135deg, #6B7280 0%, #9CA3AF 100%);
}

/* ==================== 宠物展示区容器 ==================== */
.pet-display-area {
  position: relative;
  width: 100%;
  height: 55vh;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background: var(--pet-bg-normal);
  border-radius: 0 0 24px 24px;
  transition: background 0.5s ease;
}

.pet-display-area.mood-happy { background: var(--pet-bg-happy); }
.pet-display-area.mood-normal { background: var(--pet-bg-normal); }
.pet-display-area.mood-sad { background: var(--pet-bg-sad); }

/* ==================== 宠物主体容器 ==================== */
.pet-avatar-wrapper {
  position: relative;
  width: 150px;
  height: 150px;
  display: flex;
  justify-content: center;
  align-items: center;
  transform: translateZ(0);
  will-change: transform;
}

/* ==================== 主Emoji ==================== */
.pet-emoji-main {
  font-size: 100px;
  line-height: 1;
  display: inline-block;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.2s ease, filter 0.3s ease;
}

.pet-emoji-main:active {
  transform: scale(0.95);
}

/* ==================== 心情动画 (与app.js对齐) ==================== */

/* 正常呼吸 */
@keyframes breathing {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.pet-emoji-main.breathing {
  animation: breathing 2s ease-in-out infinite;
}

/* 开心弹跳 */
@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-15px) scale(1.05); }
}

.pet-emoji-main.bounce {
  animation: bounce 0.5s ease-in-out infinite;
}

/* 躺下 */
@keyframes lie-down {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(20px) rotate(-5deg); }
}

.pet-emoji-main.lie-down {
  animation: lie-down 1s ease-out forwards;
}

/* 眨眼 */
@keyframes blink {
  0%, 90%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

.pet-emoji-main {
  animation: blink 4s ease-in-out infinite;
}

/* ==================== 心情状态联动 ==================== */

/* 开心 (≥80) */
.mood-happy .pet-emoji-main {
  filter: brightness(1.1) saturate(1.2);
}

/* 难过 (<50) */
.mood-sad .pet-emoji-main {
  filter: brightness(0.85) saturate(0.8);
}

.mood-sad .pet-ear {
  transform: rotate(25deg);
}

/* ==================== 耳朵 ==================== */
.pet-ear {
  position: absolute;
  width: 20px;
  height: 30px;
  background: inherit;
  border-radius: 50%;
  top: 15%;
  filter: brightness(0.9);
  transition: transform 0.3s ease;
}

.pet-ear-left {
  left: 20%;
  transform: rotate(-15deg);
}

.pet-ear-right {
  right: 20%;
  transform: rotate(15deg);
}

.pet-ear.droop {
  transform: rotate(25deg) !important;
}

/* ==================== 尾巴 ==================== */
.pet-tail {
  position: absolute;
  width: 15px;
  height: 35px;
  background: inherit;
  border-radius: 8px;
  bottom: 15%;
  right: 20%;
  transform-origin: bottom center;
  transition: transform 0.3s ease;
}

.pet-tail.wag {
  animation: tailWag 0.3s ease-in-out infinite;
}

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

/* ==================== 心情状态类 ==================== */
.pet-animation-container.mood-happy { background: var(--pet-bg-happy); }
.pet-animation-container.mood-normal { background: var(--pet-bg-normal); }
.pet-animation-container.mood-sad { background: var(--pet-bg-sad); }

/* ==================== 特效 ==================== */
.tear-effect {
  position: absolute;
  font-size: 20px;
  animation: tearDrop 1s ease-in infinite;
}

@keyframes tearDrop {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(30px); }
}

.hunger-indicator {
  position: absolute;
  font-size: 16px;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==================== 6宠专属动画 ==================== */

/* 猫 */
@keyframes catBreathing {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* 狗 */
@keyframes dogBreathing {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* 兔 */
@keyframes rabbitBreathing {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* 鼠 */
@keyframes hamsterBreathing {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* 狐 */
@keyframes foxBreathing {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

/* 龙 */
@keyframes dragonBreathing {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.03); filter: brightness(1.2) drop-shadow(0 0 10px orange); }
}

/* 6宠emoji特定动画 */
.pet-emoji-main.cat.breathing { animation: catBreathing 2s ease-in-out infinite; }
.pet-emoji-main.dog.breathing { animation: dogBreathing 1.5s ease-in-out infinite; }
.pet-emoji-main.rabbit.breathing { animation: rabbitBreathing 2.5s ease-in-out infinite; }
.pet-emoji-main.hamster.breathing { animation: hamsterBreathing 1s ease-in-out infinite; }
.pet-emoji-main.fox.breathing { animation: foxBreathing 2s ease-in-out infinite; }
.pet-emoji-main.dragon.breathing { animation: dragonBreathing 2s ease-in-out infinite; }

/* ==================== 性能分级 ==================== */
@media (prefers-reduced-motion: reduce) {
  .pet-emoji-main {
    animation: none !important;
    transform: none !important;
  }
  .pet-ear, .pet-tail {
    animation: none !important;
    transform: none !important;
  }
  .tear-effect, .hunger-indicator {
    display: none !important;
  }
}

/* ==================== 响应式 ==================== */
@media (max-width: 375px) {
  .pet-emoji-main {
    font-size: 80px;
  }
  .pet-avatar-wrapper {
    width: 120px;
    height: 120px;
  }
}

@media (min-width: 768px) {
  .pet-emoji-main {
    font-size: 120px;
  }
  .pet-avatar-wrapper {
    width: 180px;
    height: 180px;
  }
}

/* ==================== 动画完成检查 ==================== */
/* ✅ 6宠专属动画 - cat/dog/rabbit/hamster/fox/dragon */
/* ✅ 心情状态 - happy/normal/sad */
/* ✅ 旧类名兼容 - pet-emoji-main, bounce, breathing, lie-down */
/* ✅ 耳朵/尾巴联动 */
/* ✅ 性能分级+无障碍 */