/* ==========================================================================
   NOW PLAYING: a Spotify-style player living on the speaker's screen.
   The 3D room paints this element to a texture (no gradients, opacity or
   transforms there), so the base state uses flat colours and plain boxes;
   gradients, glows, tilt and motion are live-only (pseudo-elements, keyframes).
   Everything is sized in em: the speaker screen is 20em wide.
   ========================================================================== */
.surface.music {
  --g: #1ed760;               /* spotify green */
  --pk: #ff9ebb;
  --np-art: url("/np-art.jpg");
  --p: 0%;                    /* playback progress, set by JS */
  --v: 20%;                   /* volume, set by JS */
  isolation: isolate;
  position: relative;
  overflow: hidden;
  background: #07080d;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: none;
  align-items: center;
  gap: 1.15em;
  padding: .8em 1.1em .8em .9em;
  color: #f4e7e2;
  perspective: 40em;
}
.surface.music .np-bg { display: none; }

/* live-only atmosphere */
.surface.music::before {
  content: ""; position: absolute; inset: -30%; z-index: -2;
  background: var(--np-art) center / cover;
  filter: blur(26px) brightness(.38) saturate(1.5);
  animation: np-drift 22s ease-in-out infinite alternate;
}
.surface.music::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 90% at 0% 100%, #ff6a2a33, transparent 70%),
    radial-gradient(50% 80% at 100% 0%, #ff9ebb26, transparent 70%),
    repeating-linear-gradient(0deg, #ffffff07 0 1px, transparent 1px 3px);
}
@keyframes np-drift { from { transform: scale(1) translate(0, 0); } to { transform: scale(1.12) translate(-3%, 2%); } }

/* ---- sleeve + record ---- */
.music .stage {
  position: relative;
  width: 7em; height: 5.6em;
  transform-style: preserve-3d;
  transform: rotateX(calc(var(--ry, 0) * -1deg)) rotateY(calc(var(--rx, 0) * 1deg));
  transition: transform .25s cubic-bezier(.2, .7, .2, 1);
}
.music .art {
  position: absolute; left: 0; top: 0; z-index: 2;
  width: 5.6em; height: 5.6em; object-fit: cover; object-position: 50% 58%;
  border-radius: .45em; background: #1b1f33;
  box-shadow: 0 .9em 1.8em -.5em #000c, 0 0 2.2em -.4em #ff6a2a66, 0 0 0 1px #ffffff1f;
  animation: np-art-in .9s cubic-bezier(.2, .8, .2, 1) both;
}
.music .vinyl {
  position: absolute; z-index: 1; top: .3em; left: .5em;
  width: 5em; height: 5em; border-radius: 50%;
  background: #0b0b10;
  display: grid; place-items: center;
  transition: left .9s cubic-bezier(.3, .8, .2, 1);
  animation: np-spin 5.5s linear infinite paused;
  box-shadow: 0 .4em 1em -.3em #000c;
}
.music[data-state="playing"] .vinyl { left: 2em; animation-play-state: running; }
.music .vinyl .grv { position: absolute; inset: .35em; border-radius: 50%; border: 1px solid #ffffff14; }
.music .vinyl .lbl { width: 1.7em; height: 1.7em; border-radius: 50%; background: var(--pk); }
.music .vinyl .hole { position: absolute; width: .3em; height: .3em; border-radius: 50%; background: #07080d; }
.music .vinyl::after { /* sheen, live only */
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 20%, #ffffff1f 25%, transparent 30% 70%, #ffffff1f 75%, transparent 80%);
}
@keyframes np-spin { to { transform: rotate(360deg); } }
@keyframes np-art-in { from { opacity: 0; transform: translateX(-1em) scale(.92); } }

/* ---- text column ---- */
.music .np { display: flex; flex-direction: column; gap: .42em; min-width: 0; }
.music .np > * { animation: np-rise .7s cubic-bezier(.2, .8, .2, 1) both; }
.music .np > :nth-child(2) { animation-delay: .08s; }
.music .np > :nth-child(3) { animation-delay: .16s; }
.music .np > :nth-child(4) { animation-delay: .24s; }
@keyframes np-rise { from { opacity: 0; transform: translateY(.7em); } }

.music .head { display: flex; align-items: center; gap: .45em; min-width: 0; }
.music .spot { width: .95em; height: .95em; flex: none; display: block; }
.music .kicker { margin: 0; color: var(--g); font-size: .6em; letter-spacing: .16em; line-height: 1; }
.music .pill {
  margin-left: auto; display: inline-flex; align-items: center; gap: .5em; flex: none;
  padding: .32em .7em .32em .55em; border-radius: 1em; background: #ffffff1a;
  font: .5em/1 "Space Mono", ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; color: #d9cdd0; white-space: nowrap;
}
.music .eq { display: inline-flex; align-items: flex-end; gap: .15em; height: 1em; }
.music .eq i { width: .17em; height: .3em; background: var(--g); border-radius: 1px; display: block; }
.music[data-state="playing"] .eq i { animation: np-eq .9s ease-in-out infinite alternate; }
.music[data-state="playing"] .eq i:nth-child(2) { animation-duration: .65s; animation-delay: -.3s; }
.music[data-state="playing"] .eq i:nth-child(3) { animation-duration: 1.1s; animation-delay: -.55s; }
.music[data-state="playing"] .eq i:nth-child(4) { animation-duration: .75s; animation-delay: -.15s; }
@keyframes np-eq { from { height: .25em; } to { height: 1em; } }
.music[data-state="paused"] .eq i { background: #8b849e; }
.music[data-state="paused"] .kicker { color: #b9b2c4; }

.music h3 {
  margin: 0; font-size: 1.55em; font-weight: 700; letter-spacing: -.03em; line-height: 1.05;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* progress */
.music .prog { display: flex; align-items: center; gap: .55em; font: .46em/1 "Space Mono", ui-monospace, monospace; color: #b9b2c4; }
.music .tm { min-width: 3em; font-variant-numeric: tabular-nums; }
.music .tm::before { content: attr(data-t); }
.music .tm.dur { text-align: right; }
.music .bar { flex: 1; height: .4em; border-radius: .4em; background: #ffffff38; position: relative; cursor: pointer; display: block; }
.music .bar .fill { position: absolute; left: 0; top: 0; bottom: 0; width: var(--p); border-radius: .4em; background: #f4e7e2; display: block; transition: background .2s; }
.music .bar::after { content: ""; position: absolute; top: 50%; left: var(--p); width: 1em; height: 1em; margin: -.5em 0 0 -.5em; border-radius: 50%; background: #fff; box-shadow: 0 0 .6em #0008; transform: scale(0); transition: transform .2s; }
.music .bar::before { content: ""; position: absolute; inset: -.9em 0; }
.music .bar:hover .fill, .music .bar:focus-visible .fill { background: var(--g); }
.music .bar:hover::after, .music .bar:focus-visible::after { transform: scale(1); }
.music .bar:focus-visible { outline: 2px solid var(--pk); outline-offset: .4em; }

/* controls */
.music .foot { display: flex; align-items: center; gap: .7em; }
.music .play {
  flex: none; width: 2em; height: 2em; padding: 0; border: 0; border-radius: 50%;
  background: #f4e7e2; color: #07080d; cursor: pointer; display: grid; place-items: center;
  transition: transform .2s cubic-bezier(.2, .7, .2, 1), background .2s, box-shadow .2s;
  box-shadow: 0 .3em .9em -.2em #0009;
}
.music .play svg { width: 1.1em; height: 1.1em; display: block; }
.music .play svg[hidden] { display: none; }
.music .play:hover { transform: scale(1.08); background: #fff; box-shadow: 0 0 1.4em -.1em #1ed76080; }
.music .play:active { transform: scale(.95); }
.music .vol { flex: 1; display: flex; align-items: center; gap: .5em; min-width: 0; }
.music .vol button { flex: none; width: 1.2em; height: 1.2em; padding: 0; border: 0; background: transparent; color: #b9b2c4; cursor: pointer; transition: color .2s, transform .2s; }
.music .vol button:hover { color: #fff; transform: scale(1.12); }
.music .vol svg { width: 100%; height: 100%; display: block; fill: none; stroke: currentColor; stroke-width: 1.5px; stroke-linecap: round; stroke-linejoin: round; }
.music .vol .cone { fill: currentColor; }
.music .vol .cross, .music .vol[data-muted] .waves { display: none; }
.music .vol[data-muted] .cross { display: inline; }
.music .track { flex: 1; position: relative; height: .3em; min-width: 2em; border-radius: .3em; background: #ffffff38; }
.music .track::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--v); border-radius: .3em; background: var(--g); transition: width .12s; }
.music .track::after { content: ""; position: absolute; top: 50%; left: var(--v); width: .85em; height: .85em; margin: -.425em 0 0 -.425em; border-radius: 50%; background: #fff; box-shadow: 0 0 .5em #0008; transform: scale(0); transition: transform .2s; }
.music .vol:hover .track::after, .music .track:has(input:focus-visible)::after { transform: scale(1); }
.music .track input { appearance: none; -webkit-appearance: none; position: absolute; inset: -.7em 0; width: 100%; height: auto; margin: 0; opacity: 0; cursor: pointer; background: transparent; }
.music .pct { flex: none; min-width: 2.4em; text-align: right; font: .46em/1 "Space Mono", ui-monospace, monospace; color: #b9b2c4; font-variant-numeric: tabular-nums; }
.music .pct::before { content: attr(data-t); }
.music .vol[data-muted] .track::before { background: #8b849e; }
.music button:focus-visible { outline: 2px solid var(--pk); outline-offset: 2px; }

/* the 3D room paints a flat copy: no tilt, motion or transforms there */
.music.painting *, .music.painting::before { transform: none !important; translate: none !important; rotate: none !important; scale: none !important; }
.music.painting .vinyl { left: .5em; }
.music.painting[data-state="playing"] .vinyl { left: 2em; }

/* ---- phone / full sheet: tall layout ---- */
.surface.sheet.music {
  grid-template-columns: 1fr; grid-template-rows: auto auto; align-content: center; justify-items: center;
  gap: 1.4em; padding: 1.4em 1.2em; text-align: center; overflow-y: auto;
}
.sheet.music .stage { width: 13.4em; height: 11.6em; }
.sheet.music .art { width: 11.6em; height: 11.6em; border-radius: .7em; }
.sheet.music .vinyl { width: 10.4em; height: 10.4em; top: .6em; left: 1em; }
.sheet.music[data-state="playing"] .vinyl { left: 2.8em; }
.sheet.music .vinyl .lbl { width: 3.4em; height: 3.4em; }
.sheet.music .np { width: 100%; gap: .8em; }
.sheet.music .head { justify-content: center; }
.sheet.music .pill { margin-left: .4em; }
.sheet.music h3 { font-size: 1.9em; text-align: center; }
.sheet.music .prog { font-size: .6em; }
.sheet.music .foot { flex-direction: column; gap: 1em; }
.sheet.music .play { width: 3em; height: 3em; }
.sheet.music .vol { width: 100%; }
.sheet.music .pct { font-size: .6em; }

/* ---- static (2D) page ---- */
html.flat .surface.music { display: none; }
html.flat .surface.music.s-live {
  display: grid; width: min(100%, 680px); padding: 22px; gap: 22px; font-size: 18px;
  margin-top: clamp(64px, 8vw, 96px); border: 1px solid #262c44; border-radius: 22px;
  grid-template-columns: auto minmax(0, 1fr); perspective: none;
}
html.flat .surface.music.s-live::before { inset: -30%; opacity: .9; }
html.flat .music .kicker::after { content: none; }
@media (width <= 520px) {
  html.flat .surface.music.s-live { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  html.flat .music .head { justify-content: center; }
  html.flat .music .stage { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .surface.music::before, .music .np > *, .music .art, .music .vinyl, .music .eq i { animation: none !important; }
  .music .stage { transition: none; }
}
