/* ============================================================
   Cultural Borders — Dark Atlas Theme
   Mobile-first, full-screen WebGL map application
   ============================================================ */

/* ------------------------------------------------------------
   1. CUSTOM PROPERTIES
   ------------------------------------------------------------ */
:root {
  /* Color tokens */
  --clr-bg:           #09090f;
  --clr-surface:      #111120;
  --clr-surface-2:    #191930;
  --clr-surface-hover:#1e1e38;
  --clr-border:       rgba(255,255,255,0.07);
  --clr-border-strong:rgba(255,255,255,0.14);

  --clr-text:         #e2e2f0;
  --clr-text-muted:   #7070a0;
  --clr-text-faint:   #40405a;
  --clr-accent:       #6b6bff;
  --clr-accent-glow:  rgba(107,107,255,0.25);
  --clr-danger:       #ff5b5b;

  /* Sizing */
  --panel-w:          400px;
  --panel-radius:     16px;
  --radius-sm:        6px;
  --radius-md:        10px;

  /* Timing */
  --ease-out:         cubic-bezier(0.4, 0, 0.2, 1);
  --dur-panel:        320ms;
  --dur-fade:         200ms;

  /* Z-layers */
  --z-map:      0;
  --z-ui:       10;
  --z-tooltip:  20;
  --z-legend:   30;
  --z-overlay:  40;
  --z-panel:    50;
  --z-loader:   100;
}

/* ------------------------------------------------------------
   2. RESET & BASE
   ------------------------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--clr-bg);
  color: var(--clr-text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

a { color: inherit; }

/* ------------------------------------------------------------
   3. MAP
   ------------------------------------------------------------ */
#map {
  position: fixed;
  inset: 0;
  z-index: var(--z-map);
  width: 100vw;
  height: 100vh;
}

/* MapLibre UI overrides */
.maplibregl-ctrl-group {
  background: var(--clr-surface) !important;
  border: 1px solid var(--clr-border) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4) !important;
  border-radius: var(--radius-md) !important;
  overflow: hidden;
}

.maplibregl-ctrl-group button {
  background: transparent !important;
  border: none !important;
  color: var(--clr-text-muted) !important;
  transition: background 0.15s, color 0.15s;
}

.maplibregl-ctrl-group button:hover {
  background: var(--clr-surface-hover) !important;
  color: var(--clr-text) !important;
}

.maplibregl-ctrl-group button + button {
  border-top: 1px solid var(--clr-border) !important;
}

.maplibregl-ctrl-attrib {
  background: rgba(9,9,15,0.7) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--clr-text-faint) !important;
  font-size: 11px !important;
}

.maplibregl-ctrl-attrib a { color: var(--clr-text-muted) !important; }

/* Zoom controls icon fill */
.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon,
.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon {
  filter: invert(60%) sepia(10%) saturate(200%) hue-rotate(200deg);
}

/* ------------------------------------------------------------
   4. LOADING OVERLAY
   ------------------------------------------------------------ */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-loader);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--clr-bg);
  transition: opacity 0.5s var(--ease-out), visibility 0.5s;
}

.loading-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  text-align: center;
  width: min(320px, 90vw);
}

/* Animated globe rings */
.loader-graphic {
  margin-bottom: 2rem;
}

.loader-globe {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto;
}

.loader-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
}

.loader-ring.r1 {
  border-top-color: var(--clr-accent);
  animation: spin 1.2s linear infinite;
}

.loader-ring.r2 {
  inset: 10px;
  border-right-color: rgba(107,107,255,0.5);
  animation: spin 1.8s linear infinite reverse;
}

.loader-ring.r3 {
  inset: 22px;
  border-bottom-color: rgba(107,107,255,0.25);
  animation: spin 2.4s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-title {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--clr-text);
  margin-bottom: 0.3rem;
}

.loader-subtitle {
  font-size: 0.75rem;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 2rem;
}

.loader-stages {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.loader-stage {
  display: grid;
  grid-template-columns: 10px 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.6rem;
  row-gap: 0.3rem;
  align-items: center;
  opacity: 0.4;
  transition: opacity 0.3s;
}

.loader-stage.is-active { opacity: 1; }
.loader-stage.is-done   { opacity: 0.6; }

.stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--clr-text-faint);
  transition: background 0.3s;
}

.loader-stage.is-active .stage-dot { background: var(--clr-accent); }
.loader-stage.is-done .stage-dot   { background: #3ddc84; }

.stage-label {
  font-size: 0.75rem;
  color: var(--clr-text-muted);
  text-align: left;
}

.stage-bar {
  grid-column: 2;
  height: 3px;
  background: var(--clr-border);
  border-radius: 2px;
  overflow: hidden;
}

.stage-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--clr-accent);
  border-radius: 2px;
  transition: width 0.2s ease;
}

