/* =====================================================================
   SANGITIFY — player: mini player, desktop bar, full player, YouTube dock
   ===================================================================== */

/* ---------- Shared bar (mini on mobile, full bar on desktop) ---------- */
.player {
  --h: 280;
  position: fixed; z-index: 44; left: 8px; right: 8px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 8px);
  height: var(--mini-h);
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 8px;
  border-radius: 18px; overflow: hidden;
  background:
    linear-gradient(90deg, hsl(var(--h) 60% 30% / .55), hsl(calc(var(--h) + 50) 60% 25% / .35)),
    var(--glass-strong);
  backdrop-filter: blur(22px) saturate(1.5); -webkit-backdrop-filter: blur(22px) saturate(1.5);
  border: 1px solid var(--border-strong);
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, .8);
  transform: translateY(0); transition: transform .35s var(--ease), opacity .35s;
}
.player[hidden] { display: flex; transform: translateY(160%); opacity: 0; pointer-events: none; }
html[data-theme="light"] .player { background: linear-gradient(90deg, hsl(var(--h) 80% 92% / .9), hsl(calc(var(--h) + 50) 80% 94% / .9)), var(--glass-strong); }
.player .p-open { position: absolute; inset: 0; z-index: 0; border-radius: inherit; }
.player > *:not(.p-open):not(.p-line) { position: relative; z-index: 1; }
.player .p-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.player .p-center { display: flex; align-items: center; }
.player .p-art .initial { display: none; }
.player .p-art { width: 48px; flex: none; border-radius: 12px; box-shadow: 0 6px 18px -6px hsl(var(--h) 90% 50% / .7); }
.player .p-art::after { display: none; }
.player .p-art .initial { font-size: .62rem; }
.player .p-meta { flex: 1; min-width: 0; pointer-events: none; }
.player .p-title { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .p-artist { font-size: var(--fs-xs); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; align-items: center; }
.player .p-artist .badge { height: 16px; font-size: 9px; padding: 0 5px; }
.player .p-controls { display: flex; align-items: center; gap: 2px; }
.player .p-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--text); transition: transform .15s, background .2s, color .2s; }
.player .p-btn:hover { background: rgba(255, 255, 255, .08); }
.player .p-btn:active { transform: scale(.9); }
.player .p-btn.on { color: var(--pink); }
.player .p-btn.small { color: var(--text-2); }
.player .p-play { position: relative; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); }
.player .p-play:active { transform: scale(.92); }
.player .p-play.loading::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--pink); }
.player .p-like.on { color: var(--pink); }
.player .p-line { position: absolute; left: 14px; right: 14px; bottom: 3px; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, .15); overflow: hidden; z-index: 1; pointer-events: none; }
.player .p-line i { display: block; height: 100%; width: 0; background: var(--grad); }
.player .p-progress, .player .p-extra, .player .hide-mini { display: none; }

/* seek bar used in desktop bar & full player */
.seek { display: flex; align-items: center; gap: 10px; width: 100%; font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.seek time { min-width: 38px; text-align: center; }
.range {
  --p: 0%;
  -webkit-appearance: none; appearance: none; flex: 1; height: 20px; background: transparent; cursor: pointer; margin: 0;
}
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--pink), var(--purple)) 0/var(--p) 100% no-repeat, var(--border-strong); }
.range::-moz-range-track { height: 4px; border-radius: 4px; background: var(--border-strong); }
.range::-moz-range-progress { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--pink), var(--purple)); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .4); transform: scale(0); transition: transform .15s; }
.range::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; transform: scale(0); transition: transform .15s; }
.range:hover::-webkit-slider-thumb, .range:focus-visible::-webkit-slider-thumb { transform: scale(1); }
.range:hover::-moz-range-thumb, .range:focus-visible::-moz-range-thumb { transform: scale(1); }
.range:focus-visible { box-shadow: none; }
.range:focus-visible::-webkit-slider-runnable-track { box-shadow: var(--focus); }
.range[disabled] { opacity: .5; cursor: default; }

