/* audio.css: WS7 audio. The HUD sound toggle (+ 5-bar meter) and the pre-roll mirror. */

.hud-sound,
.preroll-sound-btn {
  display: inline-flex; align-items: center; gap: .45em;
}
.hud-sound .hs-dot:empty,
.preroll-sound-btn .hs-dot:empty { display: none; }

/* meter: five bars, lit up to data-n; only while sound is on */
.hud-sound .hs-meter {
  display: none;
  align-items: flex-end; gap: 1px;
  height: 8px;
  margin-left: .15em;
}
.hud-sound[data-state="on"] .hs-meter { display: inline-flex; }
.hud-sound .hs-meter i {
  display: block; width: 2px;
  background: currentColor;
  opacity: .25;
}
.hud-sound .hs-meter i:nth-child(1) { height: 20%; }
.hud-sound .hs-meter i:nth-child(2) { height: 40%; }
.hud-sound .hs-meter i:nth-child(3) { height: 60%; }
.hud-sound .hs-meter i:nth-child(4) { height: 80%; }
.hud-sound .hs-meter i:nth-child(5) { height: 100%; }
.hud-sound .hs-meter[data-n="1"] i:nth-child(-n+1),
.hud-sound .hs-meter[data-n="2"] i:nth-child(-n+2),
.hud-sound .hs-meter[data-n="3"] i:nth-child(-n+3),
.hud-sound .hs-meter[data-n="4"] i:nth-child(-n+4),
.hud-sound .hs-meter[data-n="5"] i:nth-child(-n+5) { opacity: 1; }
/* the HUD's pressed=false dimming must not apply to the 'tap to resume' prompt */
.hud-controls .hud-sound[data-state="resume"],
.hud-controls .hud-sound[data-state="pending"] { opacity: 1; }

/* reduced motion: the meter is a static dot */
@media (prefers-reduced-motion: reduce) {
  .hud-sound .hs-meter i { display: none; }
  .hud-sound .hs-meter { height: auto; align-items: center; }
  .hud-sound .hs-meter::before {
    content: ""; display: block;
    width: 4px; height: 4px; border-radius: 50%;
    background: currentColor;
  }
}

/* pre-roll mirror (inside WS2's #preroll-sound slot): 44 px hit area around the label */
.preroll-sound-btn {
  appearance: none; -webkit-appearance: none;
  background: none; border: 0; border-radius: 0;
  color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit;
  padding: 16px 10px; margin: -16px -10px;
  cursor: pointer;
  white-space: nowrap;
  opacity: .7;
  transition: opacity .2s;
}
.preroll-sound-btn:hover,
.preroll-sound-btn[data-state="on"],
.preroll-sound-btn[data-state="pending"],
.preroll-sound-btn[data-state="resume"] { opacity: 1; }
.preroll-sound-btn:focus-visible { outline-offset: -6px; }

/* ≤400 px: the 3 s iOS 'silent switch?' note replaces the label and the meter */
@media (max-width: 400px) {
  .hud-sound[data-silent] .hs-meter { display: none; }
}

/* ≤400 px in IV (lights off) the HUD also carries the 'lights' button: shorten to '● on' with no meter */
@media (max-width: 400px) {
  body[data-lights="off"] .hud-sound .hs-txt,
  body[data-lights="off"] .hud-sound .hs-meter { display: none; }
  body[data-lights="off"] .hud-sound::after { content: attr(data-short); }
}