.loader-stage.is-active .stage-bar-fill {
  /* Indeterminate pulse when no progress value */
  animation: indeterminate 1.4s ease-in-out infinite;
}

.loader-stage.is-active .stage-bar-fill.has-progress {
  animation: none;
}

@keyframes indeterminate {
  0%   { width: 0%;   margin-left: 0%; }
  50%  { width: 60%;  margin-left: 20%; }
  100% { width: 0%;   margin-left: 100%; }
}

/* ------------------------------------------------------------
   5. TITLE CARD
   ------------------------------------------------------------ */
.title-card {
  position: fixed;
  top: 1.25rem;
  left: 1.25rem;
  z-index: var(--z-ui);
  pointer-events: none;
  user-select: none;
}

.title-card__name {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--clr-text);
  line-height: 1;
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
}

.title-card__sub {
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 0.25rem;
}

.title-card__about-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.45rem;
  padding: 0.18rem 0.42rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(17,17,32,0.5);
  color: var(--clr-text-muted);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.18s, color 0.18s, border-color 0.18s, background 0.18s;
  pointer-events: auto;
}

.title-card__about-link:hover,
.title-card__about-link:focus-visible {
  opacity: 1;
  color: var(--clr-text);
  border-color: var(--clr-accent);
  background: rgba(17,17,32,0.85);
  outline: none;
}

/* ------------------------------------------------------------
   6. TOOLTIP
   ------------------------------------------------------------ */
.tooltip {
  position: fixed;
  z-index: var(--z-tooltip);
  background: rgba(17,17,32,0.93);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid var(--clr-border-strong);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.875rem;
  pointer-events: none;
  max-width: 240px;
  min-width: 160px;
  transition: opacity var(--dur-fade) ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.tooltip.is-hidden {
  opacity: 0;
  visibility: hidden;
}

/* Tooltip is desktop-only; touch devices use the bottom sheet. */
@media (max-width: 767px) {
  .tooltip { display: none !important; }
}

.tooltip__territory {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--clr-accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tooltip__row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.tooltip__badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--clr-text-faint);
  margin-top: 1px;
  min-width: 20px;
}

.tooltip__track {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--clr-text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tooltip__artist {
  font-size: 0.7rem;
  color: var(--clr-text-muted);
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------
   7. LEGEND
   ------------------------------------------------------------ */
.legend {
  position: fixed;
  bottom: 2.5rem;
  left: 1.25rem;
  z-index: var(--z-legend);
  max-width: 220px;
}

/* Hide legend on mobile */
@media (max-width: 767px) {
  .legend { display: none; }
}

.legend__btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border-strong);
  border-radius: 20px;
  color: var(--clr-text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.legend__btn:hover {
  background: var(--clr-surface-hover);
  color: var(--clr-text);
  border-color: var(--clr-accent);
}

.legend__icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.legend__chevron {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.legend__btn[aria-expanded="true"] .legend__chevron {
  transform: rotate(180deg);
}

.legend__body {
  margin-top: 0.5rem;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  max-height: 40vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--clr-border) transparent;
}

.legend__body::-webkit-scrollbar { width: 3px; }
.legend__body::-webkit-scrollbar-thumb { background: var(--clr-border); border-radius: 2px; }

.legend__heading {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.6rem;
}

.legend__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend__artist {
  font-size: 0.7rem;
  color: var(--clr-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.legend__count {
  font-size: 0.65rem;
  color: var(--clr-text-faint);
  flex-shrink: 0;
}

/* ------------------------------------------------------------
   8. PANEL — shared base
   ------------------------------------------------------------ */
.panel {
  position: fixed;
  z-index: var(--z-panel);
  background: var(--clr-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--dur-panel) var(--ease-out);
  will-change: transform;
}

/* ---- 8a. DESKTOP: right side panel ---- */
@media (min-width: 768px) {
  .panel {
    top: 0;
    right: 0;
    width: var(--panel-w);
    height: 100dvh;
    border-left: 1px solid var(--clr-border);
    transform: translateX(100%);
    box-shadow: -8px 0 48px rgba(0,0,0,0.6);
  }

  .panel--open { transform: translateX(0); }
}

/* ---- 8b. MOBILE: bottom sheet ---- */
@media (max-width: 767px) {
  .panel {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 72dvh;
    border-radius: var(--panel-radius) var(--panel-radius) 0 0;
    border-top: 1px solid var(--clr-border);
    transform: translateY(110%);
    box-shadow: 0 -8px 48px rgba(0,0,0,0.6);
  }

  .panel--open { transform: translateY(0); }
}

/* Drag handle (mobile) */
.panel__handle {
  display: none;
  width: 36px;
  height: 4px;
  background: var(--clr-border-strong);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .panel__handle { display: block; }
}

/* Panel header */
.panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.25rem 0.75rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--clr-border);
}

.panel__title-wrap {
  min-width: 0;
}

.panel__territory {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--clr-text);
  line-height: 1.2;
  word-break: break-word;
}

.panel__type {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.3rem;
}

.panel__close {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--clr-surface-2);
  color: var(--clr-text-muted);
  transition: background 0.15s, color 0.15s;
  margin-top: 2px;
}

