/* ═══════════════════════════════════════════════════════════
   Lightbox AG Industrie — galerie Chantiers
   Vanilla, sans dépendance. Layer par-dessus la grille.
   ═══════════════════════════════════════════════════════════ */

.lb-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: oklch(0.04 0.018 248 / 0.92);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  opacity: 0;
  transition: opacity 200ms ease-out;
  font-family: 'Public Sans', system-ui, sans-serif;
  color: oklch(0.96 0.005 240);
  --lb-blue: oklch(0.78 0.18 240);
  --lb-line: oklch(0.40 0.020 240 / 0.5);
}
.lb-overlay.is-open { display: flex; opacity: 1; }
.lb-overlay.is-closing { opacity: 0; }

/* Click-catcher fond (sous l'image) */
.lb-backdrop {
  position: absolute;
  inset: 0;
  cursor: zoom-out;
}

/* Conteneur stage : image + caption empilés */
.lb-stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  max-width: 92vw;
  max-height: 92vh;
  pointer-events: none; /* le fond reçoit le clic ; on ré-active sur les enfants */
}

/* Track horizontal pour le slide entre images */
.lb-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 90vw;
  max-width: 1400px;
  height: 78vh;
  pointer-events: auto;
  touch-action: pan-y; /* on gère pan-x nous-mêmes */
  user-select: none;
  -webkit-user-select: none;
}

.lb-img {
  max-width: 90vw;
  max-height: 78vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  box-shadow: 0 30px 80px -20px oklch(0.02 0.02 248 / 0.9);
  border-radius: 2px;
  transform: scale(0.98);
  opacity: 0;
  transition: opacity 250ms ease-out, transform 250ms cubic-bezier(.2,.7,.2,1);
}
.lb-img.is-ready {
  opacity: 1;
  transform: scale(1) translateX(0);
}
/* Transitions de slide : appliquées via classes is-out-left / is-out-right */
.lb-img.is-out-left  { opacity: 0; transform: translateX(-40px) scale(.99); }
.lb-img.is-out-right { opacity: 0; transform: translateX(40px)  scale(.99); }
.lb-img.is-in-left   { opacity: 0; transform: translateX(40px)  scale(.99); }
.lb-img.is-in-right  { opacity: 0; transform: translateX(-40px) scale(.99); }

/* Suit le doigt pendant le drag (pas de transition) */
.lb-img.is-dragging {
  transition: none;
}

/* Caption sous l'image — typo du site */
.lb-caption {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 18px;
  text-align: center;
  pointer-events: auto;
  max-width: 90vw;
  padding-inline: 16px;
}
.lb-num {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.18em;
  color: var(--lb-blue);
  text-shadow: 0 0 18px oklch(0.62 0.20 245 / 0.5);
}
.lb-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 500;
  font-size: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: oklch(0.94 0.008 240);
  line-height: 1.3;
}
.lb-counter {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: oklch(0.70 0.015 240);
  padding-left: 18px;
  border-left: 1px solid var(--lb-line);
}

/* Boutons ronds (flèches + close) */
.lb-btn {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: oklch(0.18 0.025 248 / 0.55);
  border: 1px solid var(--lb-line);
  color: oklch(0.95 0.008 240);
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 180ms ease-out, border-color 180ms ease-out, color 180ms ease-out, transform 180ms ease-out;
}
.lb-btn:hover,
.lb-btn:focus-visible {
  background: oklch(0.24 0.04 248 / 0.85);
  border-color: var(--lb-blue);
  color: var(--lb-blue);
  outline: none;
  transform: scale(1.05);
}
.lb-btn:focus-visible {
  box-shadow: 0 0 0 3px oklch(0.62 0.20 245 / 0.25);
}
.lb-btn svg { width: 22px; height: 22px; }

.lb-prev { left: 24px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 24px; top: 50%; transform: translateY(-50%); }
.lb-prev:hover, .lb-prev:focus-visible { transform: translateY(-50%) scale(1.05); }
.lb-next:hover, .lb-next:focus-visible { transform: translateY(-50%) scale(1.05); }
.lb-close { top: 20px; right: 20px; width: 44px; height: 44px; }
.lb-close svg { width: 18px; height: 18px; }

/* Empêche le scroll body quand ouvert (la classe est posée par le JS) */
body.lb-open { overflow: hidden; }

/* Responsive ----------------------------------------------- */
@media (max-width: 768px) {
  .lb-track {
    width: 100vw;
    height: 70vh;
  }
  .lb-img {
    max-width: 94vw;
    max-height: 70vh;
  }
  .lb-stage { gap: 18px; max-width: 100vw; }
  /* Sur mobile : les flèches restent visibles mais plus discrètes ; le swipe est primaire */
  .lb-prev, .lb-next {
    width: 40px; height: 40px;
    background: oklch(0.10 0.02 248 / 0.55);
    opacity: 0.7;
  }
  .lb-prev { left: 10px; }
  .lb-next { right: 10px; }
  .lb-close { top: 12px; right: 12px; width: 40px; height: 40px; }
  .lb-title { font-size: 13px; letter-spacing: 0.06em; }
  .lb-num { font-size: 11px; }
  .lb-counter { font-size: 11px; padding-left: 12px; }
}

/* Indique la cliquabilité sur les images de la galerie */
.gallery-grid .gal { cursor: zoom-in; }
.gallery-grid .gal:focus-visible {
  outline: 2px solid var(--blue, oklch(0.78 0.18 240));
  outline-offset: 2px;
}

/* Respecte prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .lb-overlay,
  .lb-img { transition: opacity 80ms linear; }
  .lb-img.is-out-left, .lb-img.is-out-right,
  .lb-img.is-in-left,  .lb-img.is-in-right { transform: none; }
}
