/* ============================================================
   SIGNAL FEED — AUDIO CONTROLS
   Terra Conflictus 2066

   Floating bottom-left HUD control. Governs the master level of
   the site's signal audio (procedural intercept SFX + voice clip).

   Drop-in module. Pairs with audio-controls.js:
     <link rel="stylesheet" href="audio-controls.css">
     <script src="audio-controls.js" defer></script>
   ============================================================ */

#tc-audio {
  /* token fallbacks so the module survives outside index.html */
  --a-cyan:    var(--tc-cyan, #3ee9ff);
  --a-magenta: var(--tc-magenta, #ff2d8a);
  --a-lime:    var(--tc-lime, #c9ff37);
  --a-dim:     var(--tc-dim, #8a82a0);
  --a-line:    var(--tc-line, rgba(255,255,255,0.08));
  --a-ink:     var(--tc-ink, #f3eaff);

  position: fixed;
  left: 18px;
  bottom: 18px;
  right: auto;
  top: auto;
  z-index: 9998;

  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 10px;

  font-family: var(--font-mono, "JetBrains Mono", "Courier New", monospace);
  color: var(--a-ink);

  background: rgba(8, 6, 12, 0.82);
  border: 1px solid rgba(62, 233, 255, 0.30);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);

  opacity: 0.58;
  transform: translateY(0);
  transition: opacity 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}
#tc-audio:hover,
#tc-audio:focus-within {
  opacity: 1;
  border-color: rgba(62, 233, 255, 0.55);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(62, 233, 255, 0.12);
}

/* corner ticks — matches the feed/HUD framing */
#tc-audio::before,
#tc-audio::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  pointer-events: none;
  opacity: 0.55;
}
#tc-audio::before {
  left: 4px; top: 4px;
  border-left: 1px solid var(--a-cyan);
  border-top: 1px solid var(--a-cyan);
}
#tc-audio::after {
  right: 4px; bottom: 4px;
  border-right: 1px solid var(--a-magenta);
  border-bottom: 1px solid var(--a-magenta);
}

/* ── mute / unmute button ───────────────────────────────── */
.tc-audio-mute {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(62, 233, 255, 0.35);
  border-radius: 8px;
  background: rgba(62, 233, 255, 0.06);
  color: var(--a-cyan);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.tc-audio-mute:hover { background: rgba(62, 233, 255, 0.12); }
.tc-audio-mute:focus-visible {
  outline: 2px solid var(--a-cyan);
  outline-offset: 2px;
}
.tc-audio-mute svg { width: 19px; height: 19px; display: block; }
.tc-audio-mute .spk { fill: currentColor; }
.tc-audio-mute .waves,
.tc-audio-mute .cross {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}
.tc-audio-mute .cross { display: none; }
#tc-audio.is-muted .tc-audio-mute {
  color: var(--a-magenta);
  border-color: rgba(255, 45, 138, 0.5);
  background: rgba(255, 45, 138, 0.08);
}
#tc-audio.is-muted .tc-audio-mute .waves { display: none; }
#tc-audio.is-muted .tc-audio-mute .cross { display: inline; }

/* ── label + EQ + readout column ────────────────────────── */
.tc-audio-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.tc-audio-caption {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--a-dim);
  white-space: nowrap;
}
.tc-audio-caption .label-on  { color: var(--a-cyan); }
#tc-audio.is-muted .tc-audio-caption .dot { color: var(--a-magenta); }
.tc-audio-caption .dot { color: var(--a-lime); }

/* tiny live equalizer — pure flourish, stops when silent */
.tc-audio-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 10px;
}
.tc-audio-eq i {
  width: 2px;
  height: 100%;
  background: var(--a-cyan);
  transform-origin: bottom;
  border-radius: 1px;
  animation: tcAudioEq 1s ease-in-out infinite;
}
.tc-audio-eq i:nth-child(1) { animation-delay: -0.9s; }
.tc-audio-eq i:nth-child(2) { animation-delay: -0.5s; }
.tc-audio-eq i:nth-child(3) { animation-delay: -0.2s; }
.tc-audio-eq i:nth-child(4) { animation-delay: -0.7s; }
@keyframes tcAudioEq {
  0%, 100% { transform: scaleY(0.25); }
  50%      { transform: scaleY(1); }
}
#tc-audio.is-muted .tc-audio-eq i {
  animation-play-state: paused;
  transform: scaleY(0.2);
  background: var(--a-magenta);
  opacity: 0.5;
}

/* ── slider row ─────────────────────────────────────────── */
.tc-audio-row {
  display: flex;
  align-items: center;
  gap: 9px;
}
.tc-audio-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 116px;
  height: 4px;
  margin: 0;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    var(--a-magenta) 0%,
    var(--a-cyan) var(--val, 100%),
    rgba(255, 255, 255, 0.14) var(--val, 100%),
    rgba(255, 255, 255, 0.14) 100%
  );
  cursor: pointer;
  outline: none;
}
.tc-audio-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--a-ink);
  border: 2px solid var(--a-cyan);
  box-shadow: 0 0 8px rgba(62, 233, 255, 0.6);
  cursor: pointer;
}
.tc-audio-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--a-ink);
  border: 2px solid var(--a-cyan);
  box-shadow: 0 0 8px rgba(62, 233, 255, 0.6);
  cursor: pointer;
}
.tc-audio-slider:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--a-cyan); outline-offset: 2px; }
.tc-audio-slider:focus-visible::-moz-range-thumb { outline: 2px solid var(--a-cyan); outline-offset: 2px; }
#tc-audio.is-muted .tc-audio-slider::-webkit-slider-thumb { border-color: var(--a-magenta); box-shadow: 0 0 8px rgba(255, 45, 138, 0.55); }
#tc-audio.is-muted .tc-audio-slider::-moz-range-thumb { border-color: var(--a-magenta); box-shadow: 0 0 8px rgba(255, 45, 138, 0.55); }

.tc-audio-pct {
  flex: 0 0 auto;
  min-width: 38px;
  text-align: right;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--a-dim);
  font-variant-numeric: tabular-nums;
}
#tc-audio.is-muted .tc-audio-pct { color: var(--a-magenta); }

/* ── reduced motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .tc-audio-eq i { animation: none; transform: scaleY(0.5); }
  #tc-audio { transition: none; }
}

/* ── small screens ──────────────────────────────────────── */
@media (max-width: 640px) {
  #tc-audio {
    left: 10px;
    bottom: 10px;
    padding: 7px 9px 7px 8px;
    gap: 8px;
    opacity: 0.92;
  }
  .tc-audio-slider { width: 88px; }
  .tc-audio-caption { font-size: 8px; letter-spacing: 0.18em; }
}
