/* Lecteur vidéo natif plein écran (téléphone, tablette, desktop) */

.cepac-video-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
}

.cepac-video-modal--open {
  display: flex;
}

body.cepac-video-modal-open {
  overflow: hidden;
  touch-action: none;
}

.cepac-video-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  cursor: pointer;
}

.cepac-video-modal__box {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  max-width: 100vw;
  height: 100%;
  max-height: 100dvh;
  max-height: 100svh;
  margin: 0 auto;
  padding:
    max(3rem, calc(env(safe-area-inset-top, 0px) + 0.5rem))
    max(0.25rem, env(safe-area-inset-right, 0px))
    max(0.5rem, env(safe-area-inset-bottom, 0px))
    max(0.25rem, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
}

.cepac-video-modal__stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

.cepac-video-modal__close {
  position: absolute;
  top: max(0.5rem, env(safe-area-inset-top, 0px));
  right: max(0.5rem, env(safe-area-inset-right, 0px));
  z-index: 3;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cepac-video-modal__close:hover {
  background: rgba(255, 255, 255, 0.35);
}

.cepac-video-modal__player {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  min-width: 0;
  min-height: 120px;
  object-fit: contain;
  object-position: center;
  background: #000;
}

/* Mobile / tablette : vidéo la plus grande possible à l'écran */
@media (max-width: 991.98px) {
  .cepac-video-modal__box {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    height: 100svh;
    max-height: 100dvh;
    max-height: 100svh;
    padding:
      max(2.75rem, calc(env(safe-area-inset-top, 0px) + 0.35rem))
      0
      max(0.35rem, env(safe-area-inset-bottom, 0px))
      0;
  }

  .cepac-video-modal__stage {
    width: 100vw;
    max-width: 100vw;
  }

  .cepac-video-modal__player {
    width: 100vw;
    max-width: 100vw;
    height: auto;
    max-height: calc(100dvh - 3.25rem);
    max-height: calc(100svh - 3.25rem);
    object-fit: contain;
  }
}

/* Lecteur inline dans une carte (desktop uniquement en pratique) */
@media (max-width: 991.98px) {
  .publication-card__media .pub-media-video--playing,
  .pub-detail-card__media .pub-media-video--playing {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
  }

  .publication-card__media .pub-media-video__player,
  .pub-detail-card__media .pub-media-video__player {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 100% !important;
    min-height: 0 !important;
    object-fit: contain !important;
    object-position: center !important;
    background: #000;
  }
}

.pub-media-video--playing .pub-media-video__player {
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

a.pub-video-lightbox {
  cursor: pointer;
  text-decoration: none;
}

a.pub-video-lightbox .pub-media-video__thumb,
a.pub-video-lightbox .pub-media-video__poster-img {
  pointer-events: none;
}
