/* ============================================================================
 * HOTBOX — Floating audio control (mute + genre + volume)
 * "Psychedelic Speakeasy" — neon/glass per docs/DESIGN.md.
 * Fixed top-right, safe-area aware, sits above the table header, unobtrusive.
 * ========================================================================== */

.hbx-audio {
  --hbx-acid: #b6ff3c;
  --hbx-ember: #ff8a3d;
  --hbx-ink: #f4f0ff;
  --hbx-ink-dim: #a99fc2;
  --hbx-surface: rgba(18, 12, 28, 0.62);
  --hbx-surface-2: rgba(28, 20, 40, 0.78);

  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 9000; /* above table header, below modal loaders if any */

  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;

  background: var(--hbx-surface);
  border: 1px solid rgba(182, 255, 60, 0.18);
  border-radius: 999px;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow:
    0 0 28px rgba(182, 255, 60, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);

  font-family: "Hanken Grotesk", sans-serif;
  color: var(--hbx-ink);
  user-select: none;
  transition: box-shadow 0.3s ease, opacity 0.3s ease;
}

.hbx-audio:hover {
  box-shadow:
    0 0 40px rgba(182, 255, 60, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* ---- buttons ------------------------------------------------------------- */
.hbx-audio__btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--hbx-ink);
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

.hbx-audio__btn:hover {
  background: rgba(182, 255, 60, 0.1);
  color: var(--hbx-acid);
  box-shadow: 0 0 18px rgba(182, 255, 60, 0.28);
  transform: translateY(-1px);
}
.hbx-audio__btn:active {
  transform: scale(0.94);
}
.hbx-audio__btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(182, 255, 60, 0.35);
}

/* mute icon glows acid when sound is on */
.hbx-audio__mute {
  color: var(--hbx-acid);
}
.hbx-audio.is-muted .hbx-audio__mute {
  color: var(--hbx-ink-dim);
}
.hbx-audio.is-muted {
  border-color: rgba(169, 159, 194, 0.22);
  box-shadow:
    0 0 18px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* genre button shows current genre emoji */
.hbx-audio__genre-ico {
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(182, 255, 60, 0.35));
}

/* ---- popover menu -------------------------------------------------------- */
.hbx-audio__menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 184px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;

  background: var(--hbx-surface-2);
  border: 1px solid rgba(182, 255, 60, 0.18);
  border-radius: 20px;
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(182, 255, 60, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);

  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  transform-origin: top right;
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
.hbx-audio__menu.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.hbx-audio__item {
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--hbx-ink);
  font-family: "Hanken Grotesk", sans-serif;
  font-size: 0.92rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.hbx-audio__item:hover {
  background: rgba(182, 255, 60, 0.08);
}
.hbx-audio__item:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(182, 255, 60, 0.4);
}
.hbx-audio__item-ico {
  font-size: 17px;
  line-height: 1;
}
.hbx-audio__item-label {
  flex: 1;
}
.hbx-audio__item-check {
  color: var(--hbx-acid);
  font-weight: 700;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.hbx-audio__item.is-active {
  background: rgba(182, 255, 60, 0.12);
  color: var(--hbx-acid);
}
.hbx-audio__item.is-active .hbx-audio__item-check {
  opacity: 1;
  transform: scale(1);
}

/* ---- volume slider ------------------------------------------------------- */
.hbx-audio__vol {
  margin-top: 4px;
  padding: 8px 12px 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.hbx-audio__range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--hbx-acid) 0%,
    var(--hbx-acid) 50%,
    rgba(169, 159, 194, 0.25) 50%,
    rgba(169, 159, 194, 0.25) 100%
  );
  cursor: pointer;
  outline: none;
}
.hbx-audio__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--hbx-acid);
  border: 2px solid #0a0710;
  box-shadow: 0 0 12px rgba(182, 255, 60, 0.6);
  cursor: pointer;
}
.hbx-audio__range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--hbx-acid);
  border: 2px solid #0a0710;
  box-shadow: 0 0 12px rgba(182, 255, 60, 0.6);
  cursor: pointer;
}
.hbx-audio__range:focus-visible {
  box-shadow: 0 0 0 3px rgba(182, 255, 60, 0.3);
}

/* ---- small screens ------------------------------------------------------- */
@media (max-width: 420px) {
  .hbx-audio {
    gap: 4px;
    padding: 4px;
  }
  .hbx-audio__btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
  }
}

/* ---- reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .hbx-audio,
  .hbx-audio__btn,
  .hbx-audio__menu,
  .hbx-audio__item,
  .hbx-audio__item-check {
    transition: none !important;
  }
  .hbx-audio__btn:hover,
  .hbx-audio__btn:active {
    transform: none;
  }
}

/* ---- Phones: collapse to a compact mute button + reserve header room so the
   floating control never overlaps a screen header (bb pill, icons, etc). ---- */
@media (max-width: 540px) {
  .hbx-audio { padding: 3px; gap: 0; top: max(8px, env(safe-area-inset-top)); right: max(6px, env(safe-area-inset-right)); }
  .hbx-audio__genre { display: none; }
  .hbx-audio__btn { width: 40px; height: 40px; min-width: 40px; }
  /* Screen headers reserve space for the mute button (audio.css loads last). */
  .cz2-head, .lobby-head, .pf-head { padding-right: 50px; }
}
