/* AudibleAura — UI chrome.
 * A machined instrument panel rather than a generic dark card. Two colour
 * domains, kept apart so they never fight: green belongs to the audio (LCD,
 * meter, source), and --accent — set by app.js to the current style's own
 * accent on every switch — belongs to the visual. That is why the toggles are
 * accent-tinted outlines and not solid fills: the chrome shifts with the plate
 * behind it instead of sitting on top of it in one fixed colour.
 */
:root {
  --bg: #050608;
  --glass: rgba(10, 11, 14, 0.66);
  --glass-bd: rgba(255, 255, 255, 0.07);
  --glass-bd-hi: rgba(255, 255, 255, 0.16);
  --ink: #eef1f6;
  --ink-dim: rgba(238, 241, 246, 0.52);
  --ink-faint: rgba(238, 241, 246, 0.28);
  --accent: #9aa0ff;
  --lcd: #39ff7c;
  --radius: 14px;
  --ctrl: 36px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; }
body { color: var(--ink); user-select: none; -webkit-user-select: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--ink); }

/* stacked render surfaces */
#stage { position: fixed; inset: 0; background: #000; }
#gl, #c2d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
canvas.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
body.immersive { cursor: none; }

/* ============================ CONTROL BAR ============================== */
#bar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  padding: 9px 11px;
  width: min(960px, calc(100vw - 32px));
  background: var(--glass);
  border: 1px solid var(--glass-bd);
  border-radius: var(--radius);
  backdrop-filter: blur(30px) saturate(1.25);
  -webkit-backdrop-filter: blur(30px) saturate(1.25);
  /* an outer hairline, a lifted top edge and a deep contact shadow: three
     cheap layers that read as a machined panel rather than a flat rectangle */
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,255,0.07),
    inset 0 -1px 0 rgba(0,0,0,0.35),
    0 26px 60px -14px rgba(0,0,0,0.8);
  transition: opacity .45s ease, transform .45s cubic-bezier(.2,.8,.2,1);
  z-index: 20;
}
#bar.away { opacity: 0; transform: translate(-50%, 22px); pointer-events: none; }

/* --- LCD readout: the audio domain, always green ------------------------ */
.lcd {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 11px;
  padding: 7px 11px; min-width: 208px; height: var(--ctrl);
  background: linear-gradient(180deg, #06150e, #020b07 62%, #04110b);
  border: 1px solid rgba(57,255,124,0.16);
  border-radius: 9px;
  box-shadow: inset 0 0 20px rgba(57,255,124,0.09), inset 0 1px 0 rgba(255,255,255,0.04);
}
/* fine scanlines, so the well reads as a lit panel and not a green box */
.lcd::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(180deg, rgba(0,0,0,0.28) 0 1px, transparent 1px 3px);
  opacity: .55;
}
.lcd-text { font-family: var(--mono); line-height: 1.2; }
.lcd-title {
  font-size: 12px; font-weight: 600; color: var(--lcd);
  letter-spacing: .06em; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 9px rgba(57,255,124,0.45);
}
.lcd-sub { font-size: 9px; color: rgba(57,255,124,0.42); letter-spacing: .18em; text-transform: uppercase; }
.meter { display: flex; align-items: flex-end; gap: 2.5px; height: 22px; }
.meter i {
  width: 4px; border-radius: 1px; height: 8%;
  background: linear-gradient(180deg, #b9ffd6, #2fd06a 55%, #14663a);
  box-shadow: 0 0 6px rgba(57,255,124,0.35);
  transition: height .06s linear;
}

/* --- buttons: the visual domain, tinted by the current style ------------ */
.btns { display: flex; align-items: center; gap: 6px; }
button.ctl {
  width: var(--ctrl); height: var(--ctrl);
  display: grid; place-items: center;
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--glass-bd);
  border-radius: 10px; color: rgba(238,241,246,0.74);
  cursor: pointer; padding: 0;
  transition: background .18s, border-color .18s, transform .08s, color .18s, box-shadow .25s;
}
button.ctl:hover { background: rgba(255,255,255,0.085); border-color: var(--glass-bd-hi); color: var(--ink); }
button.ctl:active { transform: scale(0.94); }
/* An outline that glows in the style's own accent. The old solid acid-green
   fill was the loudest thing on screen and belonged to no style at all. */
