/* ============================================================
   语音聊天 UI（WebRTC mesh）
   - .voice-bar   顶部菜单栏右侧的语音控制组（跟随 .v4-top 右对齐）
   - .seat.is-speaking / .dock__me.is-speaking  席位说话环
   - .seat .seat-mic-off  远端静音角标
   ============================================================ */

/* 顶部栏里的语音组：与 .tchip 同高同材质，整体右对齐 */
.voice-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 40px;
  padding: 0 6px;
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--ink);
  border: 2px solid rgba(58, 74, 90, 0.3);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3), 0 8px 16px rgba(0, 0, 0, 0.28);
  font: 700 11px/1 var(--font);
  flex: none;
}
.voice-bar[hidden] { display: none; }

.voice-bar .vb-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  border: 2px solid rgba(58, 74, 90, 0.26);
  background: rgba(255, 255, 255, 0.4);
  color: var(--slate);
  font: 700 11px/1 var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s var(--ease-out), border-color 0.12s, background 0.12s;
}
.voice-bar .vb-btn:hover { border-color: var(--mustard); transform: translateY(-1px); }
.voice-bar .vb-btn:active { transform: translateY(1px); }
.voice-bar .vb-btn .icon { width: 13px; height: 13px; }
.voice-bar .vb-btn.is-on {
  background: var(--teal);
  border-color: rgba(0, 0, 0, 0.2);
  color: var(--paper);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}
.voice-bar .vb-btn.is-muted {
  background: var(--brick);
  border-color: rgba(0, 0, 0, 0.2);
  color: var(--paper);
}
.voice-bar .vb-btn.is-ptt { min-width: 64px; justify-content: center; }
.voice-bar .vb-btn.is-ptt.is-down { background: var(--mustard); color: var(--ink); border-color: rgba(0, 0, 0, 0.2); }
.voice-bar .vb-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
/* hidden 属性要压过 .vb-btn 的 display，否则声控模式下 PTT 按钮藏不住 */
.voice-bar .vb-btn[hidden],
.voice-bar .vb-state[hidden],
.voice-bar .vb-count[hidden] { display: none !important; }

.voice-bar .vb-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 7px;
  height: 26px;
  border-radius: var(--r-sm);
  background: rgba(58, 74, 90, 0.08);
  color: var(--slate);
  font: 600 11px/1 var(--font);
  max-width: 132px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.voice-bar .vb-state.is-mine { background: rgba(29, 106, 94, 0.16); color: var(--teal); }
.voice-bar .vb-state.is-warn { background: rgba(169, 58, 38, 0.14); color: var(--brick); }
.voice-bar .vb-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); flex: none; }
.voice-bar .vb-dot.is-idle { background: rgba(58, 74, 90, 0.35); }
.voice-bar .vb-dot.is-live { animation: vb-pulse 1.1s ease-in-out infinite; }
@keyframes vb-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.45); opacity: 0.55; } }
.voice-bar .vb-count { font: 700 10px/1 var(--mono); color: var(--slate); opacity: 0.85; }

/* 麦克风电平表（声控阈值竖线） */
.voice-bar .vb-meter {
  position: relative;
  width: 46px;
  height: 8px;
  flex: none;
  border-radius: 4px;
  background: rgba(58, 74, 90, 0.16);
  overflow: hidden;
}
.voice-bar .vb-meter[hidden] { display: none; }
.voice-bar .vb-meter-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: rgba(58, 74, 90, 0.55);
  transition: width 0.08s linear, background-color 0.12s linear;
}
.voice-bar .vb-meter.is-open .vb-meter-fill { background: var(--teal); }
.voice-bar .vb-meter.is-clipped .vb-meter-fill { background: var(--brick); }
.voice-bar .vb-meter-thresh {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 60%;
  width: 2px;
  background: var(--mustard);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

/* 说话环：席位 / 自己的行动坞 */
.seat.is-speaking,
.dock__me.is-speaking {
  outline: 3px solid rgba(29, 106, 94, 0.55);
  outline-offset: 2px;
}
.seat.is-speaking .avatar,
.dock__me.is-speaking .avatar {
  box-shadow: 0 0 0 3px rgba(29, 106, 94, 0.35);
  animation: vb-ring 1.15s ease-in-out infinite;
}
@keyframes vb-ring {
  0%, 100% { box-shadow: 0 0 0 3px rgba(29, 106, 94, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(29, 106, 94, 0.12); }
}
.seat .seat-mic-off {
  position: absolute;
  right: -6px;
  top: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brick);
  color: var(--paper);
  border: 2px solid var(--paper);
}
.seat .seat-mic-off .icon { width: 9px; height: 9px; }

.voice-audio { display: none !important; }

/* 窄屏：先收状态文字，再收电平表，保证顶栏不换行 */
@media (max-width: 1280px) {
  .voice-bar .vb-state { max-width: 96px; }
}
@media (max-width: 1120px) {
  .voice-bar .vb-state { display: none; }
}
@media (max-width: 980px) {
  .voice-bar .vb-meter { display: none; }
  .voice-bar .vb-count { display: none; }
  .voice-bar .vb-btn span { display: none; }
  .voice-bar .vb-btn { padding: 0 7px; min-width: 28px; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .voice-bar .vb-dot.is-live,
  .seat.is-speaking .avatar,
  .dock__me.is-speaking .avatar { animation: none; }
}
