/* Serie Tracker - systeme visuel
   Encre chaude quasi-noire, deux accents oklch de meme clarte et meme chroma :
   l'ambre porte l'action, le jade confirme. Jamais les deux en competition. */

:root {
  --bg: #0b0a0d;
  --surf: #141218;
  --surf2: #1d1a22;
  --line: #2b2732;
  --text: #f3efe9;
  --dim: #948da0;
  --hot: oklch(0.72 0.16 55);
  --jade: oklch(0.72 0.16 168);
  --danger: #e2506a;
  --hot-soft: color-mix(in srgb, var(--hot) 17%, transparent);
  --jade-soft: color-mix(in srgb, var(--jade) 17%, transparent);
  --danger-soft: color-mix(in srgb, var(--danger) 17%, transparent);
  --r: 16px;
  --tap: 44px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --cardgap: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}
body { padding-bottom: calc(78px + var(--safe-b)); }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { display: block; max-width: 100%; }

/* Defaut pour toutes les icones inline : sans taille explicite un <svg> vaut
   300x150. Les regles specifiques ci-dessous n'ajustent que la taille. */
svg {
  width: 20px; height: 20px; flex: 0 0 auto;
  fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

.disp {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 700; letter-spacing: -.025em;
}

/* ---------- En-tetes ---------- */

.app-header {
  position: sticky; top: 0; z-index: 20;
  padding: calc(18px + var(--safe-t)) 20px 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  display: flex; align-items: flex-start; gap: 10px;
}
.app-header h1 { margin: 0; font-size: 29px; line-height: 1.05; }
.app-header .date { margin: 4px 0 0; color: var(--dim); font-size: 13px; font-weight: 500; }
.app-header .grow { flex: 1; min-width: 0; }
.hdr-btns { display: flex; gap: 8px; flex: 0 0 auto; }

.back-header {
  position: sticky; top: 0; z-index: 20;
  padding: calc(14px + var(--safe-t)) 20px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  display: flex; align-items: center; gap: 12px;
}
.back-header h1 {
  margin: 0; font-size: 17px; font-weight: 600; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: 50%;
  display: grid; place-items: center; flex: 0 0 auto;
  background: var(--surf); border: 1px solid var(--line); color: var(--text);
  transition: transform .18s var(--ease), background .18s var(--ease);
}
.icon-btn svg {
  width: 20px; height: 20px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.icon-btn:active { transform: scale(.9); }
.icon-btn.primary { background: var(--hot-soft); border-color: transparent; color: var(--hot); }
.icon-btn.primary svg { stroke-width: 2.4; }

main { padding: 0 20px 24px; max-width: 900px; margin: 0 auto; }
main.flush { padding: 0 0 24px; }
.pad { padding: 0 20px; }

/* ---------- Barre d'onglets ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding: 8px 12px calc(14px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
}
.tabbar button {
  min-height: 52px; border-radius: 13px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  color: var(--dim); font-size: 11px; font-weight: 600;
  transition: color .18s var(--ease), background .18s var(--ease);
}
.tabbar button svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.tabbar button[aria-current="page"] { color: var(--hot); background: var(--hot-soft); }
.tabbar button:active { transform: scale(.95); }
/* L'espace compte est un mode : le lisere ambre le signale en permanence. */
.tabbar.account { border-top-color: color-mix(in srgb, var(--hot) 34%, var(--line)); }

/* ---------- Segments ---------- */

.segmented {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 16px;
  background: var(--surf); border: 1px solid var(--line); border-radius: 999px;
}
.segmented button {
  flex: 1; min-height: var(--tap); border-radius: 999px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  color: var(--dim); font-size: 13.5px; font-weight: 600;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.segmented button[aria-pressed="true"] { background: var(--hot); color: #17110b; }
.segmented .n { font-size: 11px; font-weight: 700; opacity: .72; font-variant-numeric: tabular-nums; }

/* ---------- Bandeau decouvertes ---------- */

.discover-banner {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  min-height: var(--tap); padding: 14px; margin-bottom: 14px; border-radius: var(--r);
  border: 1px solid color-mix(in srgb, var(--hot) 30%, var(--line));
  background: linear-gradient(105deg, var(--hot-soft), transparent 72%), var(--surf);
  color: var(--text);
}
.discover-banner .cnt {
  font-family: "Bricolage Grotesque", system-ui, sans-serif; font-weight: 800;
  font-size: 22px; color: var(--hot); line-height: 1; font-variant-numeric: tabular-nums;
}
.discover-banner p { margin: 0; font-size: 13.5px; font-weight: 600; }
.discover-banner small { display: block; color: var(--dim); font-size: 12px; font-weight: 400; }
.discover-banner svg {
  width: 18px; height: 18px; fill: none; stroke: var(--dim);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto;
}

/* ---------- Cartes ---------- */

.queue { display: flex; flex-direction: column; gap: var(--cardgap); }

.card {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 13px; align-items: center;
  width: 100%; text-align: left; padding: 12px;
  background: var(--surf); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--text);
  transition: transform .18s var(--ease), opacity .25s var(--ease), background .18s var(--ease);
}
.card:active { transform: scale(.985); background: var(--surf2); }
.card.is-done { opacity: 0; transform: translateX(28px) scale(.96); pointer-events: none; }

.card .poster {
  width: 72px; height: 104px; border-radius: 10px; object-fit: cover;
  background: var(--surf2); flex: 0 0 auto;
}
.card .meta { min-width: 0; text-align: left; }
.card .title {
  margin: 0; font-size: 15.5px; font-weight: 700; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card .sub {
  margin: 2px 0 0; color: var(--dim); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card .sub .code { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.badge {
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: var(--surf2); color: var(--dim); white-space: nowrap;
}
.badge.accent { background: var(--hot-soft); color: var(--hot); }
.badge.success { background: var(--jade-soft); color: var(--jade); }
.badge.warn { background: var(--hot-soft); color: var(--hot); }

.countdown {
  width: 52px; text-align: center; line-height: 1.1;
  font-family: "Bricolage Grotesque", system-ui, sans-serif; font-weight: 800;
  font-size: 17px; color: var(--hot); font-variant-numeric: tabular-nums;
}
.countdown span {
  display: block; font-family: "Public Sans", system-ui, sans-serif;
  font-weight: 600; font-size: 10.5px; color: var(--dim);
  letter-spacing: .04em; text-transform: uppercase;
}

/* Bouton "vu" : la cible principale, plus large que le minimum tactile. */
.watch-btn {
  width: 52px; height: 52px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--hot-soft); color: var(--hot);
  transition: transform .18s var(--ease), background .18s var(--ease);
}
.watch-btn svg {
  width: 24px; height: 24px; fill: none; stroke: currentColor;
  stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round;
}
.watch-btn:active { transform: scale(.85); }
.watch-btn.done { background: var(--jade); color: #04180f; }
.watch-btn[disabled] { opacity: .5; pointer-events: none; }

.progress { display: block; height: 3px; border-radius: 2px; background: var(--surf2); overflow: hidden; margin-top: 9px; }
.progress i { display: block; height: 100%; background: var(--hot); transition: width .35s var(--ease); }

/* ---------- Controles ---------- */

.sortline { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sortline .count { flex: 1; color: var(--dim); font-size: 12.5px; font-weight: 600; }

.chip {
  min-height: var(--tap); display: inline-flex; align-items: center; gap: 7px;
  padding: 0 15px; border-radius: 999px;
  background: var(--surf); border: 1px solid var(--line); color: var(--text);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: transform .18s var(--ease), background .18s var(--ease);
}
.chip svg {
  width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.chip:active { transform: scale(.95); }
.chip[aria-pressed="true"] { background: var(--hot); border-color: var(--hot); color: #17110b; }
.chip.sm { min-height: 36px; padding: 0 12px; font-size: 12px; }

.actions { display: flex; gap: 8px; margin: 16px 0 22px; overflow-x: auto; scrollbar-width: none; }
.actions::-webkit-scrollbar { display: none; }
.actions .chip { flex: 0 0 auto; }

.field {
  width: 100%; min-height: 46px; padding: 12px 14px;
  background: var(--surf); border: 1px solid var(--line);
  border-radius: 13px; outline: none;
  transition: border-color .18s var(--ease);
}
.field:focus { border-color: var(--hot); }

.search-field {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 46px; padding: 0 14px; margin-bottom: 14px;
  background: var(--surf); border: 1px solid var(--line); border-radius: 13px;
  color: var(--dim); font-size: 14px; text-align: left;
}
.search-field svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; flex: 0 0 auto;
}

.btn {
  min-height: var(--tap); padding: 12px 20px; border-radius: 11px;
  background: var(--hot); color: #17110b; font-weight: 700; font-size: 13.5px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .18s var(--ease), opacity .18s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.ghost { background: var(--surf2); border: 1px solid var(--line); color: var(--text); }
.btn.block { width: 100%; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Grille bibliotheque ---------- */

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.tile { text-align: left; padding: 0; color: var(--text); }
/* display:block obligatoire : `aspect-ratio` est sans effet sur un element
   inline, et l'affiche debordait alors sur le titre de la rangee suivante. */
.tile .art { display: block; position: relative; width: 100%; aspect-ratio: 2 / 3; border-radius: 12px; overflow: hidden; background: var(--surf2); }
.tile .art img { width: 100%; height: 100%; object-fit: cover; }
.tile .ov { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0, 0, 0, .5); }
.tile .ov i { display: block; height: 100%; background: var(--hot); }
.tile .title {
  margin: 8px 0 0; font-size: 12.5px; font-weight: 600; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile .sub { margin: 1px 0 0; color: var(--dim); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tile:active { transform: scale(.97); }

/* ---------- Activite ---------- */

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 24px; }
.stat { padding: 14px 12px; background: var(--surf); border: 1px solid var(--line); border-radius: var(--r); }
.stat b {
  display: block; font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 800; font-size: 23px; line-height: 1; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.stat span { display: block; margin-top: 5px; color: var(--dim); font-size: 11.5px; font-weight: 500; }

.day-group { margin-bottom: 24px; }
.day-group h2 {
  margin: 0 0 10px; font-size: 11px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--dim);
}
.history-row {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.history-row img { width: 34px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--surf2); }
.history-row .title { margin: 0; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-row .sub { margin: 1px 0 0; color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.history-row time { color: var(--dim); font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* ---------- Espace compte ---------- */

.section-head {
  margin: 0 0 10px; font-size: 11px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--dim);
}
.panel {
  background: var(--surf); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; margin-bottom: 18px;
}
.lrow {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  width: 100%; min-height: 56px; padding: 11px 14px; text-align: left;
  border-bottom: 1px solid var(--line); color: var(--text);
}
.lrow:last-child { border-bottom: 0; }
.lrow .lb { margin: 0; font-size: 14.5px; font-weight: 600; }
.lrow .lv { margin: 1px 0 0; color: var(--dim); font-size: 12.5px; }
.lrow .chev { width: 16px; height: 16px; fill: none; stroke: var(--dim); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.lrow.danger .lb { color: var(--danger); }
.lrow .body { min-width: 0; }

.me { display: flex; align-items: center; gap: 14px; padding: 18px 16px; margin-bottom: 20px;
  background: var(--surf); border: 1px solid var(--line); border-radius: var(--r); }
.me .av {
  width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  background: var(--hot-soft); color: var(--hot);
  font-family: "Bricolage Grotesque", system-ui, sans-serif; font-weight: 800; font-size: 21px;
}
.me .n { margin: 0; font-size: 17px; font-weight: 700; }
.me .e { margin: 2px 0 0; color: var(--dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }

/* L'interrupteur est decoratif : la ligne entiere est la cible tactile. */
.switch {
  width: 46px; height: 28px; border-radius: 999px; position: relative; flex: 0 0 auto;
  background: var(--surf2); border: 1px solid var(--line);
  transition: background .2s var(--ease), border-color .2s var(--ease);
}
.switch i {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--dim);
  transition: transform .2s var(--ease), background .2s var(--ease);
}
.switch.on { background: var(--jade); border-color: var(--jade); }
.switch.on i { transform: translateX(18px); background: #04180f; }

.provider-logo {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  font-family: "Bricolage Grotesque", system-ui, sans-serif; font-weight: 800;
  font-size: 12.5px; color: #fff; letter-spacing: -.02em; flex: 0 0 auto;
}
.explain {
  padding: 13px 15px; background: var(--surf2); border-bottom: 1px solid var(--line);
  color: var(--dim); font-size: 12.5px; line-height: 1.6;
}
.explain:last-child { border-bottom: 0; }
.explain ol { margin: 9px 0 0; padding-left: 17px; }
.explain li { margin-bottom: 5px; }
.explain b { color: var(--text); }
.pin-code {
  font-family: "Bricolage Grotesque", system-ui, sans-serif; font-weight: 800;
  font-size: 30px; text-align: center; letter-spacing: 6px; margin: 12px 0;
  color: var(--hot); font-variant-numeric: tabular-nums;
}

/* ---------- Fiche serie ---------- */

.show-hero { position: relative; height: 216px; }
.show-hero img { width: 100%; height: 100%; object-fit: cover; }
.show-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, var(--bg) 5%, rgba(11, 10, 13, .15) 72%, transparent);
}
.show-hero .back {
  position: absolute; top: calc(16px + var(--safe-t)); left: 20px; z-index: 2;
  background: rgba(11, 10, 13, .62); backdrop-filter: blur(10px);
}
.show-head { margin-top: -52px; position: relative; z-index: 1; }
.show-head h1 { margin: 0 0 8px; font-size: 27px; line-height: 1.08; }

.season-block { margin-bottom: 22px; }
.season-block header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.season-block h2 { margin: 0; font-size: 15px; font-weight: 700; flex: 1; }

.ep-row {
  display: grid; grid-template-columns: 1fr var(--tap); gap: 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
  transition: opacity .2s var(--ease);
}
.ep-row .code {
  color: var(--dim); font-size: 12.5px; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.ep-row .title { margin: 2px 0 0; font-size: 14px; font-weight: 500; }
.ep-row.watched .title { opacity: .5; }
.ep-row.unaired { opacity: .35; }
.ep-toggle {
  width: var(--tap); height: var(--tap); border-radius: 50%;
  display: grid; place-items: center; background: var(--surf2); color: var(--dim);
  transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
.ep-toggle svg {
  width: 19px; height: 19px; fill: none; stroke: currentColor;
  stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round;
}
.ep-toggle.done { background: var(--jade-soft); color: var(--jade); }
.ep-toggle:active { transform: scale(.88); }
.ep-toggle[disabled] { opacity: .5; pointer-events: none; }

/* ---------- Etats ---------- */

.empty { text-align: center; padding: 56px 24px; color: var(--dim); }
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 16px; }
.empty p { margin: 0; font-size: 14px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 6px 0 0; }

.skeleton {
  height: 128px; border-radius: var(--r); margin-bottom: 10px;
  background: linear-gradient(100deg, var(--surf) 30%, var(--surf2) 50%, var(--surf) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { to { background-position: -120% 0; } }

/* ---------- Feuille modale ---------- */

.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .66); animation: fade .2s var(--ease); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 88vh; overflow-y: auto;
  padding: 16px 20px calc(24px + var(--safe-b));
  background: var(--surf); border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  animation: slide-up .28s var(--ease);
}
.sheet h2 { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.sheet .grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 16px; }
.opt-row {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  min-height: 50px; border-bottom: 1px solid var(--line);
  color: var(--text); font-size: 14.5px; font-weight: 500; text-align: left;
}
.opt-row:last-child { border-bottom: 0; }
.opt-row.on { color: var(--hot); font-weight: 700; }
.opt-row svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(100%); } }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); z-index: 50;
  transform: translateX(-50%); max-width: calc(100% - 40px);
  padding: 11px 18px; border-radius: 999px;
  background: var(--surf2); border: 1px solid var(--line);
  font-size: 13px; box-shadow: 0 8px 28px rgba(0, 0, 0, .6);
  animation: toast-in .25s var(--ease);
}
.toast .undo { margin-left: 12px; color: var(--hot); font-weight: 700; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 14px); } }

/* ---------- Resultats de recherche ---------- */

.results { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* ---------- Authentification ---------- */

.auth { max-width: 340px; margin: 0 auto; padding: 12vh 20px; }
.auth h1 { font-size: 30px; margin: 0 0 6px; }
.auth p.lead { color: var(--dim); margin: 0 0 26px; }
.auth form { display: flex; flex-direction: column; gap: 11px; }
.auth .switch-mode { margin-top: 18px; text-align: center; color: var(--dim); font-size: 14px; }
.auth .switch-mode button { color: var(--hot); font-weight: 700; }

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