/* =====================================================================
   Shared audio / settings bar for the mini-games.
   A small control strip with a play/pause button and a settings gear that
   opens a popover (currently: a Background Music on/off toggle).
   Each game supplies its own track via data-src on #audioBar (per-game music).
   ===================================================================== */

.audio-bar{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 6;
}
/* The settings popover overflows the bar and visually overlaps the game board,
   whose overlays (trace gate z7, timer z8, tutorial z9) live in a sibling
   stacking context. Because .audio-bar establishes its own context at z6, the
   popover's internal z-index:30 can't escape it and those overlays paint on
   top — trapping the controls behind the timed-level overlay. While the popover
   is open, lift the whole bar's context above every board overlay so the
   settings (and their controls) are clickable. */
.audio-bar:has(.audio-settings.open){
  z-index: 40;
}

.audio-bar-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(0,229,255,0.35);
  background: rgba(8,19,31,0.85);
  color: #9fdcff;
  font-size: 15px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.audio-bar-btn:hover{
  color: #00e5ff;
  border-color: rgba(0,229,255,0.7);
  box-shadow: 0 0 10px rgba(0,229,255,0.35);
}
.audio-bar-btn:active{ transform: translateY(1px); }
.audio-bar-btn svg{ display: block; width: 16px; height: 16px; }
.audio-bar-btn.active{
  color: #00e5ff;
  border-color: rgba(0,229,255,0.8);
  box-shadow: 0 0 12px rgba(0,229,255,0.45) inset;
}

/* settings popover */
.audio-settings{
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  min-width: 190px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(0,229,255,0.4);
  background: rgba(4,11,20,0.97);
  box-shadow: 0 8px 24px rgba(0,0,0,0.55), 0 0 14px rgba(0,229,255,0.2);
  font-family: 'Share Tech Mono', monospace;
  color: #cbe9ff;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}
.audio-settings.open{ opacity: 1; visibility: visible; transform: translateY(0); }

.audio-settings-title{
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #6fb2d8;
  margin-bottom: 10px;
}

.audio-setting-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  letter-spacing: 1px;
}
.audio-setting-row + .audio-setting-row{ margin-top: 10px; }

/* toggle switch */
.audio-toggle{
  position: relative;
  width: 42px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(0,229,255,0.4);
  background: rgba(20,40,58,0.9);
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.audio-toggle::after{
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #6b8399;
  transition: transform 0.15s ease, background 0.15s ease;
}
.audio-toggle.on{
  background: rgba(0,229,255,0.25);
  border-color: rgba(0,229,255,0.8);
}
.audio-toggle.on::after{
  transform: translateX(20px);
  background: #00e5ff;
  box-shadow: 0 0 8px rgba(0,229,255,0.7);
}

/* track picker (prev / name / next) inside the settings popover */
.audio-track-row{ align-items: center; }
.audio-track-picker{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.audio-track-nav{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid rgba(0,229,255,0.4);
  background: rgba(20,40,58,0.9);
  color: #9fdcff;
  font-family: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.audio-track-nav:hover{
  color: #00e5ff;
  border-color: rgba(0,229,255,0.8);
  box-shadow: 0 0 8px rgba(0,229,255,0.35);
}
.audio-track-nav:active{ transform: translateY(1px); }
.audio-track-name{
  min-width: 92px;
  max-width: 120px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: #cbe9ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- music volume slider (settings popover) ---- */
.audio-volume-row{ align-items: center; }
.audio-volume{
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 6px;
  flex: 0 0 auto;
  margin: 0;
  border-radius: 999px;
  background: rgba(20,40,58,0.9);
  border: 1px solid rgba(0,229,255,0.4);
  cursor: pointer;
  outline: none;
  /* --vol-pct is set by audio-bar.js; fills the track up to the thumb. */
  background-image: linear-gradient(to right,
    rgba(0,229,255,0.55) 0%,
    rgba(0,229,255,0.55) var(--vol-pct, 50%),
    rgba(20,40,58,0.9) var(--vol-pct, 50%),
    rgba(20,40,58,0.9) 100%);
}
/* WebKit / Blink thumb */
.audio-volume::-webkit-slider-thumb{
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #00e5ff;
  border: 1px solid rgba(4,11,20,0.9);
  box-shadow: 0 0 8px rgba(0,229,255,0.7);
  cursor: pointer;
  transition: box-shadow 0.12s ease, transform 0.12s ease;
}
.audio-volume::-webkit-slider-thumb:hover{ box-shadow: 0 0 12px rgba(0,229,255,0.9); }
.audio-volume:active::-webkit-slider-thumb{ transform: scale(1.1); }
/* Firefox track + thumb */
.audio-volume::-moz-range-track{
  height: 6px;
  border-radius: 999px;
  background: rgba(20,40,58,0.9);
}
.audio-volume::-moz-range-progress{
  height: 6px;
  border-radius: 999px;
  background: rgba(0,229,255,0.55);
}
.audio-volume::-moz-range-thumb{
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #00e5ff;
  border: 1px solid rgba(4,11,20,0.9);
  box-shadow: 0 0 8px rgba(0,229,255,0.7);
  cursor: pointer;
}
.audio-volume:focus-visible{
  border-color: rgba(0,229,255,0.9);
  box-shadow: 0 0 10px rgba(0,229,255,0.4);
}
