/* ------------------------------------------------------------------------
   SOUNDROOM
   A night colour scheme: ink with a violet bias, lit by sodium-lamp amber,
   and a daytime counterpart that keeps the same violet cast rather than
   turning into cream. Two voices: Bricolage Grotesque speaks, Martian Mono
   reports numbers.

   Every colour is declared twice on purpose. The first declaration is the
   dark value, which is what a browser without light-dark() will use; the
   second adds the light half. Old browsers get the night look, which is the
   one this app was designed in, rather than an unreadable half-theme.
   ------------------------------------------------------------------------ */

@font-face { font-family: 'Bricolage Fallback'; src: local('Helvetica Neue'); size-adjust: 100%; }

:root {
  /* Follow the system unless the toggle pins a choice. */
  color-scheme: light dark;

  --ink:        #0A0912;  --ink:        light-dark(#F2F0F7, #0A0912);
  --ink-lift:   #100D1B;  --ink-lift:   light-dark(#FAF9FC, #100D1B);
  --panel:      #171325;  --panel:      light-dark(#FFFFFF, #171325);
  --panel-2:    #1F1A2E;  --panel-2:    light-dark(#EFECF6, #1F1A2E);
  --line:       #2C2542;  --line:       light-dark(#D9D3E6, #2C2542);
  --line-soft:  #221D35;  --line-soft:  light-dark(#E7E3F0, #221D35);

  --bone:       #ECE7F7;  --bone:       light-dark(#171226, #ECE7F7);
  --dim:        #918AAC;  --dim:        light-dark(#5B5474, #918AAC);
  --dimmer:     #625C7A;  --dimmer:     light-dark(#8B84A2, #625C7A);

  --sodium:     #FFAE5C;  --sodium:     light-dark(#B45906, #FFAE5C);
  --sodium-hot: #FFD5A6;  --sodium-hot: light-dark(#D8791C, #FFD5A6);
  --sodium-deep:#C9762C;  --sodium-deep:light-dark(#8A4406, #C9762C);
  --lock:       #74EFC0;  --lock:       light-dark(#0A6E51, #74EFC0);
  --drift:      #FF7A6B;  --drift:      light-dark(#B02D26, #FF7A6B);

  /* Text that sits on top of a sodium fill. */
  --on-sodium:  #21140A;  --on-sodium:  light-dark(#FFF7EF, #21140A);

  /* Sampled from the cover art at runtime. */
  --art-1: #3A2E5C;  --art-1: light-dark(#CFC4E4, #3A2E5C);
  --art-2: #6E4A8A;  --art-2: light-dark(#E0CDEA, #6E4A8A);

  /* How loudly the artwork is allowed to colour the room. Daylight needs a
     much lighter touch or the whole page turns to soup. */
  --wash-opacity: .5;   --wash-opacity: light-dark(.34, .5);
  --glow-opacity: .55;  --glow-opacity: light-dark(.38, .55);
  --vignette: rgba(6,5,12,.85);  --vignette: light-dark(rgba(150,140,180,.16), rgba(6,5,12,.85));
  --art-shadow: rgba(0,0,0,.9);  --art-shadow: light-dark(rgba(70,52,110,.20), rgba(0,0,0,.9));
  --drop: rgba(0,0,0,.55);       --drop: light-dark(rgba(60,45,95,.18), rgba(0,0,0,.55));

  /* The QR code is drawn with dark modules, so its card stays light in both
     themes. A dark QR on a dark card scans as nothing at all. */
  --qr-paper: #F3F1F8;

  --display: 'Bricolage Grotesque', 'Bricolage Fallback', 'Helvetica Neue', system-ui, sans-serif;
  --mono: 'Martian Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 20px;

  --rail: 60px;
  --ease: cubic-bezier(.22,.61,.36,1);

  accent-color: var(--sodium);
  scrollbar-color: var(--line) transparent;
}

