/* ---------------------------------------------------------------------------
   Lightbox — feuille PARTAGEE par le site public et le back-office.

   Un fichier a part plutot que le meme bloc recopie dans site-preview.css et
   portal.css : deux copies auraient fini par diverger, et on aurait corrige
   un defaut d'un seul cote.

   Reprise de celle du projet « Site wetransfer-like » (assets/css/app.css),
   sans la partie video et avec les icones Font Awesome a la place des SVG.
   --------------------------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000; /* au-dessus de la barre collante du back-office (20) et des
                    modales de la bibliotheque (1300) */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.93);
  animation: lightbox-apparition 0.15s ease;
  /* Les gestes sont geres par le script : sans ca, le navigateur zoomerait la
     PAGE au lieu de l'image. */
  touch-action: none;
}

.lightbox[hidden] { display: none; }

@keyframes lightbox-apparition {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Le fond de page ne defile plus derriere l'image agrandie. */
body.lightbox-ouverte { overflow: hidden; }

.lightbox-image {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
  transform-origin: center center;
  touch-action: none;
}

.lightbox-image.est-chargee { opacity: 1; }

.lightbox-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: lightbox-rotation 0.7s linear infinite;
}

.lightbox-loader[hidden] { display: none; }

@keyframes lightbox-rotation {
  to { transform: rotate(360deg); }
}

.lightbox-fermer,
.lightbox-ouvrir,
.lightbox-nav {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}

.lightbox-fermer[hidden],
.lightbox-ouvrir[hidden],
.lightbox-nav[hidden] { display: none; }

.lightbox-fermer:hover,
.lightbox-ouvrir:hover,
.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-fermer:focus-visible,
.lightbox-ouvrir:focus-visible,
.lightbox-nav:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.lightbox-fermer,
.lightbox-ouvrir {
  top: 16px;
  width: 40px;
  height: 40px;
  font-size: 1.05rem;
}

.lightbox-fermer { right: 16px; }
.lightbox-ouvrir { right: 64px; }

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  font-size: 1.15rem;
}

.lightbox-prec { left: 16px; }
.lightbox-suiv { right: 16px; }

.lightbox-legende {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: 80vw;
  margin: 0;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  color: #ffffff;
  font-size: 0.85rem;
  text-align: center;
}

.lightbox-legende[hidden] { display: none; }

/* Ce qui ouvre la lightbox doit se voir cliquable. La classe est posee par le
   script : une image d'article devient cliquable sans qu'on ait touche au
   HTML enregistre. */
.lightbox-declencheur { cursor: zoom-in; }

.lightbox-declencheur:focus-visible {
  outline: 2px solid var(--color-primary, var(--preview-primary, #4f46e5));
  outline-offset: 2px;
}

@media (max-width: 640px) {
  /* Les commandes descendent en bas, la ou le pouce les atteint, et cessent
     de recouvrir l'image sur un ecran etroit. */
  .lightbox-nav {
    top: auto;
    bottom: 16px;
    transform: none;
    width: 44px;
    height: 44px;
  }

  .lightbox-prec { left: 20px; }
  .lightbox-suiv { right: 20px; }

  .lightbox-legende {
    bottom: 74px;
    font-size: 0.8rem;
  }

  .lightbox-image { max-height: 78vh; }
}
