/* ===== Galerie ESA Saint-Luc : grille + visionneuse (sans plugin, sans jQuery) ===== */

/* --- Grille : appliquée automatiquement au conteneur des miniatures --- */
.sl-gal.sl-gal {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
  gap: 8px !important;
  float: none !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 0 24px !important;
  padding: 0 !important;
  list-style: none;
}
.sl-gal.sl-gal > * {
  float: none !important;
  width: auto !important;
  max-width: none !important;
  min-width: 0;
  margin: 0 !important;
  padding: 0 !important;
  position: static;
}
.sl-gal.sl-gal > .sl-gal-skip { grid-column: 1 / -1; }

.sl-gal a[data-sl-g] {
  display: block;
  position: relative;
  overflow: hidden;
  background: #cfcfcf;
  aspect-ratio: 1 / 1;
  line-height: 0;
}
.sl-gal a[data-sl-g] img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  object-fit: cover;
  transition: transform .25s ease;
}
.sl-gal a[data-sl-g]:hover img,
.sl-gal a[data-sl-g]:focus-visible img { transform: scale(1.06); }
.sl-gal a[data-sl-g]:focus-visible { outline: 3px solid #eb5b25; outline-offset: 2px; }

/* Les images des galeries WordPress natives restent dans leur mise en page, on ajoute juste le curseur */
a[data-sl-g] { cursor: zoom-in; }

/* --- Visionneuse --- */
html.sl-lb-open { overflow: hidden; }

dialog.sl-lb {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  overflow: hidden;
}
dialog.sl-lb::backdrop { background: rgba(12, 12, 12, .94); }

.sl-lb__stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 72px;
  touch-action: pan-y pinch-zoom;
}
.sl-lb__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: opacity .15s ease;
  user-select: none;
  -webkit-user-drag: none;
}
.sl-lb__img.is-loading { opacity: .25; }

.sl-lb__count {
  position: absolute;
  top: 18px;
  left: 20px;
  margin: 0;
  font: 500 14px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: .04em;
  opacity: .85;
}

.sl-lb__btn {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  cursor: pointer;
  transition: background .15s ease;
}
.sl-lb__btn:hover { background: rgba(255, 255, 255, .26); }
.sl-lb__btn:focus-visible { outline: 3px solid #eb5b25; outline-offset: 2px; }
.sl-lb__btn[hidden] { display: none; }
.sl-lb__close { top: 12px; right: 16px; }
.sl-lb__prev  { left: 16px;  top: 50%; margin-top: -24px; }
.sl-lb__next  { right: 16px; top: 50%; margin-top: -24px; }

@media (max-width: 640px) {
  /* 3 colonnes sur téléphone : miniatures de ~110 px, nettes (elles font 150 px à l'origine) */
  .sl-gal.sl-gal { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }
  .sl-lb__stage { padding: 56px 8px 72px; }
  .sl-lb__prev, .sl-lb__next { top: auto; bottom: 12px; margin-top: 0; }
  .sl-lb__prev { left: calc(50% - 60px); }
  .sl-lb__next { right: calc(50% - 60px); }
}

@media (prefers-reduced-motion: reduce) {
  .sl-gal a[data-sl-g] img, .sl-lb__img, .sl-lb__btn { transition: none; }
}
