/* Somike "My mic" tab: level meter, volume and voice clean-up.
   Builds on the tokens and components of app.css. */

/* Which section shows (see soundboard.css for the other two). */
.app[data-tab="voice"] #main { display: none !important; }
.app:not([data-tab="voice"]) #voice,
.app[data-view="setup"] #voice,
.app[data-view="loading"] #voice { display: none !important; }

.voice {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 8px max(16px, calc((100% - 600px) / 2)) 14px;
  scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent;
}
/* Cards keep their height; the section scrolls instead. */
.voice > * { flex: none; }
.voice .banner .btn { flex: none; }
.voice .card { display: grid; grid-template-columns: minmax(0, 1fr); padding-bottom: 4px; }

/* ---------------------------------------------------------------- level */
.vo-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.vo-status[data-tone="ok"] { color: #86efac; }
.vo-status[data-tone="warn"] { color: #fcd34d; }
.vo-status[data-tone="err"] { color: #fca5a5; }

.vo-meter {
  --level: 0%; --peak: 0%;
  position: relative; height: 16px; border-radius: 8px;
  background: var(--panel-3);
}
/* The recommended range for speech peaks: -18 to -6 dBFS (GOOD_* in voice.js). */
.vo-good {
  position: absolute; top: 0; bottom: 0; left: 70%; width: 20%;
  background: rgba(34, 197, 94, 0.16);
  border-inline: 1px solid rgba(34, 197, 94, 0.4);
}
/* The whole colour scale, revealed up to the level: a colour always means the
   same loudness. */
.vo-fill {
  position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(90deg, #6d28d9 0%, #8b5cf6 45%, #22c55e 70%, #22c55e 90%, #f59e0b 94%, #ef4444 98%);
  clip-path: inset(0 calc(100% - var(--level)) 0 0 round 8px);
  transition: clip-path 0.07s linear, opacity 0.15s, filter 0.15s;
}
.vo-meter[data-muted="true"] .vo-fill { opacity: 0.35; filter: grayscale(1); }
.vo-peak {
  position: absolute; top: 2px; bottom: 2px; left: var(--peak); width: 2px; margin-left: -2px;
  border-radius: 1px; background: #fff; opacity: 0;
}
.vo-meter[data-peak="true"] .vo-peak { opacity: 0.8; }
.vo-gate-mark {
  position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px;
  border-radius: 1px; background: #f0abfc; box-shadow: 0 0 0 2px var(--panel);
}
.vo-scale { position: relative; height: 16px; margin-top: 5px; color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.vo-scale span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.vo-scale span:first-child { transform: none; }
.vo-scale span:last-child { transform: translateX(-100%); }

.vo-advice { margin: 6px 0 4px; min-height: 19px; color: var(--muted); }
.vo-advice[data-tone="ok"] { color: #86efac; }
.vo-advice[data-tone="warn"] { color: #fcd34d; }
.vo-monitor { border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- volume */
.vo-volume-head { gap: 10px; }
.vo-gain-out { flex: 1; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
#vo-auto { min-width: 112px; font-variant-numeric: tabular-nums; }
#vo-auto.vo-listening { border-color: rgba(236, 72, 153, 0.6); color: #f9a8d4; }

/* Filled from the centre (0 dB) to the thumb. */
.voice input.vo-gain {
  --from: 50%; --to: 50%;
  width: 100%; height: 8px; margin: 6px 0; border-radius: 4px;
  background: linear-gradient(90deg, var(--panel-3) var(--from), var(--accent) var(--from),
    var(--accent-2) var(--to), var(--panel-3) var(--to));
}
.voice input.vo-gain::-webkit-slider-thumb { width: 22px; height: 22px; }
.voice input[type="range"]:disabled { opacity: 0.5; }
.vo-gain-scale { display: grid; grid-template-columns: 1fr 1fr 1fr; margin: 2px 0 6px; color: var(--muted); font-size: 11.5px; }
.vo-gain-scale span:nth-child(2) { text-align: center; }
.vo-gain-scale span:nth-child(3) { text-align: right; }
.vo-gain-scale + .row { border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- clean up */
/* Details of the switch above them. */
.voice .row + .vo-sub { border-top: 0; min-height: 40px; margin-top: -6px; padding: 0 0 6px 14px; }
.voice .vo-sub .row-label span { font-weight: 500; }
.voice .slider output { width: 50px; }

.vo-foot { display: flex; align-items: flex-start; gap: 16px; padding: 0 4px; }
.vo-foot p { flex: 1; margin: 0; color: var(--muted); font-size: 12px; }
.vo-foot .btn { flex: none; }

@media (max-width: 440px) {
  .tab { padding: 0 6px; gap: 6px; }
  .voice .vo-sub input[type="range"] { width: 110px; }
}
@media (max-height: 720px) {
  .voice { gap: 10px; }
  .voice .card { padding-bottom: 2px; }
}
