/* =============== GALLERY CONTROLS =============== */
.gallery-controls {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}
.gallery-controls > * {
  margin: 0 1rem;
}

/* =============== GALLERY SWIPER CONTAINER =============== */
.gallery-slider-container {
  max-width: 600px;
  margin: 40px auto;
}

/* Style for the gallery container to prevent FOUC (Flash of Unstyled Content) */
.gallery-swiper {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  min-height: 200px; /* Prevent collapse before images load */
 
}

/* Style for slides before they're fully initialized */
.swiper-slide {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px; /* Prevent collapse */
}

/* =============== GALLERY MATERIAL WRAPPER (NO SHADOW) =============== */
.gallery-material-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background-color: transparent; /* Changed from white to transparent to avoid white flash */
  overflow: hidden;
}

.gallery-material-content {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: #f0f0f0; /* Light gray background that will be visible before skeleton loads */
}

/* OPTIONAL SCALE EFFECT */
[data-swiper-material-scale="1.25"] {
  transition: transform 0.6s ease;
  transform-origin: center center;
}
.swiper-slide-active [data-swiper-material-scale="1.25"] {
  transform: scale(1.06) translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  transition: transform 0.5s ease, box-shadow 0.5s ease;
}

/* =============== GALLERY IMAGES =============== */
.gallery-material-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
  opacity: 0; /* Start with 0 opacity */
  transition: opacity 0.5s ease; /* Smooth transition when loaded */
}

/* Skeleton placeholder */
.skeleton-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    #f0f0f0 0%, 
    #ffffff 50%, 
    #f0f0f0 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.2s infinite ease-in-out;
  border-radius: 16px;
  z-index: 1;
}

.skeleton-placeholder.loaded {
  opacity: 0;
  transition: opacity 0.5s ease;
}

@keyframes skeleton-loading {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Lazy loading spinner - keep as fallback */
.swiper-lazy-preloader {
  width: 42px;
  height: 42px;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -21px;
  margin-top: -21px;
  z-index: 0; /* Lower z-index so skeleton shows above */
  transform-origin: 50%;
  animation: swiper-preloader-spin 1s infinite linear;
  box-sizing: border-box;
  border: 4px solid var(--swiper-preloader-color, var(--swiper-theme-color));
  border-radius: 50%;
  border-top-color: transparent;
  display: none; /* Hide spinner in favor of skeleton */
}

@keyframes swiper-preloader-spin {
  100% {
    transform: rotate(360deg);
  }
}

/* =============== GALLERY VIDEO THUMBNAIL + ICON =============== */
.gallery-video-thumbnail {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}
.gallery-youtube-icon-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 64px;
  height: 64px;
  transform: translate(-50%, -50%);
  z-index: 1;
  pointer-events: none;
}
.gallery-youtube-icon-overlay img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* =============== GALLERY SWIPER PAGINATION =============== */
.gallery-swiper-pagination {
  margin-top: 20px;
  text-align: center;
}
.swiper-pagination-bullet {
  background: #000;
  opacity: 0.4;
}
.swiper-pagination-bullet-active {
  opacity: 1;
  background: #2f2f2f !important;
}
.swiper-pagination {
  position: unset !important;
  margin-top: 18px;
}

