/* ====================================================
   Arms — Page Playlist Spotify
   Tuiles façon grille Spotify (cover carrée + nom en dessous) plutôt que
   les cartes .card classiques du site, mais avec les tokens de couleur
   du site (pas le vert Spotify). Deux actions en overlay sur la cover :
   ouvrir dans Spotify (app ou web player, voir page-spotify.js) et voir
   les titres via une modale (même idiome que .site-search-modal-* /
   .ssr-* de global-search.css, réutilisés pour le loader/l'état vide).
   ==================================================== */

/* ---------- Widget "En écoute actuellement" ----------
   Masqué par défaut (attribut hidden, voir spotify.php) : affiché/masqué
   au fil du polling de /api/spotify/now-playing par page-spotify.js. Un
   simple lien (pas de bouton JS dédié) : cliquer ouvre directement le
   morceau sur Spotify, comme le reste des actions de cette page. */
.now-playing-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 32px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
/* Sans cette règle, [hidden] (posé/retiré dynamiquement par page-spotify.js
   selon la réponse de /api/spotify/now-playing) n'a aucun effet visuel :
   même spécificité que le display:flex ci-dessus, et cette règle-ci est
   chargée après la feuille de style par défaut du navigateur donc elle
   l'emporte dans la cascade — la carte restait affichée en permanence,
   peu importe l'état réel (is_playing autre que true, rien en cours...). */
.now-playing-card[hidden] {
  display: none;
}
.now-playing-card:hover {
  border-color: var(--c-red-dim);
  transform: translateY(-2px);
}

.now-playing-cover {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--c-surface-2);
}

.now-playing-info {
  flex: 1;
  min-width: 0;
}

.now-playing-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-green-live);
  margin-bottom: 4px;
}
.now-playing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-green-live);
  animation: pulse-dot 1.4s ease-in-out infinite;
}

.now-playing-name {
  margin: 0;
  font-weight: 600;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-playing-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--c-text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Avancée par JS entre deux appels API (voir page-spotify.js) : la
   position exacte n'est connue qu'au moment de l'appel à
   /api/spotify/now-playing (toutes les 20s), donc la barre progresse
   elle-même seconde par seconde côté client plutôt que de retaper l'API
   en continu. */
.now-playing-progress {
  margin-top: 8px;
}
.now-playing-progress-track {
  height: 3px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.now-playing-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--c-red-glow);
  border-radius: var(--r-pill);
  transition: width 1s linear;
}
.now-playing-progress-time {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--c-text-dim);
}

.now-playing-external {
  width: 18px;
  height: 18px;
  color: var(--c-text-dim);
  flex-shrink: 0;
}

.playlist-tile {
  cursor: default;
  border-radius: var(--r-card);
  padding: 12px;
  margin: -12px;
  transition: background 0.2s ease;
}
.playlist-tile:hover,
.playlist-tile:focus-within {
  background: var(--c-surface);
}

.playlist-cover {
  aspect-ratio: 1/1;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  background: var(--c-surface-2);
  box-shadow: var(--shadow-card);
}
.playlist-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}
.playlist-tile:hover .playlist-cover img {
  transform: scale(1.04);
}

.playlist-tile-body {
  padding: 12px 2px 0;
}
.playlist-tile-body h3 {
  font-size: 14.5px;
  font-weight: 600;
  margin: 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.playlist-tile-sub {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--c-text-dim);
}

/* Boutons d'action affichés en permanence sous la tuile (plutôt qu'en
   overlay au survol sur la cover, moins lisible et redondant avec le
   watermark "spotify.com" de la cover) : deux petits boutons icône +
   libellé, côte à côte, pleine largeur de la tuile. */
.playlist-tile-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.playlist-tile-action-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: var(--r-pill);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  color: var(--c-text-dim);
  font-family: var(--f-mono);
  font-size: 11px;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.playlist-tile-action-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.playlist-tile-action-btn:hover,
.playlist-tile-action-btn:focus-visible {
  border-color: var(--c-red);
  color: var(--c-red-glow);
  background: rgba(var(--c-secondary-rgb), 0.08);
}

/* ---------- Modale "Voir les titres" ---------- */
/* Même idiome que .site-search-modal-* (global-search.css) : overlay
   plein écran, boîte alignée vers le haut, pas de duplication du style
   scrollbar/loader/état vide — .ssr-loading, .loading et .ssr-empty sont
   réutilisés tels quels. */
