/* Grille justifiée type Google Photos.
   --h : hauteur cible d'une ligne ; --r : ratio largeur/hauteur de la photo.
   Chaque photo démarre à --r * --h de large puis s'étire pour remplir la ligne,
   en gardant son ratio grâce au <i> de remplissage. */
.pgallery {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 24px 0;
}
.pgallery::after {           /* évite d'étirer la dernière ligne */
  content: "";
  flex-grow: 999999;
}
.pgallery figure {
  position: relative;
  margin: 0;
  flex-grow: var(--r);
  flex-basis: calc(var(--r) * var(--h));
  overflow: hidden;
  background: #eaeef2;
}
.pgallery figure > i {
  display: block;
  padding-bottom: calc(100% / var(--r));
}
.pgallery img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  box-sizing: border-box;
  background: none;
  transition: transform .25s ease;
}
.pgallery figure:hover img { transform: scale(1.03); }
.pgallery figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 16px 8px 6px;
  color: #fff;
  font-size: 13px;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.pgallery figure:hover figcaption { opacity: 1; }

@media (max-width: 768px) {
  .pgallery { --h: 140px !important; gap: 2px; }
}

/* Visionneuse plein écran : photo à gauche, informations à droite */
.pgallery-lb {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  background: #111;
}
.pgallery-lb.open { display: flex; }

.pgallery-lb .lb-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 56px 16px;
}
.pgallery-lb .lb-stage img {
  max-width: 100%;
  max-height: calc(100vh - 110px);
  object-fit: contain;
}
.pgallery-lb .lb-cap { color: #ddd; margin: 10px 0 0; font-size: 14px; min-height: 1.4em; text-align: center; }

.pgallery-lb button {
  border: 0;
  background: none;
  color: #fff;
  line-height: 1;
  cursor: pointer;
  opacity: .7;
}
.pgallery-lb button:hover { opacity: 1; }
.pgallery-lb .lb-prev,
.pgallery-lb .lb-next { position: absolute; top: 50%; transform: translateY(-50%); font-size: 44px; padding: 12px 14px; }
.pgallery-lb .lb-prev { left: 4px; }
.pgallery-lb .lb-next { right: 4px; }
.pgallery-lb .lb-tools { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.pgallery-lb .lb-tools button { font-size: 26px; padding: 6px 10px; }

.pgallery-lb .lb-info {
  width: 340px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 20px;
  background: #fff;
  color: #24292f;
  font-size: 14px;
  line-height: 1.5;
}
.pgallery-lb.lb-hide-info .lb-info,
.pgallery-lb.lb-no-info .lb-info { display: none; }
.pgallery-lb.lb-no-info .lb-toggle { display: none; }

.pgallery-lb .lb-info h3 { margin: 0 0 10px; font-size: 18px; }
.pgallery-lb .lb-desc { margin-bottom: 14px; }
.pgallery-lb .lb-desc p { margin: 0 0 8px; }
.pgallery-lb .lb-info dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0 0 16px;
  padding-top: 12px;
  border-top: 1px solid #d0d7de;
}
.pgallery-lb .lb-info dt { color: #57606a; }
.pgallery-lb .lb-info dd { margin: 0; }
.pgallery-lb .lb-map iframe {
  width: 100%;
  height: 240px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
}
.pgallery-lb .lb-map a { display: inline-block; margin-top: 4px; font-size: 13px; }
.pgallery-lb .lb-coord { float: right; margin-top: 4px; font-size: 12px; color: #57606a; font-family: monospace; }

@media (prefers-color-scheme: dark) {
  .pgallery-lb .lb-info { background: #161b22; color: #c9d1d9; }
  .pgallery-lb .lb-info dt, .pgallery-lb .lb-coord { color: #8b949e; }
  .pgallery-lb .lb-info dl, .pgallery-lb .lb-map iframe { border-color: #30363d; }
}

/* Mobile : informations sous la photo */
@media (max-width: 768px) {
  .pgallery-lb { flex-direction: column; overflow-y: auto; }
  .pgallery-lb .lb-stage { flex: none; height: 65vh; padding: 44px 8px 8px; }
  .pgallery-lb .lb-stage img { max-height: calc(65vh - 80px); }
  .pgallery-lb .lb-info { width: auto; overflow: visible; }
}
