/* ============================================================
   Movix TV — 10-foot UI, dark, télécommande-friendly
   ============================================================ */
:root {
  --bg: #0a0d14;
  --bg2: #121826;
  --bg3: #1a2233;
  --txt: #eef1f7;
  --dim: #93a0b4;
  --accent: #e50914;
  --accent2: #f43f5e;
  --focus: #ffd166;
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--txt);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 18px;
  overflow-x: hidden;
}

#app { min-height: 100vh; }

.boot {
  display: grid; place-items: center;
  min-height: 100vh; color: var(--dim);
  font-size: 22px; letter-spacing: 0.08em;
}

/* ---------- Focus TV ---------- */
[data-nav] { outline: none; }
[data-nav]:focus,
[data-nav]:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 24px rgba(255, 209, 102, 0.35);
  z-index: 10;
}
button[data-nav]:focus,
button[data-nav]:focus-visible { transform: scale(1.05); }

/* ---------- Header ---------- */
.topbar {
  display: flex; align-items: center; gap: 28px;
  padding: 22px 48px;
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(180deg, rgba(10,13,20,0.97) 0%, rgba(10,13,20,0.88) 70%, rgba(10,13,20,0) 100%);
}
.brand {
  font-size: 30px; font-weight: 900; letter-spacing: 0.06em;
  color: var(--accent); text-decoration: none; flex-shrink: 0;
}
.brand span { color: var(--txt); font-weight: 300; }
.topnav { display: flex; gap: 8px; align-items: center; }
.navbtn {
  background: transparent; color: var(--txt);
  border: none; border-radius: 999px;
  font-size: 19px; font-weight: 600;
  padding: 10px 22px; cursor: pointer;
  transition: background 0.15s;
}
.navbtn.on { background: var(--accent); }
.navbtn.on:focus { background: var(--accent2); }
.searchbtn { margin-left: auto; flex-shrink: 0; }
.burger { display: none; background: transparent; border: none; color: var(--txt); font-size: 30px; line-height: 1; cursor: pointer; padding: 4px 10px; }

