/* MboaFlix — feuille de style unique, chargee avant l'app pour eviter tout flash clair. */

:root {
  --bg: #08080a;
  --bg-elevated: #101014;
  --surface: #17171d;
  --surface-2: #1f1f27;
  --border: #2a2a34;

  --gold: #f0b429;
  --gold-dim: #b98a1f;
  --green: #00a651;

  --text: #f5f5f7;
  --muted: #9a9aa5;
  --danger: #e5484d;

  --nav-h: 62px;
  --radius: 10px;
  --maxw: 1400px;

  /* Retrait des encoches iOS : sans ca la nav basse passe sous la barre d'accueil. */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { padding-bottom: calc(var(--nav-h) + var(--safe-b)); }
body.player-open { overflow: hidden; }

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

.hidden { display: none !important; }

/* ---------- Marque ---------- */

.brand { display: flex; align-items: center; gap: 8px; }
.brand__mark { width: 30px; height: 30px; flex: 0 0 auto; }
.brand__name { font-size: 19px; font-weight: 800; letter-spacing: -0.3px; }
.brand__name em { font-style: normal; color: var(--gold); }

/* ---------- En-tete ---------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, rgba(8,8,10,.96) 60%, rgba(8,8,10,0));
  backdrop-filter: blur(8px);
}

.appbar__actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }

.tabs {
  display: flex;
  gap: 22px;
  padding: 0 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: calc(58px + var(--safe-t));
  z-index: 39;
  background: var(--bg);
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  padding: 4px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--gold);
  border-radius: 2px;
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  margin: 0 16px 26px;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  max-height: 460px;
  background: var(--surface);
}
@media (min-width: 760px) { .hero { aspect-ratio: 21 / 9; } }

.hero__img { width: 100%; height: 100%; object-fit: cover; }

.hero__shade {
  position: absolute; inset: 0;
  background: linear-gradient(0deg, rgba(8,8,10,.96) 4%, rgba(8,8,10,.45) 45%, rgba(8,8,10,.1) 100%);
}

.hero__body {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 18px;
}

.hero__title {
  margin: 0 0 6px;
  font-size: clamp(28px, 7vw, 46px);
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--gold);
  text-shadow: 0 2px 18px rgba(0,0,0,.7);
}

.hero__meta {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #d8d8de;
}

.hero__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  transition: transform .06s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }

.btn--gold { background: var(--gold); color: #17130a; }
.btn--gold:hover { background: #ffc63d; }

.btn--ghost { background: rgba(255,255,255,.14); color: var(--text); backdrop-filter: blur(4px); }
.btn--ghost:hover { background: rgba(255,255,255,.22); }

.btn--block { width: 100%; justify-content: center; padding: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Rangees ---------- */

.row { margin-bottom: 26px; }

.row__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 16px 10px;
}
.row__title { margin: 0; font-size: 16px; font-weight: 700; }
.row__more { font-size: 12px; font-weight: 600; color: var(--muted); }
.row__more:hover { color: var(--gold); }

.row__scroller {
  display: flex;
  gap: 10px;
  padding: 0 16px 4px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.row__scroller::-webkit-scrollbar { display: none; }

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

.card {
  flex: 0 0 auto;
  width: 124px;
  scroll-snap-align: start;
  text-align: left;
}
@media (min-width: 760px) { .card { width: 158px; } }

.card__art {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
}
.card__art img { width: 100%; height: 100%; object-fit: cover; }

.card__fallback {
  position: absolute; inset: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  background: linear-gradient(150deg, #23232c, #14141a);
}

.card__badge {
  position: absolute;
  top: 6px; left: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  background: rgba(8,8,10,.78);
  color: var(--gold);
}

.card__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.2); }
.card__bar span { display: block; height: 100%; background: var(--gold); }

.card__title {
  margin: 7px 2px 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: #dcdce3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Grille (Explorer) ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 14px 10px;
  padding: 0 16px;
}
.grid .card { width: auto; }

