/* ============================================
   乡音互通模块样式 · Taste Skill v4
   视觉风格：纯白画布 · 非对称对话 · 岁月词汇
   设计原则：黑色系阴影 · 发丝边框 · 错落布局 · 金色脉动
   对齐 Airbnb 设计标准：纯色背景 · 1px 边框 · 统一阴影层级
   ============================================ */

/* ===== Hero ===== */
.dialect-hero {
  padding: calc(var(--header-h) + var(--sp-8)) var(--sp-5) var(--sp-6);
  text-align: center;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
.dialect-hero-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
}
.dialect-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 900;
  margin-bottom: var(--sp-3);
  color: var(--gold);
  letter-spacing: 0.05em;
}
.dialect-subtitle {
  font-size: 1.05rem;
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: var(--sp-5);
}

/* ===== 方向切换器 ===== */
.direction-switch {
  display: flex;
  justify-content: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.direction-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline, var(--rule));
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
}
.direction-btn:hover {
  background: var(--gold-bg);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.direction-btn.active {
  background: var(--gold-bg);
  color: var(--gold);
  box-shadow: var(--shadow);
}
.direction-btn .arrow {
  color: var(--muted-dim);
  font-size: 1.2rem;
}
.direction-btn.active .arrow { color: var(--gold); }

/* ===== 语音输入区 — 非对称偏左布局 ===== */
.voice-input-section {
  max-width: 660px;
  margin: 0 auto var(--sp-6) 0;
}
.voice-input-card {
  background: var(--bg-card);
  border: 1px solid var(--hairline, var(--rule));
  border-radius: var(--r-md);
  padding: var(--sp-6);
  text-align: center;
  box-shadow: var(--shadow);
  transition: all var(--dur) var(--ease);
  position: relative;
}
.voice-input-card.recording {
  box-shadow:
    0 0 0 4px rgba(0,0,0,0.04),
    0 8px 32px rgba(0,0,0,0.08),
    0 4px 12px rgba(0,0,0,0.04);
}

/* ===== 麦克风按钮 ===== */
.voice-mic-btn {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  background: var(--gold);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--sp-4);
  box-shadow: var(--shadow-lg);
  transition: all var(--dur) var(--ease-spring);
  position: relative;
}
.voice-mic-btn svg {
  width: 48px;
  height: 48px;
  color: #fff;
  display: block;
}
.voice-mic-btn:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-lg);
}
.voice-mic-btn:active { transform: scale(0.96); }

/* --- 录音状态：金色脉动光环（功能性反馈，保留金色） --- */
.voice-mic-btn.recording {
  background: var(--gold-active);
  animation: pulse 1.5s ease-in-out infinite;
}
.voice-mic-btn.recording svg {
  color: #fff;
}
.voice-mic-btn.recording::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  opacity: 0.5;
  animation: pulse-ring 1.5s ease-out infinite;
}
.voice-mic-btn.recording::after {
  content: '';
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  border: 2px solid var(--gold-light);
  opacity: 0.3;
  animation: pulse-ring 1.5s ease-out 0.4s infinite;
}

.voice-mic-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: var(--sp-1);
}
.voice-mic-hint {
  font-size: 0.88rem;
  color: var(--muted);
}
.voice-wave-display {
  display: flex;
  justify-content: center;
  margin: var(--sp-4) 0;
}
.voice-text-display {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  background: var(--bg-warm);
  border-radius: var(--r);
  border-left: 4px solid var(--gold);
  text-align: left;
  min-height: 60px;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink);
}
.voice-text-display.empty {
  color: var(--muted-dim);
  font-style: italic;
}

/* ===== 手动输入区 ===== */
.text-input-section {
  margin-top: var(--sp-4);
  display: flex;
  gap: var(--sp-2);
}
.text-input-section .form-input {
  flex: 1;
}
.text-input-section .btn {
  white-space: nowrap;
}

/* ===== 翻译结果 — 非对称偏右错位 ===== */
.translate-result {
  max-width: 680px;
  margin: 0 0 var(--sp-8) auto;
  animation: slideInRight var(--dur-slow) var(--ease);
}
.translate-result.empty { display: none; }
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--hairline, var(--rule));
  border-radius: var(--r-md);
  padding: var(--sp-5);
  box-shadow: var(--shadow);
}
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.result-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 700;
  font-size: 1.05rem;
}
.result-label .avatar { font-size: 1.5rem; }
.result-original {
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-warm);
  border-radius: var(--r);
  margin-bottom: var(--sp-3);
  color: var(--ink-soft);
  line-height: 1.7;
  font-size: 0.98rem;
}
.result-translated {
  padding: var(--sp-3) var(--sp-4);
  background: var(--gold-bg);
  border-radius: var(--r);
  border: 1px solid var(--hairline, var(--rule));
  color: var(--ink);
  line-height: 1.7;
  font-size: 1.05rem;
  font-weight: 500;
}
.result-annotations {
  margin-top: var(--sp-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.annotation-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  background: var(--bg-warm);
  border: 1px solid var(--hairline-soft, var(--rule-soft));
  border-radius: var(--r-full);
  font-size: 0.82rem;
  color: var(--ink-soft);
  box-shadow: var(--shadow-xs);
}
.annotation-tag .word { color: var(--gold); font-weight: 600; }
.result-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  flex-wrap: wrap;
}

/* ===== 对话历史 — 交替左右气泡布局 ===== */
.conversation-section {
  background: var(--bg-warm);
  padding: var(--sp-10) 0;
  position: relative;
}
.conversation-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  max-width: 860px;
  margin: 0 auto;
  padding: 0 var(--sp-5);
}

