/* ==========================================================
   GALERIE 3 x 3 (3 images par ligne, 3 lignes)
   À charger après styles.css et le thème :
   <link rel="stylesheet" href="css/galerie.css">
   Utilise les variables du thème actif (--muted, --shadow-card...).
   ========================================================== */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);   /* 3 colonnes : 9 images = 3 lignes */
  gap: .5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
@media (min-width: 40rem) { .gallery { gap: 1rem; } }

.gallery-btn {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  cursor: zoom-in;
  aspect-ratio: 1 / 1;                      /* carrés sur téléphone */
  background: var(--muted);
  box-shadow: var(--shadow-card);
}
@media (min-width: 40rem) {
  .gallery-btn { aspect-ratio: 4 / 3; border-radius: 16px; }
}
.gallery-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s cubic-bezier(.22, 1, .36, 1);
}
.gallery-btn:hover img,
.gallery-btn:focus-visible img { transform: scale(1.07); }

/* Légende au survol, sur dégradé sombre (lisible sur toute photo) */
.gallery-cap {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1.75rem .75rem .6rem;
  color: #fff;
  font-size: 13px;
  text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, .7));
  opacity: 0;
  transition: opacity .3s;
}
.gallery-btn:hover .gallery-cap,
.gallery-btn:focus-visible .gallery-cap { opacity: 1; }
@media (max-width: 39.99rem) { .gallery-cap { display: none; } }

/* Agrandissement */
.gallery-dialog {
  margin: auto;                             /* le reset du site met margin:0 sur tout */
  width: 100%;
  max-width: min(96vw, 1100px);
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}
.gallery-dialog::backdrop { background: rgba(0, 0, 0, .88); }
.gallery-dialog figure { position: relative; margin: 0; }
.gallery-dialog img {
  display: block;
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 12px;
}
.gallery-dialog figcaption {
  margin-top: .6rem;
  color: #fff;
  font-size: 14px;
  text-align: center;
}
.gallery-nav, .gallery-close {
  position: absolute;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  color: #111;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.gallery-nav { top: 50%; transform: translateY(-50%); }
.gallery-prev { left: .5rem; }
.gallery-next { right: .5rem; }
.gallery-close { top: -3.25rem; right: 0; }
.gallery-nav:focus-visible, .gallery-close:focus-visible { outline: 3px solid var(--brand-teal); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .gallery-btn img, .gallery-cap { transition: none; }
  .gallery-btn:hover img { transform: none; }
}
