.gallery-popup-wrapper {
  display: grid;
  gap: var(--gap, 15px);
  width: 100%;
}

.gallery-popup-grid[data-desktop="1"] {
  grid-template-columns: repeat(1, 1fr);
}
.gallery-popup-grid[data-desktop="2"] {
  grid-template-columns: repeat(2, 1fr);
}
.gallery-popup-grid[data-desktop="3"] {
  grid-template-columns: repeat(3, 1fr);
}
.gallery-popup-grid[data-desktop="4"] {
  grid-template-columns: repeat(4, 1fr);
}
.gallery-popup-grid[data-desktop="5"] {
  grid-template-columns: repeat(5, 1fr);
}
.gallery-popup-grid[data-desktop="6"] {
  grid-template-columns: repeat(6, 1fr);
}

@media (max-width: 991px) {
  /* Tab  */
  .gallery-popup-grid[data-tablet="1"] {
    grid-template-columns: repeat(1, 1fr);
  }
  .gallery-popup-grid[data-tablet="2"] {
    grid-template-columns: repeat(2, 1fr);
  }
  .gallery-popup-grid[data-tablet="3"] {
    grid-template-columns: repeat(3, 1fr);
  }
  .gallery-popup-grid[data-tablet="4"] {
    grid-template-columns: repeat(4, 1fr);
  }
  .gallery-popup-grid[data-tablet="5"] {
    grid-template-columns: repeat(5, 1fr);
  }
  .gallery-popup-grid[data-tablet="6"] {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (max-width: 767px) {
  /* mobile  */
  .gallery-popup-grid[data-mobile="1"] {
    grid-template-columns: repeat(1, 1fr);
  }
  .gallery-popup-grid[data-mobile="2"] {
    grid-template-columns: repeat(2, 1fr);
  }
  .gallery-popup-grid[data-mobile="3"] {
    grid-template-columns: repeat(3, 1fr);
  }
  .gallery-popup-grid[data-mobile="4"] {
    grid-template-columns: repeat(4, 1fr);
  }
  .gallery-popup-grid[data-mobile="5"] {
    grid-template-columns: repeat(5, 1fr);
  }
  .gallery-popup-grid[data-mobile="6"] {
    grid-template-columns: repeat(6, 1fr);
  }
}

.gallery-popup-item {
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease;
}
.gallery-popup-item a {
  text-decoration: none;
}

.gallery-img-container {
  position: relative;
  cursor: zoom-in;
}

.gallery-img-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
  aspect-ratio: 1;
}

.gallery-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 5;
}

.gallery-popup-item:hover .gallery-overlay {
  opacity: 1;
}

.gallery-icon-svg {
  width: 70px;
  height: 70px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  backdrop-filter: blur(5px);
  border: 2px solid rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-icon-svg svg {
  width: 100%;
  height: 100%;
}

.gallery-text-overlay {
  opacity: 1;
  text-align: center;
  padding: 2px;
  font-family: "Lato", sans-serif;
  color: #5a471c;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 1px;
}

/* Prevents jump to top and layout shifts when Magnific Popup opens */
.mfp-no-scroll body {
    overflow: visible !important;
    position: relative !important;
    height: auto !important;
}

.mfp-bg {
    background: rgba(0, 0, 0, 0.85);
    z-index: 1042;
}

.mfp-wrap {
    z-index: 1043;
}

/* Ensure content doesn't overflow viewport */
.mfp-container {
    padding-left: 15px;
    padding-right: 15px;
}

.mfp-img {
    max-height: 85vh !important;
    width: auto;
    max-width: 100%;
}

.mfp-iframe-holder .mfp-content {
    max-width: 900px;
    height: 80vh;
    max-height: 500px;
}

@media (max-height: 600px) {
    .mfp-img {
        max-height: 70vh !important;
    }
}

/* Animations */
.mfp-fade.mfp-bg {
	opacity: 0;
	transition: all 0.15s ease-out;
}
.mfp-fade.mfp-bg.mfp-ready {
	opacity: 0.8;
}
.mfp-fade.mfp-bg.mfp-removing {
	opacity: 0;
}

.mfp-fade.mfp-wrap .mfp-content {
	opacity: 0;
	transition: all 0.15s ease-out;
}
.mfp-fade.mfp-wrap.mfp-ready .mfp-content {
	opacity: 1;
}
.mfp-fade.mfp-wrap.mfp-removing .mfp-content {
	opacity: 0;
}