@media (min-width: 1024px) {
  .player {
    left: 0; right: 0; bottom: 0; height: var(--bar-h); border-radius: 0; z-index: 55;
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 1.4fr) minmax(0, 1fr); gap: 20px;
    padding: 0 24px; border: 0; border-top: 1px solid var(--border);
    background: var(--glass-strong);
  }
  html[data-theme="light"] .player { background: var(--glass-strong); }
  .player[hidden] { display: grid; transform: none; opacity: 1; pointer-events: auto; }
  .player[hidden] .p-left, .player[hidden] .p-center, .player[hidden] .p-extra { opacity: .45; pointer-events: none; }
  .player .p-open, .player .p-line { display: none; }
  .player .p-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
  .player .p-art { width: 56px; cursor: pointer; }
  .player .p-meta { pointer-events: auto; }
  .player .p-title a:hover, .player .p-artist a:hover { text-decoration: underline; }
  .player .p-center { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
  .player .p-controls { gap: 8px; }
  .player .hide-mini { display: grid; }
  .player .p-play { width: 40px; height: 40px; }
  .player .p-progress { display: flex; width: 100%; max-width: 640px; }
  .player .p-extra { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
  .player .p-extra .range { flex: none; width: 110px; }
  .player .p-next-mobile { display: none; }
}

/* ---------- Mini player: little equaliser on the artwork ---------- */
.player .p-left { position: relative; }
.player .p-eq { position: absolute; left: 30px; bottom: 2px; height: 14px; padding: 2px 3px; border-radius: 6px; background: rgba(0, 0, 0, .55); pointer-events: none; z-index: 2; }
.player .p-eq i { width: 2px; }
.player .p-eq.paused { opacity: 0; transition: opacity .3s; }
@media (min-width: 1024px) { .player .p-eq { left: 38px; } }

/* ---------- Full-screen player ---------- */
.fullplayer {
  --h: 280;
  position: fixed; inset: 0; z-index: 150; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 20px calc(20px + var(--safe-b));
  background: var(--bg); isolation: isolate;
  transform: translateY(100%); visibility: hidden;
  transition: transform .42s var(--ease), visibility 0s linear .42s;
}
.fullplayer.open { transform: none; visibility: visible; transition: transform .42s var(--ease), visibility 0s; }

/* Animated background: slow drifting colour clouds taken from the song's hue */
.fp-bg { position: fixed; inset: -10%; z-index: -1; pointer-events: none; overflow: hidden; background: radial-gradient(120% 80% at 50% 0%, hsl(var(--h) 70% 18%), var(--bg) 70%); transition: background 1s; }
.fp-bg i { position: absolute; border-radius: 50%; opacity: .55; will-change: transform; } /* soft edges come from the gradient — no blur filter (cheap on phones) */
.fp-bg .b1 { width: 70vmax; height: 70vmax; left: -15%; top: -20%; background: radial-gradient(closest-side, hsl(var(--h) 85% 50%), hsl(var(--h) 85% 50% / .35) 55%, transparent); animation: fp-drift-a 22s ease-in-out infinite alternate; }
.fp-bg .b2 { width: 60vmax; height: 60vmax; right: -20%; top: 20%; background: radial-gradient(closest-side, hsl(calc(var(--h) + 55) 85% 52%), hsl(calc(var(--h) + 55) 85% 52% / .35) 55%, transparent); animation: fp-drift-b 26s ease-in-out infinite alternate; }
.fp-bg .b3 { width: 55vmax; height: 55vmax; left: 10%; bottom: -30%; background: radial-gradient(closest-side, hsl(calc(var(--h) - 50) 80% 45%), hsl(calc(var(--h) - 50) 80% 45% / .35) 55%, transparent); animation: fp-drift-c 30s ease-in-out infinite alternate; opacity: .4; }
.fp-bg .grain { inset: 0; border-radius: 0; filter: none; opacity: 1; background: radial-gradient(transparent 0, rgba(0, 0, 0, .35) 100%); }
html[data-theme="light"] .fp-bg { background: radial-gradient(120% 80% at 50% 0%, hsl(var(--h) 80% 88%), var(--bg) 70%); }
html[data-theme="light"] .fp-bg i { opacity: .35; }
.fullplayer:not(.playing) .fp-bg i { animation-play-state: paused; }
.fullplayer.watching .fp-bg i { opacity: .25; }
@keyframes fp-drift-a { to { transform: translate(18%, 14%) scale(1.15) rotate(25deg); } }
@keyframes fp-drift-b { to { transform: translate(-22%, -10%) scale(.9) rotate(-20deg); } }
@keyframes fp-drift-c { to { transform: translate(15%, -18%) scale(1.2); } }

.fullplayer .fp-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 56px; }
.fullplayer .fp-top .ctx { text-align: center; font-size: var(--fs-xs); color: var(--text-2); min-width: 0; }
.fullplayer .fp-top .ctx b { display: block; color: var(--text); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fullplayer .fp-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 20px; width: 100%; max-width: 520px; margin: 0 auto; transition: max-width .45s var(--ease); }
.fullplayer.watching .fp-body { max-width: 1000px; justify-content: flex-start; }

