/**
 * Music page player — custom SoundCloud Widget API player.
 * Ported from design/boards/Music.dc.html (desktop) and MusicMobile.dc.html (phone).
 * Kept out of jt.css on purpose (see DESIGN-HANDOFF.md): everything is scoped
 * under .jt-music / .jt-music-mini so the generic class names below can't leak.
 * Tokens come from jt.css (:root): --music, --basalt, --snow, --ash, --rule, --sun.
 */

/* ---- Keyframes ---- */
@keyframes jtm-drop { 0% { transform: translateY(-130%) rotate(-14deg); opacity: 0 } 55% { transform: translateY(7%) rotate(2deg); opacity: 1 } 80% { transform: translateY(-3%) rotate(-1deg) } }
@keyframes jtm-rise { from { transform: translateY(24px); opacity: 0 } }
@keyframes jtm-wipe { from { clip-path: polygon(0 100%, 100% 100%, 100% 100%, 0 100%) } }
@keyframes jtm-spin { to { transform: rotate(360deg) } }
@keyframes jtm-eq { 0% { transform: scaleY(.25) } 50% { transform: scaleY(1) } 100% { transform: scaleY(.45) } }
@keyframes jtm-ttl { from { transform: translateY(45%); opacity: 0 } }
@keyframes jtm-swap { from { transform: translateX(90px) rotate(5deg); opacity: 0 } }

/* ---- Layout wrapper ---- */
.jt-music { padding-bottom: 24px; }
.jt-music .jtm-widget { position: absolute; width: 1px; height: 1px; left: -9999px; top: 0; border: 0; }

