/* Detail Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 42;
  overflow-y: auto;
  overscroll-behavior: contain; /* scroller la fiche/lecteur ne bouge pas la liste dessous */
  background: var(--bg);
  padding-top: max(0.8rem, env(safe-area-inset-top));
  /* opacity-only reveal: NO residual transform. A transform (even translateY(0)
     via `forwards`) fait de .overlay le bloc conteneur de ses enfants position:fixed
     (.az-scrub, .close) -> they were trapped in scroll and disappeared on scroll. */
  animation: overlayReveal 0.3s ease forwards;
}

/* Overlay hierarchy: detail opens ABOVE "See all", player
   above all. Without this, all .overlay were z-index:40 and #detail,
   placed before #category in DOM, opened BEHIND category -> click on
   film dans "Voir tout" = fiche invisible sous la grille (semblait ne rien charger). */
#category { z-index: var(--z-modal); }
#detail { z-index: calc(var(--z-modal) + 2); }
#guide { z-index: calc(var(--z-modal) + 1); }
/* Fiche programme ouverte DEPUIS le guide : au-dessus (sinon invisible sous la grille). */
#epg-prog { z-index: calc(var(--z-modal) + 3); }
/* Palette et aide clavier : toujours au premier plan comme la fiche programme. */
#cmdk, #kbd-help { z-index: calc(var(--z-modal) + 3); }
#player { z-index: var(--z-player); }

@keyframes overlayReveal {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Light fade on tab change (native effect, non-intrusive) */
.tab-enter {
  animation: tabEnter 0.16s ease-out both;
}
@keyframes tabEnter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.overlay .close {
  position: fixed;
  top: max(1.2rem, env(safe-area-inset-top));
  right: 1.2rem;
  z-index: calc(var(--z-modal) + 5);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: #0a0a0a;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.overlay .close:hover {
  background: white;
  color: black;
  transform: rotate(90deg) scale(1.05);
}
.overlay .close:focus-visible {
  outline: 2px solid #e50914;
  outline-offset: 2px;
}

/* In category (See all), A-Z scrubber is on right edge -> offset close button */
#category .close { right: 5rem; }

.detail-hero {
  position: relative;
  height: 60vh;
  min-height: 380px;
  background-position: center 25%;
  background-size: cover;
  background-repeat: no-repeat;
  /* repli: visible si l'image de fond rate (2e couche inline) */
  background-color: var(--surface);
}

.detail-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.4) 50%, var(--bg) 100%);
}

.detail-body {
  position: relative;
  z-index: 1;
  margin-top: max(-150px, min(-70px, calc(-0.15 * 100vw)));
  padding: 4rem 5rem clamp(2rem, 5vw, 6rem);
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-top: 1px solid var(--glass-border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.7);
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.detail-body h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 3.2rem;
  font-weight: 800;
  margin-bottom: 0.8rem;
  letter-spacing: -0.8px;
  line-height: 1.15;
  color: var(--text-bright);
}

.detail-meta {
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  margin: 2.5rem 0;
}
.detail-head { display: contents; }
.detail-poster { display: none; }

/* #237: pills statut + categorie (channel-details) */
.detail-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.8rem;
}
.live-pill,
.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-full, 999px);
}
.live-pill {
  background: rgba(229, 9, 20, 0.92);
  color: #fff;
}
.live-pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: live-blink 1.4s ease-in-out infinite;
}
@keyframes live-blink {
  50% { opacity: 0.35; }
}
.cat-pill {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  color: var(--muted);
}

.btn {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-6);
  min-height: 48px; /* Issue #10 — accessible touch target */
  font-weight: 600;
  font-size: 1.02rem;
  background: #0a0a0a;
  color: white;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  transition: var(--transition);
}

.btn:hover,
.btn:active {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}
.btn:focus-visible {
  outline: 2px solid #e50914;
  outline-offset: 2px;
}

.btn:active {
  transform: translateY(0) scale(0.97);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  box-shadow: var(--shadow-glow);
}

.btn.primary:hover,
.btn.primary:active {
  background: var(--accent-hover);
  color: #000;
  box-shadow: 0 8px 25px rgba(255, 255, 255, 0.15);
}