button.ctl.on {
  color: var(--accent);
  background: color-mix(in oklab, var(--accent) 13%, transparent);
  border-color: color-mix(in oklab, var(--accent) 46%, transparent);
  box-shadow:
    inset 0 0 0 1px color-mix(in oklab, var(--accent) 18%, transparent),
    inset 0 1px 0 rgba(255,255,255,0.10),
    0 0 18px -4px color-mix(in oklab, var(--accent) 70%, transparent);
}
button.ctl.on:hover { background: color-mix(in oklab, var(--accent) 20%, transparent); }
button.ctl svg { width: 18px; height: 18px; display: block; }
button.ctl:disabled { opacity: .3; cursor: default; }
button.ctl:disabled:hover { background: rgba(255,255,255,0.035); border-color: var(--glass-bd); color: rgba(238,241,246,0.74); }

/* --- now playing -------------------------------------------------------- */
.now { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 0 4px; }
.now .name {
  font-size: 13.5px; font-weight: 600; letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.now .meta { display: flex; align-items: baseline; gap: 8px; min-width: 0; max-width: 100%; }
.now .cnt {
  flex: none; font-family: var(--mono); font-size: 10px; letter-spacing: .04em;
  font-variant-numeric: tabular-nums; color: var(--accent); opacity: .85;
  transition: color .3s ease;
}
.now .blurb { font-size: 11px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sep {
  width: 1px; height: 22px; border: 0; flex: none;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.14), transparent);
}

/* --- source pill -------------------------------------------------------- */
.source { display: flex; align-items: center; gap: 8px; }
button.src {
  display: flex; align-items: center; gap: 8px; height: var(--ctrl); padding: 0 13px;
  background: rgba(255,255,255,0.035); border: 1px solid var(--glass-bd); border-radius: 10px;
  color: rgba(238,241,246,0.88); cursor: pointer; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  transition: background .18s, border-color .18s, color .18s;
}
button.src:hover { background: rgba(255,255,255,0.085); border-color: var(--glass-bd-hi); color: var(--ink); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #ffb020; box-shadow: 0 0 8px #ffb020; animation: pulse 1.6s ease-in-out infinite; }
body.live .dot { background: #2fe06a; box-shadow: 0 0 9px #2fe06a; animation: none; }
@keyframes pulse { 50% { opacity: .35; } }

/* ============================ STYLE PICKER ============================= */
#picker {
  position: fixed; inset: 0; z-index: 30; display: none;
  align-items: center; justify-content: center;
  background: rgba(3,4,6,0.6); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
#picker.open { display: flex; }
.picker-card {
  width: min(880px, 92vw); padding: 22px;
  max-height: calc(100vh - 44px); overflow-y: auto;
  background: var(--glass); border: 1px solid var(--glass-bd); border-radius: 18px;
  backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.07), 0 40px 90px -20px rgba(0,0,0,.8);
}
.picker-card h2 { margin: 0 0 3px; font-size: 15px; font-weight: 600; letter-spacing: .005em; }
.picker-card p { margin: 0 0 18px; font-size: 12px; color: var(--ink-dim); }
.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
@media (max-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
.tile {
  position: relative; aspect-ratio: 1; border-radius: 11px; cursor: pointer; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06); background: #0a0c12;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 9px;
  transition: transform .14s cubic-bezier(.2,.8,.2,1), border-color .18s, box-shadow .18s;
}
/* an inner hairline over the swatch, so each tile reads as a mounted plate */
.tile::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.07), inset 0 14px 26px -14px rgba(0,0,0,.6);
}
.tile:hover { transform: translateY(-3px); border-color: rgba(255,255,255,0.22); }
.tile.active { border-color: var(--tile); box-shadow: 0 0 0 1px var(--tile), 0 0 22px -6px var(--tile); }
.tile .swatch { position: absolute; inset: 0; opacity: .92; }
.tile .idx {
  position: absolute; top: 7px; left: 9px; z-index: 2;
  font-family: var(--mono); font-size: 10px; letter-spacing: .04em;
  color: rgba(255,255,255,0.8); text-shadow: 0 1px 4px rgba(0,0,0,.8);
}
.tile .tname { position: relative; z-index: 2; font-size: 11.5px; font-weight: 600; text-shadow: 0 1px 6px rgba(0,0,0,.85); }

