/* Module galerie : grille « justifiée » (hauteurs de ligne égales, aucune image rognée) + visionneuse.
   Variables à surcharger dans le site : --gv-accent, --gv-row-h (hauteur cible d'une ligne), --gv-gap. */
.gallery-justified { --gv-row-h: 320px; --gv-gap: 8px; display: flex; flex-wrap: wrap; gap: var(--gv-gap); list-style: none; margin: 0; padding: 0; }
.gallery-justified > li {
  position: relative; min-width: 0;
  /* longhands : le raccourci `flex` avec calc() pour la croissance est ignoré par les navigateurs */
  flex-grow: calc(var(--ar) * 100); flex-shrink: 1; flex-basis: calc(var(--ar) * var(--gv-row-h));
}
.gallery-justified a.gv-item { display: block; overflow: hidden; aspect-ratio: var(--ar); background: #111; cursor: zoom-in; }
.gallery-justified picture, .gallery-justified img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery-justified img { transition: transform .5s cubic-bezier(.23, 1, .32, 1); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .gallery-justified a.gv-item:hover img { transform: scale(1.03); }
}
@media (max-width: 767px) { .gallery-justified > li { flex-basis: 100%; } }

/* Bouton de téléchargement sur la vignette */
.gallery-dl {
  position: absolute; right: 10px; bottom: 10px;
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0, 0, 0, .65); color: #fff; backdrop-filter: blur(4px);
  transition: background-color .2s ease, color .2s ease, transform .16s ease;
}
.gallery-dl:active { transform: scale(.95); }
@media (hover: hover) { .gallery-dl:hover { background: var(--gv-accent, #fff); color: #000; } }

/* Visionneuse */
.gv { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #000; color: #fff; overscroll-behavior: contain; touch-action: pan-y; }
.gv[open] { display: grid; grid-template-columns: 64px 1fr 64px; grid-template-rows: 64px 1fr; }
.gv::backdrop { background: rgba(0, 0, 0, .96); }
html.gv-open { overflow: hidden; }
.gv-bar { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: max(10px, env(safe-area-inset-top)) 12px 10px 20px; }
.gv-count { margin-right: auto; font-size: 14px; letter-spacing: .08em; opacity: .8; font-variant-numeric: tabular-nums; }
.gv-btn { display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer; transition: background-color .2s ease, color .2s ease, transform .16s ease; }
.gv-btn:active { transform: scale(.95); }
@media (hover: hover) { .gv-btn:hover { background: var(--gv-accent, #fff); color: #000; } }
.gv-btn:focus-visible { outline: 2px solid var(--gv-accent, #fff); outline-offset: 2px; }
.gv-nav { align-self: center; justify-self: center; }
.gv-single .gv-nav { visibility: hidden; }
.gv-fig { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; margin: 0; padding: 0 0 max(16px, env(safe-area-inset-bottom)); }
.gv-img { max-width: 100%; max-height: calc(100dvh - 130px); width: auto; height: auto; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.gv-cap { margin-top: 10px; font-size: 14px; opacity: .75; text-align: center; }
.gv-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 767px) {
  .gv[open] { grid-template-columns: 0 1fr 0; grid-template-rows: 64px 1fr auto; }
  .gv-nav { grid-row: 3; position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); }
  .gv-prev { left: 16px; } .gv-next { right: 16px; }
  .gv-img { max-height: calc(100dvh - 200px); }
  .gv-fig { padding-bottom: 80px; }
}
@media (prefers-reduced-motion: no-preference) {
  .gv[open] { animation: gv-in .2s cubic-bezier(.23, 1, .32, 1); }
  @keyframes gv-in { from { opacity: 0; } }
}