.btn.fav.on {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.btn.vlc {
  border-color: rgba(241, 90, 36, 0.25);
  color: #f15a24;
}
.btn.vlc:hover {
  background: rgba(241, 90, 36, 0.12);
  border-color: rgba(241, 90, 36, 0.45);
  transform: translateY(-2px);
}

.btn svg, .icon-btn svg, .close svg, .ctrl-btn svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.btn.primary svg {
  color: white;
}

.btn.fav svg, .btn.fav.on svg {
  transition: var(--transition);
}

.btn.fav.on svg {
  color: #f87171;
}

.btn.sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.78rem;
  gap: 0.4rem;
}

.plot {
  color: #ccc;
  line-height: 1.75;
  margin: 2rem 0;
  font-size: 1.1rem;
}

.cast {
  color: var(--muted);
  font-size: 1rem;
  margin: 0.6rem 0;
  line-height: 1.6;
}

.cast b {
  color: #ddd;
}

/* Seasons & Episodes — Jellyfin-style rail: compact pills, fade at edge
   right = "continues" affordance, active season returns to view (JS) */
.seasons {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  margin: 2.8rem 0 1.2rem;
  padding: 2px 2px 0.6rem;
  scrollbar-width: none;
  mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent);
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent);
}
.seasons::-webkit-scrollbar {
  display: none;
}

.pill {
  flex-shrink: 0;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.015);
  color: var(--muted);
  border-radius: var(--radius-full);
  padding: var(--sp-2) 1.25rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  transition: var(--transition);
}
.pill .count {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.72rem;
  opacity: 0.5;
  font-weight: 500;
  vertical-align: middle;
}

.pill:hover {
  color: white;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}
.pill:hover .count {
  opacity: 0.8;
}

.pill.active {
  background: var(--accent);
  color: #000;
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}
.pill.active .count {
  opacity: 0.8;
}

.episodes {
  display: flex;
  flex-direction: column;
  margin-top: 1.5rem;
}

.ep {
  display: flex;
  min-width: 0;
  gap: 1.2rem;
  align-items: flex-start;
  padding: 0.75rem 0.5rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.2s ease;
  position: relative;
}

.ep:last-child {
  border-bottom: none;
}

.ep:hover {
  background: rgba(255, 255, 255, 0.05);
}

.ep-index {
  flex-shrink: 0;
  width: 2.4rem;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  padding-top: 0.2rem;
  font-variant-numeric: tabular-nums;
}

.ep-thumb {
  position: relative;
  width: 18vw;
  max-width: 240px;
  min-width: 100px;
  aspect-ratio: 16/9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #080808;
  flex-shrink: 0;
  transition: box-shadow 0.25s ease;
}

.ep:hover .ep-thumb {
  box-shadow: 0 0 0 2px var(--accent);
}

/* duration badge placed on thumbnail */
.ep-dur {
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 0.08rem 0.4rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  pointer-events: none;
}

.ep-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.ep:hover .ep-thumb img {
  transform: scale(1.06);
}

.ep-play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  color: white;
  transition: opacity 0.2s ease;
}
.ep-play-overlay svg {
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
}
.ep:hover .ep-play-overlay {
  opacity: 1;
}

.ep-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  padding-top: 0.1rem;
}

.ep .ep-t {
  font-weight: 600;
  font-size: 1rem;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}

.ep-plot {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.5rem;
}

.ep-actions {
  display: flex;
  gap: 0.4rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.ep:hover .ep-actions,
.ep:focus-within .ep-actions {
  opacity: 1;
}
.ep-actions .btn.sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  gap: 0.3rem;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.btn-icon:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}
.btn-icon:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-icon[title="VLC"]:hover {
  color: #f47d31;
}
.btn-icon[title="VLC"]:focus-visible {
  outline-color: #f47d31;
}
.ep-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  flex-shrink: 0;
  margin-left: 0.75rem;
  padding-top: 0.1rem;
}
.ep-meta-dur,
.ep-meta-ext {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ep-meta-ext {
  text-transform: uppercase;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-sm);
}

.epg {
  margin: 2.5rem 0;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}

.epg .now {
  color: white;
  font-weight: 600;
  font-size: 1.15rem;
  margin-bottom: 0.6rem;
}

