/* =====================================================================
   Page de détail (film / série)
   ===================================================================== */
.detail { position: relative; isolation: isolate; min-height: calc(100vh / var(--ui)); }

.detail__backdrop {
  position: absolute;
  inset: 0 0 auto 0;
  /* Au moins l'écran, et au moins du 16:9 (les fonds le sont) : sur un écran large, l'image
     entière, sans haut coupé, qui descend derrière la distribution */
  height: min(max(calc(100vh / var(--ui)), calc(100vw / var(--ui) * 9 / 16)), 1600px);
  z-index: -1;
  overflow: hidden;
  -webkit-mask-image: var(--fade-down);
  mask-image: var(--fade-down);
}
.detail__img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 20%;
  opacity: 0;
  transition: opacity 800ms var(--ease);
}
.detail__img.is-loaded { opacity: 1; }
/* Titre sans fond : son affiche entière, à droite, entre la barre du haut et le bas de l'en-tête,
   sur le fond ambiant flouté */
.detail__img.is-poster {
  display: block;
  margin-top: calc(var(--nav-h) + 20px);
  height: calc(min(calc(92vh / var(--ui)), 1000px) - var(--nav-h) - 40px);
  object-fit: contain;
  object-position: 88% 0;
}
/* Écran peu large (4:3…) : le texte passe sur l'affiche, assombrie pour rester lisible */
@media (max-aspect-ratio: 3/2) and (min-width: 621px) { .detail__img.is-poster { filter: brightness(.42); } }
.detail__backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .82) 0%, rgba(0, 0, 0, .5) 38%, rgba(0, 0, 0, 0) 72%),
    linear-gradient(0deg, rgba(0, 0, 0, .45) 0%, rgba(0, 0, 0, 0) 40%);
}

/* Tout l'écran à l'arrivée : l'affiche, le titre, le résumé et les boutons ; la suite (distribution,
   épisodes, avis) commence en dessous, après un défilement. svh : sans les barres du navigateur (téléphone). */
