/* Visionneuse d'images (js/components/lightbox.js) : une image liée à sa version complète
   s'agrandit par-dessus la page. Balisage : <a href="image.jpg"><img …></a> dans une <figure>.
   Couleur : --page-accent. */

/* l'image cliquable s'annonce : curseur loupe, léger éclat, étiquette « Agrandir » */
a:is([href$=".jpg"], [href$=".jpeg"], [href$=".png"], [href$=".webp"]):has(> img) { position: relative; display: block; cursor: zoom-in; overflow: hidden; }
a:is([href$=".jpg"], [href$=".jpeg"], [href$=".png"], [href$=".webp"]):has(> img) > img { transition: transform .5s var(--ease, ease), filter .3s; }
a:is([href$=".jpg"], [href$=".jpeg"], [href$=".png"], [href$=".webp"]):has(> img)::after {
  content: 'Agrandir'; position: absolute; right: 10px; bottom: 10px; padding: 6px 10px; pointer-events: none;
  background: rgba(8, 11, 18, .82); border: 1px solid var(--line-strong);
  font-size: .6rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--pearl);
  opacity: 0; transform: translateY(4px); transition: opacity .25s, transform .25s;
}
a:is([href$=".jpg"], [href$=".jpeg"], [href$=".png"], [href$=".webp"]):has(> img):is(:hover, :focus-visible) > img { transform: scale(1.03); filter: brightness(1.08); }
a:is([href$=".jpg"], [href$=".jpeg"], [href$=".png"], [href$=".webp"]):has(> img):is(:hover, :focus-visible)::after { opacity: 1; transform: none; }
a:is([href$=".jpg"], [href$=".jpeg"], [href$=".png"], [href$=".webp"]):has(> img):focus-visible { outline: 2px solid var(--page-accent, var(--gold)); outline-offset: 3px; }

/* Dans les briques communes, le lien prend toute la place de la photo */
.quarter-photo > a[href], .event-img > a[href] { height: 100%; }
.quarter-photo > a[href] > img, .event-img > a[href] > img { width: 100%; height: 100%; object-fit: cover; }
.atlas-photo > a[href] { position: absolute; inset: 0; }

.lightbox {
  position: fixed; inset: 0; width: 100vw; max-width: none; height: 100vh; height: 100dvh; max-height: none; margin: 0; padding: 0;
  display: none; place-items: center; background: transparent; border: 0; color: var(--ink); overflow: hidden;
}
.lightbox[open] { display: grid; animation: lightbox-in .28s ease; }
.lightbox::backdrop { background: rgba(3, 5, 11, .9); backdrop-filter: blur(6px); animation: lightbox-in .28s ease; }
.lightbox.closing, .lightbox.closing::backdrop { opacity: 0; transition: opacity .18s ease; }
@keyframes lightbox-in { from { opacity: 0; } }

/* L'image remplit l'écran disponible : la largeur se déduit du format (--ar), de la hauteur de la légende (--cap)
   et de deux fois la taille réelle au plus (--nw), le tout posé par le script. */
.lightbox figure {
  --pad-t: 52px; --pad-x: 72px; --pad-b: 24px;
  display: grid; justify-items: center; align-content: center; gap: 14px; width: 100%; height: 100%; margin: 0;
  padding: var(--pad-t) var(--pad-x) var(--pad-b); box-sizing: border-box; cursor: zoom-out;
}
.lightbox img {
  display: block; max-width: none; max-height: none; height: auto; aspect-ratio: var(--ar);
  width: min(100vw - 2 * var(--pad-x), (100vh - var(--pad-t) - var(--pad-b) - 14px - var(--cap, 0px)) * var(--ar, 1.5), var(--nw, 100vw));
  width: min(100vw - 2 * var(--pad-x), (100dvh - var(--pad-t) - var(--pad-b) - 14px - var(--cap, 0px)) * var(--ar, 1.5), var(--nw, 100vw));
  object-fit: contain; cursor: zoom-in; touch-action: none; user-select: none; -webkit-user-drag: none; transform-origin: 50% 50%;
  border: 1px solid rgba(255, 255, 255, .28); background: #080b12;
  box-shadow: 0 40px 120px -30px #000, 0 0 0 1px rgba(0, 0, 0, .6);
}
/* zoom : l'image se glisse, la légende s'efface */
.lightbox img.is-easing { transition: transform .3s cubic-bezier(.2, .8, .2, 1); }
.lightbox.is-zoomed img { cursor: grab; }
.lightbox.is-zoomed.is-dragging img { cursor: grabbing; }
.lightbox figcaption { max-width: 760px; cursor: default; text-align: center; font-size: .92rem; line-height: 1.6; color: #cdd3e6; transition: opacity .25s; }
.lightbox.is-zoomed figcaption { opacity: 0; pointer-events: none; }
.lightbox figcaption b { color: var(--pearl); }
.lightbox figcaption span { display: block; margin-top: 4px; font-size: .64rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }

.lightbox button {
  position: absolute; display: grid; place-items: center; width: 46px; height: 46px; padding: 0 0 3px; cursor: pointer;
  background: rgba(8, 11, 18, .7); border: 1px solid var(--line-strong); font: inherit; font-size: 1.7rem; line-height: 1; color: var(--pearl);
  transition: border-color .2s, background .2s, transform .2s var(--ease, ease);
}
.lightbox button:hover, .lightbox button:focus-visible { outline: 0; border-color: #fff; background: rgba(233, 241, 255, .16); }
.lightbox button[hidden] { display: none; }
.lightbox button:disabled { opacity: .35; cursor: default; border-color: var(--line-strong); background: rgba(8, 11, 18, .7); }
.lightbox-close { top: 16px; right: 16px; }
.lightbox-zoom { top: 16px; }
.lightbox-zoom--in { right: 70px; }
.lightbox-zoom--out { right: 124px; }
.lightbox-nav { top: 50%; margin-top: -23px; }
.lightbox-nav--prev { left: 14px; }
.lightbox-nav--next { right: 14px; }
.lightbox-nav--prev:hover { transform: translateX(-3px); }
.lightbox-nav--next:hover { transform: translateX(3px); }
.lightbox-hint { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); margin: 0; padding: 6px 12px; pointer-events: none; white-space: nowrap;
  background: rgba(8, 11, 18, .6); font-size: .62rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.lightbox-count { position: absolute; top: 28px; left: 24px; margin: 0; font-size: .7rem; font-weight: 800; letter-spacing: .18em; color: var(--page-accent-hi, var(--gold-hi)); font-variant-numeric: tabular-nums; }

@media (max-width: 680px) {
  .lightbox figure { --pad-t: 64px; --pad-x: 12px; --pad-b: 84px; }
  .lightbox-zoom { display: none !important; }
  .lightbox-hint { top: 26px; padding: 4px 8px; font-size: .56rem; letter-spacing: .08em; }
  .lightbox-nav { top: auto; bottom: 18px; margin: 0; }
  .lightbox-nav--prev { left: calc(50% - 54px); }
  .lightbox-nav--next { right: calc(50% - 54px); }
  .lightbox figcaption { font-size: .84rem; }
}
@media (prefers-reduced-motion: reduce) {
  .lightbox[open], .lightbox::backdrop { animation: none; }
}