/* Stage: spinning disc with pulsing rings + radial visualiser */
.fullplayer .fp-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.fullplayer .fp-art-wrap { --size: min(68vw, 340px, 40vh); position: relative; display: grid; place-items: center; width: var(--size); aspect-ratio: 1; margin: calc(var(--size) * .2) auto; transition: width .45s var(--ease), opacity .35s, margin .45s var(--ease); }
.fullplayer.is-yt .fp-art-wrap { --size: min(52vw, 260px, 30vh); margin: calc(var(--size) * .18) auto calc(var(--size) * .12); }
.fullplayer.watching .fp-art-wrap { width: 0; margin: 0; opacity: 0; pointer-events: none; }
.fullplayer .fp-art { position: relative; z-index: 2; width: 100%; border-radius: 50%; box-shadow: 0 0 0 6px rgba(255, 255, 255, .06); will-change: transform; animation: fp-spin 24s linear infinite; animation-play-state: paused; transition: transform .5s var(--ease); }
.fullplayer .fp-art::before { content: ""; position: absolute; inset: 0; z-index: 3; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(0, 0, 0, .55) 0 5%, transparent 5.5%), repeating-radial-gradient(circle, rgba(255, 255, 255, .05) 0 1px, transparent 1px 5px); mix-blend-mode: overlay; }
.fullplayer .fp-art::after { display: none; }
.fullplayer .fp-art .initial { font-size: 1.4rem; }
.fullplayer.playing .fp-art { animation-play-state: running; }
.fullplayer:not(.playing) .fp-art-wrap { transform: scale(.94); }
.fullplayer .fp-art-wrap { transition: transform .5s var(--ease), width .45s var(--ease), opacity .35s, margin .45s var(--ease); }
@keyframes fp-spin { to { transform: rotate(360deg); } }
.fullplayer .fp-halo { position: absolute; inset: -18%; border-radius: 50%; z-index: 0; background: conic-gradient(from 0deg, hsl(var(--h) 90% 60% / 0), hsl(var(--h) 90% 60% / .45), hsl(calc(var(--h) + 70) 90% 60% / .35), hsl(var(--h) 90% 60% / 0)); animation: fp-spin 9s linear infinite reverse; will-change: transform; mask: radial-gradient(closest-side, #000 55%, transparent); -webkit-mask: radial-gradient(closest-side, #000 55%, transparent); animation-play-state: paused; }
.fullplayer.playing .fp-halo { animation-play-state: running; }
.fullplayer .fp-ring { position: absolute; inset: 0; z-index: 1; border-radius: 50%; border: 2px solid hsl(var(--h) 90% 70% / .5); opacity: 0; pointer-events: none; }
.fullplayer.playing .fp-ring { animation: fp-ring 3.6s cubic-bezier(.2, .6, .3, 1) infinite; }
.fullplayer.playing .fp-ring.r2 { animation-delay: 1.2s; border-color: hsl(calc(var(--h) + 50) 90% 70% / .45); }
.fullplayer.playing .fp-ring.r3 { animation-delay: 2.4s; border-color: hsl(calc(var(--h) - 40) 90% 70% / .4); }
@keyframes fp-ring { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(1.65); opacity: 0; } }
.fullplayer .fp-viz { position: absolute; z-index: 1; width: 150%; height: 150%; left: -25%; top: -25%; pointer-events: none; }

/* The YouTube video card (the real player floats exactly over this placeholder) */
.fullplayer .fp-video { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.fullplayer .fp-video[hidden] { display: none; }
.fullplayer .fp-video-slot { width: min(100%, 356px); min-width: 200px; aspect-ratio: 16 / 9; min-height: 200px; border-radius: var(--r-lg); background: rgba(0, 0, 0, .35); box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .9); transition: width .45s var(--ease); }
.fullplayer.watching .fp-video-slot { width: 100%; max-height: 72vh; }
.fullplayer .fp-watch { gap: 8px; backdrop-filter: blur(10px); }

.fullplayer .fp-info { display: flex; align-items: center; gap: 12px; }
.fullplayer .fp-info > div { flex: 1; min-width: 0; }
.fullplayer .fp-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fullplayer .fp-artist { color: var(--text-2); font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fullplayer .fp-artist a:hover { color: var(--text); text-decoration: underline; }
.fullplayer .fp-like { width: 48px; height: 48px; }
.fullplayer .fp-like.on { color: var(--pink); }
.fullplayer .fp-controls { display: flex; align-items: center; justify-content: space-between; }
.fullplayer .fp-controls .icon-btn { width: 52px; height: 52px; }
.fullplayer .fp-controls .icon-btn.on { color: var(--pink); }
.fullplayer .fp-controls .icon-btn.on::after { content: ""; position: absolute; bottom: 6px; width: 4px; height: 4px; border-radius: 50%; background: var(--pink); }
.fullplayer .fp-controls .big { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); box-shadow: 0 16px 40px -12px hsl(var(--h) 90% 60% / .8); transition: transform .15s; }
.fullplayer .fp-controls .big:active { transform: scale(.94); }
.fullplayer .fp-controls .big svg.i { width: 30px; height: 30px; }
.fullplayer .fp-bottom { display: flex; justify-content: space-between; align-items: center; }
.fullplayer .fp-bottom .icon-btn { color: var(--text-2); }
.fullplayer .fp-bottom .icon-btn:hover { color: var(--text); }
.fullplayer .fp-bottom .sleep-on { color: var(--pink); }
.fullplayer .fp-note { text-align: center; color: var(--text-3); font-size: var(--fs-xs); }
.fullplayer .seek { font-size: var(--fs-xs); }
.fullplayer .seek time { min-width: 42px; }
.fullplayer.watching .fp-info, .fullplayer.watching .seek, .fullplayer.watching .fp-controls, .fullplayer.watching .fp-bottom { width: 100%; max-width: 560px; margin-left: auto; margin-right: auto; }
@media (min-width: 900px) {
  .fullplayer.is-yt:not(.watching) .fp-body { max-width: 860px; display: grid; grid-template-columns: 1fr 1fr; align-content: center; column-gap: 48px; }
  .fullplayer.is-yt:not(.watching) .fp-stage { grid-row: 1 / span 6; justify-content: center; }
  .fullplayer.is-yt:not(.watching) .fp-art-wrap { --size: min(26vw, 300px, 40vh); }
}

/* Calm version for "reduce motion" */
@media (prefers-reduced-motion: reduce) {
  .fp-bg i, .fullplayer .fp-art, .fullplayer .fp-halo, .fullplayer .fp-ring { animation: none !important; }
  .fullplayer .fp-viz { display: none; }
}

/* ---------- Official YouTube player ----------
   YouTube requires the player to stay visible (≥ 200×200 px) and uncovered
   while a video is loaded. While browsing it is a small floating card the
   listener can drag to the other side; in the full player it sits exactly
   over the video card (anchored). Minimising it pauses the music. */
.yt-dock {
  --yt-lift: 0px;
  position: fixed; z-index: 46; width: 248px;
  right: 10px; bottom: calc(var(--nav-h) + var(--mini-h) + var(--safe-b) + 16px + var(--yt-lift));
  border-radius: 16px; overflow: hidden; background: #000;
  border: 1px solid var(--border-strong); box-shadow: 0 22px 50px -16px rgba(0, 0, 0, .9);
  display: none; touch-action: none;
  transition: left .4s var(--ease), right .4s var(--ease), top .4s var(--ease), width .4s var(--ease), height .4s var(--ease), border-radius .3s;
}
.yt-dock[data-side="left"] { right: auto; left: 10px; }
.yt-dock.active { display: block; animation: yt-pop .35s var(--ease); }
@keyframes yt-pop { from { transform: scale(.85) translateY(20px); opacity: 0; } }
.yt-dock.dragging { transition: none; opacity: .92; cursor: grabbing; }
.yt-dock .yt-head { display: flex; align-items: center; gap: 4px; height: 34px; padding: 0 2px 0 4px; background: #0b0d12; color: #d6d9e0; font-size: 11px; cursor: grab; user-select: none; }
.yt-dock .yt-grip { display: grid; place-items: center; width: 18px; color: #6b7280; }
.yt-dock .yt-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.yt-dock .yt-btns { display: flex; }
.yt-dock .yt-head button { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #d6d9e0; }
.yt-dock .yt-head button:hover { background: rgba(255, 255, 255, .1); }
.yt-dock .yt-frame { position: relative; width: 100%; height: 200px; min-width: 200px; }
.yt-dock .yt-frame iframe, .yt-dock .yt-frame > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.yt-dock.collapsed .yt-frame { display: none; }
.yt-dock.collapsed { width: auto; max-width: 260px; }
.yt-dock.collapsed .yt-big { display: none; }
@media (min-width: 1024px) {
  .yt-dock { width: 356px; right: 20px; bottom: calc(var(--bar-h) + 16px + var(--yt-lift)); }
  .yt-dock[data-side="left"] { left: calc(var(--sidebar-w, 240px) + 20px); }
}
/* Anchored inside the full player: no header, fills the placeholder (≥ 200 px tall) */
.yt-dock.anchored { z-index: 160; right: auto; bottom: auto; border-radius: var(--r-lg); box-shadow: 0 30px 70px -25px rgba(0, 0, 0, .95); animation: none; }
.yt-dock.anchored .yt-head { display: none; }
.yt-dock.anchored .yt-frame { height: 100%; min-height: 200px; }
html.fp-open .yt-dock.active:not(.anchored) { z-index: 160; } /* never covered by the full player */

/* ---------- Queue ---------- */
.queue-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px 10px; }
.queue-head h2 { padding: 0; }
.queue-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 8px 10px; }
.queue-list .row { grid-template-columns: 48px minmax(0, 1fr) auto; }
.queue-list .row .actions .icon-btn { width: 36px; height: 36px; }
.queue-label { font-size: var(--fs-xs); color: var(--text-2); font-weight: 600; padding: 12px 8px 4px; }
.fullplayer .fp-art { overflow: hidden; }
@media (max-width: 599px) {
  /* Phones: the big video uses the full screen width */
  .fullplayer.watching .fp-video-slot { width: calc(100% + 40px); margin: 0 -20px; border-radius: 0; }
  .fullplayer.watching .fp-body { padding-top: 12px; }
}
.fullplayer .fp-art .initial { display: none; }

@media (max-width: 1023px) {
  .player { backdrop-filter: none; -webkit-backdrop-filter: none;
    background: linear-gradient(90deg, hsl(var(--h) 45% 20%), hsl(calc(var(--h) + 50) 40% 16%)), #0d1017; }
  html[data-theme="light"] .player { background: linear-gradient(90deg, hsl(var(--h) 80% 93%), hsl(calc(var(--h) + 50) 80% 95%)), #fff; }
}
/* progress line moves with transform (GPU) instead of width (layout + repaint) */
.player .p-line i { width: 100% !important; transform-origin: 0 50%; transform: scaleX(var(--pl, 0)); will-change: transform; }

.fullplayer .fp-art-wrap::after { content: ""; position: absolute; inset: 4% 4% -6%; z-index: 1; border-radius: 50%; box-shadow: 0 30px 70px -25px hsl(var(--h) 90% 50% / .95); pointer-events: none; }
.fullplayer:not(.open) .fp-bg i, .fullplayer:not(.open) .fp-art, .fullplayer:not(.open) .fp-halo, .fullplayer:not(.open) .fp-ring { animation-play-state: paused !important; }
.fullplayer .fp-ring { will-change: transform, opacity; }
