/* AI 机器人浮动动画图标 */

/* 浮动容器 */
.ai-avatar-btn {
  position: relative;
  width: 64px;
  height: 64px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* 图片帧容器 */
.ai-avatar-frames {
  position: relative;
  width: 64px;
  height: 64px;
  animation: aiAvatarFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 8px 16px rgba(100, 181, 246, 0.4));
  transition: filter 0.2s ease;
}

.ai-avatar-btn:hover .ai-avatar-frames {
  filter: drop-shadow(0 12px 24px rgba(100, 181, 246, 0.7));
  animation: aiAvatarFloatFast 1.5s ease-in-out infinite;
}

/* 各帧图片 */
.ai-avatar-frame {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
}

/* 帧动画：4帧循环，每帧显示 0.6s，总周期 2.4s */
.ai-avatar-frame:nth-child(1) { animation: aiFrame1 2.4s steps(1) infinite; }
.ai-avatar-frame:nth-child(2) { animation: aiFrame2 2.4s steps(1) infinite; }
.ai-avatar-frame:nth-child(3) { animation: aiFrame3 2.4s steps(1) infinite; }
.ai-avatar-frame:nth-child(4) { animation: aiFrame4 2.4s steps(1) infinite; }

/* 悬停时加速切换 */
.ai-avatar-btn:hover .ai-avatar-frame:nth-child(1) { animation: aiFrame1 0.8s steps(1) infinite; }
.ai-avatar-btn:hover .ai-avatar-frame:nth-child(2) { animation: aiFrame2 0.8s steps(1) infinite; }
.ai-avatar-btn:hover .ai-avatar-frame:nth-child(3) { animation: aiFrame3 0.8s steps(1) infinite; }
.ai-avatar-btn:hover .ai-avatar-frame:nth-child(4) { animation: aiFrame4 0.8s steps(1) infinite; }

/* 脉冲光晕（待机状态） */
.ai-avatar-glow {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 10px;
  background: radial-gradient(ellipse, rgba(100,181,246,0.5) 0%, transparent 70%);
  animation: aiAvatarGlow 3s ease-in-out infinite;
  border-radius: 50%;
}

/* 说话气泡（AI 正在思考时） */
.ai-avatar-thinking {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, #42a5f5, #1976d2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: aiThinkingPulse 1s ease-in-out infinite;
  opacity: 0;
  transition: opacity 0.3s;
}

.ai-avatar-thinking.active {
  opacity: 1;
}

.ai-avatar-thinking::after {
  content: '';
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  animation: aiDotPulse 0.6s ease-in-out infinite alternate;
}

/* ── Keyframes ── */

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

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

@keyframes aiAvatarGlow {
  0%, 100% { opacity: 0.4; transform: translateX(-50%) scaleX(1); }
  50% { opacity: 0.8; transform: translateX(-50%) scaleX(1.3); }
}

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

@keyframes aiDotPulse {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

/* 帧切换：4帧，每帧占 25% 周期 */
@keyframes aiFrame1 {
  0%    { opacity: 1; }
  25%   { opacity: 0; }
  100%  { opacity: 0; }
}
@keyframes aiFrame2 {
  0%    { opacity: 0; }
  25%   { opacity: 1; }
  50%   { opacity: 0; }
  100%  { opacity: 0; }
}
@keyframes aiFrame3 {
  0%    { opacity: 0; }
  50%   { opacity: 1; }
  75%   { opacity: 0; }
  100%  { opacity: 0; }
}
@keyframes aiFrame4 {
  0%    { opacity: 0; }
  75%   { opacity: 1; }
  100%  { opacity: 1; }
}

/* 点击波纹效果 */
.ai-avatar-btn:active .ai-avatar-frames {
  transform: scale(0.92);
  transition: transform 0.1s ease;
}
