/* Favorites grouped by type: channels in wider columns (landscape logo 16/10) */
.fav-sec { margin-bottom: 2.5rem; }
.fav-sec h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 1.1rem;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}
.fav-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.1rem 0.55rem;
  border-radius: var(--radius-full);
}
/* channels: SAME column width as movies/series (inherited standard grid),
   just a landscape poster. A wider dedicated minmax made them too large
   (270px vs 170px in Live tab) -- inconsistent. */

/* Clickable row title ("See all") */
.row-head {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  max-width: 100%; /* so title truncates instead of wrapping + misaligning "See all" */
  min-height: 44px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
}
/* Title on ONE line, truncated if too long -> "See all" stays aligned (no more ugly mobile wrap) */
.row-head h2 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}
.row-head .see-all {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-hover);
  opacity: 0.75;
  transform: translateX(-4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
  line-height: 1.4;
}
.row-head:hover .see-all { opacity: 1; transform: translateX(0); }

/* "See all" view of a category */
.cat-head {
  padding: 1rem 3rem 1.5rem;
  padding-top: max(4.5rem, calc(env(safe-area-inset-top) + 3.5rem));
  max-width: 1760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.cat-head .cat-back { flex: 0 0 auto; }
.cat-head h1 {
  font-family: 'Bricolage Grotesque', 'Outfit', sans-serif;
  font-size: clamp(1.8rem, 3.5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-bright);
  margin: 0;
}
.cat-count { color: var(--muted); font-size: 0.95rem; }

.cat-grid {
  max-width: 1760px;
  margin: 0 auto;
  padding: 0 3.4rem 6rem 3rem; /* space on right for A-Z index */
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 28px 24px;
}
.az-anchor { scroll-margin-top: 5.5rem; }

/* Bandeau de lettre sticky façon template (A–Z) : lettre Bricolage 44px
   violette glowée + compteur + trait dégradé, sans fond. */
.az-letter {
  grid-column: 1 / -1;
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 18px;
  padding: 8px 0 0;
}
.az-letter-ch {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 44px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #cbbcff;
  text-shadow: 0 0 28px rgba(167, 139, 250, 0.5);
}
.az-letter-count { font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: #aea9b8; }
.az-letter::after {
  content: "";
  flex: 1 1 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(167, 139, 250, 0.55), rgba(167, 139, 250, 0));
  box-shadow: 0 0 14px rgba(167, 139, 250, 0.35);
}

/* Index alphabétique flottant à droite, façon template : conteneur glass. */
.az-scrub {
  position: fixed;
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  border-radius: 26px;
  background: rgba(22, 18, 32, 0.78);
  touch-action: none;
}
.az-scrub .az {
  background: none;
  border: none;
  color: #d8d4de;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  width: 44px;
  height: 22px;
  padding: 0;
  cursor: pointer;
  border-radius: 8px;
  touch-action: none;
  transition: color 0.15s ease, background 0.15s ease;
}
.az-scrub .az:hover, .az-scrub .az:active, .az-scrub .az.cur {
  color: #14101f;
  background: linear-gradient(180deg, #bba8ff, #a78bfa);
}
/* Lettre active : disque violet (template) */
.az-scrub .az.cur {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 500;
  transform: none;
  box-shadow: 0 6px 14px -4px rgba(167, 139, 250, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
/* .off remains draggable: scrub jumps to next available letter.
   pointer-events:none broke finger drag (elementFromPoint missed the letter). */
.az-scrub .az.off { color: rgba(255, 255, 255, 0.35); }

/* Android/Jellyfin binder bubble: large letter during drag. */
.az-bubble {
  position: fixed;
  right: 3.4rem;
  z-index: 51;
  transform: translateY(-50%) scale(0.6);
  width: 68px;
  height: 68px;
  border-radius: 50% 50% 12px 50%; /* droplet pointing to bar on right */
  background: var(--accent);
  color: #000;
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.az-bubble.show { opacity: 1; transform: translateY(-50%) scale(1); }

/* Mobile: tall column, spaced and widened letters -> reliable thumb drag (iOS style). */
@media (max-width: 768px) {
  .az-scrub {
    top: 4rem;
    bottom: 1.5rem;
    transform: none;
    justify-content: space-between;
    padding: 0.5rem 0.4rem 0.5rem 1rem;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.55), transparent);
    border-radius: var(--radius-md) 0 0 var(--radius-md);
  }
  .az-scrub .az {
    width: 30px;
    height: auto;
    flex: 1 0 auto;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .cat-head { padding: 1rem 1rem 1.25rem; }
  .cat-grid.grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 8px; padding: 0 10px 4rem 10px; }
  .cat-grid .card { flex: none; width: 100%; }
  .az-letter { margin: 0 0 10px; padding: 6px 0 0; gap: 10px; }
  .az-letter-ch { font-size: 26px; }
  .az-letter-count { font-size: 10.5px; }
}

/* Media Cards */
.card {
  flex: 0 0 170px;
  width: 170px;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-md);
}

.grid .card {
  width: auto;
}

.card .poster {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: var(--radius-md);
  background-color: #1a1a1a;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.card .poster-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.75rem;
  background-color: #0a0a0a;
}

.card.live .poster {
  aspect-ratio: 16/10;
}

/* ---------- Live channel grid ---------- */
.grid-live {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.grid-live .card {
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  transition: var(--transition);
}
.grid-live .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

/* Logo fallback: initiales sur fond violet */
.poster-fallback img {
  position: relative;
  z-index: 2;
}
.logo-fallback {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6d28d9 0%, #a785f2 100%);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  user-select: none;
}

/* EPG overlay enrichi */
.card-epg-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 0.6rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 2;
}
.card-epg-now {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-epg-next {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card.live .poster { position: relative; }

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

.card:hover .poster {
  transform: scale(1.03);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}

/* Allow scaled poster to overflow on hover (fix invisible bar at top) */
.card:hover { overflow: visible; z-index: 10; }

.card:active .poster {
  transform: translateY(-4px) scale(0.97);
}

.card:hover img,
.card:active img {
  transform: scale(1.02);
}

/* Play Overlay on Hover */
.card .poster::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.04) 0%, transparent 80%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.8) 0%, transparent 60%);
  opacity: 0;
  transition: var(--transition);
}

