/* =========================================================================
 * Galerie & visionneuse — composant partagé entre le site vitrine et
 * l'administration v2. Sans dépendance : classes préfixées « glb- » pour la
 * visionneuse (lightbox) et « galerie- » pour les vignettes, afin de ne
 * jamais entrer en conflit avec Tailwind ni avec les styles des pages.
 * ========================================================================= */

/* ---------------------------------------------------------- vignettes ---- */

/* Tuile à ratio fixe : réserve la place avant chargement, donc plus aucun
   saut de mise en page quand les images arrivent. */
.galerie-tuile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 0;
  margin: 0;
  padding: 0;
  border-radius: .6rem;
  background: #ece9ec;
  cursor: zoom-in;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}

/* Fondu de squelette tant que l'image n'est pas chargée. */
.galerie-tuile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, #ece9ec 30%, #f6f2f5 50%, #ece9ec 70%);
  background-size: 200% 100%;
  animation: galerie-shimmer 1.3s ease-in-out infinite;
}
.galerie-tuile.charge::before { display: none; }

@keyframes galerie-shimmer {
  0%   { background-position: 180% 0; }
  100% { background-position: -80% 0; }
}

.galerie-tuile img,
.galerie-tuile video {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: transform .45s ease, opacity .4s ease;
}
.galerie-tuile.charge img,
.galerie-tuile.charge video { opacity: 1; }

.galerie-tuile:hover img,
.galerie-tuile:hover video,
.galerie-tuile:focus-visible img,
.galerie-tuile:focus-visible video { transform: scale(1.06); }

.galerie-tuile:focus-visible {
  outline: 3px solid #fb7185;
  outline-offset: 2px;
}

/* Pastille ▶ sur les vignettes vidéo. */
.galerie-pastille-video {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.galerie-pastille-video::after {
  content: "";
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 9999px;
  background: rgba(15, 23, 42, .55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E") center / 1.5rem no-repeat;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
  transition: transform .2s ease, background-color .2s ease;
}
.galerie-tuile:hover .galerie-pastille-video::after { transform: scale(1.1); background-color: rgba(225, 29, 72, .85); }

/* ------------------------------------------------------- visionneuse ---- */

.glb-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 18, .92);
  opacity: 0;
  transition: opacity .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.glb-overlay.actif { display: flex; opacity: 1; }

body.glb-ouvert { overflow: hidden; }

.glb-scene {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(.5rem, 3vw, 3rem);
  box-sizing: border-box;
}

.glb-img,
.glb-video {
  max-width: 100%;
  max-height: 88vh;
  border-radius: .4rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
  background: #0b0d14;
  animation: glb-apparition .25s ease;
}
.glb-img { object-fit: contain; cursor: zoom-in; user-select: none; }
.glb-img.glb-zoom { transform: scale(2.4); cursor: zoom-out; max-height: 88vh; }
.glb-video { width: auto; height: auto; }

@keyframes glb-apparition {
  from { opacity: 0; transform: scale(.97); }
  to   { opacity: 1; transform: scale(1); }
}

.glb-spinner {
  position: absolute;
  width: 2.75rem;
  height: 2.75rem;
  border: 3px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  border-radius: 9999px;
  display: none;
}
.glb-spinner.actif { display: block; animation: glb-rotation .8s linear infinite; }
@keyframes glb-rotation { to { transform: rotate(360deg); } }

.glb-fermer,
.glb-nav {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255, 255, 255, .12);
  border: 0;
  border-radius: 9999px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background-color .15s ease, transform .15s ease;
}
.glb-fermer:hover,
.glb-nav:hover { background: rgba(255, 255, 255, .28); }
.glb-fermer:focus-visible,
.glb-nav:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.glb-fermer {
  top: max(.75rem, env(safe-area-inset-top));
  right: max(.75rem, env(safe-area-inset-right));
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.9rem;
  line-height: 1;
}

.glb-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 3rem;
  height: 3rem;
  font-size: 2rem;
  line-height: 1;
  padding-bottom: .2rem;
}
.glb-nav:hover { transform: translateY(-50%) scale(1.08); }
.glb-prec { left: clamp(.5rem, 2vw, 1.5rem); }
.glb-suiv { right: clamp(.5rem, 2vw, 1.5rem); }

.glb-barre {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(.5rem, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0 1rem;
  color: rgba(255, 255, 255, .85);
  font-size: .8rem;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}
.glb-legende { max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.glb-compteur { font-variant-numeric: tabular-nums; font-weight: 600; }

@media (max-width: 640px) {
  .glb-nav { width: 2.5rem; height: 2.5rem; font-size: 1.6rem; }
  .glb-legende { max-width: 50vw; }
}

@media (prefers-reduced-motion: reduce) {
  .glb-overlay,
  .glb-img,
  .glb-video,
  .galerie-tuile img,
  .galerie-tuile video { transition: none; animation: none; }
  .galerie-tuile::before { animation: none; }
  .glb-spinner.actif { animation-duration: 1.6s; }
}