/* ============================ FIRST-RUN HINT =========================== */
#hint {
  position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%);
  z-index: 25; width: min(420px, 90vw); text-align: center;
  padding: 26px 24px; border-radius: 18px;
  background: var(--glass); border: 1px solid var(--glass-bd);
  backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.07), 0 40px 90px -20px rgba(0,0,0,.8);
  transition: opacity .5s ease;
}
#hint.gone { opacity: 0; pointer-events: none; }
#hint .logo { font-size: 21px; font-weight: 650; letter-spacing: -.015em; margin-bottom: 6px; }
#hint .logo b { color: var(--lcd); font-weight: 650; }
#hint p { font-size: 13px; line-height: 1.55; color: var(--ink-dim); margin: 0 0 20px; }
#hint .cta {
  display: inline-flex; align-items: center; gap: 9px; padding: 10px 18px; cursor: pointer;
  background: var(--ink); color: #0a0c12; border: none; border-radius: 10px; font-size: 13px; font-weight: 650;
  transition: transform .1s;
}
#hint .cta:active { transform: scale(.97); }
#hint .skip { display: block; margin: 13px auto 0; background: none; border: none; color: var(--ink-faint); font-size: 12px; cursor: pointer; }
#hint .skip:hover { color: var(--ink-dim); }

.toast {
  position: fixed; left: 50%; top: 22px; transform: translateX(-50%) translateY(-12px);
  z-index: 40; padding: 10px 16px; border-radius: 10px; font-size: 12.5px;
  background: rgba(26,10,10,0.92); border: 1px solid rgba(255,90,77,0.35); color: #ffd9d4;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hide { display: none !important; }

/* ============================ RESPONSIVE / A11Y ======================== */
/* The bar packs a source pill, the LCD, transport, title and three toggles.
   Below ~800px that overflows, so shed the least-critical pieces. */
@media (max-width: 800px) {
  #bar { gap: 9px; padding: 8px 9px; bottom: max(14px, env(safe-area-inset-bottom)); }
  .lcd { min-width: 0; padding: 6px 8px; }
  .lcd-text, .sep { display: none; }
  button.src span:last-child { display: none; }
  button.src { padding: 0 11px; }
  .now .blurb { display: none; }
}
@media (max-width: 480px) {
  .lcd { display: none; }
  #hint { padding: 20px 16px; }
}

/* keyboard focus must stay visible now that the chrome auto-hides */
button:focus-visible, input:focus-visible, .tile:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  #bar, .tile, button.ctl, button.src, #hint, .toast { transition-duration: .01ms; }
  .dot { animation: none; }
  .meter i { transition: none; }
}

/* --- colour popover: drift mode + a hue to hold -------------------------- */
.popwrap { position: relative; display: flex; }
.pop {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 9px;
  padding: 11px; width: 208px;
  background: var(--glass); border: 1px solid var(--glass-bd); border-radius: 12px;
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: 0 14px 40px -12px rgba(0,0,0,0.8);
  z-index: 5;
}
/* `display:flex` above outranks the UA's [hidden]{display:none}, so the panel
   needs its own hidden rule or the toggle silently does nothing. */
.pop[hidden] { display: none; }
.pop-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pop .chip {
  height: 26px; padding: 0 6px; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: 11px; letter-spacing: .01em;
  color: rgba(238,241,246,0.74);
  background: rgba(255,255,255,0.035); border: 1px solid var(--glass-bd);
}
.pop .chip:hover { background: rgba(255,255,255,0.085); border-color: var(--glass-bd-hi); color: var(--ink); }
.pop .chip.on {
  color: var(--accent);
  background: color-mix(in oklab, var(--accent) 13%, transparent);
  border-color: color-mix(in oklab, var(--accent) 46%, transparent);
}
/* The rail is the hue circle itself, so the swatch under the thumb is the
   colour you are choosing rather than a number you have to interpret. */
.huerail {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 14px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--glass-bd);
  background: linear-gradient(90deg,
    #ff4d4d 0%, #ffd24d 17%, #6bff4d 33%, #4dffd2 50%,
    #4d8cff 67%, #d24dff 83%, #ff4d4d 100%);
}
.huerail::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 20px; border-radius: 5px; cursor: pointer;
  background: #fff; border: 1px solid rgba(0,0,0,0.55);
  box-shadow: 0 1px 6px rgba(0,0,0,0.6);
}
.huerail::-moz-range-thumb {
  width: 12px; height: 18px; border-radius: 5px; cursor: pointer;
  background: #fff; border: 1px solid rgba(0,0,0,0.55);
}
