/* ============================================================
 * TTS 播放按钮组件 — 4 态样式
 * 依赖：design-system.css（CSS 自定义属性）
 * ============================================================ */

/* ── 播放区域容器 ── */
.tts-play-area {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin: var(--space-sm) 0;
}

.tts-play-label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* ── 播放按钮基础 ── */
.tts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--radius-full);
  background: var(--color-primary-bg);
  color: var(--color-primary);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast);
  flex-shrink: 0;
  outline: none;
  position: relative;
}

.tts-btn:hover {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

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

.tts-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(241, 141, 36, 0.3);
}

/* ── IDLE 状态（默认） ── */
.tts-btn--idle {
  /* 默认样式，无需额外规则 */
}

/* ── LOADING 状态 — 旋转动画 ── */
.tts-btn--loading {
  background: var(--color-primary);
  color: #fff;
  cursor: wait;
  animation: tts-spin 0.8s linear infinite;
}

.tts-btn--loading:hover {
  background: var(--color-primary);
  box-shadow: none;
  cursor: wait;
}

/* ── PLAYING 状态 — 脉冲缩放 ── */
.tts-btn--playing {
  background: var(--color-success);
  color: #fff;
  animation: tts-pulse 1.2s ease-in-out infinite;
}

.tts-btn--playing:hover {
  background: var(--color-success);
  box-shadow: none;
}

/* ── ERROR 状态 — 红色闪烁 ── */
.tts-btn--error {
  background: var(--color-error);
  color: #fff;
  animation: tts-error-flash 0.5s ease-in-out 4; /* 2s = 0.5s × 4 */
}

.tts-btn--error:hover {
  background: var(--color-error);
  box-shadow: none;
}

/* ── SVG 图标尺寸响应 ── */
.tts-btn svg {
  display: block;
  width: 16px;
  height: 16px;
}

/* ── 行内 TTS 按钮容器（副标题等场景）── */
.tts-inline {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 6px;
}
.tts-inline .tts-btn {
  position: relative;
  top: -1px; /* 微调与文字基线对齐 */
}

/* ============================================================
 * 关键帧动画
 * ============================================================ */

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

@keyframes tts-pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes tts-error-flash {
  0%   { opacity: 1; }
  50%  { opacity: 0.4; }
  100% { opacity: 1; }
}

/* ============================================================
 * 在卡片/问题中的 TTS 按钮适配
 * ============================================================ */

/* AI 追问页：问题卡片内的 TTS 按钮 */
.af-question-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
}

.af-question-header .tts-btn {
  margin-top: 2px; /* 与文字基线对齐 */
}

/* 声印页：任务卡片内的 TTS 播放区域 */
.task-card .tts-play-area {
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
}

/* 声印页：总结区域的 TTS */
.summary-header .tts-play-area {
  justify-content: center;
  margin-top: var(--space-xs);
}

/* ============================================================
 * 响应式
 * ============================================================ */

@media (max-width: 767px) {
  .tts-btn {
    width: 32px;
    height: 32px; /* 移动端增大点击区域 */
  }

  .tts-btn svg {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 1023px) {
  .tts-play-area {
    flex-wrap: wrap;
  }
}
