/*
 * The release player — themes/default/music/_audio-player.php.
 *
 * Self-contained: the embed page loads this file and nothing else, so every
 * rule is scoped to .mp and nothing leans on the theme or on music.css. On the
 * release page it sits inside the theme's typography and inherits its font.
 *
 * Colours are custom properties on .mp so a theme can restyle the player by
 * overriding a handful of variables rather than the rules.
 */

.mp {
  --mp-bg: #ffffff;
  --mp-fg: #16161a;
  --mp-muted: #6b6b76;
  --mp-line: #e6e6ea;
  --mp-track: #e4e4e9;
  --mp-accent: #2f7cf6;
  --mp-chip: #f2f2f5;
  --mp-chip-hover: #e8e8ed;
  --mp-shadow: 0 1px 2px rgba(16, 16, 24, .06), 0 6px 24px rgba(16, 16, 24, .07);
  --mp-radius: 16px;
  --mp-art: 128px;

  position: relative;
  box-sizing: border-box;
  container-type: inline-size;
  container-name: mp;
  max-width: 640px;
  padding: 16px;
  border: 1px solid var(--mp-line);
  border-radius: var(--mp-radius);
  background: var(--mp-bg);
  color: var(--mp-fg);
  box-shadow: var(--mp-shadow);
  font-family: inherit;
  line-height: 1.3;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.mp *,
.mp *::before,
.mp *::after { box-sizing: border-box; }

.mp--dark {
  --mp-bg: #17171c;
  --mp-fg: #f4f4f6;
  --mp-muted: #a0a0ab;
  --mp-line: #2a2a32;
  --mp-track: #34343d;
  --mp-accent: #5b9bff;
  --mp-chip: #24242b;
  --mp-chip-hover: #2e2e36;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */

.mp-main {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.mp-art {
  flex: 0 0 var(--mp-art);
  width: var(--mp-art);
  height: var(--mp-art);
  border-radius: 10px;
  overflow: hidden;
  background: var(--mp-chip);
}
.mp-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.mp-art-empty {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--mp-chip), var(--mp-line));
}

.mp-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.mp-head { min-width: 0; }
.mp-title,
.mp-artist {
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.mp-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.mp-artist {
  margin-top: 2px;
  font-size: .9rem;
  color: var(--mp-muted);
}

/* The mark, top right. The title and artist keep clear of it. */
.mp-mark {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1;
  display: block;
  width: 28px;
  height: 28px;
  line-height: 0;
}
.mp-mark svg { display: block; width: 100%; height: 100%; }
a.mp-mark { border-radius: 7px; transition: transform .15s; }
/* A bigger tap target than the 24-28px tile: 40-44px, invisible, reaching
   only into the card padding and the title's reserved gutter. */
a.mp-mark::after { content: ""; position: absolute; inset: -8px; }
a.mp-mark:hover { transform: scale(1.06); }
a.mp-mark:focus-visible { outline: 2px solid var(--mp-accent); outline-offset: 2px; }
.mp-head { padding-right: 40px; }

/* ── Progress ─────────────────────────────────────────────────────────────── */

.mp-times {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
  color: var(--mp-muted);
}

.mp-seek,
.mp-volume-range {
  --mp-fill: 0%;
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 16px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.mp-seek:disabled { cursor: default; }
.mp-seek::-webkit-slider-runnable-track,
.mp-volume-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--mp-accent) var(--mp-fill), var(--mp-track) var(--mp-fill));
}
.mp-seek::-moz-range-track,
.mp-volume-range::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: var(--mp-track);
}
.mp-seek::-moz-range-progress,
.mp-volume-range::-moz-range-progress {
  height: 4px;
  border-radius: 4px;
  background: var(--mp-accent);
}
.mp-seek::-webkit-slider-thumb,
.mp-volume-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border: 0;
  border-radius: 50%;
  background: var(--mp-accent);
  opacity: 0;
  transition: opacity .15s;
}
.mp-seek::-moz-range-thumb,
.mp-volume-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: var(--mp-accent);
  opacity: 0;
  transition: opacity .15s;
}
.mp:hover .mp-seek::-webkit-slider-thumb,
.mp-seek:focus-visible::-webkit-slider-thumb,
.mp-volume-range::-webkit-slider-thumb { opacity: 1; }
.mp:hover .mp-seek::-moz-range-thumb,
.mp-seek:focus-visible::-moz-range-thumb,
.mp-volume-range::-moz-range-thumb { opacity: 1; }

