/* ownflix — feuille de style unique, sans dépendance externe. */

/* ---------- Tokens ---------- */
:root {
  --bg: #09090c;
  --bg-2: #0e0e13;
  --surface: #16161d;
  --surface-2: #1d1d26;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #f3f3f6;
  --muted: #9a9aa9;
  --faint: #6c6c7a;
  --accent: #ffb224;
  --accent-2: #ff6b3d;
  --accent-ink: #1a1206;
  /* Deux listes, deux couleurs : l'ambre appelle à l'achat, le vert dit « c'est
     chez toi ». On sait de quel côté on se trouve sans lire un mot. */
  --own: #34c98a;
  --own-ink: #04231a;
  --danger: #ff5f56;
  --skeleton: linear-gradient(100deg, #17171f 20%, #212129 40%, #17171f 60%);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .7);
  --glass: rgba(9, 9, 12, .72);

  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: 180ms;

  --pad: clamp(16px, 4vw, 40px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f6f5f3;
  --bg-2: #efeeeb;
  --surface: #ffffff;
  --surface-2: #f2f1ee;
  --line: rgba(18, 18, 28, .10);
  --line-strong: rgba(18, 18, 28, .20);
  --text: #14141a;
  --muted: #63636f;
  --faint: #8a8a96;
  --accent: #b96a00;
  --accent-2: #d1461c;
  --accent-ink: #fff8ec;
  --own: #0e8a5f;
  --own-ink: #f0fff8;
  --danger: #cc2f24;
  --skeleton: linear-gradient(100deg, #e8e7e3 20%, #f3f2ef 40%, #e8e7e3 60%);
  --shadow-sm: 0 2px 8px rgba(20, 20, 30, .08);
  --shadow-lg: 0 24px 60px -16px rgba(20, 20, 30, .25);
  --glass: rgba(246, 245, 243, .8);

  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

/* Halo discret derrière l'en-tête : donne de la profondeur sans image. */
body::before {
  content: "";
  position: fixed;
  inset: -20vh 0 auto 0;
  height: 60vh;
  background: radial-gradient(60% 60% at 50% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Les règles `display` d'auteur battent l'attribut [hidden] du UA stylesheet :
   sans ce garde-fou, masquer un élément en JS n'aurait aucun effet. */
[hidden] { display: none !important; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }
p { margin: 0; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: 10px; font-weight: 600;
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- Barre supérieure ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex; align-items: center; gap: clamp(10px, 2vw, 20px);
  padding: 10px var(--pad);
  max-width: 1560px; margin: 0 auto;
}

/* Le logo se colore par héritage : `color` peint la silhouette (currentColor),
   --accent l'ambre. Rien à redéfinir pour le thème clair. */
.brand { display: flex; align-items: center; flex: none; color: var(--text); }
.brand-lockup, .brand-mark { height: 30px; width: auto; display: block; }
.brand-mark { display: none; }

.search {
  position: relative; flex: 1 1 auto;
  /* min-width: 0 — sans ça le champ refuse de descendre sous sa largeur
     intrinsèque et pousse les onglets hors de la barre sur un téléphone. */
  max-width: 640px; min-width: 0; margin-inline: auto;
  display: flex; align-items: center;
}
.search-icon {
  position: absolute; left: 13px; width: 18px; height: 18px;
  color: var(--faint); pointer-events: none;
}
#q {
  width: 100%;
  padding: 11px 76px 11px 40px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 15px;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  -webkit-appearance: none; appearance: none;
}
#q::placeholder { color: var(--faint); }
#q::-webkit-search-cancel-button { display: none; }
#q:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: var(--surface-2);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}
.search-kbd {
  position: absolute; right: 12px;
  font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--faint);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 7px; pointer-events: none;
}
.search:focus-within .search-kbd, .search.has-value .search-kbd { opacity: 0; }
.search-clear {
  position: absolute; right: 8px;
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  color: var(--muted);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.search-clear:hover { background: var(--surface-2); color: var(--text); }
.search-clear svg { width: 16px; height: 16px; }

/* position: relative — le menu déroulant s'accroche au bord droit de ce bloc,
   donc au bouton, quels que soient les onglets posés à sa gauche. */
.topbar-actions { position: relative; flex: none; display: flex; align-items: center; gap: clamp(6px, 1.4vw, 12px); }

.icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 50%;
  color: var(--muted);
  border: 1px solid transparent;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface); color: var(--text); border-color: var(--line); }

.menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 214px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 50;
  animation: pop var(--dur) var(--ease);
}
.menu button, .menu a {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text); text-align: left;
  transition: background var(--dur) var(--ease);
}
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu svg { width: 17px; height: 17px; color: var(--muted); flex: none; }

@keyframes pop {
  from { opacity: 0; transform: translateY(-6px) scale(.97); }
}

/* ---------- Zone principale ---------- */
.wrap {
  position: relative; z-index: 1;
  max-width: 1560px; margin: 0 auto;
  padding: clamp(18px, 3vw, 30px) var(--pad) calc(80px + var(--safe-b));
}

.toolbar { margin-bottom: clamp(14px, 2vw, 22px); }

/* Le titre de la liste. Seul le dernier mot prend la couleur : un titre
   entièrement ambre ou vert crierait plus fort que la grille qu'il annonce,
   alors que le contraste entre « Ma » estompé et « collection » coloré suffit
   à dire d'un coup d'œil laquelle des deux moitiés on regarde. */
.view-title {
  margin: 0 0 12px;
  /* Pente raide exprès : à 4.2vw le titre tombait sur son plancher dès le
     téléphone et n'y pesait plus que deux fois un titre de carte (13.5px),
     contre presque trois sur grand écran — il se lisait comme un intertitre.
     À 9vw il garde le même rapport partout, et plafonne dès 420px. */
  font-size: clamp(30px, 9vw, 38px);
  font-weight: 700; letter-spacing: -.02em; line-height: 1.08;
  color: var(--muted);
}
.view-title em { font-style: normal; color: var(--accent); }
.view-title.is-own em { color: var(--own); }
/* En recherche, aucune des deux listes n'est courante : la colorer en ambre
   donnerait à un résultat des airs de wishlist. */
.view-title.is-search em { color: var(--text); }

.toolbar-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 14px; }
.view-count { color: var(--faint); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Les onglets nomment la liste *et* la changent : c'est la navigation
   principale, elle se tient dans la barre supérieure, à côté du menu. D'où un
   gabarit calé sur le bouton rond (38px) plutôt que sur les puces de filtre. */
.tabs {
  display: inline-flex; gap: 3px; padding: 3px; flex: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
}
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--text); }
.tab[data-view="wishlist"][aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.tab[data-view="collection"][aria-selected="true"] { background: var(--own); color: var(--own-ink); }
.tab-n { font-size: 12px; opacity: .62; font-variant-numeric: tabular-nums; }
.tab-n:empty { display: none; }

/* Bandeau de statistiques : réservé à la collection, où « 8,4 de moyenne sur 19 »
   dit quelque chose de ce qu'on possède. */
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.stat {
  padding: 7px 13px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; color: var(--muted); white-space: nowrap;
}
.stat b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 5px;
  margin-left: auto; padding: 7px 13px 7px 9px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 13.5px; font-weight: 550; color: var(--muted);
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.ghost-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface); }
.ghost-btn svg { width: 16px; height: 16px; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
/* Ni le tri ni le partage animation / reste ne sont des filtres de la même
   famille que les puces : eux seuls partent à droite. Les groupes de chips, eux,
   se suivent — les envoyer aux deux bouts de l'écran laisserait croire qu'ils
   portent sur des choses différentes. */
.filters-end { display: inline-flex; align-items: center; gap: 10px; margin-left: auto; flex: none; }
.filters .select { flex: none; }

/* Le partage se dessine en groupe segmenté, comme les onglets : une puce de
   plus se lirait comme un critère à réunir avec les tags, alors qu'il choisit
   une moitié de liste à l'exclusion de l'autre. Il reste neutre (--text) : les
   deux couleurs de l'app disent déjà la liste, pas le genre. */
.scope {
  display: inline-flex; gap: 2px; padding: 3px; flex: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
}
.scope-opt {
  padding: 4px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 550; color: var(--muted); white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.scope-opt:hover { color: var(--text); }
.scope-opt[aria-pressed="true"] { background: var(--text); color: var(--bg); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-tags, .chips-formats { flex: 0 1 auto; min-width: 0; }
/* Le support filtre les deux listes : la pastille prend la couleur de la liste
   affichée, sans quoi un filtre vert donnerait à une wishlist des airs de
   collection. */
.chips-formats .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chips-formats.is-own .chip[aria-pressed="true"] { background: var(--own); border-color: var(--own); color: var(--own-ink); }
/* Un filet sépare les deux familles de critères sans les éloigner. */
.chips-formats::before {
  content: ""; align-self: center; flex: none;
  width: 1px; height: 18px; margin-right: 4px;
  background: var(--line-strong);
}
.chips-formats.is-alone::before { display: none; }
.chip {
  padding: 6px 13px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; font-weight: 550; color: var(--muted);
  white-space: nowrap;
  transition: all var(--dur) var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip[aria-pressed="true"] {
  background: var(--text); border-color: var(--text); color: var(--bg);
}
.chip .chip-n { opacity: .55; margin-left: 5px; font-variant-numeric: tabular-nums; }

.select { position: relative; display: inline-flex; align-items: center; }
.select select {
  -webkit-appearance: none; appearance: none;
  padding: 7px 32px 7px 13px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; font-weight: 550; cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.select select:hover { color: var(--text); border-color: var(--line-strong); }
.select svg { position: absolute; right: 10px; width: 15px; height: 15px; color: var(--faint); pointer-events: none; }
.select option { background: var(--surface); color: var(--text); }

/* ---------- Grille ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(112px, 15vw, 168px), 1fr));
  gap: clamp(12px, 1.6vw, 22px) clamp(10px, 1.4vw, 18px);
}

.card { position: relative; animation: rise var(--dur) var(--ease) backwards; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.poster img {
  width: 100%; height: 100%; object-fit: cover;
  -webkit-user-drag: none;
  transition: transform 400ms var(--ease), opacity 300ms var(--ease);
}
.poster img[data-loading] { opacity: 0; }

.poster-fallback {
  position: absolute; inset: 0;
  display: grid; place-content: center; gap: 8px; justify-items: center;
  padding: 12px; text-align: center;
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  color: var(--faint);
}
.poster-fallback span { font-size: 11.5px; line-height: 1.3; }
.poster-fallback svg { width: 26px; height: 26px; opacity: .5; }

@media (hover: hover) {
  .card:hover .poster { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
  .card:hover .poster img { transform: scale(1.05); }
}

/* Deux destinations possibles pour une même affiche : « + » vers la wishlist,
   « ✓ » vers la collection. Elles s'empilent plutôt que de se disputer le coin
   de l'affiche. */
.poster-acts {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  display: flex; flex-direction: column; gap: 6px;
}
.poster-act {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(10, 10, 14, .62); color: #fff;
  border: 1px solid rgba(255, 255, 255, .18);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: all var(--dur) var(--ease);
}
.poster-act svg { width: 18px; height: 18px; stroke-width: 2.2; }
.poster-act[data-act="wish"]:hover { background: var(--accent); color: var(--accent-ink); border-color: transparent; transform: scale(1.08); }
.poster-act[data-act="own"]:hover { background: var(--own); color: var(--own-ink); border-color: transparent; transform: scale(1.08); }
/* .is-marker = « déjà rangé », affiché en permanence sur les résultats de
   recherche. Marqueur et non bouton : le clic traverse jusqu'à l'affiche, qui
   ouvre la fiche — seul endroit d'où l'on retire un film. */
.poster-act.is-marker {
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
  pointer-events: none;
}
.poster-act.is-marker.is-own { background: var(--own); color: var(--own-ink); }
@media (hover: hover) {
  .poster-act { opacity: 0; transform: scale(.85); }
  .card:hover .poster-act, .poster-act:focus-visible, .poster-act.is-marker { opacity: 1; transform: none; }
}

.poster-tags {
  position: absolute; left: 7px; bottom: 7px; right: 7px;
  display: flex; flex-wrap: wrap; gap: 4px; pointer-events: none;
}
/* Un tag est un libellé saisi : ni capitales forcées ni interlettrage, sinon
   « à offrir » devient illisible. */
.tag {
  padding: 3px 7px; border-radius: 6px;
  font-size: 10.5px; font-weight: 600;
  background: rgba(10, 10, 14, .68); color: #f2f2f5;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, .12);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Le support prime sur les tags : c'est ce qu'on cherche des yeux dans une
   collection. D'où des pastilles pleines, et non translucides. Le support
   d'une envie d'achat reste ambre : deux couleurs, deux listes. */
.tag.is-format { background: var(--own); color: var(--own-ink); border-color: transparent; }
.tag.is-format.is-wish { background: var(--accent); color: var(--accent-ink); }

.card-meta { padding: 9px 3px 0; }
.card-title {
  font-size: 13.5px; font-weight: 600; letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-sub {
  margin-top: 3px; font-size: 12px; color: var(--faint);
  display: flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.card-sub .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .6; }
.star { color: var(--accent); font-size: 11px; }
/* Ma note remplace celle de TMDB sur un film possédé : c'est la mienne qui
   compte quand le film est déjà sur l'étagère. */
.mystars { color: var(--accent); font-size: 11px; letter-spacing: .5px; }

/* ---------- Glisser-déposer ---------- */
.grid.is-manual .poster { cursor: grab; }
.grid.is-manual .poster:active { cursor: grabbing; }

/* L'emplacement d'origine reste visible en creux : on voit où l'affiche
   atterrira si on lâche maintenant. */
.card.is-dragging { opacity: 1; }
.card.is-dragging .poster {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: none; transform: none;
}
.card.is-dragging .poster > * { opacity: 0; }
.card.is-dragging .card-meta { opacity: .25; }

.drag-clone {
  position: fixed; z-index: 70; margin: 0;
  pointer-events: none; will-change: transform;
  animation: none; opacity: .96;
}
.drag-clone .poster {
  transform: scale(1.05) rotate(1.2deg);
  box-shadow: var(--shadow-lg);
  border-color: var(--line-strong);
  cursor: grabbing;
}
.drag-clone .poster-act, .drag-clone .card-meta { display: none; }

body.is-dragging-card {
  -webkit-user-select: none; user-select: none;
  cursor: grabbing;
}

/* ---------- Squelettes ---------- */
.skeleton .poster { border-color: transparent; }
.sk-box {
  background: var(--skeleton); background-size: 300% 100%;
  animation: shimmer 1.4s linear infinite; border-radius: var(--radius);
}
.sk-line { height: 11px; border-radius: 6px; margin-top: 9px; }
@keyframes shimmer { to { background-position: -300% 0; } }

/* ---------- États ---------- */
.state {
  display: grid; justify-items: center; gap: 10px;
  padding: clamp(40px, 9vw, 90px) 20px; text-align: center;
}
.state-icon {
  width: 54px; height: 54px; display: grid; place-items: center;
  border-radius: 18px; background: var(--surface); border: 1px solid var(--line);
  color: var(--accent); margin-bottom: 4px;
}
.state-icon svg { width: 25px; height: 25px; }
.state h2 { font-size: 19px; }
.state p { color: var(--muted); max-width: 42ch; font-size: 14px; }
.state .primary-btn { margin-top: 8px; }

.section-head {
  display: flex; align-items: baseline; gap: 9px;
  margin: clamp(30px, 5vw, 48px) 0 14px;
}
.section-head h2 { font-size: 17px; }
.section-head span { color: var(--faint); font-size: 13px; }

/* ---------- Boutons ---------- */
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink); font-weight: 650; font-size: 14.5px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.primary-btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.primary-btn:active { transform: translateY(0); }
.primary-btn[disabled] { opacity: .55; pointer-events: none; }
.primary-btn svg { width: 18px; height: 18px; stroke-width: 2.2; }
/* « Je l'ai » : même poids que l'action d'achat, l'autre couleur. */
.primary-btn.is-own { background: var(--own); color: var(--own-ink); }

.subtle-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text); font-weight: 550; font-size: 14px;
  transition: all var(--dur) var(--ease);
}
.subtle-btn:hover { background: var(--surface); border-color: var(--line-strong); }
.subtle-btn.is-danger { color: var(--danger); }
.subtle-btn.is-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.subtle-btn svg { width: 17px; height: 17px; }

/* ---------- Tiroir de détail ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet-scrim {
  position: absolute; inset: 0;
  background: rgba(4, 4, 8, .6);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade var(--dur) var(--ease);
}
@keyframes fade { from { opacity: 0; } }

.sheet-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(560px, 100%);
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  overflow-y: auto; overscroll-behavior: contain;
  animation: slide-in 260ms var(--ease);
}
.sheet-panel:focus { outline: none; }
@keyframes slide-in { from { transform: translateX(100%); } }

.sheet-close {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  background: rgba(10, 10, 14, .55); color: #fff;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .14);
}
.sheet-close:hover { background: rgba(10, 10, 14, .8); color: #fff; }

.sheet-hero { position: relative; aspect-ratio: 16 / 9; background: var(--surface); }
.sheet-hero img { width: 100%; height: 100%; object-fit: cover; }
.sheet-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 30%, var(--bg-2) 98%);
}

.sheet-headline { position: relative; margin-top: -64px; padding: 0 clamp(18px, 4vw, 28px); z-index: 2; }
/* Sans hero au-dessus, plus rien à chevaucher — mais le titre doit dégager la
   croix de fermeture, qui n'a plus d'affiche sous elle. */
.sheet-headline.is-plain {
  margin-top: 0;
  padding-top: clamp(22px, 5vw, 30px);
  padding-right: 58px;
}
.sheet-headline h2 { font-size: clamp(21px, 4.4vw, 27px); }
.sheet-tagline { margin-top: 6px; color: var(--muted); font-size: 13.5px; font-style: italic; }

.sheet-facts {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 12px; color: var(--muted); font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.sheet-facts .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; }
.cert { border: 1px solid var(--line-strong); border-radius: 5px; padding: 1px 5px; font-size: 11px; font-weight: 650; }

.sheet-section { padding: clamp(18px, 4vw, 26px) clamp(18px, 4vw, 28px); border-top: 1px solid var(--line); }
.sheet-section:first-of-type { border-top: 0; }
/* `>` obligatoire : les cartes des rails contiennent elles aussi des h3. */
.sheet-section > h3 {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--faint); margin-bottom: 12px;
}
.overview { color: var(--muted); font-size: 14.5px; line-height: 1.62; }

.actions-row { display: flex; flex-wrap: wrap; gap: 9px; }
.actions-row .primary-btn, .actions-row .subtle-btn { flex: 1 1 auto; }

/* Champs de la fiche */
.field + .field { margin-top: 18px; }
.field-label {
  display: block; font-size: 12px; font-weight: 650; color: var(--faint);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px;
}

/* Sélecteur de tags : tout le catalogue s'affiche, on allume ceux du film. */
.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-toggle {
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 13px; font-weight: 550; color: var(--muted);
  transition: all var(--dur) var(--ease);
}
.tag-toggle:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); }
.tag-toggle[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: var(--accent); color: var(--accent);
}
.tag-toggle.is-format[aria-pressed="true"] {
  background: color-mix(in srgb, var(--own) 16%, transparent);
  border-color: var(--own); color: var(--own);
}

/* Ma note : cinq boutons, et recliquer la même étoile efface. */
.stars { display: flex; gap: 6px; }
.star-btn {
  font-size: 26px; line-height: 1; color: var(--line-strong);
  transition: color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.star-btn[aria-pressed="true"] { color: var(--accent); }
.star-btn:hover { transform: scale(1.15); }
/* Plafond atteint : les tags non posés deviennent inertes plutôt que de
   disparaître sous les doigts. */
.tag-toggle:disabled { opacity: .4; cursor: not-allowed; }

.tag-create { display: flex; gap: 8px; margin-top: 10px; }
.tag-create .subtle-btn, .tag-create .primary-btn { flex: none; }

.tag-create input, .tag-name, .text-field {
  flex: 1 1 auto; min-width: 0;
  padding: 10px 13px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line);
  font-size: 14px;
  transition: border-color var(--dur) var(--ease);
}
.tag-create input:focus, .tag-name:focus, .text-field:focus {
  outline: none; border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}
.tag-create input::placeholder, .text-field::placeholder { color: var(--faint); }
.text-field { width: 100%; }
.tag-create input:disabled { opacity: .5; }

.tag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tag-row { display: flex; align-items: center; gap: 10px; }
.tag-name { font-weight: 550; }
.tag-count {
  flex: none; font-size: 12px; color: var(--faint);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.icon-btn.is-danger { width: 34px; height: 34px; flex: none; }
.icon-btn.is-danger:hover {
  color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}
.icon-btn.is-danger svg { width: 17px; height: 17px; }

.note-field {
  width: 100%; min-height: 76px; resize: vertical;
  padding: 11px 13px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line);
  font-size: 14px; line-height: 1.5;
  transition: border-color var(--dur) var(--ease);
}
.note-field:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.note-field::placeholder { color: var(--faint); }
.save-hint { display: block; margin-top: 7px; font-size: 12px; color: var(--faint); min-height: 16px; }

.rail {
  display: flex; gap: 12px; overflow-x: auto;
  padding-bottom: 6px; margin: 0 calc(-1 * clamp(18px, 4vw, 28px));
  padding-inline: clamp(18px, 4vw, 28px);
  scroll-snap-type: x proximity; scrollbar-width: thin;
}
.rail::-webkit-scrollbar { height: 6px; }
.rail::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }


