/* ==========================================================================
   Paddy Prompt Studio — Music player
   Layers on /blog/style.css (same dark indigo/cyan palette and type scale).
   Only the player widget lives here; prose styling is inherited.

   Mobile-first: the stage stacks under 860px, every control keeps a 44px
   touch target, and a compact sticky bar takes over once the main player
   scrolls out of view so playback stays reachable while reading.
   ========================================================================== */

:root {
  --good: #34d399;
  --art-radius: 14px;
}

/* ------------------------------------------------------------ Player shell */
.player {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border); border-radius: 22px;
  padding: 1.15rem; margin: 0.5rem 0 1.25rem;
  box-shadow: 0 30px 70px -40px rgba(99, 102, 241, 0.6);
}

/* Stage: artwork / video on the left, now-playing and controls on the right */
.stage { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 1.25rem; }

.art-frame {
  position: relative; align-self: start;
  border-radius: var(--art-radius); overflow: hidden;
  background: #07080d; border: 1px solid var(--border);
  aspect-ratio: 1 / 1;
}
/* Portrait music videos get a 9:16 frame; audio tracks stay square. */
.player[data-kind="video"] .art-frame { aspect-ratio: 9 / 16; max-height: 60svh; margin-inline: auto; width: 100%; }
.art-frame img,
.art-frame video {
  display: block; width: 100%; height: 100%; object-fit: cover; background: #07080d;
}
.art-frame video { object-fit: contain; }
.player[data-kind="audio"] .art-frame video { display: none; }
.player[data-kind="video"] .art-frame img { display: none; }

/* Badge marking a track that has a video, top-left of the artwork */
.art-badge {
  position: absolute; top: 0.6rem; left: 0.6rem; z-index: 2;
  display: none; align-items: center; gap: 0.35rem;
  padding: 0.22rem 0.55rem; border-radius: 999px;
  background: rgba(4, 5, 7, 0.72); backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: #a5f3fc;
}
.player[data-kind="video"] .art-badge { display: inline-flex; }

/* Big translucent play overlay on the artwork (tap target on mobile) */
.art-tap {
  position: absolute; inset: 0; z-index: 3; cursor: pointer;
  display: grid; place-items: center; border: 0; padding: 0;
  background: radial-gradient(60% 60% at 50% 50%, rgba(4, 5, 7, 0.35), rgba(4, 5, 7, 0.08));
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.25s ease;
}
.art-tap .disc {
  width: 4.5rem; height: 4.5rem; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(4, 5, 7, 0.55); backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.9);
}
.art-tap .disc::before {
  content: ""; width: 1.25rem; height: 1.4rem; background: #fff;
  clip-path: polygon(0 0, 100% 50%, 0 100%); margin-left: 0.25rem;
}
.player.is-playing .art-tap { opacity: 0; }
.player.is-playing .art-tap:hover,
.player.is-playing .art-tap:focus-visible { opacity: 1; }
.player.is-playing .art-tap .disc::before { clip-path: none; width: 1.1rem; height: 1.2rem; border-radius: 2px; }

/* ------------------------------------------------------------- Now playing */
.now { min-width: 0; display: flex; flex-direction: column; }
.now .eyebrow { margin-bottom: 0.35rem; }
.now h2 {
  font-family: "Space Grotesk", "Inter", sans-serif; font-weight: 800;
  font-size: clamp(1.35rem, 3.6vw, 1.9rem); line-height: 1.15; letter-spacing: -0.02em;
  margin: 0 0 0.3rem; color: #fff;
}
.now .meta {
  margin: 0 0 0.9rem; color: var(--text-dim); font-size: 0.85rem;
  font-family: "JetBrains Mono", ui-monospace, monospace; letter-spacing: 0.06em;
}
.now .meta .sep { opacity: 0.45; padding: 0 0.45rem; }
.now .blurb { margin: 0 0 1rem; color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; }

/* ------------------------------------------------------------- Visualiser */
/* Twenty-four bars driven by an FFT of the playing track. If the Web Audio
   analyser is unavailable (or refuses to start) the bars fall back to a
   decorative CSS pulse so the player never looks broken. */