/* =============== GALLERY LIGHTBOX MODAL =============== */
.gallery-lightbox-modal {
  position: fixed;
  z-index: 9999;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.gallery-lightbox-modal.visible {
  opacity: 1;
  visibility: visible;
}

/* GALLERY CLOSE BUTTON */
.gallery-modal-close {
  background-color: rgba(255, 255, 255, 0.8);
  font-size: 1.2rem;
  color: #333;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  position: absolute;
  top: 10px;
  right: 15px;
  transition: background-color 0.2s ease, transform 0.2s ease;
  z-index: 10001;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.gallery-modal-close:hover {
  background-color: rgba(255, 255, 255, 1);
  transform: scale(1.1);
}

.gallery-modal-close:active {
  transform: scale(0.95);
}

/* Adjust for high contrast mode */
@media (forced-colors: active) {
  .gallery-modal-close,
  .lightbox-nav-btn {
    border: 2px solid currentColor;
  }
}

/* GALLERY MODAL CONTENT */
.gallery-modal-content {
  position: relative;
  margin: 5% auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 90%;
}

/* GALLERY IMAGE CONTAINER */
.gallery-modal-image-container {
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 8px;
  transition: opacity 0.2s ease;
}

.gallery-modal-image-container.transitioning {
  opacity: 0;
}

.gallery-modal-img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 16px;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform-origin: center center;
  cursor: zoom-in;
}

/* Modal skeleton placeholder */
.modal-skeleton-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    #e0e0e0 0%, 
    #ffffff 50%, 
    #e0e0e0 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.2s infinite ease-in-out;
  border-radius: 16px;
  z-index: 1;
}

.modal-skeleton-placeholder.loaded {
  opacity: 0;
  transition: opacity 0.5s ease;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Progress bar/thumbnails navigation */
.gallery-progress-bar {
  position: absolute;
  bottom: 80px; /* Positioned higher on all screens */
  left: 50%;
  transform: translateX(-50%);
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  width: 60%;
  max-width: 300px;
  overflow: hidden;
  z-index: 10001;
}

/* Adjust progress bar position on small screens */
@media (max-width: 767px) {
  .gallery-progress-bar {
    bottom: 100px; /* Even higher on small screens */
  }
}

.gallery-progress-indicator {
  height: 100%;
  background: #fff;
  transition: width 0.3s ease;
}

/* For screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* GALLERY VIDEO CONTAINER */
.gallery-modal-video-container {
  position: relative;
  width: 90vw;
  max-width: 1600px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
}
.gallery-modal-video {
  width: 100%;
  height: 100%;
  border: none;
}

/* =============== LIGHTBOX NAVIGATION =============== */
.lightbox-navigation {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  z-index: 10001;
}

.lightbox-nav-btn {
  width: 44px;
  height: 44px;
  background-color: rgba(255, 255, 255, 0.7);
  border: none;
  border-radius: 50%;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
}

.lightbox-nav-btn:hover {
  background-color: rgba(255, 255, 255, 0.9);
  transform: scale(1.1);
}

.lightbox-nav-btn:active {
  transform: scale(0.95);
}

.prev-btn {
  margin-right: 10px;
}

.next-btn {
  margin-left: 10px;
}

.lightbox-indicator {
  color: white;
  background-color: rgba(0, 0, 0, 0.4);
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 14px;
}

/* On larger screens, position nav buttons on the sides and indicator at bottom */
@media (min-width: 768px) {
  .lightbox-navigation {
    bottom: auto;
    top: 0;
    bottom: 0;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none; /* Make the navigation container not block clicks */
  }
  
  .lightbox-nav-btn {
    pointer-events: auto; /* Allow clicks on the buttons */
  }
  
  .lightbox-indicator {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto; /* Allow clicks if needed */
  }
  
  /* Thumbnail strip for larger screens */
  .gallery-thumbnail-strip {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10001;
  }
  
  .gallery-thumbnail-item {
    width: 60px;
    height: 40px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.6;
    border: 2px solid transparent;
    transition: all 0.2s ease;
  }
  
  .gallery-thumbnail-item.active {
    opacity: 1;
    border-color: #fff;
  }
  
  .gallery-thumbnail-item:hover {
    opacity: 0.9;
  }
  
  .gallery-thumbnail-img {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
  }
}

.gallery-title-desc {
  margin-bottom: 30px;
  text-align: center;
}
.gallery-title-desc h3 {
  margin: 0 0 5px;
  font-size: 1.5rem;
  margin-top: 20px;
}
.gallery-title-desc p {
  margin: 0;
  margin-bottom: -15px;
  font-size: 0.9rem;
  color: #333;
}