.card .title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 0.85rem;
  color: #ddd;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 0.1rem;
}

.card, .card img, .card .card-overlay {
  transition: transform 220ms ease, opacity 220ms ease, color 220ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .card:hover {
    transform: scale(1.045);
    z-index: 4;
  }
}

@media (hover: hover) {
  .card:hover .title { color: var(--text-bright); }
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 8rem 1rem;
  font-size: 1.2rem;
}

/* Clean empty state (favorites, etc.) */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.8rem;
  padding: 6rem 1.5rem;
  max-width: 420px;
  margin: 0 auto;
}

.empty-icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent-hover);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.6rem;
}

.empty-state h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-bright);
}

.empty-state p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.empty-state .btn {
  margin-top: 1rem;
}



/* EPG "en ce moment" sous les cartes live */
.epg-line {
  min-height: 1.1rem;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 0.1rem;
}

.epg-line.on::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef4444;
  margin-right: 6px;
  vertical-align: middle;
}

/* "Resume" row -- landscape 16:9 thumbnails Netflix/Prime style */
.card.resume {
  width: 280px;
}

/* #235: badge "vu" + barre de progression (inspi IPTVnator) */
.watched-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  min-width: 24px;
  height: 24px;
  padding-inline: 5px;
  background: rgba(70, 211, 105, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  z-index: 2;
  pointer-events: none;
}

.card-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.18);
  z-index: 2;
  pointer-events: none;
}

.card-progress-fill {
  height: 100%;
  background: #e50914;
}

.card.resume .poster {
  aspect-ratio: 16/9;
}

/* progress bar overlaid at BOTTOM of thumbnail (Netflix style) */
.card.resume .resume-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  z-index: 3;
}

.resume-bar {
  height: 4px;
  margin-top: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.resume-bar-fill {
  height: 100%;
  background: var(--grad);
  border-radius: var(--radius-full);
}

.resume-x {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  /* #audit-prod: 32 -> 24 -> 20px. La croix XXX restait un gros visuel
     gris au centre de la vignette mobile; 20px en coin discret + fin. */
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
}
.resume-x svg { width: 10px; height: 10px; }

.card.resume:hover .resume-x {
  opacity: 1;
}

.resume-x:hover {
  color: white;
  background: rgba(239, 68, 68, 0.35);
}

@media (hover: none) {
  .resume-x {
    opacity: 1; /* mobile: pas de hover, toujours visible */
    /* 36px = pastille trop présente sur vignette 240px ; 26px discret mais tactile */
    width: 26px;
    height: 26px;
    background: rgba(0, 0, 0, 0.5);
  }
}

/* ---------- #184: overlay actions au survol (Info / Play / Favori) ---------- */
/* Desktop only: au tactile pas de hover — le détail (tap sur la card) garde
   Play/Favori, l'overlay serait inaccessible. */
.card .card-overlay {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(to top, rgba(0,0,0,.6), rgba(0,0,0,.08) 45%, rgba(0,0,0,.35));
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}
.card:hover .card-overlay,
.card:focus-within .card-overlay {
  opacity: 1;
  pointer-events: auto;
}
.ov-btn {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.ov-btn:hover { transform: scale(1.12); background: rgba(229, 9, 20, 0.9); }
.ov-info { top: 8px; left: 8px; }
.ov-fav { top: 8px; right: 8px; }
.ov-fav.on { color: #f87171; }
.ov-fav.on svg { fill: currentColor; }
.ov-play {
  position: static;
  width: 48px;
  height: 48px;
  background: rgba(229, 9, 20, 0.92);
  border-color: transparent;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}
/* bouton favori réutilisé dans l'overlay: neutralise le style .btn pleine taille */
.card-overlay .btn.fav { position: absolute; top: 8px; right: 8px; padding: 0.5rem; min-width: 34px; min-height: 34px; background: rgba(0,0,0,.65); border: 1px solid rgba(255,255,255,.25); }
.card-overlay .btn.fav.on { color: #f87171; background: rgba(0,0,0,.65); }
@media (hover: none) {
  /* même spécificité que la règle de base (.card .card-overlay),
     sinon display:flex gagne et des boutons invisibles restent tactiles */
  .card .card-overlay { display: none; }
}
/* ---------- #191: flèches de défilement des rails — supprimées (demande UI) ----------
   swipe + fondu suffisent ; fonction addRailArrows retirée de app.min.js */
.row { position: relative; }
/* note sous le titre (année · ★) — pas de bouton info sur le poster */
.card .card-meta {
  margin: 0.15rem 0.15rem 0;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Historique: rail limité à 12, Voir tout -> grille complète */
#history-row:not(.expanded) .row-scroll .card:nth-child(n+13) { display: none; }
#history-row.expanded .row-scroll {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  overflow: visible;
  mask-image: none;
  -webkit-mask-image: none;
}
#history-row.expanded .card { width: auto; }