.viz {
  display: flex; align-items: flex-end; gap: 3px; height: 34px;
  margin: 0 0 0.9rem; opacity: 0.35; transition: opacity 0.3s ease;
}
.viz span {
  flex: 1 1 0; min-width: 0; height: 12%; border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, #a5f3fc, #818cf8);
  transform-origin: bottom;
}
.player.is-playing .viz { opacity: 1; }
/* Analyser mode: JS scales each bar from the FFT, so the box is full height */
.viz.live span { height: 100%; transform: scaleY(0.12); }
.viz.fallback span { animation: vizPulse 1.1s ease-in-out infinite; height: 100%; transform: scaleY(0.12); }
.player.is-playing .viz.fallback span { animation-play-state: running; }
.viz.fallback span { animation-play-state: paused; }
.viz.fallback span:nth-child(3n) { animation-duration: 1.45s; }
.viz.fallback span:nth-child(3n + 1) { animation-duration: 0.9s; }
.viz.fallback span:nth-child(4n) { animation-delay: 0.2s; }
.viz.fallback span:nth-child(5n) { animation-delay: 0.45s; }
@keyframes vizPulse {
  0%, 100% { transform: scaleY(0.12); }
  50% { transform: scaleY(0.85); }
}

/* --------------------------------------------------------------- Seek row */
.seek-row { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.85rem; }
.seek-row .t {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.78rem;
  color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 3.1rem;
}
.seek-row .t.right { text-align: right; }

input[type="range"].slider {
  -webkit-appearance: none; appearance: none; flex: 1 1 auto; min-width: 0;
  height: 26px; background: transparent; cursor: pointer; margin: 0;
  touch-action: none;
}
input[type="range"].slider::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, #818cf8 0%, #22d3ee var(--pct, 0%), rgba(255, 255, 255, 0.12) var(--pct, 0%));
}
input[type="range"].slider::-moz-range-track {
  height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.12);
}
input[type="range"].slider::-moz-range-progress {
  height: 6px; border-radius: 999px; background: linear-gradient(90deg, #818cf8, #22d3ee);
}
input[type="range"].slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%; margin-top: -5px;
  background: #fff; border: 0; box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.25);
}
input[type="range"].slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 0; box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.25);
}
input[type="range"].slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px rgba(129, 140, 248, 0.55); }

