:root {
  --bg: #0d0d0f;
  --bg-card: #17171b;
  --border: #2a2a30;
  --text: #e8e8ea;
  --muted: #8a8a92;
  --accent: #e0393e;
  --accent-hover: #ff4b50;
  --accent-glow: rgba(224, 57, 62, 0.35);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lift: 0 14px 32px rgba(0, 0, 0, 0.5);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  animation: pageFadeIn 0.35s var(--ease);
}

/* --- Header --- */

header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 16px 32px;
  background: rgba(13, 13, 15, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: box-shadow 0.3s var(--ease);
}

header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow) 50%, transparent);
}

header.scrolled { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }

header .logo {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.5px;
  color: var(--text);
  text-decoration: none;
}

header .logo-mark { flex-shrink: 0; filter: drop-shadow(0 0 6px var(--accent-glow)); }
header .logo span { color: var(--accent); transition: text-shadow 0.25s var(--ease); }
header .logo:hover span { text-shadow: 0 0 14px var(--accent-glow); }

.nav-center { justify-self: center; display: flex; align-items: center; gap: 32px; }
.nav-right { justify-self: end; display: flex; align-items: center; gap: 24px; }

.nav-center a, .nav-right a {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 6px 2px;
  transition: color 0.2s var(--ease);
}

.nav-center a::after, .nav-right a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s var(--ease);
}

.nav-center a:hover, .nav-right a:hover { color: var(--text); }
.nav-center a:hover::after, .nav-right a:hover::after { transform: scaleX(1); }

.nav-center a.active { color: var(--text); font-weight: 600; }
.nav-center a.active::after { transform: scaleX(1); }

main { max-width: 1100px; margin: 0 auto; padding: 32px; }

h1 { font-size: 1.6rem; margin-bottom: 24px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.grid.posters {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.row-scroll {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
  mask-image: linear-gradient(90deg, transparent, black 24px, black calc(100% - 24px), transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, black 24px, black calc(100% - 24px), transparent);
}

.row-scroll .card { width: 150px; flex-shrink: 0; scroll-snap-align: start; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  display: block;
  box-shadow: var(--shadow-card);
  animation: fadeInUp 0.4s var(--ease);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}

.card:hover { border-color: var(--accent); transform: translateY(-4px); box-shadow: var(--shadow-lift); }

.card:nth-child(1) { animation-delay: 0.02s; }
.card:nth-child(2) { animation-delay: 0.04s; }
.card:nth-child(3) { animation-delay: 0.06s; }
.card:nth-child(4) { animation-delay: 0.08s; }
.card:nth-child(5) { animation-delay: 0.1s; }
.card:nth-child(6) { animation-delay: 0.12s; }
.card:nth-child(7) { animation-delay: 0.14s; }
.card:nth-child(8) { animation-delay: 0.16s; }
.card:nth-child(9) { animation-delay: 0.18s; }
.card:nth-child(10) { animation-delay: 0.2s; }
.card:nth-child(11) { animation-delay: 0.22s; }
.card:nth-child(12) { animation-delay: 0.24s; }

.card .poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: #0a0a0c;
  display: block;
  transition: transform 0.35s var(--ease);
}

.card:hover .poster { transform: scale(1.06); }

.card .body { padding: 12px 14px; }

.card .title { font-weight: 600; margin-bottom: 6px; font-size: 0.92rem; line-height: 1.3; }

.card .meta { font-size: 0.78rem; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }

.card .rating { color: #f0c96b; font-weight: 600; }

/* Bouton retirer (watchlist / historique) : discret, visible au survol de la carte. */
.card-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(13, 13, 15, 0.8);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.card:hover .card-remove { opacity: 1; transform: scale(1); }
.card-remove:hover { background: var(--accent); border-color: var(--accent); }
.card-remove:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Squelettes de chargement --- */

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.skel-shimmer {
  background: linear-gradient(100deg, var(--bg-card) 30%, #26262c 50%, var(--bg-card) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.card.skeleton { pointer-events: none; animation: fadeInUp 0.3s var(--ease); }
.card.skeleton .poster { background: none; }
.card.skeleton .skel-line { height: 10px; border-radius: 4px; margin-bottom: 8px; }
.card.skeleton .skel-line:last-child { width: 40%; margin-bottom: 0; }

.empty { color: var(--muted); padding: 40px 0; text-align: center; }

.player-wrap {
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 20px;
}

video { width: 100%; display: block; max-height: 70vh; background: #000; }

.player-wrap iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  border: 0;
  background: #000;
}

/* Page Chaines : onglets categories + grille de chaines + lecteur inline. */
.channel-tabs { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }

.channel-tabs button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
}

.channel-tabs button:hover { background: var(--bg-card); box-shadow: none; color: var(--text); }
.channel-tabs button.active { background: rgba(255, 255, 255, 0.04); border-color: var(--accent); color: var(--accent); }

.channel-card {
  background: linear-gradient(160deg, var(--bg-card), #101013 120%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 118px;
  text-align: center;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
  animation: fadeInUp 0.4s var(--ease) backwards;
}

.channel-card:hover { border-color: var(--accent); transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.channel-card:hover .channel-icon { background: var(--accent-glow); transform: scale(1.08); }

.channel-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}

.channel-card .channel-title { font-weight: 600; font-size: 0.88rem; line-height: 1.3; }

.channel-player { position: sticky; top: 76px; z-index: 5; margin-bottom: 24px; }
.channel-player .player-wrap { margin-bottom: 12px; }

/* Page Matchs : cartes match (equipes/tournoi) + lecteur video natif (HLS.js, pas d'iframe). */
.live-match-card {
  background: linear-gradient(160deg, var(--bg-card), #101013 130%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
  animation: fadeInUp 0.4s var(--ease) backwards;
}

.live-match-card:hover { border-color: var(--accent); transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.live-match-card:hover .sport-badge { background: var(--accent-glow); transform: scale(1.08); }

.live-match-card .live-match-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.live-match-card .meta-left { display: flex; align-items: center; gap: 8px; }

.sport-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}

.live-match-card .sport-name { font-size: 0.75rem; color: var(--muted); font-weight: 600; }

.live-match-card .live-badge { color: var(--accent); font-weight: 700; font-size: 0.78rem; display: inline-flex; align-items: center; gap: 5px; }
.live-match-card .live-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); animation: pulseLive 1.6s ease-in-out infinite; }

@keyframes pulseLive {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent-glow); }
  50% { box-shadow: 0 0 0 5px transparent; }
}

.live-match-card .live-match-tournament { font-size: 0.76rem; color: var(--muted); margin-bottom: 10px; text-align: center; }
.live-match-card .live-match-teams { font-weight: 700; font-size: 1rem; text-align: center; line-height: 1.4; }
.live-match-card .live-match-teams .vs {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  margin: 0 8px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  vertical-align: middle;
}

.live-match-card .live-match-score {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--accent);
}
.live-match-card .live-match-clock { font-weight: 500; font-size: 0.72rem; color: var(--muted); }

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

