body.lightbox-open {
  overflow: hidden;
}

.lightbox-trigger {
  cursor: pointer;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
  touch-action: pan-y;
  user-select: none;
}

.lightbox-track {
  display: flex;
  align-items: center;
  height: 100%;
  will-change: transform;
}

/* Sur mobile et tablette, chaque image occupe tout l'ecran (effet "plein
   ecran" demande), sans apercu des voisines : on navigue au glisser. */
.lightbox-slide {
  flex: 0 0 auto;
  margin: 0;
  width: 100vw;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}

.lightbox-slide.is-current {
  cursor: default;
}

.lightbox-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  touch-action: none;
  transform-origin: center center;
  -webkit-user-drag: none;
  user-drag: none;
}

/* A partir du desktop, l'image courante devient carree et touche le haut
   et le bas de l'ecran ; les images precedente et suivante depassent sur
   les cotes (effet "coverflow"), cliquables pour naviguer. */
@media (min-width: 701px) {
  .lightbox-track {
    gap: clamp(16px, 3vw, 40px);
  }

  .lightbox-slide {
    width: auto;
    aspect-ratio: 1 / 1;
    opacity: 0.4;
    transition: opacity 0.4s ease;
  }

  .lightbox-slide.is-current {
    opacity: 1;
  }

  /* Variante "urbanisme" : documents au format papier (21 x 29,7) au lieu
     d'un cadre carre, pour ne pas rogner les planches. */
  .lightbox--paper .lightbox-slide {
    aspect-ratio: 21 / 29.7;
  }

  /* Meme variante, orientation paysage (29,7 x 21). Les documents reels
     n'ont pas forcement exactement ce ratio : on affiche l'image entiere
     (bandes noires en haut/bas si besoin) plutot que de la rogner. */
  .lightbox--paper-landscape .lightbox-slide {
    aspect-ratio: 29.7 / 21;
  }

  .lightbox--paper-landscape .lightbox-image {
    object-fit: contain;
  }

  .lightbox-image {
    object-fit: cover;
  }
}

.lightbox-close {
  position: fixed;
  top: clamp(12px, 3vw, 24px);
  right: clamp(12px, 3vw, 24px);
  z-index: 201;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.lightbox-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 201;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.lightbox-arrow:hover,
.lightbox-arrow:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.lightbox-arrow--prev {
  left: clamp(10px, 3vw, 28px);
}

.lightbox-arrow--next {
  right: clamp(10px, 3vw, 28px);
}

.lightbox-zoom-controls {
  position: fixed;
  top: clamp(12px, 3vw, 24px);
  left: clamp(12px, 3vw, 24px);
  z-index: 201;
  display: flex;
  gap: 8px;
}

.lightbox-zoom {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.lightbox-zoom:hover,
.lightbox-zoom:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.lightbox-pagination {
  position: fixed;
  bottom: clamp(16px, 3vw, 28px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 201;
  display: flex;
  gap: 10px;
}

.lightbox-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  background: transparent;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.lightbox-dot.active {
  background: #fff;
  transform: scale(1.2);
}

.lightbox-dot:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@media (max-width: 700px) {
  .lightbox-arrow {
    width: 44px;
    height: 44px;
  }
}
