/* ========================================================
   HUD DE AUDIO · GABASTRO
   El botón de silencio vive aquí: esquina inferior izquierda,
   fijo, por encima de modales y del reloj a pantalla completa
   (z-index 10050 > 10010 del modal comparativo y 10000 del
   botón de salir del reloj). Está siempre accesible, pero si
   nadie lo toca se aparta a un aspa tenue (data-idle).

   Estética: panel de máquina — esquinas cortadas, tipografía
   mono, cian de instrumentación y ámbar de aviso.
   ======================================================== */

.audio-hud {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 10050;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  font-family: var(--font-mono);
  -webkit-user-select: none;
  user-select: none;
  /* El paso al modo discreto (data-idle) se hace suave, no de golpe. */
  transition: opacity 0.5s ease, transform 0.5s ease;

  --au-cyan: #4af626;
  --au-amber: #ffb000;
  --au-red: #ff5a3d;
}

/* ---------------------------------------------- píldora (mute / estado) */
.audio-hud-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 13px 8px 11px;
  background: linear-gradient(180deg, rgba(16, 23, 28, 0.93), rgba(5, 8, 10, 0.95));
  border: 1px solid rgba(74, 246, 38, 0.34);
  border-radius: 4px;
  /* Esquina cortada: paneles de nave, no burbujas de móvil. */
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 9px 100%, 0 calc(100% - 9px));
  color: var(--au-cyan);
  cursor: pointer;
  text-transform: uppercase;
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.55),
    inset 0 0 18px rgba(74, 246, 38, 0.07);
  transition: border-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.1s, background 0.2s;
}

.audio-hud-pill:hover {
  border-color: var(--au-cyan);
  box-shadow:
    0 6px 22px rgba(0, 0, 0, 0.6),
    0 0 14px rgba(74, 246, 38, 0.25),
    inset 0 0 22px rgba(74, 246, 38, 0.12);
}

.audio-hud-pill:active { transform: translateY(1px); }

.audio-hud-pill:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(74, 246, 38, 0.35);
}

/* ------------------------------------------- barras de nivel animadas */
.audio-hud-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}

.audio-hud-bars i {
  display: block;
  width: 3px;
  height: 15px;
  background: currentColor;
  opacity: 0.6;
  /* Se anima con scaleY, no con height: así el vúmetro no provoca un layout
     del documento en cada fotograma (eran ~60 layouts/s con el HUD activo). */
  transform-origin: bottom center;
  animation: au-bar 1.6s ease-in-out infinite;
}

.audio-hud-bars i:nth-child(1) { animation-delay: -1.4s; }
.audio-hud-bars i:nth-child(2) { animation-delay: -0.9s; }
.audio-hud-bars i:nth-child(3) { animation-delay: -1.1s; }
.audio-hud-bars i:nth-child(4) { animation-delay: -0.5s; }
.audio-hud-bars i:nth-child(5) { animation-delay: -1.2s; }

/* Cada vez que suena algo, el vúmetro salta. */
.audio-hud[data-active="1"] .audio-hud-bars i {
  animation-duration: 0.34s;
  opacity: 1;
}

@keyframes au-bar {
  0%, 100% { transform: scaleY(0.2667); opacity: 0.45; }  /* 4 px de 15 */
  50% { transform: scaleY(1); opacity: 0.95; }
}

/* ------------------------------------------------------------ etiquetas */
.audio-hud-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.08;
}

.audio-hud-text b {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  font-weight: 700;
}

.audio-hud-text small {
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  opacity: 0.62;
}

/* --------------------------------------------------- palanca del mezclador */
.audio-hud-caret {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0.6rem;
  line-height: 1;
  color: var(--au-amber);
  background: linear-gradient(180deg, rgba(16, 23, 28, 0.93), rgba(5, 8, 10, 0.95));
  border: 1px solid rgba(255, 176, 0, 0.35);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, transform 0.25s, box-shadow 0.2s;
}

.audio-hud-caret:hover {
  border-color: var(--au-amber);
  box-shadow: 0 0 12px rgba(255, 176, 0, 0.3);
}

.audio-hud-caret[aria-expanded="true"] { transform: rotate(180deg); }

/* ------------------------------------------------------- estados del HUD */
.audio-hud[data-muted="true"] .audio-hud-pill {
  color: var(--au-red);
  border-color: rgba(255, 90, 61, 0.48);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.55),
    inset 0 0 18px rgba(255, 90, 61, 0.1);
}

.audio-hud[data-muted="true"] .audio-hud-bars i {
  animation: none;
  height: 3px;
  opacity: 0.55;
}

/* Antes del primer gesto el navegador no deja sonar: se pide el clic. */
.audio-hud[data-locked="true"][data-muted="false"] .audio-hud-pill {
  animation: au-invite 2.4s ease-in-out infinite;
}

