/* Stem Player — styles. Re-theme by overriding the custom properties on .sp */

.sp {
  --sp-bg: #111214;
  --sp-bar: #18191c;
  --sp-text: #ecebe8;
  --sp-muted: #9a988f;
  --sp-track: #34353a;
  --sp-buffer: #55565c;
  --sp-accent: #e8a33d;     /* playhead / voice */
  --sp-voice: #e8a33d;
  --sp-music: #5cb8a8;
  --sp-radius: 12px;
  --sp-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--sp-bg);
  color: var(--sp-text);
  font-family: var(--sp-font);
  font-size: 14px;
  border-radius: var(--sp-radius);
  overflow: hidden;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.sp *, .sp *::before, .sp *::after { box-sizing: border-box; }
.sp:focus-visible { box-shadow: 0 0 0 2px var(--sp-accent); }
.sp [hidden] { display: none !important; }
.sp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- stage ---------- */
.sp-stage { position: relative; aspect-ratio: 16 / 9; background: #000; }
.sp-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; cursor: pointer; }

.sp-bigplay {
  position: absolute; inset: 0; margin: auto;
  width: 76px; height: 76px; border-radius: 50%;
  border: 0; padding: 0 0 0 5px;
  display: grid; place-items: center;
  background: rgba(17, 18, 20, 0.72);
  color: #fff; cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.2s ease;
}
.sp-bigplay svg { width: 34px; height: 34px; }
.sp-bigplay:hover { transform: scale(1.06); background: var(--sp-accent); color: #111; }
.sp-playing .sp-bigplay { opacity: 0; pointer-events: none; }

.sp-spinner {
  position: absolute; inset: 0; margin: auto; width: 44px; height: 44px;
  border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: #fff;
  animation: sp-spin 0.8s linear infinite; pointer-events: none;
}
@keyframes sp-spin { to { transform: rotate(360deg); } }

.sp-error {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 24px;
  background: rgba(0, 0, 0, 0.82); color: var(--sp-text); text-align: center; font-size: 15px;
}
.sp-has-error .sp-bigplay { display: none; }

/* ---------- control bar ---------- */
.sp-bar { background: var(--sp-bar); padding: 10px 16px 12px; display: flex; flex-direction: column; gap: 8px; }

.sp-timeline { display: flex; align-items: center; gap: 12px; }
.sp-time { font-variant-numeric: tabular-nums; color: var(--sp-muted); font-size: 12.5px; min-width: 3.4em; }
.sp-remaining { text-align: right; }

.sp-scrub { position: relative; flex: 1; height: 22px; --p: 0%; --b: 0%; }
.sp-scrub-track {
  position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px;
  border-radius: 2px; background: var(--sp-track); overflow: hidden; transition: height 0.12s, margin 0.12s;
}
.sp-scrub:hover .sp-scrub-track { height: 6px; margin-top: -3px; }
.sp-scrub-buf, .sp-scrub-fill { position: absolute; left: 0; top: 0; bottom: 0; }
.sp-scrub-buf { width: var(--b); background: var(--sp-buffer); }
.sp-scrub-fill { width: var(--p); background: var(--sp-accent); }

.sp-scrub-tip {
  position: absolute; bottom: 100%; transform: translate(-50%, -4px);
  background: #000; color: #fff; font-size: 12px; font-variant-numeric: tabular-nums;
  padding: 3px 7px; border-radius: 5px; pointer-events: none; white-space: nowrap;
}

/* shared range reset */
.sp input[type="range"] {
  -webkit-appearance: none; appearance: none; background: transparent;
  margin: 0; cursor: pointer; touch-action: none;
}
.sp input[type="range"]:focus { outline: none; }
.sp input[type="range"]::-webkit-slider-runnable-track { height: 100%; background: transparent; border: 0; }
.sp input[type="range"]::-moz-range-track { height: 100%; background: transparent; border: 0; }
.sp input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 0; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  margin-top: calc((var(--h, 22px) - 14px) / 2);
  transition: transform 0.12s;
}
.sp input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.sp input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--sp-accent); }
.sp input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--sp-accent); }

.sp-scrub-input { position: absolute; inset: 0; width: 100%; height: 100%; --h: 22px; }
.sp-scrub-input::-webkit-slider-thumb { transform: scale(0); }
.sp-scrub:hover .sp-scrub-input::-webkit-slider-thumb,
.sp-scrub-input:active::-webkit-slider-thumb,
.sp-scrub-input:focus-visible::-webkit-slider-thumb { transform: scale(1); }