.playlist-tracks-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 6vh 20px;
}
.playlist-tracks-modal.open {
  display: flex;
}
.playlist-tracks-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 7, 0.72);
  backdrop-filter: blur(3px);
}

/* Disposition en deux colonnes (maquette Arms) : boîte large et haute,
   sidebar fixe à gauche (carte d'identité de la playlist) + liste des
   titres qui prend toute la hauteur/largeur restante à droite. */
.playlist-tracks-box {
  position: relative;
  width: 100%;
  max-width: 1080px;
  height: 84vh;
  max-height: 820px;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-card);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.playlist-tracks-sidebar {
  flex: 0 0 320px;
  width: 320px;
  display: flex;
  flex-direction: column;
  padding: 28px 24px;
  border-right: 1px solid var(--c-border);
  overflow-y: auto;
}
.playlist-tracks-cover {
  flex-shrink: 0;
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 10px;
  object-fit: cover;
  background: var(--c-surface-2);
  box-shadow: var(--shadow-card);
}
.playlist-tracks-sidebar h3 {
  margin: 18px 0 0;
  font-size: 19px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.playlist-tracks-description {
  margin: 8px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--c-text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.playlist-tracks-submeta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--c-text-dim);
}
.playlist-tracks-submeta span:not([hidden]) + span:not([hidden])::before {
  content: "·";
  margin-right: 10px;
}
.playlist-tracks-owner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.playlist-tracks-owner-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--c-surface-2);
}
.playlist-tracks-owner-avatar[hidden] {
  display: none;
}

.playlist-tracks-sidebar-divider {
  height: 1px;
  background: var(--c-border);
  margin: 20px 0;
}

.playlist-tracks-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.playlist-tracks-actions .btn {
  width: 100%;
  justify-content: center;
}

.playlist-tracks-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-dim);
  background: rgba(10, 10, 13, 0.5);
  backdrop-filter: blur(4px);
  transition: background 0.2s ease, color 0.2s ease;
}
.playlist-tracks-close svg {
  width: 16px;
  height: 16px;
}
.playlist-tracks-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--c-text);
}

.playlist-tracks-list {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border-strong) transparent;
}
.playlist-tracks-list::-webkit-scrollbar {
  width: 9px;
}
.playlist-tracks-list::-webkit-scrollbar-track {
  background: transparent;
}
.playlist-tracks-list::-webkit-scrollbar-thumb {
  background-color: var(--c-border-strong);
  background-clip: padding-box;
  border: 2px solid transparent;
  border-radius: 999px;
}
.playlist-tracks-list::-webkit-scrollbar-thumb:hover {
  background-color: var(--c-red-dim);
}

/* Chargement infini : petit indicateur texte en bas de la liste pendant
   qu'une page suivante se charge (voir page-spotify.js) — pas besoin du
   loader SVG plein cadre ici, la liste déjà affichée reste visible/
   scrollable pendant ce temps. */
.playlist-tracks-inline-loader {
  padding: 12px 8px;
  text-align: center;
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--c-text-dim);
}

.ptrack-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}
.ptrack-item:hover {
  background: rgba(var(--c-secondary-rgb), 0.08);
}
.ptrack-cover {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--c-surface-2);
}
.ptrack-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ptrack-name {
  font-size: 13.5px;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ptrack-artists {
  font-size: 12px;
  color: var(--c-text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ptrack-duration {
  flex-shrink: 0;
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--c-text-dim);
}

@media (max-width: 780px) {
  .playlist-tracks-modal { padding: 0; }
  .playlist-tracks-box {
    max-width: none;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    flex-direction: column;
  }
  .playlist-tracks-sidebar {
    flex: 0 0 auto;
    width: 100%;
    max-height: 46vh;
    border-right: none;
    border-bottom: 1px solid var(--c-border);
    padding: 22px 18px;
  }
  .playlist-tracks-cover { width: 88px; height: 88px; aspect-ratio: auto; }
  .playlist-tracks-description { -webkit-line-clamp: 2; }
  .playlist-tracks-actions { margin-top: 18px; flex-direction: row; }
  .playlist-tracks-list { padding: 8px; }
}
