/* ==========================================================================
   COMPONENTS — briques réutilisables. Thème "Noir" : aplats, filets 1px,
   un seul accent rouge, rayons serrés. Voir DESIGN.md.
   ========================================================================== */

/* ================= BOUTONS ================= */
.btn {
  border: 1px solid var(--hairline);
  background: var(--surface-1);
  color: var(--ink);
  border-radius: var(--r-1);
  padding: 10px 14px;
  font-size: var(--t-body); font-weight: var(--w-medium); font-family: var(--font);
  cursor: pointer;
  transition: background var(--fast) var(--ease);
}
.btn:active { background: var(--surface-3); }

/* primaire = plein rouge, le seul bouton "fort" */
.btn-primary {
  border: none; border-radius: var(--r-1);
  background: var(--red); color: var(--on-red);
  padding: 12px 18px;
  font-size: var(--t-body); font-weight: var(--w-bold); font-family: var(--font);
  cursor: pointer;
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn-primary:active { background: var(--red-press); transform: scale(.98); }
.btn-primary.big { width: 100%; padding: 14px; font-size: 16px; }
.btn-primary:disabled { opacity: .45; }

/* bouton icône : neutre, sans fond au repos */
.icon-btn {
  border: none; border-radius: var(--r-1);
  width: 40px; height: 40px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; color: var(--ink-dim);
  font-size: 19px; cursor: pointer;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.icon-btn:active { background: var(--surface-2); color: var(--ink); }
.icon-btn.big { width: 44px; height: 44px; font-size: 21px; }
.icon-btn.xl  { width: 52px; height: 52px; font-size: 27px; color: var(--ink); }
.icon-btn.light { color: rgba(255,255,255,.75); }
.icon-btn.light:active { background: rgba(255,255,255,.12); color: #fff; }
/* `display:inline-flex` ci-dessus ÉCRASE l'attribut [hidden] (une règle
   d'auteur bat le style de l'agent utilisateur) : sans cette ligne, tout
   .icon-btn marqué hidden en JS restait visible — dont le « × » du champ de
   recherche, affiché même quand le champ est vide. */
.icon-btn[hidden] { display: none; }
/* actif = rouge (favori, shuffle/repeat ON) */
.icon-btn[aria-pressed="true"], .icon-btn.on { color: var(--red); }

/* pastille d'action (Paroles / Télécharger) — vraie pilule, verre dépoli */
.action-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--hairline-2); border-radius: var(--r-round);
  background: var(--glass-2); color: var(--ink);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  padding: 12px 20px; min-height: 44px;
  font-size: var(--t-body); font-weight: var(--w-medium); letter-spacing: -0.01em;
  font-family: var(--font); cursor: pointer;
  box-shadow: var(--glass-edge);
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.action-pill .ico { font-size: 17px; color: var(--ink-dim); }
.action-pill:active { background: var(--glass-3); transform: scale(.97); }
.action-pill.on { border-color: var(--red); color: var(--red); background: color-mix(in srgb, var(--red) 14%, var(--glass-2)); }
.action-pill.on .ico { color: var(--red); }
.action-pill:disabled { opacity: .4; cursor: default; }
.pill-count { color: var(--ink-dim); font-weight: var(--w-regular); }

/* ================= CHAMPS ================= */
.text-input {
  width: 100%; border: 1px solid var(--hairline); border-radius: var(--r-1);
  background: var(--surface-1); color: var(--ink);
  padding: 12px 14px; font-size: 16px; font-family: var(--font);
  outline: none;
}
.text-input:focus { border-color: var(--hairline-2); }
.text-input::placeholder { color: var(--ink-faint); }
select.sort-select {
  border: 1px solid var(--hairline); border-radius: var(--r-1);
  background: var(--surface-1); color: var(--ink);
  padding: 8px 12px; font-size: var(--t-meta); font-family: var(--font);
}

/* slider (seek + volume) : rail fin, remplissage rouge, pouce blanc */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 24px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px;
  background: linear-gradient(to right, var(--red) 0 var(--fill, 0%), var(--surface-3) var(--fill, 0%) 100%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff; margin-top: -5px;
}
input[type="range"]::-moz-range-track { height: 3px; border-radius: 2px; background: var(--surface-3); }
input[type="range"]::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--red); }
input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border: none; border-radius: 50%; background: #fff; }

/* ================= CARTES & RANGS ================= */
.card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  padding: var(--s3);
  margin-bottom: var(--s2);
}
.card.small { color: var(--ink-dim); font-size: var(--t-meta); }
.card.row { display: flex; align-items: center; gap: var(--s3); }
.card.pressable { cursor: pointer; }
.card.pressable:active { background: var(--surface-2); }

