/* ==========================================================================
   gallery.css — Gallery grid and lightbox styles for Mombasa Apartments
   ==========================================================================
   Gallery grid: responsive columns adapting to all breakpoints.
   Lightbox: full-screen overlay with image, close button, and navigation.
   Uses CSS custom properties from style.css.
   ========================================================================== */

/* ---------- Gallery Section ---------- */
.gallery {
  max-width: var(--max-width, 1200px);
  margin: 2rem auto;
  padding: 0 1.5rem 2rem;
}

.gallery h2 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  color: var(--color-heading, #111111);
}

/* ---------- Gallery Grid ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.gallery-item {
  display: block;
  overflow: hidden;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  position: relative;
  aspect-ratio: 4 / 3;
}

.gallery-item:focus-visible {
  outline: 3px solid var(--color-link, #0056b3);
  outline-offset: 2px;
}

.gallery-item:hover .gallery-img {
  transform: scale(1.05);
}

.gallery-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

/* ---------- Lightbox Overlay ---------- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--color-overlay, rgba(0, 0, 0, 0.55));
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ---------- Lightbox Content ---------- */
.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* ---------- Lightbox Close Button ---------- */
.lightbox-close {
  position: absolute;
  top: -2.5rem;
  right: -0.5rem;
  background: none;
  border: none;
  color: var(--color-overlay-text, #ffffff);
  font-size: 2rem;
  cursor: pointer;
  padding: 0.5rem;
  line-height: 1;
  transition: opacity 0.2s ease;
  z-index: 2001;
}

.lightbox-close:hover,
.lightbox-close:focus {
  opacity: 0.7;
}

.lightbox-close:focus-visible {
  outline: 2px solid var(--color-overlay-text, #ffffff);
  outline-offset: 2px;
}

/* ---------- Lightbox Navigation Buttons ---------- */
.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: var(--color-overlay-text, #ffffff);
  font-size: 2rem;
  cursor: pointer;
  padding: 0.75rem 1rem;
  line-height: 1;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  z-index: 2001;
}

.lightbox-prev {
  left: -4rem;
}

.lightbox-next {
  right: -4rem;
}

.lightbox-prev:hover,
.lightbox-prev:focus,
.lightbox-next:hover,
.lightbox-next:focus {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-prev:focus-visible,
.lightbox-next:focus-visible {
  outline: 2px solid var(--color-overlay-text, #ffffff);
  outline-offset: 2px;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

/* ---------- Desktop: 4 columns at 1920px+ ---------- */
@media (min-width: 1920px) {
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
  }
}

/* ---------- Tablet: 768px – 991px — 2 columns ---------- */
@media (max-width: 991px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .lightbox-prev {
    left: 0.5rem;
  }

  .lightbox-next {
    right: 0.5rem;
  }
}

/* ---------- Mobile: below 768px — 2 columns, smaller gap ---------- */
@media (max-width: 767px) {
  .gallery {
    padding: 0 1rem 1.5rem;
    margin: 1.5rem auto;
  }

  .gallery h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .lightbox-close {
    top: -2rem;
    right: 0;
    font-size: 1.5rem;
  }

  .lightbox-prev,
  .lightbox-next {
    font-size: 1.5rem;
    padding: 0.5rem 0.75rem;
  }

  .lightbox-content {
    max-width: 95vw;
  }
}

/* ---------- Small mobile: below 480px — 1 column ---------- */
@media (max-width: 479px) {
  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}