.epg .next {
  color: var(--muted);
  font-size: 1rem;
}

.lm-container {
  position: absolute;
  inset: 0;
  z-index: 50; /* same plane as #player-video (controls are at 63) */
  background: #000;
}
.lm-container canvas,
.lm-container video {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}

/* ---------- VLC help (protocol not registered) ---------- */
.vlc-help {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.8);
}
.vlc-help-card {
  width: 100%;
  max-width: 520px;
  padding: 2rem;
  border-radius: var(--radius-lg);
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
}
.vlc-help-card h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.vlc-help-card h2::before {
  content: "";
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #000;
  border-radius: 50%;
  box-shadow: inset 0 0 0 5px rgba(0,0,0,0.12);
}
.vlc-help-card p, .vlc-help-card li {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}
.vlc-help-card ol {
  margin: 0.8rem 0 1.2rem 1.1rem;
  display: grid;
  gap: 0.5rem;
}
.vlc-help-card b { color: var(--text-bright); }
.vlc-help-card code {
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-hover);
  font-size: 0.85em;
}
.vlc-help-url {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text-bright);
  font-size: 0.8rem;
  font-family: ui-monospace, monospace;
}
.vlc-help-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

/* ---------- Player: quality selector (provider variants) ---------- */
.pc-quality { position: relative; display: flex; align-items: center; gap: 0.5rem; }
.pc-qbtn {
  /* pill, not 44px .pc-btn circle: label ("Standard") was clipped */
  width: auto;
  min-width: 0;
  padding: 0 0.9rem;
  height: 40px;
  border-radius: var(--radius-full) !important;
  border: 1px solid rgba(255, 255, 255, 0.25);
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.pq-menu {
  position: absolute;
  bottom: calc(100% + 0.6rem);
  right: 0;
  z-index: 64;
  min-width: 230px;
  max-height: 260px;
  overflow-y: auto;
  padding: 0.35rem;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.96);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

/* Mobile: prevent menu from overflowing screen (#97) */
@media (max-width: 480px) {
  .pq-menu {
    min-width: 180px;
    max-width: calc(100vw - 2rem);
    right: 0.5rem;
    bottom: calc(100% + 0.4rem);
    max-height: 50vh;
  }
}

/* Player overlay override: video fullscreen MUST NOT scroll (unlike detail/category) */
#player,
.overlay.player {
  overflow: hidden !important;
  overflow-y: hidden !important;
  overflow-x: hidden !important;
  overscroll-behavior: none !important;
}

/* #189: synopsis long pliable (clic pour déplier/replier) */
.plot.clampable {
  cursor: pointer;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  position: relative;
}
.plot.clampable.clamped { -webkit-line-clamp: unset; }

/* #226: synopsis épisodes pliable (même pattern #189, 2 lignes) */
.ep-plot.clampable {
  cursor: pointer;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ep-plot.clampable.clamped { -webkit-line-clamp: unset; }

/* ---------- TMDB (#225/#227): cast rail, trailer, similaires ---------- */
.trailer-btn { background: var(--surface); color: var(--text); border: 1px solid var(--glass-border); }
.trailer-modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  display: flex; align-items: center; justify-content: center;
}
.trailer-modal iframe { width: min(960px, 92vw); aspect-ratio: 16/9; border: 0; border-radius: var(--radius-md); background: #000; }
.trailer-modal .close { position: absolute; top: 1rem; right: 1rem; }

.tmdb-cast .row-scroll, .tmdb-similar .row-scroll { display: flex; overflow-x: auto; gap: 0.8rem; padding-bottom: 0.6rem; }
.cast-card { flex: 0 0 96px; text-align: center; }
.cast-head { width: 96px; height: 144px; object-fit: cover; border-radius: var(--radius-md); background: #161616; }
.cast-name { font-size: 0.75rem; font-weight: 600; color: var(--text); margin-top: 0.35rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cast-role { font-size: 0.68rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tmdb-similar .card { flex: 0 0 130px; width: 130px; }
@media (max-width: 768px) { .cast-card { flex-basis: 84px; } .cast-head { width: 84px; height: 126px; } }
