/* app/assets/stylesheets/immo/gallery.css */

/* ── Grille éditoriale ── */
#immo-page .galerie {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 240px;
  grid-auto-flow: dense;
  gap: 6px;
}

#immo-page .galerie__item {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  cursor: zoom-in;
  background: var(--sand);
}

/* Pattern : grand (2×2) tous les 8, large (2×1) tous les 8 décalé de 4 */
#immo-page .galerie__item:nth-child(8n+1) {
  grid-column: span 2;
  grid-row: span 2;
}
#immo-page .galerie__item:nth-child(8n+5) {
  grid-column: span 2;
}

#immo-page .galerie__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .5s ease;
}

/* ── Overlay hover ── */
#immo-page .galerie__item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 26, 0);
  transition: background .35s ease;
  z-index: 1;
  pointer-events: none;
}

#immo-page .galerie__item::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 44px; height: 44px;
  transform: translate(-50%, -50%) scale(.6);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='14.9' y1='14.9' x2='21' y2='21'/%3E%3Cline x1='11' y1='8' x2='11' y2='14'/%3E%3Cline x1='8' y1='11' x2='14' y2='11'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity .35s ease, transform .35s ease;
  z-index: 2;
  pointer-events: none;
}

#immo-page .galerie__item:hover::before {
  background: rgba(26, 26, 26, .4);
}

#immo-page .galerie__item:hover img {
  transform: scale(1.06);
}

#immo-page .galerie__item:hover::after {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ── Lightbox ── */
#immo-page .lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, .94);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 24px 80px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#immo-page .lightbox.is-open { display: flex; }

#immo-page .lightbox__img {
  max-width: 100%;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 32px 96px rgba(0,0,0,.7);
  opacity: 1;
  transition: opacity .22s ease;
}

#immo-page .lightbox__img.is-fading { opacity: 0; }

/* ── Bouton fermer ── */
#immo-page .lightbox__close {
  position: fixed;
  top: 18px; right: 22px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 50%;
  color: rgba(255,255,255,.8);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background .2s, color .2s;
  line-height: 1;
}

#immo-page .lightbox__close:hover {
  background: rgba(255,255,255,.2);
  color: #fff;
}

/* ── Navigation ── */
#immo-page .lightbox__nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  color: rgba(255,255,255,.85);
  font-size: 1.4rem;
  cursor: pointer;
  transition: background .2s, color .2s, transform .2s;
}

#immo-page .lightbox__nav:hover {
  background: rgba(255,255,255,.18);
  color: #fff;
}

#immo-page .lightbox__nav--prev {
  left: 16px;
  transform: translateY(-50%);
}

#immo-page .lightbox__nav--next {
  right: 16px;
  transform: translateY(-50%);
}

#immo-page .lightbox__nav--prev:hover { transform: translateY(-50%) translateX(-2px); }
#immo-page .lightbox__nav--next:hover { transform: translateY(-50%) translateX(2px); }

/* ── Compteur ── */
#immo-page .lightbox__counter {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: .75rem;
  color: rgba(255,255,255,.5);
  letter-spacing: .15em;
  background: rgba(255,255,255,.06);
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.1);
  white-space: nowrap;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  #immo-page .galerie {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 180px;
  }

  #immo-page .galerie__item:nth-child(8n+1) {
    grid-column: span 2;
    grid-row: span 1;
  }

  #immo-page .galerie__item:nth-child(8n+5) {
    grid-column: span 2;
  }

  #immo-page .lightbox {
    padding: 16px;
  }

  #immo-page .lightbox__nav {
    width: 40px; height: 40px;
    font-size: 1.1rem;
  }

  #immo-page .lightbox__nav--prev { left: 8px; }
  #immo-page .lightbox__nav--next { right: 8px; }
}

@media (max-width: 480px) {
  #immo-page .galerie {
    grid-auto-rows: 140px;
    gap: 4px;
  }
}