.detail__hero {
  min-height: calc(100vh / var(--ui));
  min-height: calc(100svh / var(--ui));
  display: flex;
  align-items: flex-end;
  padding: calc(var(--nav-h) + 40px) var(--gutter) clamp(40px, calc(9vh / var(--ui)), 110px);
}
.detail__main { display: grid; justify-items: start; gap: 18px; max-width: min(920px, 100%); }
.detail__logo {
  max-width: min(520px, calc(84vw / var(--ui)));
  max-height: clamp(90px, calc(18vh / var(--ui)), 190px);
  width: auto;
  object-fit: contain;
  object-position: left bottom;
  filter: drop-shadow(0 6px 30px rgba(0, 0, 0, .55));
}
/* Logo attendu (TMDB) : sa place est gardée, rien ne saute à son arrivée */
.detail__logo--wait { height: clamp(90px, calc(18vh / var(--ui)), 190px); width: min(420px, 60%); }
.detail__title { font-size: var(--fs-display); }
.detail__kicker { display: inline-flex; align-self: start; padding: 5px 12px; border-radius: var(--r-pill); background: var(--label); color: var(--on-focus); font-size: var(--fs-body); font-weight: 700; }
.detail__about { display: grid; justify-items: start; gap: 6px; }
/* Résumé sur 3 lignes ; « Plus » (ou un clic dessus) le déplie */
.detail__desc {
  max-width: 60ch;
  color: var(--label-2);
  font-size: var(--fs-callout);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.detail__desc.is-open { display: block; -webkit-line-clamp: unset; line-clamp: none; overflow: visible; }
.detail__desc.is-clamped { cursor: pointer; }
.detail__more { padding: 2px 0; border-radius: 6px; color: var(--label); font-size: var(--fs-body); font-weight: 600; }
.detail__more[hidden] { display: none; }
@media (hover: hover) {
  .detail__desc.is-clamped:hover { color: var(--label); }
  .detail__more:hover { text-decoration: underline; text-underline-offset: 3px; }
}
.detail__resume { color: var(--label-2); font-size: var(--fs-body); display: flex; align-items: center; gap: 12px; }
.detail__resume .card__progress { width: 140px; }

/* Bouton principal : affiche ce qui va se passer (Reprendre S2, É4…) */
.btn__stack { display: grid; text-align: left; line-height: 1.15; }
.btn__stack small { font-size: var(--fs-caption); font-weight: 500; opacity: .66; }

/* Bouton « 4/5 » quand le titre est noté */
.btn--rated .ico { color: var(--warn); }
.is-kb .btn--rated:focus .ico { color: inherit; }

/* ---- Sections sous les informations : avis des membres, À voir ensuite ---- */
.detail-section { display: grid; gap: 16px; padding: 0 var(--gutter); margin-top: clamp(40px, calc(6vw / var(--ui)), 72px); max-width: 1400px; }
.detail-section--rows { padding: 0; max-width: none; gap: 0; }
.detail-section--rows > .row:first-of-type { margin-top: 10px; }
.detail-section__head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.detail-section__head .btn { margin-left: auto; }
.detail-section__title { font-size: var(--fs-title2); font-weight: 700; letter-spacing: -.01em; }
.detail-section__title--padded { padding: 0 var(--gutter); }
.detail-section__score { display: inline-flex; align-items: center; gap: 8px; color: var(--label-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.detail-section__empty { color: var(--label-2); }

/* ---- Épisodes ---- */
.episodes { margin-top: 8px; }
.episodes__head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 0 var(--gutter); }
.episodes__title { font-size: var(--fs-title3); font-weight: 600; }
.episodes__seasons { flex: 1; min-width: 0; }
.episodes__seasons .chips { margin: 0; padding: 8px 0 12px; }
.episodes__actions:empty { display: none; }

/* Épisode + « Marquer vu » dessous */
.ep-item { flex: none; display: grid; justify-items: start; gap: 4px; width: var(--wide-w); }
.ep-seen {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 6px 12px 6px 9px;
  border-radius: var(--r-pill);
  color: var(--label-3);
  font-size: var(--fs-caption);
  font-weight: 600;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease);
}
.ep-seen .ico { width: 16px; height: 16px; }
.ep-seen.is-on { color: var(--ok); }
@media (hover: hover) { .ep-seen:hover { background: var(--fill); color: var(--label); } }
.is-kb .ep-seen:focus { outline: none; background: var(--focus); color: var(--on-focus); transform: scale(1.06); }

.ep-desc {
  margin-top: 6px;
  font-size: var(--fs-caption);
  color: var(--label-3);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  transition: transform var(--t-med) var(--ease);
}
.is-kb .card:focus .ep-desc { transform: translateY(12px); }
@media (hover: hover) { html:not(.is-kb) .card:hover .ep-desc { transform: translateY(12px); } }
.ep-num { color: var(--label-3); font-weight: 600; margin-right: 6px; font-variant-numeric: tabular-nums; }
.ep-date { position: absolute; top: 10px; left: 10px; }

/* ---- Distribution et détails : fermé par défaut, un bouton l'ouvre ---- */
.details { margin-top: clamp(32px, calc(5vw / var(--ui)), 64px); }
.details__toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 var(--gutter);
  padding: 12px 20px;
  border-radius: var(--r-pill);
  background: var(--fill);
  color: var(--label);
  font-size: var(--fs-callout);
  font-weight: 600;
  transition: background var(--t-fast), transform var(--t-fast) var(--ease);
}
.details__toggle .ico { width: 18px; height: 18px; transform: rotate(90deg); transition: transform var(--t-med) var(--ease); }
.details__toggle[aria-expanded="true"] .ico { transform: rotate(-90deg); }
@media (hover: hover) { .details__toggle:hover { background: var(--fill-2); } }
.is-kb .details__toggle:focus { outline: none; background: var(--focus); color: var(--on-focus); }
.details__panel { padding-top: 8px; animation: details-in var(--t-med) var(--ease); }
@keyframes details-in { from { opacity: 0; transform: translateY(-8px); } }
.details__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: 24px 40px; align-items: start; padding-right: var(--gutter); }
.details__cast { min-width: 0; }
.details__cast .row { margin-top: 18px; }
/* Même taille pour chaque personne, quelle que soit la longueur de son nom */
.details__cast .person-card { flex: none; width: clamp(112px, calc(9vw / var(--ui)), 150px); }
.details__cast .person-card__photo { width: 100%; }
.details__cast .person-card__name { overflow-wrap: anywhere; }
/* « +12 · Toute la distribution » : même taille qu'une photo */
.person-card--more { color: var(--label); }
.person-card__photo.person-card__photo--more { background: var(--fill-2); font-size: 1.5rem; font-weight: 700; }
.details__crews { display: grid; gap: 8px; padding: 18px var(--gutter) 0; color: var(--label-2); font-size: var(--fs-body); }
.details__crew-title { color: var(--label-3); margin-right: 8px; }
.details__info { display: grid; gap: 18px; justify-items: center; margin-top: 18px; }
.details__card { width: 100%; margin: 0; border-radius: var(--r-panel); background: var(--material-thick); border: 1px solid var(--separator); overflow: hidden; }
.details__row { display: flex; justify-content: space-between; align-items: baseline; gap: 18px; width: 100%; padding: 13px 18px; border-top: 1px solid var(--separator); font-size: var(--fs-body); text-align: left; }
.details__row:first-child { border-top: 0; }
.details__row dt { color: var(--label-3); flex-shrink: 0; }
.details__row dd { margin: 0; color: var(--label); text-align: right; }
.details__row--link { color: var(--label); font-weight: 600; }
.details__row--link dt { display: inline-flex; align-items: center; gap: 10px; color: var(--label); }
.details__row--link .ico { width: 18px; height: 18px; }
@media (hover: hover) { .details__row--link:hover { background: var(--fill); } }
.is-kb .details__row--link:focus { outline: none; background: var(--focus); color: var(--on-focus); }
.is-kb .details__row--link:focus dt { color: inherit; }
.details__studios { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }
.details__studios { align-items: center; }
.details__studio-link { display: block; border-radius: 10px; transition: transform var(--t-fast) var(--ease); }
@media (hover: hover) { .details__studio-link:hover { transform: scale(1.05); } }
/* Logos dans leurs couleurs, sur une pastille claire : texte noir (Columbia) comme blanc sur rouge (Marvel) restent lisibles */
.details__studio { box-sizing: content-box; max-width: 120px; max-height: 34px; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, .92); object-fit: contain; }