/* --- 交替左右排列 --- */
.convo-item.convo-left {
  align-self: flex-start;
  max-width: 82%;
  margin-right: auto;
}
.convo-item.convo-right {
  align-self: flex-end;
  max-width: 82%;
  margin-left: auto;
}

.convo-item {
  background: var(--bg-card);
  border: 1px solid var(--hairline, var(--rule));
  border-radius: var(--r-md);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
  transition: all var(--dur) var(--ease);
}
.convo-left {
  border-top-left-radius: var(--r-sm);
}
.convo-right {
  border-top-right-radius: var(--r-sm);
}
.convo-item:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

/* --- 错位入场动画 staggerInUp --- */
.convo-item.reveal {
  opacity: 0;
  transform: translateY(24px) scale(0.98);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease-spring);
}
.convo-item.reveal.active {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.convo-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.convo-avatar {
  font-size: 1.5rem;
}
.convo-speaker {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.95rem;
}
.convo-time {
  font-size: 0.8rem;
  color: var(--muted-dim);
  margin-left: auto;
}
.convo-region {
  font-size: 0.78rem;
  padding: 1px var(--sp-2);
  background: var(--bg-warm);
  border-radius: var(--r-full);
  color: var(--muted);
}

/* --- 对话气泡 --- */
.convo-bubble {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r);
  margin-bottom: var(--sp-2);
  line-height: 1.7;
  font-size: 0.98rem;
}
.convo-dialect {
  background: var(--terra-soft);
  border-left: 3px solid var(--terra);
  color: var(--ink);
  border-top-left-radius: var(--r-xs);
}
.convo-mandarin {
  background: var(--gold-bg);
  border-left: 3px solid var(--gold);
  color: var(--ink);
  border-top-left-radius: var(--r-xs);
}
.convo-right .convo-dialect {
  border-left: none;
  border-right: 3px solid var(--terra);
  border-top-left-radius: var(--r);
  border-top-right-radius: var(--r-xs);
}
.convo-right .convo-mandarin {
  border-left: none;
  border-right: 3px solid var(--gold);
  border-top-left-radius: var(--r);
  border-top-right-radius: var(--r-xs);
}
.convo-bubble-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-1);
  color: var(--muted);
}
.convo-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

/* ===== 方言词典 — masonry 错落不等高布局 ===== */
.dialect-dict-section {
  padding: var(--sp-10) 0;
}
.dict-search {
  max-width: 500px;
  margin: 0 auto var(--sp-6);
  position: relative;
}
.dict-search .form-input {
  padding-left: 44px;
}
.dict-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  pointer-events: none;
}
.dict-search-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* --- CSS columns 实现 masonry 瀑布流 --- */
.dict-grid {
  column-count: 3;
  column-gap: var(--sp-4);
}
.dict-card {
  background: var(--bg-card);
  border: 1px solid var(--hairline, var(--rule));
  border-radius: var(--r-md);
  padding: var(--sp-4);
  transition: all var(--dur) var(--ease);
  cursor: pointer;
  break-inside: avoid;
  margin-bottom: var(--sp-4);
  display: inline-block;
  width: 100%;
  box-shadow: var(--shadow-sm);
}
.dict-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.dict-word {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: var(--sp-1);
}
.dict-meaning {
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: var(--sp-2);
}
.dict-meta {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.dict-region, .dict-era {
  font-size: 0.75rem;
  padding: 1px var(--sp-2);
  border-radius: var(--r-full);
}
.dict-region { background: var(--bg-warm); color: var(--muted); }
.dict-era { background: var(--gold-bg); color: var(--gold); }

/* ===== 图标 SVG 通用样式 ===== */
.result-actions .btn svg,
.convo-actions .btn svg {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  margin-right: 4px;
  display: inline-block;
}
.empty-state-icon svg {
  width: 48px;
  height: 48px;
  color: var(--muted-dim);
  display: block;
  margin: 0 auto var(--sp-2);
}

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
  .dict-grid {
    column-count: 2;
  }
}

@media (max-width: 768px) {
  .dialect-title { font-size: 2rem; }

  /* 非对称布局在移动端回归居中 */
  .voice-input-section {
    max-width: 100%;
    margin: 0 auto var(--sp-6);
  }
  .translate-result {
    max-width: 100%;
    margin: 0 auto var(--sp-8);
  }

  .direction-btn {
    padding: var(--sp-2) var(--sp-3);
    font-size: 0.88rem;
  }
  .voice-mic-btn {
    width: 72px;
    height: 72px;
  }
  .voice-mic-btn svg {
    width: 40px;
    height: 40px;
  }
  .text-input-section { flex-direction: column; }

  /* 对话气泡在移动端取消左右交替，统一左对齐 */
  .convo-item.convo-left,
  .convo-item.convo-right {
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    align-self: stretch;
  }
  .convo-right .convo-dialect {
    border-left: 3px solid var(--terra);
    border-right: none;
    border-top-left-radius: var(--r-xs);
    border-top-right-radius: var(--r);
  }
  .convo-right .convo-mandarin {
    border-left: 3px solid var(--gold);
    border-right: none;
    border-top-left-radius: var(--r-xs);
    border-top-right-radius: var(--r);
  }
  .convo-time { display: none; }

  .dict-grid { column-count: 1; }
}

/* ===== prefers-reduced-motion 无障碍支持 ===== */
@media (prefers-reduced-motion: reduce) {
  .voice-mic-btn.recording,
  .voice-mic-btn.recording::before,
  .voice-mic-btn.recording::after {
    animation: none;
  }
  .convo-item.reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
