/*
 * Galerie photos — liste des albums, grille d'un album, visionneuse.
 *
 * Chargée seulement sur la page « Galerie photos », sur les albums, et sur une
 * fiche d'événement illustrée, pour la visionneuse de son affiche
 * (schwob_enqueue_gallery_assets(), inc/galleries.php). Les cartes d'album sont
 * celles de la section « cartes » (sections/cartes.css), chargée avec.
 *
 * La maquette ne dessine pas la galerie. La grille reprend le vocabulaire des
 * cartes : rayon --r-card, filet --line, léger agrandissement au survol. La
 * visionneuse est la seule surface sombre plein écran du site : elle reçoit le
 * liseré de focus blanc des surfaces sombres (base.css).
 */

/* ==========================================================================
   Liste des albums
   ========================================================================== */

.page-body--intro { padding-bottom: 0; }
.page-body--intro + .albums { border-top: none; }

.albums-empty {
  font-size: 1.0625rem;
  color: var(--ink-2);
}

/* Nombre de photos d'un album, sous sa présentation. */
.album-card-count {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-3);
}

.album-card-count svg {
  --icon-boost: 4px;
  width: 18px;
  height: 18px;
  color: var(--navy);
}

/* ==========================================================================
   Un album : la grille
   ========================================================================== */

.album { padding: 56px 0 var(--section-y); }

.album-count {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  margin-bottom: 28px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ink);
}

.album-hint {
  font-weight: 400;
  color: var(--ink-3);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.photo-grid-link {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: var(--r-card-sm);
  background: var(--bg-alt);
}

.photo-grid-link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s ease;
}

.photo-grid-link:hover img { transform: scale(1.04); }

/* Le liseré à l'extérieur de la vignette, que le recadrage ne coupe pas. */
.photo-grid-link:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

/* ==========================================================================
   Visionneuse
   ========================================================================== */

/* La page ne défile pas derrière la visionneuse. */
html.lightbox-open { overflow: hidden; }

.lightbox {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  color: #fff;
  background: rgba(11, 20, 36, .96);
}

.lightbox::backdrop { background: rgba(11, 20, 36, .6); }

.lightbox-inner {
  position: relative;
  display: grid;
  place-items: center;
  height: 100%;
  padding: 72px 88px 56px;
}

.lightbox-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 100%;
  max-height: 100%;
}

.lightbox-image {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 1600px);
  max-height: calc(100dvh - 190px);
  object-fit: contain;
  border-radius: 6px;
}

.lightbox-caption {
  max-width: 60ch;
  text-align: center;
  font-size: 0.9375rem;
  line-height: 1.5;
}

/* Blanc à 75 % sur le fond : 12:1. */
.lightbox-count {
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.875rem;
  color: rgba(255, 255, 255, .75);
}

.lightbox-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: var(--touch);
  height: var(--touch);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .08);
  cursor: pointer;
  transition: background .2s;
}

.lightbox-btn:hover { background: rgba(255, 255, 255, .2); }

/* « display: grid » l'emporterait sur l'attribut hidden : album d'une seule photo. */
.lightbox-btn[hidden] { display: none; }

.lightbox-btn svg {
  width: 22px;
  height: 22px;
}

.lightbox-close { top: 16px; right: 16px; }

.lightbox-prev,
.lightbox-next {
  top: 50%;
  margin-top: calc(var(--touch) / -2);
}

.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

/* Une seule icône, retournée pour « précédente ». */
.lightbox-prev svg { transform: rotate(180deg); }

/* ==========================================================================
   Points de rupture
   ========================================================================== */

@media (max-width: 980px) {
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .album { padding-top: 40px; }
}

@media (max-width: 620px) {
  .photo-grid { gap: 10px; }

  /* Les boutons passent sous la photo : sur un téléphone, ils la masquaient. */
  .lightbox-inner { padding: 64px 12px 96px; }
  .lightbox-image { max-height: calc(100dvh - 220px); }

  .lightbox-prev,
  .lightbox-next {
    top: auto;
    bottom: 20px;
    margin-top: 0;
  }

  .lightbox-prev { left: calc(50% - var(--touch) - 12px); }
  .lightbox-next { right: calc(50% - var(--touch) - 12px); }
}

@media (prefers-reduced-motion: reduce) {
  .photo-grid-link img { transition: none; }
  .photo-grid-link:hover img { transform: none; }
}
