/* ============================================================
   1. LAYOUT & GRILLE (Masonry)
   ============================================================ */
#main-gallerie {
  width: 76%;
  margin-left: auto;
  margin-right: auto;
  margin-top: max(30px, 4vw);
}

#main-gallerie > .column {
  display: none;
}

.masonry {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: max(8px, 1vw);
  padding: 0;
  box-sizing: border-box;
  user-select: none;
}

.masonry > .column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: max(8px, 1vw);
  min-width: 0;
}

.masonry > .column img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  cursor: pointer;
}

/* Optimisation des performances sur les grandes galeries */
.masonry > .column img:nth-child(n+4) {
  content-visibility: auto;
  contain-intrinsic-size: 100px 500px; 
}

@media (hover: hover) {
  .masonry > .column img:hover {
    transform: scale(1.02);
    cursor: zoom-in;
    transition: transform 0.3s ease-out;
  }
}

/* Exception de disposition en ligne MISC */
#gal-ligne {
  flex: 1 !important;
  display: flex !important;
  flex-direction: row !important;
  gap: max(8px, 1vw) !important;
  min-width: 0 !important;
  flex-wrap: nowrap !important;
  align-content: center !important;
  justify-content: center !important;
  align-items: center !important;
}

/* ============================================================
   2. COMPOSANT LIGHTBOX (Modale et Navigation)
   ============================================================ */
@keyframes lightboxin {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.900);
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
}

.lightbox.active {
  user-select: none;
  display: block;
  pointer-events: all;
  animation: lightboxin 2s;
}

.lightbox-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  max-width: 100%;
  position: relative;
}

.lightbox-image {
  max-height: 100dvh;
  max-width: 100vw;
  animation: lightboxin 2s;
}

/* Boutons de navigation */
.lightbox-next,
.lightbox-prev {
  border: none;
  background: url(/ui/flechelight.svg) 90% center / max(28px, 3vw) max(28px, 3vw) no-repeat;
  width: max(44px, 4vw);
  height: max(44px, 4vw);
  padding: 0;
  position: fixed;
  top: 45%;
  right: 0;
  margin-top: 0;
  z-index: 11;
  cursor: pointer;
  opacity: .3;
  transition: opacity .2s;
}

.lightbox-prev {
  left: 0;
  right: auto;
  transform: rotate(180deg);
}

.lightbox-next:hover, 
.lightbox-prev:hover {
  opacity: .8;
}

/* Bouton Fermer */
.lightbox-close {
  border: none;
  background: url(/ui/croixlight.svg) 90% 10% / max(32px, 2.5vw) max(32px, 2.5vw) no-repeat;
  width: max(44px, 4vw);
  height: max(44px, 4vw);
  position: fixed;
  top: 0;
  right: 0;
  margin-top: 0;
  z-index: 12;
  cursor: pointer;
  opacity: .3;
}

/* ============================================================
   3. RESPONSIVE : MOBILES & TABLETTES (Portrait)
   ============================================================ */
@media only screen and (max-width: 767px),
only screen and (min-width: 768px) and (max-width: 1024px) and (orientation: portrait),
only screen and (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) and (min-resolution: 1.90001dppx),
only screen and (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) and (max-resolution: 1.9dppx) and (pointer: fine) {
  #main-gallerie {
    width: 90%;
  }
}