/* ---------- Hero ---------- */
.hero {
  position: relative; margin-top: -92px;
  min-height: 62vh; display: flex; align-items: flex-end;
  border-radius: 0 0 28px 28px; overflow: hidden;
}
.hero-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center 20%;
  /* pas de filter ici : le compositing GPU des navigateurs TV
     plante sur les filtres CSS appliqués aux grandes images */
}
.hero-grad {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(10,13,20,0.94) 0%, rgba(10,13,20,0.5) 55%, rgba(10,13,20,0.2) 100%),
              linear-gradient(0deg, var(--bg) 2%, rgba(10,13,20,0.45) 50%);
}
.hero-body {
  position: relative; padding: 56px 56px 48px; max-width: 62%;
}
.hero-title { font-size: 46px; font-weight: 900; line-height: 1.12; margin-bottom: 14px; }
.hero-meta { color: var(--dim); font-size: 18px; margin-bottom: 12px; }
.hero-over {
  color: #c8d0dd; font-size: 19px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 26px;
}
.hero-actions { display: flex; gap: 16px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  border: none; border-radius: 10px; cursor: pointer;
  font-size: 20px; font-weight: 700; padding: 14px 30px;
  transition: transform 0.15s, background 0.15s;
}
.btn-play { background: var(--accent); color: #fff; }
.btn-play:focus { background: var(--accent2); }
.btn-ghost { background: rgba(255,255,255,0.12); color: var(--txt); }
.btn-ghost:focus { background: rgba(255,255,255,0.22); }
.btn-mini { font-size: 16px; padding: 9px 18px; border-radius: 8px; }

/* ---------- Rows ---------- */
section.row { margin: 34px 0 10px; }
.row-head { padding: 0 48px 14px; }
.row-head h2 { font-size: 25px; font-weight: 800; letter-spacing: 0.01em; }
.track {
  display: flex; gap: 16px; overflow-x: auto; overflow-y: hidden;
  padding: 6px 48px 18px;
  scroll-behavior: smooth;
}
.track::-webkit-scrollbar { display: none; }
.track .card { flex: 0 0 auto; }

/* ---------- Cartes ---------- */
.card {
  width: 172px; border: none; background: transparent;
  cursor: pointer; text-align: left; color: var(--txt);
  font-family: inherit; padding: 0;
}
.card .pic {
  display: block; /* span inline ignore width/height -> poster étiré, titre coupé */
  width: 172px; height: 258px; border-radius: var(--radius);
  background: var(--bg3); overflow: hidden;
  position: relative; transition: transform 0.16s;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .noimg { display: grid; place-items: center; height: 100%; color: var(--dim); font-size: 15px; padding: 10px; text-align: center; }
.card .badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(10,13,20,0.85); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 7px; padding: 3px 8px;
  font-size: 13px; font-weight: 800; color: #ffd166;
}
.card .badge.hd { color: #ff9f00; border-color: rgba(255,159,0,0.4); }
.card .badge.vf { color: #60a5fa; border-color: rgba(96,165,250,0.4); }
.card .badge.hd + .badge.vf { top: 34px; }
.card .t {
  margin-top: 10px; font-size: 14px; font-weight: 600; line-height: 1.28;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.56em; /* 2 lignes : dates alignées, sans trop d'espace si titre court */
}
.card .s { color: var(--dim); font-size: 14px; margin-top: 3px; }

/* ---------- Grid ---------- */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, 172px);
  gap: 26px 20px; padding: 8px 48px 60px;
}

/* ---------- Page détails ---------- */
.detail-hero {
  position: relative; display: flex; align-items: flex-start; gap: 44px;
  padding: 40px 56px 46px; min-height: 0;
  background: linear-gradient(180deg, var(--bg2) 0%, var(--bg) 100%);
}
.detail-poster {
  width: 260px; border-radius: var(--radius); flex-shrink: 0;
  box-shadow: 0 10px 34px rgba(0,0,0,0.55);
}
.detail-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.detail-title { font-size: 42px; font-weight: 900; line-height: 1.12; margin-bottom: 14px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 10px 18px; color: var(--dim); font-size: 18px; margin-bottom: 18px; }
.detail-meta b { color: #ffd166; }
.detail-over { color: #c8d0dd; line-height: 1.6; font-size: 19px; margin-bottom: 28px; max-width: 900px; }
.detail-actions { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Saisons / épisodes ---------- */
.seasonbar { padding: 26px 48px 4px; display: flex; align-items: center; gap: 18px; }
.seasonbar h2 { font-size: 25px; font-weight: 800; }
select[data-nav] {
  background: var(--bg3); color: var(--txt); border: 2px solid var(--bg3);
  border-radius: 10px; font-size: 18px; padding: 10px 14px; cursor: pointer;
  font-family: inherit;
}
select[data-nav]:focus { border-color: var(--focus); outline: none; }
.episodes { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 18px 48px 60px; max-width: 1100px; }
.ep {
  display: flex; gap: 18px; align-items: center; text-align: left;
  background: var(--bg2); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px; padding: 12px; cursor: pointer; color: var(--txt);
  font-family: inherit; width: 100%;
}
.ep:focus { background: var(--bg3); }
.ep .num {
  width: 64px; height: 44px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--bg3); font-weight: 800; font-size: 18px; color: var(--dim);
}
.ep .still { width: 150px; height: 84px; border-radius: 9px; object-fit: cover; flex-shrink: 0; background: var(--bg3); }
.ep .et { flex: 1; min-width: 0; }
.ep .et b { display: block; font-size: 18px; margin-bottom: 4px; }
.ep .et p {
  color: var(--dim); font-size: 15px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ep .seen { color: #4ade80; font-size: 14px; font-weight: 800; margin-left: 10px; }

/* ---------- Lecteur ---------- */
.player { position: fixed; inset: 0; background: #000; z-index: 100; }
.player-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 26px;
  background: linear-gradient(180deg, rgba(13,17,25,0.96) 0%, rgba(13,17,25,0.72) 65%, rgba(13,17,25,0) 100%);
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.player-bar.hide { opacity: 0; transform: translateY(-70%); pointer-events: none; }
.player-bar .pt { font-size: 20px; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 2px 8px rgba(0,0,0,0.8); }
.player-frame { position: absolute; inset: 0; background: #000; }
.player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.frame-veil { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; background: #000; pointer-events: none; }
.frame-veil.gone { display: none; }
.frame-fail { position: absolute; inset: 0; z-index: 3; display: none; place-items: center; background: #000; text-align: center; color: var(--dim); }
.frame-fail.show { display: grid; }

/* Panneau sources */
.srcpanel {
  position: absolute; top: 70px; right: 26px; z-index: 30;
  background: #121826; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px; padding: 14px; min-width: 360px; max-height: 70vh; overflow-y: auto;
  box-shadow: 0 18px 50px rgba(0,0,0,0.6);
}
.srcpanel h3 { font-size: 16px; color: var(--dim); padding: 4px 10px 12px; font-weight: 700; letter-spacing: 0.04em; }
.srcbtn {
  display: block; width: 100%; text-align: left; margin-bottom: 8px;
  background: var(--bg3); color: var(--txt); border: none; border-radius: 10px;
  padding: 13px 16px; font-size: 17px; cursor: pointer; font-family: inherit;
}
.srcbtn.on { background: var(--accent); }
.srcbtn small { display: block; color: var(--dim); font-size: 14px; margin-top: 3px; }
.srcbtn.on small { color: #ffe0e2; }
.srcbtn.noa small { color: #4ade80; }

/* ---------- Recherche ---------- */
.searchwrap { padding: 30px 48px 10px; }
.searchwrap input {
  width: 100%; max-width: 760px; font-size: 22px;
  background: var(--bg2); border: 2px solid var(--bg3); border-radius: 14px;
  color: var(--txt); padding: 16px 22px; font-family: inherit; outline: none;
}
.searchwrap input:focus { border-color: var(--focus); }

/* ---------- Divers ---------- */
.pagetitle { padding: 34px 48px 22px; font-size: 30px; font-weight: 900; }
.msg { padding: 60px 48px; color: var(--dim); font-size: 20px; }
.spinner {
  width: 44px; height: 44px; margin: 80px auto; border-radius: 50%;
  border: 4px solid var(--bg3); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.backline { padding: 20px 48px 0; }

/* ---------- Chat (GAP realtime) ---------- */
.chatpage {
  max-width: 820px; margin: 0 auto;
  padding: 22px 24px 30px;
  display: flex; flex-direction: column;
  height: calc(100vh - 104px); box-sizing: border-box;
}
.chat-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.chat-live { font-size: 15px; color: var(--dim); white-space: nowrap; font-weight: 700; }
.chat-live.on { color: #4ade80; }
.chat-live.off { color: #f87171; }
.chat-live.connecting { color: #ffd166; }
.chat-name {
  flex: 1; min-width: 0;
  background: var(--bg2); border: 2px solid var(--bg3); border-radius: 12px;
  color: var(--txt); font-size: 17px; padding: 10px 14px;
  font-family: inherit; outline: none;
}
.chat-name:focus { border-color: var(--focus); }
.chat-log {
  flex: 1; overflow-y: auto;
  background: var(--bg2); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-msg { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; line-height: 1.35; }
.cm-name { font-weight: 800; color: #7dd3fc; }
.cm-time { color: var(--dim); font-size: 12px; }
.cm-text { color: var(--txt); font-size: 17px; flex: 1 1 auto; word-break: break-word; }
.chat-input { display: flex; gap: 12px; margin-top: 14px; }
.chat-input input {
  flex: 1; min-width: 0;
  background: var(--bg2); border: 2px solid var(--bg3); border-radius: 12px;
  color: var(--txt); font-size: 18px; padding: 12px 16px;
  font-family: inherit; outline: none;
}
.chat-input input:focus { border-color: var(--focus); }
.chat-input .btn { flex-shrink: 0; }

@media (max-width: 760px) {
  .topbar { padding: 14px 20px; }
  .burger { display: block; margin-left: auto; }
  .topnav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 4px;
    background: rgba(10,13,20,0.98); padding: 12px 20px 18px;
    border-bottom: 1px solid var(--bg3);
  }
  .topbar.open .topnav { display: flex; }
  .navbtn { text-align: center; padding: 12px; }
  .searchbtn { margin-left: 0; }
  .row-head, .backline, .pagetitle, .seasonbar, .searchwrap { padding-left: 20px; padding-right: 20px; }
  .track { padding-left: 20px; padding-right: 20px; }
  .grid { padding: 8px 20px 60px; grid-template-columns: repeat(auto-fill, 140px); }
  .card { width: 140px; }
  .card .pic { width: 140px; height: 210px; }
  .hero-body { padding: 30px 24px; max-width: 100%; }
  .hero-title { font-size: 30px; }
  /* Page détail : empile poster au-dessus du texte, centré */
  .detail-hero { flex-direction: column; align-items: center; gap: 20px; padding: 24px 20px 30px; }
  .detail-info { width: 100%; max-width: none; }
  .detail-poster { width: 100%; max-width: 300px; margin: 0 auto; }
  .detail-title { font-size: 28px; }
  .detail-meta { font-size: 16px; }
  .detail-over { font-size: 17px; }
  .detail-actions { flex-direction: column; gap: 14px; width: 100%; }
  .detail-actions .btn { width: 100%; justify-content: center; }
  .episodes { padding: 18px 20px 60px; }
  .chatpage { height: calc(100vh - 78px); padding: 14px 14px 20px; }
  .chat-head { flex-wrap: wrap; gap: 10px; }
  .chat-live { order: -1; width: 100%; }
  .chat-input { flex-direction: column; }
  .chat-input .btn { width: 100%; }
  /* Les rangées horizontales doivent defiler proprement */
  .track { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .track::-webkit-scrollbar { display: none; }
}
