/* ============================================================
   css/soundtrack.css — the "Portfolio soundtrack" player
   (js/soundtrack.js builds the markup; prefix .st-)

   Desktop ≥ 900px : glass pill bottom-left — spinning vinyl, label,
                     now-playing line, analyser EQ bars, and a volume
                     slider that slides out on hover / focus.
   < 900px         : a 48px vinyl button above the tab bar, opposite
                     the chat launcher; parked over the hero (.is-parked)
                     unless it's playing.
   Hidden while the intro is up (html.intro). The soundtrack starts by
   itself after it (js/soundtrack.js) — no prompt.
   Themed with the page tokens; every var() has a light fallback.
   ============================================================ */

.st {
  --st-ease: var(--ease, cubic-bezier(.22, 1, .36, 1));
  --st-spring: cubic-bezier(.34, 1.56, .64, 1);
  --st-g1: var(--g1, #ff1b8d); --st-g2: var(--g2, #ff5a3c); --st-g3: var(--g3, #ffc23c);
  position: fixed; left: 24px; bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: calc(var(--z-chat, 90) - 1);           /* the chat sheet may cover it, never the reverse */
  display: flex; align-items: center;
  height: 56px; padding: 6px;
  border-radius: 99px;
  background: var(--glass, rgb(255 255 255 / .72));
  border: 1px solid var(--glass-line, rgb(21 17 20 / .08));
  -webkit-backdrop-filter: blur(16px) saturate(140%); backdrop-filter: blur(16px) saturate(140%);
  box-shadow:
    0 1px 2px rgb(var(--fg-rgb, 21 17 20) / .06),
    0 14px 34px -16px rgb(var(--fg-rgb, 21 17 20) / .28);
  color: var(--text, #151114);
  font-family: var(--sans, -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
  -webkit-font-smoothing: antialiased;
  transition: opacity .4s var(--st-ease), transform .45s var(--st-ease), box-shadow .3s, visibility 0s;
}
[data-theme="dark"] .st {
  box-shadow: 0 1px 0 rgb(255 255 255 / .04) inset, 0 16px 36px -18px rgb(0 0 0 / .8);
}
.st:hover { transform: translateY(-2px); }

/* hidden while the intro is up, then eases in */
html.intro .st,
.st.is-parked {
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(14px) scale(.9);
  transition: opacity .25s, transform .3s var(--st-ease), visibility 0s linear .3s;
}

/* ---------- the toggle ---------- */
.st-btn {
  display: flex; align-items: center; gap: 12px;
  height: 44px; padding: 0 14px 0 0; margin: 0;
  background: none; border: 0; border-radius: 99px;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.st-btn:focus-visible { outline: 2px solid var(--st-g2); outline-offset: 3px; }
.st-btn:active .st-disc { transform: scale(.94); }

/* ---------- vinyl ---------- */
.st-disc {
  position: relative; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  transition: transform .4s var(--st-spring);
}
.st-vinyl {
  position: absolute; inset: 0; border-radius: 50%;
  background:
    repeating-radial-gradient(circle at 50% 50%, #18171b 0 1.1px, #26252a 1.1px 2.3px);
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / .06),
    0 4px 10px -4px rgb(0 0 0 / .45);
  animation: st-spin 2.6s linear infinite;
  animation-play-state: paused;
}
.st.is-playing .st-vinyl { animation-play-state: running; }
[data-theme="dark"] .st-vinyl {                       /* a hairline rim so the record reads on graphite */
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .12), 0 4px 10px -4px rgb(0 0 0 / .6);
}
.st-label {
  position: absolute; inset: 30%; border-radius: 50%;
  background: conic-gradient(from 210deg, var(--st-g1), var(--st-g2), var(--st-g3), var(--st-g2), var(--st-g1));
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .14);
}
.st-label::before {                                   /* a tick so you can see it turn */
  content: ""; position: absolute; top: 12%; left: 50%;
  width: 2px; height: 22%; margin-left: -1px; border-radius: 2px;
  background: rgb(255 255 255 / .75);
}
.st-label::after {                                    /* spindle hole */
  content: ""; position: absolute; inset: 41%; border-radius: 50%;
  background: #141316;
}
.st-disc::after {                                     /* static sheen: light doesn't rotate with the record */
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: conic-gradient(from 20deg,
    transparent 0 8%, rgb(255 255 255 / .17) 13%, transparent 21% 52%,
    rgb(255 255 255 / .1) 60%, transparent 68%);
}
.st-glyph {                                     /* play / pause mark, sits on the label (doesn't spin) */
  position: absolute; left: 50%; top: 50%; z-index: 1;
  width: 16px; height: 16px; margin: -8px 0 0 -8px;
  display: grid; place-items: center; border-radius: 50%;
  color: #fff;
  filter: drop-shadow(0 1px 1.5px rgb(0 0 0 / .45));
  transition: opacity .25s, transform .35s var(--st-spring);
}
.st-glyph svg { width: 10px; height: 10px; display: block; }
.st:not(.is-playing) .st-label::before,
.st:not(.is-playing) .st-label::after { opacity: 0; }   /* the play mark replaces tick + hole */
.st.is-playing .st-glyph { opacity: 0; transform: scale(.6); }
.st.is-playing .st-btn:hover .st-glyph,
.st.is-playing .st-btn:focus-visible .st-glyph { opacity: 1; transform: none; }

@keyframes st-spin { to { transform: rotate(360deg); } }

/* ---------- text ---------- */
.st-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.st-kicker {
  font-size: 10px; font-weight: 600; line-height: 1;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted, #5b545c);
}
.st-now {
  position: relative; display: block;
  max-width: 184px; overflow: hidden; white-space: nowrap;
  font-size: 13px; font-weight: 600; line-height: 1.2; letter-spacing: -.01em;
  color: var(--text, #151114);
}
.st-now-inner { display: inline-block; padding-right: 2px; }   /* the last glyph’s ink can overhang its advance */
.st-now.is-long {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6px, #000 calc(100% - 14px), transparent);
          mask-image: linear-gradient(90deg, transparent, #000 6px, #000 calc(100% - 14px), transparent);
}
.st-now.is-long .st-now-inner { padding-left: 6px; animation: st-marquee var(--st-dur, 9s) ease-in-out infinite; }
@keyframes st-marquee {
  0%, 16% { transform: translateX(0); }
  48%, 64% { transform: translateX(var(--st-shift, 0)); }
  96%, 100% { transform: translateX(0); }
}

/* ---------- compact (desktop, scrolled past the hero) ----------
   The pill folds down to just the record so it stops covering content;
   hovering or focusing it opens the full player again. */
@media (min-width: 900px) {
  .st-text, .st-eq { max-width: 240px; transition: max-width .45s var(--st-ease), opacity .25s, margin .45s var(--st-ease); }
  .st-btn { transition: padding .45s var(--st-ease), gap .45s var(--st-ease); }
  .st.is-compact:not(:hover):not(:focus-within) .st-text,
  .st.is-compact:not(:hover):not(:focus-within) .st-eq { max-width: 0; opacity: 0; margin: 0; overflow: hidden; }
  .st.is-compact:not(:hover):not(:focus-within) .st-btn { padding-right: 0; gap: 0; }
}

/* ---------- EQ bars (scaleY written by the analyser loop) ---------- */
.st-eq {
  display: flex; align-items: flex-end; gap: 2.5px;
  height: 18px; margin-left: 2px; flex: none;
}
.st-eq i {
  display: block; width: 3px; height: 100%; border-radius: 2px;
  background: var(--line, #e6e0d8);
  transform: scaleY(.15); transform-origin: 50% 100%;
  transition: transform .35s var(--st-ease), background-color .3s;
}
.st.is-playing .st-eq i {
  background: linear-gradient(to top, var(--st-g1), var(--st-g2) 60%, var(--st-g3));
  transition: none;
}
/* no analyser (track played without CORS): a gentle idle dance */
.st.is-playing.is-eq-idle .st-eq i { animation: st-eq 1.15s ease-in-out infinite alternate; }
.st.is-playing.is-eq-idle .st-eq i:nth-child(2) { animation-duration: .9s; animation-delay: -.4s; }
.st.is-playing.is-eq-idle .st-eq i:nth-child(3) { animation-duration: 1.3s; animation-delay: -.7s; }
.st.is-playing.is-eq-idle .st-eq i:nth-child(4) { animation-duration: .8s; animation-delay: -.2s; }
.st.is-playing.is-eq-idle .st-eq i:nth-child(5) { animation-duration: 1.05s; animation-delay: -.55s; }
@keyframes st-eq {
  0% { transform: scaleY(.2); }
  50% { transform: scaleY(.75); }
  100% { transform: scaleY(.4); }
}

/* ---------- volume (slides out on hover / focus) ---------- */
.st-vol {
  display: flex; align-items: center;
  width: 0; opacity: 0; overflow: hidden;
  padding: 6px 0;                                     /* room for the slider's focus ring (overflow clips it) */
  transition: width .4s var(--st-ease), opacity .25s, margin .4s var(--st-ease);
}
.st:hover .st-vol,
.st:focus-within .st-vol { width: 96px; opacity: 1; margin-right: 10px; }
@media (hover: none) {
  .st-vol { width: 96px; opacity: 1; margin-right: 10px; }
}
.st-range {
  -webkit-appearance: none; appearance: none;
  width: 88px; height: 22px; margin: 0 4px; padding: 0;
  background: transparent; cursor: pointer;
}
.st-range:focus { outline: none; }
.st-range:focus-visible { outline: 2px solid var(--st-g2); outline-offset: 2px; border-radius: 6px; }
.st-range::-webkit-slider-runnable-track {
  height: 4px; border-radius: 99px;
  background:
    linear-gradient(90deg, var(--st-g1), var(--st-g2)) 0 0 / var(--st-v, 50%) 100% no-repeat,
    var(--line, #e6e0d8);
}
.st-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; margin-top: -5px; border-radius: 50%;
  background: var(--panel, #fff);
  border: 1px solid var(--line, #e6e0d8);
  box-shadow: 0 1px 3px rgb(0 0 0 / .25);
  transition: transform .25s var(--st-spring);
}
.st-range:active::-webkit-slider-thumb { transform: scale(1.15); }
.st-range::-moz-range-track { height: 4px; border-radius: 99px; background: var(--line, #e6e0d8); }
.st-range::-moz-range-progress { height: 4px; border-radius: 99px; background: linear-gradient(90deg, var(--st-g1), var(--st-g2)); }
.st-range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--panel, #fff); border: 1px solid var(--line, #e6e0d8);
  box-shadow: 0 1px 3px rgb(0 0 0 / .25);
}

.st-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- phones & tablets: a single vinyl button ---------- */
@media (max-width: 899px) {
  .st {
    left: 16px; bottom: calc(92px + env(safe-area-inset-bottom, 0px));
    width: 48px; height: 48px; padding: 0;
    border-radius: 50%; justify-content: center;
  }
  .st:hover { transform: none; }
  .st-btn { width: 48px; height: 48px; padding: 0; justify-content: center; border-radius: 50%; }
  .st-disc { width: 40px; height: 40px; }
  .st-text, .st-eq, .st-vol { display: none; }
  .st.is-playing .st-glyph { opacity: .9; transform: scale(.85); }
}

/* ---------- motion preferences ---------- */
html.motion-paused .st-vinyl,
html.motion-paused .st-now-inner,
html.motion-paused .st-eq i { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) {
  .st, .st-disc, .st-glyph, .st-vol, .st-eq i { transition: none; }
  .st:hover { transform: none; }
  .st-vinyl { animation: none; }
  .st.is-playing.is-eq-idle .st-eq i { animation: none; transform: scaleY(.5); }
  .st-now.is-long .st-now-inner { animation: none; padding-left: 0; }
  .st-now.is-long { -webkit-mask-image: none; mask-image: none; }
  .st-now { text-overflow: ellipsis; }
  .st-now-inner { display: inline; }
}
/* paused: no frozen half-scrolled title — show its start with an ellipsis */
html.motion-paused .st-now { text-overflow: ellipsis; }
html.motion-paused .st-now.is-long { -webkit-mask-image: none; mask-image: none; }
html.motion-paused .st-now.is-long .st-now-inner { display: inline; padding-left: 0; animation: none; }
/* motion off while playing: a still "equaliser" silhouette instead of flat bars */
html.motion-paused .st.is-playing .st-eq i:nth-child(1) { transform: scaleY(.45); }
html.motion-paused .st.is-playing .st-eq i:nth-child(2) { transform: scaleY(.75); }
html.motion-paused .st.is-playing .st-eq i:nth-child(3) { transform: scaleY(.55); }
html.motion-paused .st.is-playing .st-eq i:nth-child(4) { transform: scaleY(.85); }
html.motion-paused .st.is-playing .st-eq i:nth-child(5) { transform: scaleY(.4); }
@media (prefers-reduced-motion: reduce) {
  .st.is-playing .st-eq i:nth-child(1) { transform: scaleY(.45); }
  .st.is-playing .st-eq i:nth-child(2) { transform: scaleY(.75); }
  .st.is-playing .st-eq i:nth-child(3) { transform: scaleY(.55); }
  .st.is-playing .st-eq i:nth-child(4) { transform: scaleY(.85); }
  .st.is-playing .st-eq i:nth-child(5) { transform: scaleY(.4); }
}

@media print { .st { display: none !important; } }