/* The toggle pins a scheme; without it the media query above decides. */
:root[data-theme='light'] { color-scheme: light; }
:root[data-theme='dark']  { color-scheme: dark; }

/* No light-dark() support means no reliable light theme, so stay in the dark
   one rather than serve half of each. */
@supports not (color: light-dark(#000, #fff)) {
  :root { color-scheme: dark; }
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--display);
  font-size: 15px;
  line-height: 1.45;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* The ambient wash the artwork throws across the room. */
body::before {
  content: '';
  position: fixed;
  inset: -20vmax;
  z-index: -2;
  background:
    radial-gradient(50% 45% at 22% 18%, color-mix(in oklab, var(--art-1) 62%, transparent), transparent 70%),
    radial-gradient(45% 50% at 82% 78%, color-mix(in oklab, var(--art-2) 48%, transparent), transparent 72%);
  filter: blur(40px) saturate(1.25);
  opacity: var(--wash-opacity);
  transition: background 1.4s var(--ease);
}
body::after {
  content: '';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 0%, transparent 40%, var(--vignette) 100%);
}

a { color: var(--sodium); text-decoration-color: color-mix(in oklab, var(--sodium) 40%, transparent); }

:focus-visible {
  outline: 2px solid var(--sodium);
  outline-offset: 3px;
  border-radius: 4px;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }

::selection { background: color-mix(in oklab, var(--sodium) 40%, transparent); }

/* ---- shared atoms ------------------------------------------------------ */

.label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--dimmer);
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.wordmark {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--bone);
  white-space: nowrap;
}
.wordmark b { color: var(--sodium); font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--bone);
  font-size: 14px; font-weight: 600;
  letter-spacing: -.005em;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .12s var(--ease), color .18s;
}
.btn:hover { background: var(--panel-2); border-color: color-mix(in oklab, var(--sodium) 35%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .4; pointer-events: none; }

.btn-primary {
  background: linear-gradient(180deg, var(--sodium-hot), var(--sodium));
  border-color: transparent;
  color: var(--on-sodium);
  font-weight: 700;
  box-shadow: 0 6px 24px -10px color-mix(in oklab, var(--sodium) 80%, transparent);
}
.btn-primary:hover {
  background: linear-gradient(180deg, color-mix(in oklab, var(--sodium-hot) 82%, var(--bone)), var(--sodium-hot));
  border-color: transparent;
}

.btn-ghost { background: transparent; border-color: transparent; color: var(--dim); }
.btn-ghost:hover { background: var(--panel); color: var(--bone); border-color: var(--line-soft); }

.btn-sm { padding: 7px 13px; font-size: 13px; }

.themebtn {
  width: 34px; height: 34px; flex: none;
  display: grid; place-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in oklab, var(--panel) 70%, transparent);
  color: var(--dim);
  transition: color .16s var(--ease), border-color .16s var(--ease), background .16s var(--ease);
}
.themebtn:hover { color: var(--bone); border-color: color-mix(in oklab, var(--sodium) 40%, var(--line)); }

.field {
  width: 100%;
  padding: 13px 16px;
  background: var(--ink-lift);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--bone);
  transition: border-color .18s var(--ease), background .18s;
}
.field::placeholder { color: var(--dimmer); }
.field:focus { outline: none; border-color: color-mix(in oklab, var(--sodium) 55%, var(--line)); background: var(--panel); }

.card {
  background: color-mix(in oklab, var(--panel) 82%, transparent);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  backdrop-filter: blur(18px) saturate(1.1);
}

