/* =========================
   PORTFOLIO GALLERY
   ========================= */

.gallery-page{
  padding: clamp(40px,5vw,80px) 0;
}

.gallery-head{
  margin-bottom:40px;
}

.gallery-back{
  display:inline-block;
  margin-bottom:14px;
  opacity:.7;
  text-decoration:none;
  font-weight:600;
  transition: opacity .2s ease;
}

.gallery-back:hover{
  opacity:1;
}

.gallery-title{
  margin:0;
  font-size: clamp(32px,4vw,48px);
}

.gallery-sub{
  margin-top:8px;
  opacity:.7;
}

/* =========================
   MASONRY GRID
   ========================= */

.gallery-grid{
  column-count:3;
  column-gap:14px;
}

.gallery-item{
  break-inside: avoid;
  margin-bottom:14px;
  border-radius:14px;
  overflow:hidden;
  cursor:pointer;
  position:relative;

  /* ✅ perf: le navigateur “ignore” les items hors écran */
  content-visibility: auto;
  contain-intrinsic-size: 320px;
}

.gallery-item img{
  width:100%;
  height:auto;
  display:block;

  opacity:0;
  transition: opacity .6s ease, transform .5s ease;
  will-change: transform, opacity;
}

.gallery-item img.loaded{
  opacity:1;
}

.gallery-item:hover img{
  transform: scale(1.05);
}

/* =========================
   LIGHTBOX
   ========================= */

.lightbox{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.92);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:9999;
  padding:18px;
}

.lightbox.is-open{
  display:flex;
}

.lb-inner{
  position:relative;
  width: min(1200px,100%);
  height: min(82vh,820px);
  display:flex;
  align-items:center;
  justify-content:center;
}

#lightbox-img{
  max-width:100%;
  max-height:100%;
  border-radius:10px;
  box-shadow:0 26px 80px rgba(0,0,0,.55);
}

/* =========================
   LIGHTBOX CLOSE BUTTON
   ========================= */

.lb-close{
  position:absolute;
  z-index: 30;
  top:-10px;
  right:-10px;
  width:44px;
  height:44px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.10);
  color:rgba(255,255,255,.92);
  font-size:18px;
  font-weight:900;
  cursor:pointer;
  backdrop-filter: blur(6px);
  transition: transform .14s ease, background .18s ease, box-shadow .18s ease;
}

.lb-close:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,.14);
  box-shadow:0 16px 36px rgba(0,0,0,.35);
}

/* =========================
   NAV ARROWS
   ========================= */

.lb-nav{
  position:absolute;
  top:50%;
  transform: translateY(-50%);
  width:48px;
  height:48px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.10);
  color:rgba(255,255,255,.92);
  font-size:28px;
  line-height:1;
  font-weight:900;
  cursor:pointer;
  backdrop-filter: blur(6px);
  transition: transform .14s ease, background .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.lb-nav:hover{
  transform: translateY(-50%) translateY(-1px);
  background: rgba(255,255,255,.14);
  box-shadow:0 16px 36px rgba(0,0,0,.35);
}

.lb-prev{ left:-10px; }
.lb-next{ right:-10px; }

/* =========================
   CLICK ZONES
   ========================= */

.lb-hit{
  position:absolute;
  top:0;
  bottom:0;
  width:28%;
}

.lb-hit-left{ left:0; }
.lb-hit-right{ right:0; }

/* =========================
   RESPONSIVE
   ========================= */

@media (max-width:1000px){
  .gallery-grid{ column-count:2; }
}

@media (max-width:600px){
  .gallery-grid{ column-count:1; }
}

/* =========================
   MOBILE LIGHTBOX
   ========================= */

@media (max-width:640px){
  .lb-inner{ height:min(78vh,620px); }
  .lb-prev{ left:6px; }
  .lb-next{ right:6px; }
  .lb-close{ top:6px; right:6px; }
  .lb-nav{ width:44px; height:44px; font-size:26px; }
  .lb-hit{ width:0; }
}