/* Page Vidéos (videos.php) : dernière vidéo, grille de cartes, fenêtre vidéo */

/* ---------- Grille : cartes étroites par 3, cartes larges sur toute la ligne ---------- */

.video-latest__heading,
.video-list__heading {
  margin-top: 0;
  margin-bottom: 1.5rem;
}

.video-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.5rem;
}

@media (min-width: 40em) {
  .video-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3rem 2.5rem;
  }
}

@media (min-width: 62em) {
  .video-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3.5rem 3rem;
  }
}

/* Moins d'espace entre la dernière vidéo et la sélection */
.video-latest-section {
  padding-bottom: 0;
}

.video-latest-section + .section {
  padding-top: 3.5rem;
}

/* Cartes larges sur toute la ligne seulement à 3 colonnes ; à 2 colonnes, cartes normales */
@media (min-width: 62em) {
  .video-card--wide {
    grid-column: 1 / -1;
  }
}

/* ---------- Carte ---------- */

.video-card {
  display: flex;
  flex-direction: column;
  margin: 0;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-line);
  overflow: hidden;
}

/* Vignette 16:9 avec bouton lecture */
.video-card__media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: var(--color-tint);
  overflow: hidden;
  flex: none;
}

.video-card__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover; /* enlève les bandes noires des vignettes YouTube */
  /* léger zoom : les bandes noires des vignettes dépassent parfois le 16:9 d'un ou deux pixels */
  transform: scale(1.025);
  transition: transform 0.4s var(--ease), opacity 0.3s var(--ease);
}

.video-card__media:hover img,
.video-card__media:focus-visible img {
  transform: scale(1.055);
  opacity: 0.9;
}

.video-card__media:focus-visible {
  outline: 2px solid var(--color-ink);
  outline-offset: -4px;
}

.video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  margin: -2rem 0 0 -2rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--color-primary);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  transition: transform 0.25s var(--ease), background 0.25s var(--ease);
}

.video-play svg {
  width: 1.6rem;
  height: 1.6rem;
  margin-left: 0.2rem;
}

.video-card__media:hover .video-play,
.video-card__media:focus-visible .video-play {
  transform: scale(1.08);
  background: #fff;
}

.video-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.5rem 1.5rem 1.35rem;
}

.video-card__title {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  line-height: 1.35;
}

.video-card__text {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  line-height: 1.6;
}

.video-card__meta {
  margin: auto 0 0;
  font-size: 0.85rem;
  color: var(--color-muted);
}

/* Cartes étroites : toutes de la même taille. Titre sur 2 lignes et description sur 5 lignes,
   coupés si besoin ; le texte entier est dans la fenêtre vidéo. */
.video-grid .video-card .video-card__title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  height: calc(2 * 1.35em);
}

.video-grid .video-card .video-card__text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
  height: calc(5 * 1.6em);
}

/* Dernière vidéo (dès 52em) et cartes larges (à 3 colonnes) : vidéo à gauche, texte à droite */
@media (min-width: 52em) {
  .video-card--latest {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    align-items: start;
  }

  .video-card--latest .video-card__body {
    padding: 2rem 2.5rem 2rem 0.5rem;
  }

  /* Vidéo en retrait dans la carte, avec de l'air autour */
  .video-card--latest .video-card__media {
    margin: 2.5rem;
  }
}

@media (min-width: 62em) {
  .video-grid .video-card--wide {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
  }

  .video-grid .video-card--wide .video-card__body {
    padding: 2rem 2.5rem 2rem 0.5rem;
  }

  .video-grid .video-card--wide .video-card__media {
    margin: 2.5rem;
  }

  .video-grid .video-card--wide .video-card__meta {
    margin-top: 0;
  }

  /* Texte entier, non coupé */
  .video-grid .video-card--wide .video-card__title,
  .video-grid .video-card--wide .video-card__text {
    display: block;
    -webkit-line-clamp: none;
    overflow: visible;
    height: auto;
  }
}

/* À 2 colonnes : dernière carte seule sur sa ligne (nombre impair) = carte large horizontale */
@media (min-width: 40em) and (max-width: 61.99em) {
  .video-grid > .video-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
  }

  .video-grid > .video-card:last-child:nth-child(odd) .video-card__body {
    padding: 1.5rem 2rem 1.5rem 0.5rem;
  }

  .video-grid > .video-card:last-child:nth-child(odd) .video-card__media {
    margin: 2rem;
  }

  .video-grid > .video-card:last-child:nth-child(odd) .video-card__meta {
    margin-top: 0;
  }

  .video-grid > .video-card:last-child:nth-child(odd) .video-card__title,
  .video-grid > .video-card:last-child:nth-child(odd) .video-card__text {
    display: block;
    -webkit-line-clamp: none;
    overflow: visible;
    height: auto;
  }
}

.video-card--latest .video-card__title {
  font-size: 1.35rem;
}

.video-card--latest .video-card__meta {
  margin: 0 0 1rem;
}

/* Description YouTube de la dernière vidéo : coupée, « Lire la suite » pour la déplier */
.video-card__text--long {
  overflow-wrap: anywhere;
}

.video-card__text--long.is-clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 8;
  overflow: hidden;
}

.video-more {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-primary);
  font: inherit;
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.video-channel {
  margin-top: 2.5rem;
}

/* ---------- Fenêtre vidéo ---------- */

.video-modal {
  width: min(60rem, 94vw);
  max-width: none;
  max-height: 92vh;
  padding: 0;
  border: 0;
  background: var(--color-surface, #fff);
  color: var(--color-ink);
  overflow: auto;
}

.video-modal::backdrop {
  background: rgba(15, 15, 20, 0.78);
}

/* Bouton fermer : en haut à droite de l'écran, hors de la vidéo */
.video-modal__close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--color-ink);
  cursor: pointer;
}

.video-modal__close svg {
  width: 1.25rem;
  height: 1.25rem;
}

.video-modal__close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.video-modal__frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}

.video-modal__frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Sans accord « Vidéos » : message sur la vignette assombrie */
.video-modal__consent {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  background: center / cover no-repeat;
  color: #fff;
  text-align: center;
}

.video-modal__consent::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
}

.video-modal__consent > * {
  position: relative;
  margin: 0;
  max-width: 30rem;
}

.video-modal__consent-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.75rem 1.5rem;
}

.video-modal__consent a {
  color: #fff;
  text-underline-offset: 0.2em;
}

.video-modal__body {
  padding: 1.5rem 1.75rem 2rem;
}

.video-modal__title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
}

.video-modal__meta {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.video-modal__text {
  font-size: 0.95rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

body.video-modal-open {
  overflow: hidden;
}