/* ---- the sync pill: this app's vital sign ------------------------------ */

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in oklab, var(--panel) 70%, transparent);
  font-family: var(--mono);
  font-size: 10px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
  transition: color .3s, border-color .3s, background .3s;
}
.pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
}
.pill[data-q='locked']    { color: var(--lock); border-color: color-mix(in oklab, var(--lock) 30%, var(--line)); }
.pill[data-q='adjusting'] { color: var(--sodium); border-color: color-mix(in oklab, var(--sodium) 30%, var(--line)); }
.pill[data-q='armed']     { color: var(--sodium-hot); border-color: color-mix(in oklab, var(--sodium) 40%, var(--line)); }
.pill[data-q='loading'],
.pill[data-q='syncing']   { color: var(--dim); }
.pill[data-q='live']      { color: var(--lock); border-color: color-mix(in oklab, var(--lock) 30%, var(--line)); }
.pill[data-q='error'],
.pill[data-q='blocked']   { color: var(--drift); border-color: color-mix(in oklab, var(--drift) 35%, var(--line)); }
.pill[data-q='locked'] .dot { animation: breathe 3.4s var(--ease) infinite; }
.pill[data-q='syncing'] .dot,
.pill[data-q='loading'] .dot { animation: blink .9s steps(2, jump-none) infinite; }

@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklab, currentColor 60%, transparent); }
  50% { box-shadow: 0 0 0 5px transparent; }
}
@keyframes blink { 50% { opacity: .25; } }

/* ---- artwork ----------------------------------------------------------- */

.art {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: linear-gradient(150deg, var(--panel-2), var(--ink-lift));
  border: 1px solid var(--line-soft);
  isolation: isolate;
}
.art img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .6s var(--ease), transform 8s linear, filter .5s;
}
.art img[data-empty='1'] { opacity: 0; }
.art .art-empty {
  position: absolute; inset: 0;
  display: grid; place-content: center; gap: 10px; justify-items: center;
  color: var(--dimmer);
}
.art-glow {
  position: absolute; inset: -30%;
  z-index: -1;
  filter: blur(50px) saturate(1.8);
  opacity: var(--glow-opacity);
  object-fit: cover;
}

/* The cue: the one moment everybody in the room shares. */
.cue {
  position: absolute; inset: 0;
  display: grid; place-content: center;
  gap: 10px; justify-items: center;
  background: color-mix(in oklab, var(--ink) 62%, transparent);
  backdrop-filter: blur(14px) saturate(.6);
  opacity: 0; pointer-events: none;
  transition: opacity .25s var(--ease);
}
.cue[data-on='1'] { opacity: 1; }
.cue-ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.cue-ring circle { fill: none; stroke-width: 2; }
.cue-ring .track { stroke: color-mix(in oklab, var(--bone) 12%, transparent); }
.cue-ring .sweep { stroke: var(--sodium); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; }
.cue-num {
  font-family: var(--mono);
  font-size: clamp(48px, 11vw, 92px);
  font-weight: 700;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  color: var(--sodium-hot);
  text-shadow: 0 0 40px color-mix(in oklab, var(--sodium) 55%, transparent);
  line-height: 1;
}
.cue-note { color: var(--sodium); }

/* ---- scrubber ---------------------------------------------------------- */

.scrub { display: grid; gap: 8px; }
.scrub-times {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
}

input[type='range'].bar {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: none; cursor: pointer;
  --fill: 0%;
}
input[type='range'].bar::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background:
    linear-gradient(90deg, var(--sodium) var(--fill), transparent var(--fill)),
    color-mix(in oklab, var(--bone) 12%, transparent);
}
input[type='range'].bar::-moz-range-track {
  height: 6px; border-radius: 999px;
  background:
    linear-gradient(90deg, var(--sodium) var(--fill), transparent var(--fill)),
    color-mix(in oklab, var(--bone) 12%, transparent);
}
input[type='range'].bar::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; margin-top: -4px;
  border-radius: 50%; background: var(--bone);
  border: 0;
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--ink) 70%, transparent), 0 2px 10px var(--drop);
  transition: transform .15s var(--ease);
}
input[type='range'].bar::-moz-range-thumb {
  width: 14px; height: 14px; border: 0;
  border-radius: 50%; background: var(--bone);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--ink) 70%, transparent);
}
input[type='range'].bar:hover::-webkit-slider-thumb { transform: scale(1.25); }
input[type='range'].bar:disabled { opacity: .45; cursor: default; }

