/* ================================================================
 * animation.css — 动画样式
 * 所有动画集中管理
 * 必须遵守 prefers-reduced-motion
 * ================================================================ */

/* ==================== prefers-reduced-motion ==================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==================== 气泡进入动画 ==================== */
@keyframes bubble-enter-other {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bubble-enter-self {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message.other.animate-in .bubble {
  animation: bubble-enter-other var(--anim-duration) ease-out;
  transform-origin: bottom left;
}

.message.self.animate-in .bubble {
  animation: bubble-enter-self var(--anim-duration) ease-out;
  transform-origin: bottom right;
}

/* ==================== 系统消息淡入 ==================== */
@keyframes system-fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.system-message.animate-in .system-message-bubble {
  animation: system-fade-in var(--anim-duration) ease-out;
}

/* ==================== 打字指示器 ==================== */
@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  background-color: var(--color-bubble-other);
  border-radius: var(--bubble-radius);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 2px var(--color-shadow);
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-system);
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* ==================== 通知滑入 ==================== */
@keyframes notif-slide-in {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fake-notification {
  animation: notif-slide-in var(--anim-duration) ease-out;
}

/* ==================== 屏幕闪烁（恐怖效果） ==================== */
@keyframes screen-flicker {
  0%, 100% { opacity: 1; }
  10%, 30%, 50% { opacity: 0.3; }
  20%, 40%, 60% { opacity: 0.8; }
}

.screen-flicker {
  animation: screen-flicker 0.3s ease-in-out;
}

/* ==================== 屏幕震动 ==================== */
@keyframes screen-shake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-2px, -1px); }
  20% { transform: translate(2px, 1px); }
  30% { transform: translate(-2px, 1px); }
  40% { transform: translate(2px, -1px); }
  50% { transform: translate(-1px, -2px); }
  60% { transform: translate(1px, 2px); }
  70% { transform: translate(-1px, 1px); }
  80% { transform: translate(1px, -1px); }
  90% { transform: translate(-1px, 1px); }
}

.screen-shake {
  animation: screen-shake 0.4s ease-in-out;
}

/* ==================== 黑屏淡入淡出 ==================== */
@keyframes blackout-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes blackout-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

.blackout-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #000000;
  pointer-events: none;
  z-index: 100;
  opacity: 0;
}

.blackout-overlay.in {
  animation: blackout-fade-in 0.3s ease-out forwards;
}

.blackout-overlay.out {
  animation: blackout-fade-out 0.3s ease-out forwards;
}

/* ==================== 主题切换渐变 ==================== */
body,
.nav-bar,
.message-list,
.input-bar,
.bubble,
.typing-indicator {
  transition:
    background-color var(--anim-duration) ease,
    color var(--anim-duration) ease,
    border-color var(--anim-duration) ease;
}

/* ==================== 假电话全屏覆盖 ==================== */
@keyframes call-overlay-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.call-overlay {
  animation: call-overlay-in var(--anim-duration) ease-out;
}