.searchbar {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 16px 14px;
  padding: 10px 13px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.searchbar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
}
.searchbar input::placeholder { color: var(--muted); }

.chips { display: flex; gap: 8px; padding: 0 16px 16px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
}
.chip[aria-pressed="true"] { background: var(--gold); color: #17130a; border-color: var(--gold); }

/* ---------- Fiche detail ---------- */

.detail__art { position: relative; aspect-ratio: 16 / 9; background: var(--surface); }
.detail__art img { width: 100%; height: 100%; object-fit: cover; }
.detail__shade { position: absolute; inset: 0; background: linear-gradient(0deg, var(--bg) 3%, rgba(8,8,10,.25) 70%); }

.detail__back {
  position: absolute;
  top: calc(12px + var(--safe-t)); left: 12px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(8,8,10,.6);
  backdrop-filter: blur(4px);
}

.detail__body { padding: 4px 16px 30px; }
.detail__title { margin: 0 0 8px; font-size: 26px; font-weight: 800; letter-spacing: -.4px; }
.detail__meta { margin: 0 0 16px; font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.detail__actions { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.detail__synopsis { margin: 0 0 24px; font-size: 14px; line-height: 1.6; color: #c9c9d2; max-width: 66ch; }

.episodes { display: flex; flex-direction: column; gap: 8px; }
.episode {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 9px;
  background: var(--surface);
  text-align: left;
  width: 100%;
}
.episode:hover { background: var(--surface-2); }
.episode__num { font-size: 15px; font-weight: 800; color: var(--gold); min-width: 30px; }
.episode__title { flex: 1; font-size: 14px; font-weight: 600; }
.episode__dur { font-size: 12px; color: var(--muted); }

/* ---------- Lecteur ---------- */

.player {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.player video { width: 100%; height: 100%; background: #000; }
.player__close {
  position: absolute;
  top: calc(14px + var(--safe-t)); left: 14px;
  z-index: 2;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
}
.player__error {
  position: absolute;
  padding: 20px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- Navigation basse ---------- */

.bottomnav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(16,16,20,.97);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.navitem {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}
.navitem[aria-selected="true"] { color: var(--gold); }

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

.auth {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 22px calc(40px + var(--safe-b));
  max-width: 420px;
  margin: 0 auto;
}
.auth__brand { justify-content: center; margin-bottom: 8px; }
.auth__tagline { text-align: center; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); margin-bottom: 34px; }
.auth__title { margin: 0 0 18px; font-size: 21px; font-weight: 700; }

.field { margin-bottom: 13px; }
.field label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.field input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  outline: none;
}
.field input:focus { border-color: var(--gold-dim); }

.auth__switch { margin-top: 18px; text-align: center; font-size: 13px; color: var(--muted); }
.auth__switch button { color: var(--gold); font-weight: 700; }

.alert {
  margin-bottom: 14px;
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 13px;
  background: rgba(229,72,77,.12);
  border: 1px solid rgba(229,72,77,.32);
  color: #ff9a9d;
}

/* ---------- Profil ---------- */

.profile { padding: 0 16px 30px; }
.panel { padding: 16px; border-radius: 12px; background: var(--surface); margin-bottom: 14px; }
.panel__label { font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.panel__value { font-size: 16px; font-weight: 600; word-break: break-all; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge--on { background: rgba(0,166,81,.16); color: #35d17e; }
.badge--off { background: rgba(255,255,255,.08); color: var(--muted); }

.plans { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.plan { padding: 16px 14px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); text-align: center; }
.plan__days { font-size: 24px; font-weight: 800; color: var(--gold); }
.plan__label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Divers ---------- */

.empty { padding: 60px 26px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.6; }
.section-title { margin: 0 0 14px; padding: 0 16px; font-size: 18px; font-weight: 700; }

.spinner {
  width: 26px; height: 26px;
  margin: 60px auto;
  border: 2.5px solid var(--surface-2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  transform: translateX(-50%);
  z-index: 80;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

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