/* ── Controls ─────────────────────────────────────────────────────────────── */

.mp-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mp-transport,
.mp-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mp-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--mp-fg);
  cursor: pointer;
  transition: background-color .15s, color .15s, opacity .15s;
}
.mp-btn svg { width: 22px; height: 22px; }
.mp-btn:hover { background: var(--mp-chip); }
.mp-btn:focus-visible,
.mp-link:focus-visible,
.mp-list-item:focus-visible,
.mp-copy:focus-visible {
  outline: 2px solid var(--mp-accent);
  outline-offset: 2px;
}
.mp-btn:disabled { opacity: .35; cursor: default; }

.mp-btn-play {
  width: 44px;
  height: 44px;
}
.mp-btn-play svg { width: 28px; height: 28px; }
.mp-icon-pause,
.mp.is-playing .mp-icon-play { display: none; }
.mp.is-playing .mp-icon-pause { display: block; }

.mp-btn-sm {
  width: 32px;
  height: 32px;
  color: var(--mp-muted);
}
.mp-btn-sm svg { width: 18px; height: 18px; }
.mp-btn-sm[aria-pressed="true"],
.mp-btn-sm.is-active { color: var(--mp-accent); }

.mp-repeat-one {
  position: absolute;
  top: 4px;
  right: 3px;
  display: none;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}
.mp.is-repeat-one .mp-repeat-one { display: block; }

.mp-icon-muted,
.mp.is-muted .mp-icon-vol { display: none; }
.mp.is-muted .mp-icon-muted { display: block; }

.mp-volume {
  position: relative;
  display: flex;
  align-items: center;
}
.mp-volume-range {
  width: 0;
  opacity: 0;
  transition: width .2s, opacity .2s, margin .2s;
  pointer-events: none;
}
.mp-volume:hover .mp-volume-range,
.mp-volume:focus-within .mp-volume-range {
  width: 72px;
  margin: 0 6px 0 2px;
  opacity: 1;
  pointer-events: auto;
}
/* Phones set volume with the hardware buttons (and iOS ignores the property). */
@media (hover: none) {
  .mp-volume-range { display: none; }
}

.mp.is-single [data-mp-shuffle],
.mp.is-single [data-mp-prev],
.mp.is-single [data-mp-next] { opacity: .35; }

.mp.has-error .mp-title::after {
  content: " · unavailable";
  font-weight: 400;
  color: var(--mp-muted);
}

/* ── Tracklist ────────────────────────────────────────────────────────────── */

.mp-list {
  margin-top: 14px;
  border-top: 1px solid var(--mp-line);
  padding-top: 6px;
  max-height: 320px;
  overflow: auto;
}
.mp-list[hidden] { display: none; }
.mp-list-head {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 0 6px 8px;
  font-weight: 700;
}
.mp-list ol {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mp-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--mp-fg);
  font: inherit;
  font-size: .9rem;
  text-align: left;
  cursor: pointer;
}
.mp-list-item:hover { background: var(--mp-chip); }
.mp-list-item.is-current { color: var(--mp-accent); font-weight: 600; }
.mp-list-num {
  flex: 0 0 1.5em;
  text-align: right;
  color: var(--mp-muted);
  font-variant-numeric: tabular-nums;
}
.mp-list-item.is-current .mp-list-num { color: var(--mp-accent); }
.mp-list-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.mp-list-time {
  flex: 0 0 auto;
  color: var(--mp-muted);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
}
.mp-explicit {
  display: inline-block;
  margin-left: 6px;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--mp-muted);
  color: var(--mp-bg);
  font-size: .65rem;
  font-weight: 700;
  line-height: 1.5;
  vertical-align: middle;
}

/* ── Streaming / store buttons ────────────────────────────────────────────── */