input[type='range'].mini { height: 18px; }
input[type='range'].mini::-webkit-slider-runnable-track { height: 4px; }
input[type='range'].mini::-webkit-slider-thumb { width: 11px; height: 11px; margin-top: -3.5px; box-shadow: 0 0 0 3px color-mix(in oklab, var(--ink) 70%, transparent); }
input[type='range'].mini::-moz-range-track { height: 4px; }
input[type='range'].mini::-moz-range-thumb { width: 11px; height: 11px; }

/* ---- transport --------------------------------------------------------- */

.transport { display: flex; align-items: center; justify-content: center; gap: clamp(10px, 3vw, 22px); }

.tbtn {
  width: 44px; height: 44px;
  display: grid; place-content: center;
  border-radius: 50%;
  color: var(--dim);
  transition: color .16s, background .16s, transform .12s var(--ease);
}
.tbtn:hover { color: var(--bone); background: color-mix(in oklab, var(--bone) 7%, transparent); }
.tbtn:active { transform: scale(.92); }
.tbtn[aria-pressed='true'] { color: var(--sodium); }
.tbtn[disabled] { opacity: .3; pointer-events: none; }

.tbtn-play {
  width: 66px; height: 66px;
  background: linear-gradient(180deg, var(--sodium-hot), var(--sodium));
  color: var(--on-sodium);
  box-shadow: 0 10px 34px -12px color-mix(in oklab, var(--sodium) 90%, transparent);
}
.tbtn-play:hover {
  background: linear-gradient(180deg, color-mix(in oklab, var(--sodium-hot) 82%, var(--bone)), var(--sodium-hot));
  color: var(--on-sodium);
}

/* ---- lists ------------------------------------------------------------- */

.rows { display: grid; gap: 2px; }

.row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  text-align: left;
  width: 100%;
  transition: background .15s, border-color .15s;
}
.row:hover { background: color-mix(in oklab, var(--bone) 5%, transparent); }
.row[data-current='1'] { background: color-mix(in oklab, var(--sodium) 11%, transparent); border-color: color-mix(in oklab, var(--sodium) 22%, transparent); }
.row-art { width: 34px; height: 34px; border-radius: var(--r-sm); object-fit: cover; background: var(--panel-2); }
.row-main { min-width: 0; }
.row-title { font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; }
.row-sub { font-size: 11.5px; color: var(--dim); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { display: flex; align-items: center; gap: 4px; opacity: 0; transition: opacity .15s; }
.row:hover .row-end, .row:focus-within .row-end { opacity: 1; }
.row-time { font-family: var(--mono); font-size: 10.5px; color: var(--dimmer); font-variant-numeric: tabular-nums; }

.iconbtn {
  width: 28px; height: 28px; display: grid; place-content: center;
  border-radius: var(--r-sm); color: var(--dim);
  transition: background .15s, color .15s;
}
.iconbtn:hover { background: color-mix(in oklab, var(--bone) 10%, transparent); color: var(--bone); }

.empty {
  display: grid; gap: 6px; justify-items: center; text-align: center;
  padding: 34px 18px; color: var(--dimmer);
}
.empty strong { color: var(--dim); font-weight: 600; font-size: 13.5px; }
.empty span { font-size: 12.5px; max-width: 30ch; }

/* ---- toast ------------------------------------------------------------- */

.toasts {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: grid; gap: 8px; justify-items: center; z-index: 60; pointer-events: none;
}
.toast {
  padding: 10px 16px; border-radius: 999px;
  background: color-mix(in oklab, var(--panel-2) 92%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  font-size: 13px; box-shadow: 0 12px 40px -14px var(--drop);
  animation: rise .3s var(--ease) both;
}
.toast[data-kind='error'] { border-color: color-mix(in oklab, var(--drift) 45%, var(--line)); color: var(--drift); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* Several things here set an explicit display, which would otherwise win
   against the browser default for [hidden]. */
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