.sp-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.sp-btn {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 0; border-radius: 8px; padding: 0; background: transparent; color: var(--sp-text); cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.sp-btn svg { width: 22px; height: 22px; }
.sp-btn:hover { background: rgba(255, 255, 255, 0.08); }
.sp-btn:focus-visible { outline: 2px solid var(--sp-accent); outline-offset: 1px; }
.sp-btn:disabled { opacity: 0.4; cursor: default; }
.sp-play { width: 42px; height: 42px; background: var(--sp-text); color: var(--sp-bar); border-radius: 50%; }
.sp-play:hover { background: var(--sp-accent); color: #111; }
.sp-play svg { width: 20px; height: 20px; }

/* ---------- faders ---------- */
.sp-mix { display: flex; align-items: center; gap: 22px; flex: 1 1 auto; min-width: 0; }
.sp-fader { --p: 100%; --c: var(--sp-voice); display: flex; align-items: center; gap: 10px; flex: 1 1 180px; max-width: 260px; min-width: 150px; }
.sp-fader[data-track="music"] { --c: var(--sp-music); }

.sp-fader-label {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  background: none; border: 0; padding: 4px 2px; color: var(--sp-text); cursor: pointer;
  font: 600 12px/1 var(--sp-font); letter-spacing: 0.06em; text-transform: uppercase;
}
.sp-fader-label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); transition: opacity 0.12s; }
.sp-fader-label:focus-visible { outline: 2px solid var(--sp-accent); outline-offset: 2px; border-radius: 4px; }
.sp-fader.is-muted .sp-fader-label { color: var(--sp-muted); text-decoration: line-through; }
.sp-fader.is-muted .sp-fader-label::before { opacity: 0.3; }

.sp-fader input[type="range"] {
  flex: 1; min-width: 60px; height: 22px; --h: 22px;
  background:
    linear-gradient(var(--c), var(--c)) 0 50% / var(--p) 4px no-repeat,
    linear-gradient(var(--sp-track), var(--sp-track)) 0 50% / 100% 4px no-repeat;
  border-radius: 2px;
}
.sp-fader-val { width: 2.2em; text-align: right; font-size: 12px; color: var(--sp-muted); font-variant-numeric: tabular-nums; }

/* ---------- right side ---------- */
.sp-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.sp-quality { position: relative; display: flex; }
.sp-quality-select {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  height: 32px; padding: 0 28px 0 11px; border-radius: 8px;
  border: 1px solid var(--sp-track); background: transparent; color: var(--sp-text);
  font: 500 12.5px/1 var(--sp-font);
  background-image: linear-gradient(45deg, transparent 50%, var(--sp-muted) 50%), linear-gradient(135deg, var(--sp-muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.sp-quality-select:hover { border-color: var(--sp-buffer); }
.sp-quality-select:focus-visible { outline: 2px solid var(--sp-accent); outline-offset: 1px; }
.sp-quality-select option { background: var(--sp-bar); color: var(--sp-text); }

/* ---------- full screen ---------- */
.sp-is-fs { border-radius: 0; height: 100%; }
.sp-is-fs .sp-stage { flex: 1; aspect-ratio: auto; min-height: 0; }
.sp:fullscreen { width: 100vw; height: 100vh; }
.sp-pseudo-fs { position: fixed !important; inset: 0; z-index: 2147483000; width: 100vw; height: 100dvh; }
html.sp-noscroll, html.sp-noscroll body { overflow: hidden; }

/* ---------- narrow screens ---------- */
@media (max-width: 640px) {
  .sp { border-radius: 0; }
  .sp-bar { padding: 8px 12px 12px; }
  .sp-row { gap: 10px; }
  .sp-mix { order: 3; flex-basis: 100%; gap: 16px; }
  .sp-fader { max-width: none; min-width: 0; }
  .sp-bigplay { width: 64px; height: 64px; }
}

/* ---------- library ---------- */
.sp-library { font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.sp-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.sp-lib-card { display: flex; flex-direction: column; text-decoration: none; color: inherit; border-radius: 10px; overflow: hidden; background: rgba(127, 127, 127, 0.08); transition: transform 0.15s; }
.sp-lib-card:hover { transform: translateY(-2px); }
.sp-lib-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #000; display: block; }
.sp-lib-body { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 10px 12px 12px; }
.sp-lib-title { font-weight: 600; }
.sp-lib-dur { font-size: 12.5px; opacity: 0.65; font-variant-numeric: tabular-nums; }
.sp-lib-msg { opacity: 0.7; }

@media (prefers-reduced-motion: reduce) {
  .sp *, .sp-lib-card { transition: none !important; }
}