/* Noms cliquables → page de la personne */
.person-link { color: var(--label); border-radius: 4px; text-decoration: underline; text-decoration-color: var(--fill-3); text-underline-offset: 3px; transition: text-decoration-color var(--t-fast); }
@media (hover: hover) { .person-link:hover { text-decoration-color: currentColor; } }
.is-kb .person-link:focus { outline: none; background: var(--focus); color: var(--on-focus); text-decoration: none; box-shadow: 0 0 0 4px var(--focus); }

/* ---- Page d'une personne ---- */
.person__head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; gap: clamp(20px, calc(3vw / var(--ui)), 40px); padding: 0 var(--gutter); }
.person__photo { width: clamp(120px, calc(16vw / var(--ui)), 210px); aspect-ratio: 3 / 4; border-radius: 22px; object-fit: cover; object-position: 50% 20%; background: var(--fill-2); box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .9); }
.person__photo--empty { display: grid; place-items: center; color: var(--label-3); font-size: clamp(2rem, calc(4vw / var(--ui)), 3.4rem); font-weight: 700; }
.person__id { display: grid; gap: 8px; min-width: 0; padding-bottom: 6px; }
.person__name { font-size: var(--fs-display); line-height: 1; overflow-wrap: anywhere; }
.person__desc { color: var(--label); font-size: var(--fs-callout); font-weight: 500; }
.person__fact { color: var(--label-2); }
.person__id .actions { margin-top: 8px; }
.person__bio { display: grid; gap: 10px; justify-items: start; max-width: 80ch; padding: 0 var(--gutter); margin-top: clamp(24px, calc(3vw / var(--ui)), 36px); }
.person__bio:empty { display: none; }
.person__bio-text { color: var(--label-2); font-size: var(--fs-callout); line-height: 1.6; }
.person__bio-text.is-clamped { display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.person__credits { padding-bottom: 40px; }
@media (max-width: 620px) {
  .person__head { grid-template-columns: 1fr; align-items: start; }
}

@media (max-width: 620px) {
  .detail__hero { padding-bottom: 36px; }
  .detail__img.is-poster { margin-top: 0; height: 100%; }
  .detail__desc { font-size: var(--fs-body); }
}

/* ---- Actions : « Lecture », puis des pastilles rondes légendées ---- */
.detail__actions { align-items: flex-start; gap: 14px 22px; }
.detail__acts { display: flex; flex-wrap: wrap; gap: 6px 4px; }
.act {
  display: inline-grid;
  justify-items: center;
  align-content: start;
  gap: 7px;
  width: 78px;
  color: var(--label);
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.act__circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--fill-2);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  backdrop-filter: blur(20px) saturate(1.6);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease);
}
.act__circle .ico { width: 24px; height: 24px; }
.act__label { font-size: var(--fs-caption); font-weight: 600; line-height: 1.2; color: var(--label-2); }
.act.is-on .act__circle { background: var(--label); color: var(--on-focus); }
.act--rated .act__circle .ico { color: var(--warn); }
.act--live .act__circle { background: var(--live); color: #1b0610; }
@media (hover: hover) {
  .act:hover .act__circle { background: var(--fill-3); }
  .act.is-on:hover .act__circle { background: #fff; }
  .act--live:hover .act__circle { background: #ff86a0; }
  .act:hover .act__label { color: var(--label); }
}
.is-kb .act:focus { outline: none; }
.is-kb .act:focus .act__circle { background: var(--focus); color: var(--on-focus); transform: scale(1.12); }
.is-kb .act:focus .act__label { color: var(--label); }
.is-kb .act--rated:focus .act__circle .ico { color: inherit; }
/* Téléphone : « Lecture » sur toute la largeur, les pastilles en une ligne dessous */
@media (max-width: 620px) {
  .detail__actions { gap: 18px; }
  .detail__actions > .btn--primary { width: 100%; }
  .detail__acts { width: 100%; justify-content: space-between; gap: 10px 0; }
  .act { width: 54px; }
  .act__circle { width: 46px; height: 46px; }
  .act__circle .ico { width: 22px; height: 22px; }
  .act__label { font-size: 11px; }
}

/* ---- Téléphone : épisodes en liste (vignette à gauche, texte à droite), informations sur deux colonnes ---- */
@media (max-width: 620px) {
  .episodes .row__track { flex-direction: column; gap: 20px; overflow: visible; padding-top: 14px; padding-bottom: 8px; margin-bottom: 0; }
  .episodes .row__track > .ep-item,
  .episodes .row__track > .card--wide { width: 100%; }
  .episodes .card--wide { display: grid; grid-template-columns: 44% minmax(0, 1fr); grid-template-rows: auto auto 1fr; column-gap: 12px; align-items: start; }
  .episodes .card--wide .card__media { grid-row: 1 / span 3; }
  .episodes .card--wide .card__label { margin-top: 0; white-space: normal; }
  .episodes .ep-desc { -webkit-line-clamp: 3; margin-top: 4px; }
  .episodes .ep-item { justify-items: stretch; }
  .episodes .ep-seen { justify-self: end; margin-top: 2px; }
  .details__grid { grid-template-columns: minmax(0, 1fr); padding-right: 0; }
  .details__info { padding: 0 var(--gutter); }
}

/* Pas encore sorti : la date de sortie, sous les infos du titre */
.detail__soon { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; width: fit-content; padding: 9px 16px; border-radius: var(--r-pill); border: 1px solid var(--separator); background: rgba(0, 0, 0, .35); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); color: var(--label-2); }
.detail__soon .ico { width: 18px; height: 18px; }
.detail__soon b { color: var(--label); font-weight: 600; }
.detail__soon b + span::before { content: "·"; margin-right: 10px; color: var(--label-3); }