@keyframes au-invite {
  0%, 100% { border-color: rgba(74, 246, 38, 0.3); }
  50% { border-color: rgba(74, 246, 38, 0.85); }
}

/* ------------------------------------------------ modo discreto (reposo) */
/* Si nadie toca el HUD en unos segundos se aparta: se queda el vúmetro y la
   palanca, muy tenues y sin animación, y vuelve entero al pasar por encima o
   al enfocarlo. El motor decide cuándo (data-idle): nunca se aparta si tiene
   algo que decir —falta el primer clic para arrancar o está en MUTE— ni con
   el mezclador abierto. */
.audio-hud[data-idle="true"] {
  opacity: 0.3;
  transform: translateY(3px);
}

.audio-hud[data-idle="true"]:hover,
.audio-hud[data-idle="true"]:focus-within {
  opacity: 1;
  transform: none;
}

/* En reposo sobra la etiqueta: queda sólo el vúmetro (y la palanca). */
.audio-hud[data-idle="true"] .audio-hud-text { display: none; }

.audio-hud[data-idle="true"]:hover .audio-hud-text,
.audio-hud[data-idle="true"]:focus-within .audio-hud-text { display: flex; }

.audio-hud[data-idle="true"] .audio-hud-pill { padding: 7px 10px; }

.audio-hud[data-idle="true"] .audio-hud-bars i {
  animation: none;
  height: 4px;
  opacity: 0.5;
}

/* --------------------------------------------------------------- mezclador */
.audio-mixer {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  width: 268px;
  padding: 12px 13px 10px;
  background: linear-gradient(180deg, rgba(10, 17, 24, 0.97), rgba(5, 8, 10, 0.98));
  border: 1px solid rgba(74, 246, 38, 0.28);
  border-radius: 6px;
  color: var(--text-main);
  box-shadow:
    0 20px 44px rgba(0, 0, 0, 0.65),
    inset 0 0 34px rgba(74, 246, 38, 0.04);
  animation: au-mixer-in 0.16s ease-out;
}

.audio-mixer[hidden] { display: none; }

@keyframes au-mixer-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.audio-mixer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 10px;
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  color: var(--au-cyan);
  border-bottom: 1px solid rgba(74, 246, 38, 0.18);
}

.audio-mixer-x {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

.audio-mixer-x:hover { color: var(--au-red); }

.audio-mixer-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  margin-bottom: 11px;
  cursor: pointer;
}

.audio-mixer-label,
.audio-mixer-val {
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

.audio-mixer-val { color: var(--au-amber); min-width: 32px; text-align: right; }

.audio-mixer input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, rgba(74, 246, 38, 0.55), rgba(74, 246, 38, 0.12));
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.audio-mixer input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 14px;
  background: var(--au-cyan);
  border: none;
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(74, 246, 38, 0.7);
}

.audio-mixer input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 14px;
  background: var(--au-cyan);
  border: none;
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(74, 246, 38, 0.7);
}

.audio-mixer-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.audio-mixer-toggle {
  flex: 1 1 auto;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  color: var(--au-cyan);
  background: rgba(74, 246, 38, 0.09);
  border: 1px solid rgba(74, 246, 38, 0.35);
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.audio-mixer-toggle:hover { background: rgba(74, 246, 38, 0.18); }

.audio-mixer-toggle.off {
  color: var(--text-dim);
  border-color: rgba(110, 124, 116, 0.35);
  background: rgba(110, 124, 116, 0.08);
  text-decoration: line-through;
}

.audio-mixer-scene {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(74, 246, 38, 0.18);
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

.audio-mixer-scene b {
  color: var(--au-amber);
  letter-spacing: 0.14em;
}

.audio-mixer-hint {
  margin: 10px 0 0;
  font-size: 0.55rem;
  line-height: 1.5;
  color: var(--text-dim);
}

.audio-mixer-hint b { color: var(--au-amber); }

/* ------------------------------------------------------------- adaptación */
@media (max-width: 620px) {
  .audio-hud { left: 10px; bottom: 10px; gap: 4px; }
  .audio-hud-text small { display: none; }
  .audio-mixer { width: min(268px, calc(100vw - 24px)); }
}

/* En el reloj a pantalla completa el HUD se queda, pero discreto (y ahí dentro
   vive como hijo de #clock-view, no como hermano: se cubren las dos formas). */
#clock-view.clock-fullscreen ~ .audio-hud .audio-hud-pill,
#clock-view.clock-fullscreen .audio-hud .audio-hud-pill { opacity: 0.55; }

#clock-view.clock-fullscreen ~ .audio-hud .audio-hud-pill:hover,
#clock-view.clock-fullscreen .audio-hud .audio-hud-pill:hover { opacity: 1; }

#clock-view.clock-fullscreen .audio-hud[data-idle="true"] { opacity: 0.16; }