.panel__close svg {
  width: 14px;
  height: 14px;
}

.panel__close:hover {
  background: var(--clr-surface-hover);
  color: var(--clr-text);
}

/* Section label */
.panel__section-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--clr-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0.75rem 1.25rem 0.4rem;
  flex-shrink: 0;
}

/* Track list container */
.panel__tracks {
  overflow-y: auto;
  flex: 1;
  padding-bottom: 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--clr-border) transparent;
}

.panel__tracks::-webkit-scrollbar { width: 4px; }
.panel__tracks::-webkit-scrollbar-track { background: transparent; }
.panel__tracks::-webkit-scrollbar-thumb {
  background: var(--clr-border);
  border-radius: 2px;
}

/* Empty state */
.panel__empty {
  padding: 2rem 1.25rem;
  font-size: 0.8125rem;
  color: var(--clr-text-muted);
  text-align: center;
}

/* ------------------------------------------------------------
   9. TRACK ITEM
   ------------------------------------------------------------ */
.track {
  display: grid;
  grid-template-columns: 2rem 3.25rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1.25rem;
  text-decoration: none;
  color: var(--clr-text);
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.15s;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.track:last-child { border-bottom: none; }

.track:hover,
.track:focus-visible {
  background: var(--clr-surface-hover);
  outline: none;
}

.track:focus-visible {
  box-shadow: inset 0 0 0 2px var(--clr-accent);
}

/* Active (currently playing) track */
.track--active {
  background: var(--clr-surface-hover);
}

.track--active .track__rank {
  color: var(--clr-accent) !important;
}

.track__rank {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--clr-text-faint);
  text-align: right;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.track__rank--top {
  color: var(--clr-accent);
  font-size: 0.875rem;
}

.track__thumb-wrap {
  position: relative;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--clr-surface-2);
  flex-shrink: 0;
}

.track__thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s;
}

.track__thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--clr-text-faint);
}

.track__info {
  min-width: 0;
}

.track__name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--clr-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.track__artist {
  font-size: 0.7rem;
  color: var(--clr-text-muted);
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track__views {
  font-size: 0.6rem;
  color: var(--clr-text-faint);
  margin-top: 0.25rem;
  font-variant-numeric: tabular-nums;
}

/* Action icons column (play + external link) */
.track__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
}

.track__play-icon {
  color: var(--clr-text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}

.track__play-icon svg { width: 14px; height: 14px; }

.track:hover      .track__play-icon,
.track:focus-visible .track__play-icon,
.track--active    .track__play-icon {
  opacity: 1;
  color: var(--clr-accent);
}

/* Pulsing ring on the active (playing) row */
.track--active .track__play-icon svg {
  animation: playPulse 1.4s ease-in-out infinite;
}

@keyframes playPulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%       { transform: scale(1.25); opacity: 0.7; }
}

/* External YouTube link icon */
.track__ext-link {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--clr-text-faint);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
  text-decoration: none;
}

.track__ext-link svg { width: 11px; height: 11px; }

.track:hover .track__ext-link,
.track:focus-visible .track__ext-link {
  opacity: 1;
}

.track__ext-link:hover {
  color: #ff3d3d;  /* YouTube red */
  opacity: 1 !important;
}

/* ------------------------------------------------------------
   10. PANEL OVERLAY (mobile backdrop)
   ------------------------------------------------------------ */
.panel-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: opacity var(--dur-panel) var(--ease-out), visibility var(--dur-panel);
}

.panel-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Only visible on mobile */
@media (min-width: 768px) {
  .panel-overlay { display: none; }
}

/* ------------------------------------------------------------
   11. UTILITY
   ------------------------------------------------------------ */
[hidden] { display: none !important; }

/* ============================================================
   12. FLOATING MINI-PLAYER
   ============================================================ */

/* ── Z-index token for the player ─────────────────────────── */
:root { --z-player: 55; }