/* ------------------------------------------------------------- Transport */
.transport { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.tbtn {
  display: inline-grid; place-items: center; cursor: pointer;
  width: 44px; height: 44px; padding: 0; border-radius: 12px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border);
  color: var(--text); font: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.tbtn:hover { color: #fff; border-color: rgba(129, 140, 248, 0.5); background: rgba(99, 102, 241, 0.14); }
.tbtn svg { width: 20px; height: 20px; fill: currentColor; pointer-events: none; }
.tbtn[aria-pressed="true"] {
  background: rgba(99, 102, 241, 0.2); border-color: rgba(129, 140, 248, 0.6); color: #c7d2fe;
}
.tbtn.big {
  width: 58px; height: 58px; border: 0; border-radius: 16px;
  background: linear-gradient(135deg, #818cf8, #22d3ee); color: #0b0620;
}
.tbtn.big:hover { filter: brightness(1.08); }
.tbtn.big svg { width: 26px; height: 26px; }
.player.is-playing .tbtn.big .i-play,
.tbtn.big .i-pause { display: none; }
.player.is-playing .tbtn.big .i-pause { display: block; }
/* Repeat-one gets a small superscript 1 via the button's data-state */
.tbtn.repeat[data-state="one"]::after {
  content: "1"; position: absolute; margin: -0.85rem 0 0 0.95rem;
  font-size: 0.6rem; font-weight: 800; color: #c7d2fe;
}
.tbtn.repeat { position: relative; }

.transport .spacer { flex: 1 1 auto; }

/* Mute button swaps its two inline icons */
.tbtn .i-muted, .tbtn.is-muted .i-vol { display: none; }
.tbtn.is-muted .i-muted { display: block; }

/* Volume: pointless on phones (the hardware keys do it), so it hides there */
.vol { display: flex; align-items: center; gap: 0.4rem; width: 8.5rem; }
.vol input[type="range"].slider { height: 22px; }

/* ---------------------------------------------------------------- Actions */
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
/* "Make your own" links sit under the controls; .now is a column, so drop the
   shared rule's full-width flex-basis, which would become a height here. */
.now .quick-next { flex: none; margin-top: 0.85rem; }
.abtn {
  display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer;
  padding: 0.6rem 1rem; border-radius: 12px; font: inherit; font-size: 0.9rem; font-weight: 700;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.abtn:hover { color: #fff; border-color: rgba(129, 140, 248, 0.5); background: rgba(99, 102, 241, 0.14); text-decoration: none; }
.abtn svg { width: 17px; height: 17px; fill: currentColor; }
.abtn.primary {
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.22), rgba(34, 211, 238, 0.18));
  border-color: rgba(129, 140, 248, 0.45); color: #e0e7ff;
}

/* --------------------------------------------------------------- Playlist */
.playlist { margin: 1.25rem 0 0; padding: 1.15rem 0 0; border-top: 1px solid var(--border-soft); list-style: none; }
.playlist-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 1.25rem 0 0.6rem; }
.playlist-head h2 { font-size: 1.05rem !important; margin: 0 !important; }
.playlist-head .count {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.72rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim);
}

ol.playlist { counter-reset: trk; margin-top: 0.2rem; padding: 0; }
ol.playlist li {
  display: grid; grid-template-columns: 1.6rem 46px minmax(0, 1fr) auto auto;
  align-items: center; gap: 0.7rem;
  padding: 0.5rem; border-radius: 12px; border: 1px solid transparent;
}
ol.playlist li:hover { background: rgba(255, 255, 255, 0.035); border-color: var(--border-soft); }
ol.playlist li[aria-current="true"] {
  background: rgba(99, 102, 241, 0.14); border-color: rgba(129, 140, 248, 0.4);
}
.playlist .num {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.78rem;
  color: var(--text-dim); text-align: right; font-variant-numeric: tabular-nums;
}
ol.playlist li[aria-current="true"] .num { color: var(--cyan); }

.playlist .thumb {
  width: 46px; height: 46px; border-radius: 9px; overflow: hidden;
  border: 1px solid var(--border); background: #07080d; position: relative;
}
.playlist .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.playlist .thumb .vidmark {
  position: absolute; inset: auto 2px 2px auto; width: 13px; height: 13px; border-radius: 3px;
  background: rgba(4, 5, 7, 0.75); display: grid; place-items: center;
}
.playlist .thumb .vidmark::before {
  content: ""; width: 5px; height: 6px; background: #a5f3fc; clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.playlist .pick {
  min-width: 0; text-align: left; background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: var(--text);
}
.playlist .pick .t {
  display: block; font-weight: 700; font-size: 0.95rem; line-height: 1.3; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.playlist .pick:hover .t { color: #fff; }
ol.playlist li[aria-current="true"] .pick .t { color: #fff; }
.playlist .pick .s {
  display: block; font-size: 0.78rem; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.playlist .dur {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.8rem;
  color: var(--text-dim); font-variant-numeric: tabular-nums;
}
.playlist .row-share {
  width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer;
  border-radius: 9px; background: none; border: 1px solid transparent; color: var(--text-dim);
}
.playlist .row-share:hover { color: #fff; border-color: var(--border); background: rgba(255, 255, 255, 0.05); }
.playlist .row-share svg { width: 15px; height: 15px; fill: currentColor; }

/* Equaliser ticks that mark the current row while it plays */
.playlist .eq { display: none; gap: 2px; align-items: flex-end; height: 12px; }
ol.playlist li[aria-current="true"] .eq { display: flex; }
.playlist .eq i { width: 2px; background: var(--cyan); height: 40%; border-radius: 1px; }
.player.is-playing .playlist .eq i { animation: eqBar 0.9s ease-in-out infinite; }
.playlist .eq i:nth-child(2) { animation-delay: 0.15s; }
.playlist .eq i:nth-child(3) { animation-delay: 0.3s; }
@keyframes eqBar { 0%, 100% { height: 25%; } 50% { height: 100%; } }

/* ------------------------------------------------------------ Share sheet */
.share-sheet {
  margin-top: 0.9rem; padding: 0.9rem 1rem; border-radius: 14px;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border);
}
.share-sheet[hidden] { display: none; }
.share-sheet p { margin: 0 0 0.6rem; font-size: 0.85rem; color: var(--text-muted); }
.share-links { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.share-links a, .share-links button {
  display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer;
  padding: 0.45rem 0.8rem; border-radius: 999px; font: inherit; font-size: 0.83rem; font-weight: 600;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); color: var(--text-muted);
}
.share-links a:hover, .share-links button:hover { color: #fff; border-color: rgba(129, 140, 248, 0.5); text-decoration: none; }
.share-url {
  margin-top: 0.6rem; width: 100%; font: inherit; font-size: 0.8rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  background: #07080d; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 10px; padding: 0.5rem 0.65rem;
}

/* ----------------------------------------------------------------- Toast */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1.5rem);
  z-index: 60; padding: 0.6rem 1.1rem; border-radius: 999px;
  background: rgba(12, 14, 22, 0.95); border: 1px solid rgba(129, 140, 248, 0.45);
  color: #e0e7ff; font-size: 0.85rem; font-weight: 600;
  box-shadow: 0 20px 45px -25px rgba(0, 0, 0, 0.9);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------ Mini player */
/* Appears once the main player scrolls away. Bottom-docked on phones,
   which is where a thumb already is. */
.mini {
  position: fixed; z-index: 45; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.55rem 0.9rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
  background: rgba(8, 10, 16, 0.92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  /* Hidden with visibility as well as a transform, so its buttons are not
     focusable or announced while the bar is parked off-screen. */
  transform: translateY(110%); visibility: hidden;
  transition: transform 0.28s ease, visibility 0.28s ease;
}
.mini.show { transform: translateY(0); visibility: visible; }
.mini .mthumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); flex: 0 0 auto; }
.mini .mtext { min-width: 0; flex: 1 1 auto; }
.mini .mtitle { display: block; font-size: 0.85rem; font-weight: 700; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini .mtime {
  display: block; font-size: 0.72rem; color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums;
}
.mini .tbtn { width: 40px; height: 40px; flex: 0 0 auto; }
.mini .tbtn.big { width: 44px; height: 44px; border-radius: 12px; }
.mini .bar { position: absolute; left: 0; top: 0; height: 2px; background: linear-gradient(90deg, #818cf8, #22d3ee); width: 0; }

/* ------------------------------------------------------- Track-note cards */
.track-notes { display: grid; gap: 1rem; margin: 1.25rem 0 0; padding: 0; list-style: none; }
.track-note {
  display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 1rem;
  padding: 1rem; border-radius: 14px;
  background: rgba(255, 255, 255, 0.025); border: 1px solid var(--border);
}
.track-note img { width: 78px; height: 78px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); }
.track-note h3 {
  font-family: "Space Grotesk", "Inter", sans-serif; font-size: 1.02rem !important;
  margin: 0 0 0.2rem !important; color: #fff;
}
.track-note .tn-meta {
  margin: 0 0 0.45rem; font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.72rem; letter-spacing: 0.08em; color: var(--text-dim); text-transform: uppercase;
}
.track-note p { margin: 0 0 0.6rem; color: var(--text-muted); font-size: 0.93rem; line-height: 1.6; }
.track-note .tn-play {
  display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer;
  padding: 0.4rem 0.85rem; border-radius: 999px; font: inherit; font-size: 0.82rem; font-weight: 700;
  background: rgba(99, 102, 241, 0.16); border: 1px solid rgba(129, 140, 248, 0.4); color: #c7d2fe;
}
.track-note .tn-play:hover { background: rgba(99, 102, 241, 0.28); text-decoration: none; }

/* ------------------------------------------------------------- No-JS note */
/* Keyboard keys in the prose, same treatment as the tuner page */
.article-body kbd {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.78rem;
  background: rgba(129, 140, 248, 0.14); border: 1px solid var(--border-soft);
  border-radius: 5px; padding: 0.05em 0.35em; color: #c7d2fe;
}

.nojs { margin: 0.75rem 0 0; padding: 0.85rem 1rem; border-radius: 12px;
  background: rgba(252, 211, 77, 0.08); border: 1px solid rgba(252, 211, 77, 0.3);
  color: #fde68a; font-size: 0.88rem; }

/* ------------------------------------------------------------- Responsive */
@media (max-width: 860px) {
  .stage { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .art-frame { max-width: 340px; margin-inline: auto; width: 100%; }
  .player[data-kind="video"] .art-frame { max-width: 300px; }
  .now { text-align: left; }
}

@media (max-width: 600px) {
  .player { padding: 0.9rem; border-radius: 18px; }
  .vol { display: none; }
  .transport { gap: 0.4rem; justify-content: space-between; }
  .transport .spacer { display: none; }
  .tbtn { width: 46px; height: 46px; }
  .tbtn.big { width: 56px; height: 56px; }
  .actions .abtn { flex: 1 1 auto; justify-content: center; }
  ol.playlist li { grid-template-columns: 1.3rem 42px minmax(0, 1fr) auto; gap: 0.55rem; padding: 0.45rem 0.3rem; }
  .playlist .thumb { width: 42px; height: 42px; }
  .playlist .dur { display: none; }
  .track-note { grid-template-columns: 58px minmax(0, 1fr); gap: 0.8rem; padding: 0.85rem; }
  .track-note img { width: 58px; height: 58px; }
  /* Leave room for the docked mini player */
  body.has-mini { padding-bottom: 4.5rem; }
}

@media (min-width: 601px) {
  .mini { left: auto; right: 1.25rem; bottom: 1.25rem; border-radius: 16px; border: 1px solid var(--border); width: 22rem; padding: 0.6rem 0.75rem; overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .viz span, .playlist .eq i { animation: none !important; }
  .mini { transition: none; }
}
