/* ==========================================================
  Shared Media Gallery + Lightbox
  Used by: template-parts/gallery/media-gallery.php
  (single tour, single package, single visa)
============================================================= */

.media-gallery {
  display: grid;
  grid-template-columns: 3fr 1fr 1fr;
  grid-template-rows: 200px 200px;
  gap: 2px;
  margin-bottom: 30px;
  height: 410px;
  border-radius: 8px;
  overflow: hidden;
}

.media-gallery .gallery-item {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.media-gallery .gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

/* The First Image: Big and spans 2 rows */
.media-gallery .item-1 {
  grid-column: 1 / 2;
  grid-row: 1 / 3;
}

/* The Second Image: Top middle/right wide span */
.media-gallery .item-2 {
  grid-column: 2 / 4;
  grid-row: 1 / 2;
}

/* The Third and Fourth: Bottom small squares */
.media-gallery .item-3 {
  grid-column: 2 / 3;
  grid-row: 2 / 3;
}

.media-gallery .item-4 {
  grid-column: 3 / 4;
  grid-row: 2 / 3;
}

/* Hover Effect */
.media-gallery .gallery-item:hover img {
  transform: scale(1.05);
}

/* See All Photos Button Overlay */
.media-gallery .see-all-overlay {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: #fff;
  color: inherit;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  z-index: 10;
}

@media (max-width: 768px) {
  .media-gallery .see-all-overlay {
    display: none;
  }
  /* Fixed ratio so the gallery height doesn't depend on the image proportions */
  .media-gallery {
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    height: auto;
    aspect-ratio: 16 / 9;
  }
}

@media (max-width: 600px) {
  .media-gallery {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(0, 2fr) minmax(0, 1fr);
    aspect-ratio: 4 / 3;
  }
  .media-gallery .item-1 {
    grid-column: 1 / 3;
    grid-row: 1 / 2;
  }
  .media-gallery .item-2 {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
  }
  .media-gallery .item-3 {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
  }
  .media-gallery .item-4 {
    display: none;
  }
}

/* Lightbox Overlay */
#custom-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: white;
  font-size: 40px;
  cursor: pointer;
  z-index: 10001;
}

/* Main Image Container */
.lightbox-main-wrap {
  position: relative;
  max-width: 900px;
  width: 100%;
  height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-main-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

/* Navigation Arrows */
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.2);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: 0.3s;
}
.lb-prev { left: -60px; }
.lb-next { right: -60px; }

.lightbox-description {
  position: absolute;
  bottom: -30px;
  color: white;
  left: 50%;
  transform: translateX(-50%);
}

/* Thumbnails Strip */
.lightbox-thumbnails {
  display: flex;
  gap: 10px;
  margin-top: 36px;
  overflow-x: auto;
  max-width: 100%;
  padding: 10px;
  scrollbar-width: thin;
}

.thumb-item {
  width: 80px;
  height: 60px;
  flex-shrink: 0;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.5;
  transition: 0.3s;
  border: 2px solid transparent;
}

.thumb-item.active {
  opacity: 1;
  border-color: #B7559B;
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

@media (max-width: 1024px) {
  .lb-prev { left: 10px; }
  .lb-next { right: 10px; }
  .lightbox-main-wrap { height: 50vh; }
}

@media (max-width: 600px) {
  .lb-nav {
    background: rgb(0 0 0 / 65%);
  }
}