/* ── Base widget ──────────────────────────────────────────── */
.player-widget {
  position: fixed;
  z-index: var(--z-player);
  background: var(--clr-surface);
  border: 1px solid var(--clr-border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 48px rgba(0,0,0,0.75), 0 2px 8px rgba(0,0,0,0.4);
  overflow: hidden;
  display: flex;
  flex-direction: column;

  /* Default position: bottom-right corner (above map attribution) */
  bottom: 3.5rem;
  right: 1rem;
  width: 320px;

  /* Entrance / exit transition */
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  transition:
    opacity 0.28s var(--ease-out),
    transform 0.28s var(--ease-out),
    width 0.2s var(--ease-out),
    box-shadow 0.2s;
  pointer-events: none;
}

/* ── Visible state ────────────────────────────────────────── */
.player-widget--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Dragging state ───────────────────────────────────────── */
.player-widget--dragging {
  cursor: grabbing !important;
  transition: none;        /* disable transitions while dragging */
  box-shadow: 0 20px 60px rgba(0,0,0,0.85);
  user-select: none;
  -webkit-user-select: none;
}

/* ── Temporarily off-screen (mobile panel open) ───────────── */
.player-widget--offscreen {
  transform: translateY(120%);
  pointer-events: none;
}

/* ── Mobile: full-width bar at bottom ────────────────────── */
@media (max-width: 767px) {
  .player-widget {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    border-radius: var(--panel-radius) var(--panel-radius) 0 0;
    border-bottom: none;
  }
}

/* ── Drag handle ─────────────────────────────────────────── */
.pw-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  height: 22px;
  cursor: grab;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
  user-select: none;
}

.pw-handle:active { cursor: grabbing; }

/* Hide handle on mobile (no drag) */
@media (max-width: 767px) { .pw-handle { display: none; } }

.pw-handle__dots {
  color: var(--clr-text-faint);
  opacity: 0.6;
  display: flex;
  align-items: center;
}

/* ── Equaliser bars (animated, shown when playing) ─────────── */
.pw-eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}

.pw-eq__bar {
  display: inline-block;
  width: 3px;
  background: var(--clr-accent);
  border-radius: 2px;
  transform-origin: bottom;
  transform: scaleY(0.2);
}

/* Only animate when the .player-widget--playing class is set */
.player-widget--playing .pw-eq__bar { animation: eq-bounce 0.9s ease-in-out infinite; }
.player-widget--playing .pw-eq__bar:nth-child(1) { animation-delay: 0s;    animation-duration: 0.8s; }
.player-widget--playing .pw-eq__bar:nth-child(2) { animation-delay: 0.15s; animation-duration: 1.0s; }
.player-widget--playing .pw-eq__bar:nth-child(3) { animation-delay: 0.3s;  animation-duration: 0.7s; }
.player-widget--playing .pw-eq__bar:nth-child(4) { animation-delay: 0.1s;  animation-duration: 0.9s; }

@keyframes eq-bounce {
  0%, 100% { transform: scaleY(0.2); }
  50%       { transform: scaleY(1);   }
}

/* ── Header row ──────────────────────────────────────────── */
.pw-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  flex-shrink: 0;
  min-width: 0;
}

/* Thumbnail */
.pw-thumb {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--clr-surface-2);
}

/* Track info */
.pw-info {
  flex: 1;
  min-width: 0;
}

.pw-track-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--clr-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.pw-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.15rem;
}

.pw-artist {
  font-size: 0.7rem;
  color: var(--clr-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.pw-status {
  font-size: 0.65rem;
  color: var(--clr-accent);
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Action buttons */
.pw-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.pw-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--clr-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  flex-shrink: 0;
}

.pw-btn svg { width: 14px; height: 14px; }

.pw-btn:hover {
  background: var(--clr-surface-hover);
  color: var(--clr-text);
}

.pw-btn--close:hover {
  background: rgba(255,59,48,0.15);
  color: #ff3b30;
}

/* Chevron rotates when minimised */
.pw-btn[data-minimized="true"] svg {
  transform: rotate(180deg);
}

/* ── Video frame ─────────────────────────────────────────── */
.pw-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #000;
  /* Smooth collapse for minimise */
  max-height: 220px;
  transition: max-height 0.3s var(--ease-out), opacity 0.3s var(--ease-out);
}

/* 16:9 aspect-ratio spacer */
.pw-frame::before {
  content: '';
  display: block;
  padding-top: 56.25%;  /* 9/16 */
}

/* The YT iframe/div fills the frame */
.pw-frame > div,
.pw-frame > iframe {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

/* Minimised: collapse video frame */
.player-widget--minimized .pw-frame {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}