.cover {
  width: 46px; height: 46px; border-radius: 6px; flex-shrink: 0;
  object-fit: cover; background: var(--surface-2);
}
.cover.lg { width: 60px; height: 60px; }
.cover.sm { width: 40px; height: 40px; }

/* listes = lignes séparées par un filet, PAS des cartes empilées */
.result-list { display: flex; flex-direction: column; }
.result-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: 9px 4px;
  border-bottom: 1px solid var(--hairline);
}
.result-row:last-child { border-bottom: none; }
.result-row:active { background: var(--surface-1); }
.result-row .meta { flex: 1; min-width: 0; }
.result-row .title { font-weight: var(--w-medium); }
.result-row .play-mini {
  margin-left: auto;
  width: 40px; height: 40px; font-size: 17px; color: var(--ink);
}
.result-row.playing .title { color: var(--red); }
.result-row .idx {
  width: 20px; text-align: center; color: var(--ink-faint);
  font-size: var(--t-meta); font-weight: var(--w-medium); flex-shrink: 0;
}

/* badge SYNC / plain : petit texte gris, PAS une pilule colorée */
.badge {
  font-size: var(--t-micro); font-weight: var(--w-bold); letter-spacing: .07em;
  text-transform: uppercase;
  padding: 0; flex-shrink: 0;
  background: none; color: var(--ink-faint);
}
.badge.plain { color: var(--ink-faint); }
.badge.ghost { color: var(--ink-faint); }

/* ================= CHIPS / FILTRES ================= */
.chip-row { display: flex; gap: var(--s2); flex-wrap: wrap; }
.chip-block { margin: var(--s4) 0; }
.chip-head { display: flex; align-items: center; justify-content: space-between; }
.chip {
  border: 1px solid var(--hairline); border-radius: var(--r-round);
  background: none; color: var(--ink-dim);
  padding: 7px 13px; font-size: var(--t-meta); font-weight: var(--w-medium);
  font-family: var(--font);
  cursor: pointer; max-width: 220px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip.is-on {
  background: var(--ink); border-color: var(--ink); color: var(--bg);
}
.chip:active { background: var(--surface-2); }
.chip.is-on:active { background: var(--ink-dim); }
/* filtres de la bibliothèque : verre dépoli au repos */
.filter-row .chip { background: var(--glass-2); border-color: var(--hairline-2); box-shadow: var(--glass-edge); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); }
.filter-row .chip.is-on { background: var(--ink); box-shadow: none; }
.filter-row { display: flex; gap: var(--s2); overflow-x: auto; padding: 2px 0 var(--s3); scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }

/* ================= RAILS (le carrousel ne sert plus qu'aux "Ambiances") ==== */
.rail-block { margin-bottom: var(--s3); }
.rail-head { display: flex; align-items: baseline; justify-content: space-between; }
.rail-title { margin: var(--s5) 0 var(--s3); font-size: var(--t-title); font-weight: var(--w-bold); letter-spacing: -0.02em; }
.rail {
  display: flex; gap: var(--s3);
  overflow-x: auto; padding: 0 0 var(--s2);
  scroll-snap-type: x proximity; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }

/* ================= SKELETONS ================= */
.skel {
  border-radius: var(--r-1);
  background: var(--surface-1);
  position: relative; overflow: hidden;
  min-height: 56px;
}
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, var(--surface-2) 50%, transparent 80%);
  animation: skel-slide 1.3s ease-in-out infinite;
}
.skel-row { display: flex; gap: var(--s3); align-items: center; padding: 9px 4px; background: none; }
.skel-row::after { display: none; }
.skel-cover { width: 46px; height: 46px; border-radius: 6px; flex-shrink: 0; }
.skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skel-line { height: 10px; border-radius: 5px; }
.skel-line.w60 { width: 60%; } .skel-line.w40 { width: 40%; } .skel-line.w80 { width: 80%; }
.skel-tile { width: 128px; height: 178px; flex-shrink: 0; }

