/**
 * Mini-player — nav-integrated pill with an expandable popover.
 *
 * Anchored to the top-right of the viewport, aligned with the site nav
 * band. No longer occludes body content (previous 720px fixed bottom
 * strip is retired).
 *
 * States:
 *   - data-hidden="true"      : no saved cursor yet; element invisible
 *   - data-hidden="false"     : pill visible (collapsed)
 *   - data-expanded="true"    : popover open beneath the pill
 *   - data-playing="true|false": swaps play/pause glyphs
 */

.mini-player {
  position: fixed;
  top: 8px;
  right: 10px;
  z-index: 110;
  font-family: var(--font-ui, 'Space Grotesk', system-ui, sans-serif);
  color: var(--ink, #1c110c);
  pointer-events: auto;
  opacity: 1;
  transition: opacity 180ms ease, transform 240ms ease;
}

.mini-player[data-hidden="true"] {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
}

@media (prefers-reduced-motion: reduce) {
  .mini-player,
  .mini-player__panel,
  .mini-player__bar,
  .mini-player__ring-fill { transition: none; }
}

/* ── Collapsed pill ───────────────────────────────────────────────── */
.mini-player__pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 2px 10px 2px 2px;
  background: var(--paper, #f6efe4);
  color: var(--ink, #1c110c);
  border: 1px solid var(--casing-red, #a81e0f);
  border-radius: 999px;
  cursor: pointer;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.18),
    0 1px 0 rgba(255, 255, 255, 0.55) inset;
  transition: transform 140ms ease, box-shadow 160ms ease, background 160ms ease;
  font-family: inherit;
}
.mini-player__pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}
.mini-player__pill:active { transform: translateY(0); }
.mini-player__pill:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--paper, #f6efe4),
    0 0 0 4px var(--casing-red, #a81e0f);
}

/* Ring + glyph inside the pill (Apple-Music-ish indicator) */
.mini-player__ring {
  position: relative;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--casing-red, #a81e0f);
  border-radius: 50%;
}
.mini-player__ring-svg {
  position: absolute;
  inset: -1px;
  width: 32px;
  height: 32px;
  pointer-events: none;
}
.mini-player__ring-track {
  stroke: rgba(255, 255, 255, 0.35);
}
.mini-player__ring-fill {
  stroke: #fff;
  transition: stroke-dashoffset 200ms linear;
}

.mini-player__pill-label {
  display: grid;
  line-height: 1.05;
  text-align: left;
  min-width: 0;
}
.mini-player__pill-eyebrow {
  font-family: var(--font-stamp, 'Space Grotesk', system-ui, sans-serif);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--casing-red, #a81e0f);
  font-weight: 700;
}
.mini-player__pill-ch {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink, #1c110c);
  max-width: 16ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Icon swap (same rule handles pill ring AND panel play button) */
.mini-player__icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
  display: none;
  position: relative;
  z-index: 1;
}
.mini-player[data-playing="true"] .mini-player__icon--pause,
.mini-player:not([data-playing="true"]) .mini-player__icon--play {
  display: block;
}

/* ── Expanded popover ─────────────────────────────────────────────── */
.mini-player__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(340px, calc(100vw - 24px));
  padding: 10px 12px 12px;
  background: var(--paper, #f6efe4);
  color: var(--ink, #1c110c);
  border: 1px solid var(--casing-red, #a81e0f);
  border-radius: 12px;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.24),
    0 1px 0 rgba(255, 255, 255, 0.6) inset;
  display: grid;
  gap: 8px;
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity 160ms ease, transform 180ms ease;
}
.mini-player[data-expanded="true"] .mini-player__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.mini-player__panel-head {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
}
.mini-player__play {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--casing-red, #a81e0f);
  background: var(--casing-red, #a81e0f);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  transition: transform 120ms ease;
}
.mini-player__play:hover { transform: scale(1.05); }
.mini-player__play:active { transform: scale(0.97); }
.mini-player__play .mini-player__icon { width: 14px; height: 14px; }

.mini-player__meta { min-width: 0; display: grid; line-height: 1.2; }
.mini-player__label {
  font-family: var(--font-stamp, inherit);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--casing-red, #a81e0f);
  font-weight: 700;
}
.mini-player__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink, #1c110c);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-player__expand,
.mini-player__collapse {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid rgba(28, 17, 12, 0.2);
  border-radius: 6px;
  color: var(--ink, #1c110c);
  cursor: pointer;
  padding: 0;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.mini-player__expand:hover,
.mini-player__collapse:hover {
  background: rgba(168, 30, 15, 0.08);
  border-color: var(--casing-red, #a81e0f);
  color: var(--casing-red, #a81e0f);
}

/* Scrubber */
.mini-player__progress {
  position: relative;
  width: 100%;
  height: 16px;
  cursor: pointer;
  outline: none;
  border-radius: 4px;
  display: grid;
  align-items: center;
}
.mini-player__progress::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 4px;
  transform: translateY(-50%);
  background: var(--ink-dim, rgba(28, 17, 12, 0.18));
  border-radius: 2px;
}
.mini-player__bar {
  position: absolute;
  left: 0;
  top: 50%;
  height: 4px;
  width: 0%;
  transform: translateY(-50%);
  background: var(--casing-red, #a81e0f);
  border-radius: 2px;
  transition: width 160ms linear;
}
.mini-player__progress:focus-visible {
  box-shadow: 0 0 0 2px var(--casing-red, #a81e0f);
}
.mini-player__time {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--ink-dim-2, rgba(28, 17, 12, 0.7));
  white-space: nowrap;
  justify-self: end;
}

/* ── Night / Broodwich theme parity ───────────────────────────────── */
html[data-shift="night"] .mini-player__pill,
html[data-shift="night"] .mini-player__panel {
  background: var(--paper, #18140f);
  color: var(--ink, #f4e9d3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
html[data-shift="night"] .mini-player__pill-ch,
html[data-shift="night"] .mini-player__title,
html[data-shift="night"] .mini-player__time {
  color: var(--ink, #f4e9d3);
}
html[data-shift="night"] .mini-player__expand,
html[data-shift="night"] .mini-player__collapse {
  border-color: rgba(244, 233, 211, 0.22);
  color: var(--ink, #f4e9d3);
}
html[data-brood="on"] .mini-player__pill,
html[data-brood="on"] .mini-player__panel {
  border-color: var(--brood-red, #ff4a3a);
}
html[data-brood="on"] .mini-player__ring,
html[data-brood="on"] .mini-player__play {
  background: var(--brood-red, #ff4a3a);
  border-color: var(--brood-red, #ff4a3a);
}
html[data-brood="on"] .mini-player__bar {
  background: var(--brood-red, #ff4a3a);
}
html[data-brood="on"] .mini-player__pill-eyebrow,
html[data-brood="on"] .mini-player__label {
  color: var(--brood-red, #ff4a3a);
}

/* ── Mobile / narrow ──────────────────────────────────────────────── */
@media (max-width: 560px) {
  .mini-player { top: 6px; right: 8px; }
  .mini-player__pill-label { display: none; } /* pill shrinks to ring only */
  .mini-player__pill { padding: 2px; gap: 0; }
  .mini-player__panel {
    right: 0;
    width: min(300px, calc(100vw - 16px));
  }
}

/* Respect iOS safe area */
@supports (padding: max(0px)) {
  .mini-player { top: max(8px, env(safe-area-inset-top)); }
}
