/* Gallery Slideshow Styles - Progressive Enhancement */
/* Supports both no-JS fallback and Swiper.js enhancement */

/* ============================================================================
   BASE STYLES - No JavaScript Required
   ============================================================================ */

/* Set up container context for responsive queries */
.gallery-column {
  container-type: inline-size;
  container-name: gallery;
}

.gallery-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  min-height: 400px;
  display: flex;
  align-items: center;
}

.gallery-container.swiper-initialized {
  display: block;
}

/* Default: Vertical stack without JavaScript */
.swiper-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.swiper-slide {
  width: 100%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.swiper-slide picture {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.swiper-slide img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

/* Hide navigation controls by default (no JS) */
.swiper-button-prev,
.swiper-button-next,
.swiper-pagination {
  display: none;
}

/* ============================================================================
   SWIPER.JS ENHANCED STYLES
   ============================================================================ */

/* When Swiper initializes, it adds .swiper-initialized class */
.swiper-initialized .swiper-wrapper {
  /* Swiper overrides with its own flexbox + transform styles */
  flex-direction: row;
  gap: 0;
  align-items: center;
  min-height: 400px;
}

/* Show navigation when Swiper loads */
.swiper-initialized .swiper-button-prev,
.swiper-initialized .swiper-button-next {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  z-index: 10;
  transition: color 0.2s;
}

.swiper-button-prev:hover,
.swiper-button-next:hover {
  color: rgba(255, 255, 255, 1);
}

.swiper-button-prev {
  left: 10px;
}

.swiper-button-next {
  right: 10px;
}

/* Override Swiper default button styles */
.swiper-button-prev:after,
.swiper-button-next:after {
  font-size: 32px;
}

.swiper-initialized .swiper-pagination {
  display: block;
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

/* Pagination dots styling */
.swiper-pagination-bullet {
  width: 10px;
  height: 10px;
  background-color: rgba(255, 255, 255, 0.5);
  opacity: 1;
  margin: 0 4px;
  transition: background-color 0.2s;
}

.swiper-pagination-bullet-active {
  background-color: white;
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* Focus styles for keyboard navigation */
.swiper-button-prev:focus,
.swiper-button-next:focus,
.swiper-pagination-bullet:focus {
  outline: none;
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

/* Mobile adjustments */
@media (max-width: 768px) {
  .gallery-container {
    min-height: 300px;
  }

  .swiper-initialized .swiper-wrapper {
    min-height: 300px;
  }

  .swiper-button-prev,
  .swiper-button-next {
    width: 36px;
    height: 36px;
  }

  .swiper-button-prev:after,
  .swiper-button-next:after {
    font-size: 24px;
  }

  .swiper-pagination-bullet {
    width: 8px;
    height: 8px;
    margin: 0 3px;
  }
}

/* Tablet and up */
@media (min-width: 769px) {
  .gallery-container {
    max-width: 100%;
  }
}

/* ============================================================================
   SINGLE IMAGE GALLERY
   ============================================================================ */

/* When only one image, ensure controls stay hidden */
.gallery-container[data-single-image="true"] .swiper-button-prev,
.gallery-container[data-single-image="true"] .swiper-button-next,
.gallery-container[data-single-image="true"] .swiper-pagination {
  display: none !important;
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.swiper-slide img {
  loading: lazy;
}

/* Smooth transitions */
.swiper-slide {
  transition: opacity 0.3s ease;
}

/* ============================================================================
   FLAT GALLERY MODE - Masonry Layout
   ============================================================================ */

/* Flat gallery displays all images in a masonry column layout (like collection pages) */
.gallery-flat .swiper-wrapper {
  display: block !important;
  column-gap: 2rem;
  margin: 0;
  transform: none !important; /* Override Swiper transform */
  transition: none !important;
}

@container gallery (min-width: 900px) {
  .gallery-flat .swiper-wrapper {
    column-count: 2;
    column-gap: 3rem;
  }
}

@container gallery (min-width: 1200px) {
  .gallery-flat .swiper-wrapper {
    column-count: 3;
    column-gap: 3rem;
  }
}

.gallery-flat .swiper-slide {
  break-inside: avoid;
  margin-bottom: 1.5rem;
  display: inline-block;
  width: 100% !important;
  height: auto !important;
  opacity: 1 !important;
  cursor: pointer;
  transform: none !important;
  transition: opacity 0.2s ease;
}

.gallery-flat .swiper-slide:hover {
  opacity: 0.85;
}

/* Always hide Swiper controls in flat mode */
.gallery-flat .swiper-button-prev,
.gallery-flat .swiper-button-next,
.gallery-flat .swiper-pagination {
  display: none !important;
}

/* Ensure images scale properly in flat mode */
.gallery-flat .swiper-slide img {
  width: 100%;
  height: auto;
  display: block;
}

.gallery-flat .swiper-slide picture {
  display: block;
  width: 100%;
}

/* ============================================================================
   LIGHTBOX MODAL
   ============================================================================ */

.gallery-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.gallery-lightbox.active {
  display: flex;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-image {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  display: block;
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 40px;
  cursor: pointer;
  transition: color 0.2s;
  z-index: 10001;
  line-height: 1;
  padding: 0;
}

.lightbox-close:hover {
  color: rgba(255, 255, 255, 1);
}

.lightbox-next, .lightbox-prev{
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 10001;
  padding: 0;
}

.lightbox-prev svg,
.lightbox-next svg {
  color: rgba(255, 255, 255, 0.5);
  transition: color 0.2s;
  width: 27px;
  height: 44px;
}

.lightbox-prev:hover svg,
.lightbox-next:hover svg {
  color: rgba(255, 255, 255, 1);
}

.lightbox-prev svg {
  transform: rotate(180deg);
}

.lightbox-prev {
  left: 10px;
}

.lightbox-next {
  right: 10px;
}

.lightbox-pagination {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0;
  z-index: 10001;
}

.lightbox-pagination-bullet {
  width: 10px;
  height: 10px;
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  border: none;
  padding: 0;
  margin: 0 4px;
  cursor: pointer;
  opacity: 1;
  transition: background-color 0.2s;
}

.lightbox-pagination-bullet:hover {
  background-color: rgba(255, 255, 255, 0.8);
}

.lightbox-pagination-bullet.active {
  background-color: white;
}

/* Make gallery images clickable */
.gallery-container .swiper-slide {
  cursor: pointer;
}

.gallery-container .swiper-slide img {
  cursor: pointer;
}

/* Mobile adjustments for lightbox */
@media (max-width: 768px) {
  .lightbox-close {
    top: 10px;
    right: 10px;
    font-size: 32px;
  }

  .lightbox-prev svg,
  .lightbox-next svg {
    width: 20px;
    height: 32px;
  }

  .lightbox-pagination {
    bottom: 10px;
  }

  .lightbox-pagination-bullet {
    width: 8px;
    height: 8px;
    margin: 0 3px;
  }
}