.mp-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}
.mp-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--mp-chip);
  color: var(--mp-fg);
  font-size: .875rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .15s;
}
.mp-link:hover { background: var(--mp-chip-hover); color: var(--mp-fg); text-decoration: none; }
.mp-link-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  color: var(--mp-brand, var(--mp-accent));
}
.mp-link-icon svg { width: 100%; height: 100%; }

/* ── Embed code panel ─────────────────────────────────────────────────────── */

.mp-embed {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--mp-line);
  -webkit-user-select: text;
  user-select: text;
}
.mp-embed[hidden] { display: none; }
.mp-embed label {
  display: block;
  margin-bottom: 6px;
  font-size: .85rem;
  font-weight: 600;
}
.mp-embed textarea {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--mp-line);
  border-radius: 8px;
  background: var(--mp-chip);
  color: var(--mp-fg);
  font: .75rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}
.mp-copy {
  margin-top: 8px;
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--mp-fg);
  color: var(--mp-bg);
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
}
.mp-copy-status {
  margin-left: 8px;
  font-size: .8rem;
  color: var(--mp-muted);
}

.mp-noscript {
  margin: 12px 0 0;
  font-size: .85rem;
  color: var(--mp-muted);
}

/* ── Narrow ───────────────────────────────────────────────────────────────── */
/* Keyed to the PLAYER's width, not the viewport's: the same card sits in a
   wide hero, a narrow sidebar column and an iframe of any size. Below 440px
   the controls take their own row under a smaller cover, which keeps the card
   within the embed page's fixed height (music_player_embed_height()). */

@container mp (max-width: 440px) {
  .mp-main {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    grid-template-areas:
      "art head"
      "art progress"
      "controls controls";
    column-gap: 12px;
    row-gap: 4px;
  }
  .mp-art { grid-area: art; width: 76px; height: 76px; flex: none; }
  .mp-body { display: contents; }
  .mp-head { grid-area: head; align-self: end; }
  .mp-progress { grid-area: progress; align-self: start; }
  .mp-controls { grid-area: controls; margin-top: 6px; }
  .mp-title { font-size: 1rem; }
  .mp-artist { font-size: .85rem; }
  .mp-links { margin-top: 10px; }
}
@container mp (max-width: 340px) {
  .mp-btn { width: 32px; height: 32px; }
  .mp-btn-play { width: 40px; height: 40px; }
  .mp-btn-sm { width: 28px; height: 28px; }
  .mp-transport, .mp-tools { gap: 0; }
}
@media (max-width: 460px) {
  .mp { padding: 12px; }
  .mp-mark { top: 12px; right: 12px; width: 24px; height: 24px; }
  .mp-head { padding-right: 32px; }
}

/* ── The embed page (/releases/{slug}/embed/) ─────────────────────────────── */
/* Laid out for a fixed iframe height (music_player_embed_height()), so the
   card never grows: the service row scrolls sideways and the tracklist opens
   over the card instead of below it. */

html:has(.mp-embed-page),
.mp-embed-page {
  margin: 0;
  background: transparent;
}
.mp-embed-page {
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}
.mp--embed {
  max-width: none;
  height: 100vh;
  box-shadow: none;
  overflow: hidden;
}
.mp--embed .mp-links {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.mp--embed .mp-links::-webkit-scrollbar { display: none; }
.mp--embed .mp-list {
  position: absolute;
  inset: 0;
  z-index: 2;
  margin: 0;
  padding: 12px;
  max-height: none;
  border: 0;
  border-radius: var(--mp-radius);
  background: var(--mp-bg);
}
.mp--embed .mp-list-head { display: flex; }

.mp--embed .mp-artist a {
  color: inherit;
  text-decoration: none;
}
.mp--embed .mp-artist a:hover { text-decoration: underline; }

/* ── On the release page ──────────────────────────────────────────────────── */

.music-release-player .mp { margin-top: 8px; }
.music-track-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  vertical-align: middle;
  cursor: pointer;
  opacity: .7;
}
.music-track-play:hover,
.music-track-play:focus-visible { opacity: 1; }
.music-track-play svg { width: 20px; height: 20px; }

@media (prefers-reduced-motion: reduce) {
  .mp *, .mp *::before, .mp *::after { transition: none !important; }
}