/* ================= SHEETS ================= */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sheet);
  background: var(--glass-1);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--hairline-2);
  border-radius: var(--r-3) var(--r-3) 0 0;
  box-shadow: var(--glass-edge), var(--sheet-shadow);
  max-width: 640px; margin: 0 auto;
  max-height: 94vh; max-height: 94dvh;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 6px var(--s4) calc(20px + env(safe-area-inset-bottom));
  animation: sheet-up var(--slow) var(--ease);
}
.sheet[hidden] { display: none; }
.sheet-full {
  top: 0; border-radius: 0; border-top: none;
  min-height: 100vh;  /* repli : iOS < 15.4 ne connaît pas dvh */
  min-height: 100dvh;
  /* encoche / Dynamic Island : les barres np-top / lyrics-top ne passent plus dessous */
  padding-top: calc(6px + env(safe-area-inset-top));
  /* plein écran : rien derrière -> pas de verre (le lecteur/paroles gardent leur fond opaque) */
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}
.sheet-half { max-height: 80dvh; }
.sheet-grab { padding: 8px 0 4px; cursor: grab; touch-action: none; }
.sheet-grab i {
  display: block; width: 36px; height: 4px; border-radius: 2px;
  background: var(--surface-3); margin: 0 auto;
}
.sheet-grab.light i { background: rgba(255,255,255,.35); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-title { margin: var(--s2) 0; font-size: var(--t-title); font-weight: var(--w-bold); }
.backdrop {
  position: fixed; inset: 0; z-index: calc(var(--z-sheet) - 1);
  background: rgba(0, 0, 0, 0.4);
  animation: fade-in var(--fast);
}
.backdrop[hidden] { display: none; }
/* Menu ⋯ ouvert par-dessus un sheet (cas réel : lecteur plein écran -> np-more) :
   le fond doit passer AU-DESSUS du sheet (z20) pour capter le tap de fermeture,
   sinon le tap tombe sur le lecteur et le menu ne se ferme jamais.
   Piloté en CSS pur via :has() : aucun état « over » à nettoyer en JS, donc
   aucun risque de le laisser orphelin et de bloquer un sheet demi-écran. */
body:has(#ctx-menu:not([hidden])) #ctx-backdrop { z-index: calc(var(--z-ctx) - 1); }

/* ================= MENU CONTEXTUEL ================= */
.ctx-menu {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: var(--z-ctx); max-width: 616px; margin: 0 auto;
  background: var(--glass-1);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--hairline-2); border-radius: var(--r-3);
  padding: var(--s2);
  box-shadow: var(--glass-edge), var(--shadow-2);
  animation: sheet-up var(--fast) var(--ease);
}
.ctx-menu[hidden] { display: none; }
.ctx-head { display: flex; gap: var(--s3); align-items: center; padding: var(--s2) var(--s2) var(--s3); border-bottom: 1px solid var(--hairline); margin-bottom: var(--s1); }
.ctx-head canvas { width: 40px; height: 40px; border-radius: 6px; }
.ctx-item {
  display: flex; align-items: center; gap: var(--s3); width: 100%;
  background: none; border: none; border-radius: var(--r-1);
  color: var(--ink); font-size: var(--t-body); font-family: var(--font); font-weight: var(--w-regular);
  padding: 12px; cursor: pointer; text-align: left;
}
.ctx-item .ico { font-size: 17px; color: var(--ink-dim); }
.ctx-item:active { background: var(--surface-2); }
.ctx-item.danger { color: var(--ink-dim); }

/* ================= TOASTS ================= */
.toasts {
  position: fixed; left: 0; right: 0; bottom: calc(var(--dock-h, 158px) + 8px);
  z-index: var(--z-toast);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 var(--s4);
}
.toast {
  background: var(--glass-3);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--hairline-2);
  color: var(--ink); font-size: var(--t-meta); font-weight: var(--w-medium);
  padding: 10px 16px; border-radius: var(--r-round);
  max-width: 100%; text-align: center;
  box-shadow: var(--glass-edge), var(--shadow-1);
  animation: toast-in var(--fast) var(--ease);
}
.toast.good { border-color: var(--hairline-2); }
.toast.bad { border-color: var(--red); }

/* ================= ONBOARDING ================= */
.onboard {
  position: fixed; inset: 0; z-index: var(--z-onboard);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: var(--s5);
}
.onboard[hidden] { display: none; }
.onboard-card {
  width: 100%; max-width: 400px;
  text-align: center;
}
.onboard-emoji { color: var(--red); }
.onboard-emoji.ico { font-size: 44px; margin: 0 auto; }
.onboard-logo { width: 128px; height: auto; margin: 0 auto var(--s2); display: block; }
.onboard-title { margin: var(--s4) 0 var(--s2); font-size: 24px; }
.onboard-steps { text-align: left; color: var(--ink-dim); font-size: var(--t-body); padding-left: 18px; }
.onboard-steps li { margin-bottom: var(--s2); }
.onboard-card .text-input { margin: var(--s4) 0 var(--s2); text-align: center; }
.onboard-card .link-btn { margin-top: var(--s3); }

/* ================= DIVERS ================= */
.divider { height: 1px; background: var(--hairline); margin: var(--s3) 0; }
.search-meta { color: var(--ink-dim); font-size: var(--t-meta); margin: var(--s2) 0; min-height: 18px; }
.lib-tools { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s2); }
.queue-now { margin-bottom: var(--s2); }
.queue-current { font-weight: var(--w-medium); }