.back-link:hover { color: var(--text); }

form.stack { display: flex; flex-direction: column; gap: 12px; max-width: 480px; }

label { font-size: 0.85rem; color: var(--muted); }

input[type="text"], input[type="password"], input[type="url"] {
  background: #0a0a0c;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s var(--ease), transform 0.1s var(--ease), box-shadow 0.2s var(--ease);
}

button:hover { background: var(--accent-hover); }
button:not(.secondary):not(:disabled):hover { box-shadow: 0 0 16px var(--accent-glow); }
button:active:not(:disabled) { transform: scale(0.97); }

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

button.secondary:hover { color: var(--text); border-color: var(--text); }

button:disabled { opacity: 0.5; cursor: not-allowed; }

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

@keyframes slideFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 0.9rem; }
.msg.error { background: #3a1418; color: #ff8a8f; border: 1px solid #5a2027; animation: shake 0.4s var(--ease); }
.msg.ok { background: #12321c; color: #7ee2a0; border: 1px solid #1e4a2c; animation: slideFadeIn 0.3s var(--ease); }

table { width: 100%; border-collapse: collapse; margin-top: 24px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
th { color: var(--muted); font-weight: 600; }

.badge { padding: 2px 8px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge.ok { background: #12321c; color: #7ee2a0; }
.badge.error { background: #3a1418; color: #ff8a8f; }
.badge.pending { background: #332a12; color: #f0c96b; }

.row-actions button { padding: 5px 10px; font-size: 0.8rem; margin-right: 6px; }

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

.avatar-opt {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.avatar-opt img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-opt:hover { border-color: var(--text); transform: scale(1.06); }
.avatar-opt.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.nav-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 6px;
  transition: box-shadow 0.2s var(--ease);
}

a:hover .nav-avatar { box-shadow: 0 0 0 2px var(--accent); }

.login-box {
  max-width: 360px;
  margin: 60px auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px;
}

/* --- Recherche centrale (accueil) --- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 70px 32px 40px;
  text-align: center;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

.hero::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: radial-gradient(ellipse 60% 60% at 50% 20%, rgba(224, 57, 62, 0.18), transparent 70%);
  animation: pulseGlow 6s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

.hero > * { position: relative; z-index: 1; }

.hero h1 {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.hero p.tagline {
  color: var(--muted);
  margin-bottom: 28px;
}

.search-box {
  max-width: 620px;
  margin: 0 auto;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 16px 20px;
  font-size: 1.05rem;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }

section.block { margin-bottom: 40px; }

section.block h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

section.block h2::before {
  content: "";
  width: 4px;
  height: 15px;
  background: var(--accent);
  flex-shrink: 0;
}

.see-all {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s var(--ease);
}

.see-all:hover { color: var(--accent); }

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

.movie-hero {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 320px;
  margin-bottom: 28px;
  display: flex;
  align-items: flex-end;
}

@keyframes kenBurns {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.movie-hero .hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  z-index: 0;
  animation: kenBurns 20s ease-in-out infinite alternate;
}

.movie-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(13, 13, 15, 0.25) 0%, rgba(13, 13, 15, 0.97) 100%);
}

.movie-hero .inner {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 24px;
  padding: 28px;
  align-items: flex-end;
  width: 100%;
}

.movie-hero .poster-lg {
  width: 140px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift);
  flex-shrink: 0;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: #0a0a0c;
}

.movie-hero .info h1 { font-size: 1.8rem; margin: 0 0 8px; }

.movie-hero .info .sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.movie-hero .info .rating { color: #f0c96b; font-weight: 700; }

.genre-tag {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.78rem;
  color: var(--muted);
}

.overview { max-width: 720px; line-height: 1.6; color: var(--text); margin-bottom: 28px; }

.cast-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.cast-item { flex-shrink: 0; width: 100px; text-align: center; }

.cast-item img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-card);
  margin-bottom: 6px;
  transition: transform 0.25s var(--ease);
}

.cast-item:hover img { transform: scale(1.08); }

.cast-item .name { font-size: 0.8rem; font-weight: 600; }
.cast-item .character { font-size: 0.75rem; color: var(--muted); }

.action-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  max-width: 480px;
  margin-bottom: 32px;
}

.action-box p { color: var(--muted); font-size: 0.9rem; margin-top: 0; }