.mini { flex: none; width: 104px; scroll-snap-align: start; }
.mini .poster { border-radius: var(--radius-sm); }
.mini .card-title { font-size: 12px; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + var(--safe-b)); z-index: 80;
  display: flex; flex-direction: column-reverse; gap: 8px;
  width: min(440px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg); font-size: 14px;
  pointer-events: auto;
  animation: toast-in 240ms var(--ease);
}
.toast.is-out { animation: toast-out 180ms var(--ease) forwards; }
.toast-text { flex: 1; min-width: 0; }
.toast-text b { font-weight: 600; }
.toast-act {
  flex: none; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--accent);
  font-size: 13px; font-weight: 600;
  transition: background var(--dur) var(--ease);
}
.toast-act:hover { background: var(--surface-2); }
.toast.is-error { border-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.toast.is-error .toast-text { color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ---------- Écran de déverrouillage ---------- */
.lock {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 20px;
  background: var(--bg);
}
.lock-card {
  display: grid; justify-items: center; gap: 12px;
  width: min(360px, 100%); padding: 34px 26px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow-lg); text-align: center;
}
.lock-logo { height: 38px; width: auto; color: var(--text); }
.lock-card p { color: var(--muted); font-size: 14px; }
.lock-card input {
  width: 100%; padding: 12px 15px; margin-top: 6px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: 15px;
}
.lock-card input:focus { outline: none; border-color: var(--accent); }
.lock-card .primary-btn { width: 100%; }
.lock-error { color: var(--danger) !important; font-size: 13px; }

.sentinel { height: 1px; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .brand-lockup { display: none; }
  .brand-mark { display: block; }
  .search-kbd { display: none; }
  /* La réserve de droite ne sert qu'à la croix d'effacement : tant qu'il n'y a
     rien à effacer, elle est rendue au texte. Sur 375px, ces 30px décident si
     le placeholder tient ou se coupe. */
  #q { padding-right: 14px; }
  .search.has-value #q { padding-right: 44px; }
  /* Le temps de la saisie, les onglets s'effacent et rendent la barre au champ :
     à trois éléments, il ne resterait pas de quoi lire ce qu'on tape. Ils
     reviennent dès qu'on quitte le clavier, la recherche restant affichée. */
  .topbar-inner:focus-within .tabs { display: none; }
  .topbar-inner { padding: 9px 14px; gap: 8px; }

  .sheet-panel {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%; max-height: 93dvh;
    border-left: 0; border-top: 1px solid var(--line);
    border-radius: 22px 22px 0 0;
    padding-bottom: var(--safe-b);
    animation: sheet-up 280ms var(--ease);
  }
  @keyframes sheet-up { from { transform: translateY(100%); } }
  .sheet-hero { border-radius: 22px 22px 0 0; overflow: hidden; }
  /* Trois colonnes garanties sur téléphone : on voit toute la liste d'un coup
     d'œil sans faire défiler à l'infini. */
  .grid { grid-template-columns: repeat(3, 1fr); }
  .filters { gap: 10px; }
  /* Une rangée par famille de chips, le tri à côté des supports : sur un
     téléphone, chaque rangée de barre d'outils est une rangée d'affiches en
     moins. Le filet n'a plus rien à séparer une fois les groupes sur deux
     lignes. */
  .chips-tags { flex: 1 1 100%; }
  .chips-formats::before { display: none; }
  .chips { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; padding-bottom: 2px; }
  .chips::-webkit-scrollbar { display: none; }
  /* Les onglets partagent maintenant la barre supérieure avec le champ de
     recherche : les libellés tombent, l'icône et le compteur disent la même
     chose en trois fois moins large. Le nom reste dans l'aria-label. */
  .tab { padding: 7px 10px; gap: 5px; }
  .tab-label { display: none; }
  .tab svg { width: 16px; height: 16px; }
  .tab-n { font-size: 11.5px; }
  .chips-formats { flex: 1 1 100px; }
  /* Le partage et le tri ne tiennent pas côte à côte avec les supports sur un
     téléphone : ils prennent leur propre rangée, mais seulement quand il y a
     bien deux moitiés à proposer — sinon le tri reste au bout des supports. */
  .filters.has-scope .filters-end { flex: 1 1 100%; justify-content: space-between; }
  /* Les statistiques défilent plutôt que de s'empiler sur trois rangées. */
  .stats { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .stats::-webkit-scrollbar { display: none; }
  .stat { flex: none; }
  /* Sans survol, les deux pastilles restent visibles : on les resserre pour ne
     pas manger l'affiche. */
  .poster-acts { top: 6px; right: 6px; gap: 5px; }
  .poster-act { width: 30px; height: 30px; }
  .poster-act svg { width: 16px; height: 16px; }
  .stat { padding: 6px 11px; font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