/* ---- Album shelf ---- */
.jt-music-shelf { display: flex; flex-wrap: wrap; gap: 32px 28px; align-items: flex-start; padding: 8px 0 72px; }
.jt-music .alb { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 12px; width: 156px; opacity: .6; transition: transform .45s cubic-bezier(.3,1.7,.5,1), opacity .3s; animation: jtm-rise .6s ease-out backwards; }
.jt-music .alb.on { opacity: 1; transform: translateY(-16px) rotate(-3deg); }
.jt-music .alb:hover { opacity: 1; transform: translateY(-12px) rotate(-3deg); }
.jt-music .alb:focus-visible { outline: 3px solid var(--sun); outline-offset: 6px; }
.jt-music .alb .cov { display: block; width: 156px; height: 156px; background: #2f2f33; clip-path: polygon(0 6%, 100% 0, 100% 100%, 0 100%); transition: clip-path .45s cubic-bezier(.3,1.5,.5,1); overflow: hidden; }
.jt-music .alb:hover .cov { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
.jt-music .alb .cov svg, .jt-music .alb .cov img { display: block; width: 100%; height: 100%; object-fit: cover; }
.jt-music .alb .nm { font-family: var(--head); font-weight: 700; font-size: 18px; line-height: 1.15; letter-spacing: -.015em; color: var(--snow); transition: color .2s; }
.jt-music .alb.on .nm { color: var(--music); }
.jt-music .alb .bar { display: block; height: 4px; background: var(--music); transform: scaleX(0); transform-origin: left; transition: transform .5s cubic-bezier(.2,.8,.2,1); }
.jt-music .alb.on .bar { transform: scaleX(1); }

/* ---- Stage + meta ---- */
.jt-music-player { display: flex; flex-wrap: wrap; gap: 48px 80px; align-items: center; }
.jt-music-stage { position: relative; flex: 0 0 400px; max-width: 100%; }
.jt-music-stage.swap .sleeve { animation: jtm-swap .8s cubic-bezier(.2,.9,.2,1) backwards; }
.jt-music-stage:hover .sleeve { transform: rotate(-1.5deg) scale(1.02); }
.jt-music .sleeve { position: relative; width: 400px; max-width: 100%; aspect-ratio: 1; background: #2f2f33; clip-path: polygon(0 6%, 100% 0, 100% 100%, 0 100%); animation: jtm-wipe 1s cubic-bezier(.2,.9,.2,1) .5s backwards; transition: transform .6s cubic-bezier(.3,1.6,.5,1); overflow: hidden; }
.jt-music .sleeve svg, .jt-music .sleeve img { display: block; width: 100%; height: 100%; object-fit: cover; }

.jt-music-meta { flex: 1 1 440px; min-width: 0; display: flex; flex-direction: column; gap: 28px; }
.jt-music-meta .jtm-album { font-style: italic; font-size: 24px; line-height: 1.3; color: var(--ash); }
.jt-music-meta .jtm-artist { font-family: var(--head); font-weight: 500; font-size: 16px; color: var(--ash); }
.jt-music-meta .jtm-credit { font-family: var(--head); font-weight: 500; font-size: 14px; color: var(--ash); margin-top: 2px; }
.jt-music-meta .jtm-credit[hidden] { display: none; }
.jt-music-meta .jtm-title { margin: 0; font-family: var(--head); font-weight: 800; font-size: clamp(48px, 7vw, 88px); line-height: .95; letter-spacing: -.045em; color: var(--music); min-height: 84px; }
.jt-music-meta .jtm-title.anim { animation: jtm-ttl .7s cubic-bezier(.2,.9,.2,1) backwards; }

/* ---- Scrubber ---- */
.jt-music-time { display: flex; align-items: center; gap: 16px; font-family: var(--head); font-weight: 500; font-size: 16px; color: var(--ash); }
.jt-music .scrub { -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 28px; margin: 0; background: transparent; cursor: pointer; }
.jt-music .scrub::-webkit-slider-runnable-track { height: 12px; background: linear-gradient(90deg, var(--music) var(--p, 0%), var(--rule) var(--p, 0%)); clip-path: polygon(0 0, 100% 30%, 100% 100%, 0 100%); }
.jt-music .scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 28px; margin-top: -8px; background: var(--snow); clip-path: polygon(0 12%, 100% 0, 100% 100%, 0 88%); transition: transform .25s cubic-bezier(.3,1.9,.5,1); }
.jt-music .scrub:hover::-webkit-slider-thumb { transform: scaleY(1.2) scaleX(1.3); }
.jt-music .scrub::-moz-range-track { height: 12px; background: var(--rule); }
.jt-music .scrub::-moz-range-progress { height: 12px; background: var(--music); }
.jt-music .scrub::-moz-range-thumb { width: 14px; height: 28px; border: 0; border-radius: 0; background: var(--snow); }

/* ---- Transport ---- */
.jt-music-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.jt-music .ctl { width: 56px; height: 56px; border: 0; background: transparent; color: var(--snow); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .3s cubic-bezier(.3,1.9,.5,1), color .2s; }
.jt-music .ctl:hover { transform: scale(1.2); color: var(--music); }
.jt-music .ctl:active { transform: scale(.9); }
.jt-music .play { width: 96px; height: 96px; border: 0; background: var(--music); color: var(--basalt); display: flex; align-items: center; justify-content: center; cursor: pointer; clip-path: polygon(0 8%, 100% 0, 100% 100%, 0 100%); transition: transform .3s cubic-bezier(.3,1.9,.5,1); }
.jt-music .play:hover { transform: rotate(-5deg) scale(1.08); }
.jt-music .play:active { transform: scale(.92); }
.jt-music .play:focus-visible { outline: 3px solid var(--basalt); outline-offset: -8px; }
.jt-music .sc { font-family: var(--head); font-weight: 700; font-size: 16px; padding: 10px 2px; background: linear-gradient(currentColor, currentColor) 0 calc(100% - 2px) / 100% 2px no-repeat; transition: transform .3s cubic-bezier(.3,1.9,.5,1), color .2s; color: var(--snow); }
.jt-music .sc:hover { transform: translateX(6px); color: var(--music); }

/* ---- Credits block (expandable) ---- */
.jt-music-credits { margin-top: 56px; max-width: 760px; border-top: 1px solid var(--rule); }
.jt-music-credits[hidden] { display: none; }
.jt-music-credits > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 18px 0; font-family: var(--head); font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--ash); transition: color .2s; }
.jt-music-credits > summary::-webkit-details-marker { display: none; }
.jt-music-credits > summary:hover { color: var(--music); }
.jt-music-credits > summary:focus-visible { outline: 3px solid var(--sun); outline-offset: 4px; }
.jt-music-credits > summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .3s cubic-bezier(.3,1.5,.5,1); margin-top: -3px; }
.jt-music-credits[open] > summary::after { transform: rotate(-135deg); margin-top: 3px; }
.jt-music-credits .jtm-credits-list { margin: 0; padding: 0 0 24px; display: grid; gap: 14px 48px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.jt-music-credits .jtm-cr { border-top: 1px solid var(--rule); padding-top: 12px; }
.jt-music-credits .jtm-cr dt { font-family: var(--head); font-weight: 500; font-size: 13px; color: var(--ash); margin: 0 0 3px; }
.jt-music-credits .jtm-cr dd { margin: 0; font-family: var(--head); font-weight: 700; font-size: 18px; letter-spacing: -.01em; color: var(--snow); }

/* ---- Tracklist ---- */
.jt-music-tracks { list-style: none; margin: 96px 0 0; padding: 0; border-bottom: 1px solid var(--rule); }
.jt-music .tr { border-top: 1px solid var(--rule); animation: jtm-rise .6s ease-out backwards; }
.jt-music .tr button { all: unset; box-sizing: border-box; width: 100%; display: grid; grid-template-columns: 72px 1fr auto; align-items: center; padding: 20px 16px; cursor: pointer; color: var(--snow); background: linear-gradient(rgba(166,139,214,.24), rgba(166,139,214,.24)) 0 0 / 0 100% no-repeat; transition: background-size .45s cubic-bezier(.2,.8,.2,1); }
.jt-music .tr button:hover { background-size: 100% 100%; }
.jt-music .tr button:focus-visible { outline: 3px solid var(--sun); outline-offset: -3px; }
.jt-music .tr .name { font-family: var(--head); font-weight: 700; font-size: 28px; letter-spacing: -.02em; transition: transform .4s cubic-bezier(.3,1.7,.5,1); }
.jt-music .tr button:hover .name { transform: translateX(12px); }
.jt-music .tr .num, .jt-music .tr .dur { font-family: var(--head); font-weight: 500; font-size: 16px; color: var(--ash); }
.jt-music .tr .eqw { display: none; align-items: flex-end; gap: 3px; height: 22px; }
.jt-music .tr .eqw i { display: block; width: 5px; height: 22px; background: var(--basalt); transform-origin: bottom; transform: scaleY(.3); animation: jtm-eq .9s ease-in-out infinite alternate; animation-play-state: paused; }
.jt-music .tr .eqw i:nth-child(2) { animation-delay: .2s; }
.jt-music .tr .eqw i:nth-child(3) { animation-delay: .45s; }
.jt-music .tr.run .eqw i { animation-play-state: running; }
.jt-music .tr.on button { background: var(--music); color: var(--basalt); }
.jt-music .tr.on .eqw { display: flex; }
.jt-music .tr.on .num { display: none; }
.jt-music .tr.on .dur { color: var(--basalt); }

.jt-music-more { margin-top: 20px; min-height: 52px; width: 100%; border: 2px solid var(--snow); background: transparent; color: var(--snow); font-family: var(--head); font-weight: 700; font-size: 17px; cursor: pointer; display: none; transition: background .2s, color .2s; }
.jt-music-more:hover { background: var(--snow); color: var(--basalt); }

/* ---- Mini player ---- */
/* Hidden via translateY(110%) only hides it while stuck at the viewport bottom;
   at the page bottom it parks in flow right above the footer, so the opaque bar
   would paint over the footer. visibility:hidden keeps it clear there (kept
   visible through the .8s slide-out via the delayed visibility transition). */
.jt-music-mini { position: sticky; bottom: 0; z-index: 5; background: var(--music); color: var(--basalt); clip-path: polygon(0 14px, 100% 0, 100% 100%, 0 100%); transform: translateY(110%); visibility: hidden; transition: transform .8s cubic-bezier(.3,1.4,.5,1), visibility 0s linear .8s; }
.jt-music-mini.show { transform: none; visibility: visible; transition: transform .8s cubic-bezier(.3,1.4,.5,1); }
.jt-music-mini .mrow { display: flex; align-items: center; gap: 16px; padding: 22px 56px 14px; box-sizing: border-box; }
.jt-music-mini .mdisc { width: 44px; height: 44px; border-radius: 50%; background: repeating-radial-gradient(circle, var(--basalt-deep) 0 2px, var(--night) 2px 4px); position: relative; flex: 0 0 auto; animation: jtm-spin 4s linear infinite; animation-play-state: paused; }
.jt-music-mini .mdisc.on { animation-play-state: running; }
.jt-music-mini .mdisc::before { content: ""; position: absolute; inset: 32%; border-radius: 50%; background: var(--music); }
.jt-music-mini .minfo { flex: 1 1 auto; min-width: 0; }
.jt-music-mini .mtitle { font-family: var(--head); font-weight: 800; font-size: 22px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jt-music-mini .msub { font-family: var(--head); font-weight: 500; font-size: 14px; }
.jt-music-mini .mbtn { width: 48px; height: 48px; border: 0; background: transparent; color: var(--basalt); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .3s cubic-bezier(.3,1.9,.5,1); }
.jt-music-mini .mbtn:hover { transform: scale(1.2); }
.jt-music-mini .mbar { height: 4px; background: linear-gradient(90deg, var(--basalt) var(--p, 0%), rgba(35,35,38,.25) var(--p, 0%)); }

/* ---- Phone ---- */
@media (max-width: 760px) {
  .jt-music-shelf { flex-wrap: nowrap; gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 calc(var(--gutter) * -1) 24px; padding: 20px var(--gutter) 8px; -webkit-overflow-scrolling: touch; }
  .jt-music .alb { flex: 0 0 auto; width: 112px; gap: 10px; scroll-snap-align: start; }
  .jt-music .alb .cov { width: 112px; height: 112px; }
  .jt-music .alb .nm { font-size: 16px; }
  .jt-music-player { gap: 24px; flex-direction: column; align-items: stretch; }
  .jt-music-stage { flex: 0 0 auto; width: 100%; max-width: 320px; margin: 0 auto; }
  .jt-music .sleeve { width: 100%; }
  .jt-music-meta { gap: 16px; }
  .jt-music-meta .jtm-title { min-height: 0; }
  .jt-music-controls { justify-content: center; }
  .jt-music .play { width: 84px; height: 84px; }
  .jt-music .sc { margin-left: 0 !important; }
  .jt-music-tracks { margin-top: 40px; }
  .jt-music .tr button { grid-template-columns: 48px 1fr auto; min-height: 64px; padding: 12px; }
  .jt-music .tr .name { font-size: 22px; }
  .jt-music-mini .mrow { padding: 20px 16px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .jt-music *, .jt-music *::before, .jt-music *::after,
  .jt-music-mini *, .jt-music-mini *::before, .jt-music-mini *::after { animation: none !important; transition: none !important; }
  .jt-music-mini { transform: none; }
}
