/**
 * Block Styles: Image Gallery
 * 
 * BEM Notation: .image-gallery__element--modifier
 */

.image-gallery {
  position: relative;
  overflow: hidden;
}

.image-gallery__anchor {
  position: relative;
  top: -110px;
}

/* Grid */
.image-gallery__grid {
  display: grid;
  gap: 2rem;
  align-items: start;
  margin: 0 auto;
}

.image-gallery__grid--columns-1 {
  grid-template-columns: minmax(0, 1fr);
  max-width: 600px;
}

.image-gallery__grid--columns-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 800px;
}

.image-gallery__grid--columns-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 1200px;
}

/* Image item */
.image-gallery__item {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  text-align: left;
}

.image-gallery__image-wrap {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--bs-light, #f8f9fa);
  border-radius: 22px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease;
}

.image-gallery__item:hover .image-gallery__image-wrap,
.image-gallery__item:focus-visible .image-gallery__image-wrap {
  transform: translateY(-4px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.13);
}

.image-gallery__image {
  display: block;
  width: 100%;
  height: auto;
}

.image-gallery__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.image-gallery__zoom-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 999px;
  background: #fff;
  color: var(--brand-accent-color);
  font-size: 2rem;
  line-height: 1;
  font-weight: 500;
}

.image-gallery__item:hover .image-gallery__overlay,
.image-gallery__item:focus-visible .image-gallery__overlay {
  opacity: 1;
}

/* Fullscreen lightbox */
.image-gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  background: rgba(0, 0, 0, 0.94);
}

.image-gallery-lightbox.is-open {
  display: flex;
}

body.image-gallery-lightbox-open {
  overflow: hidden;
}

.image-gallery-lightbox__figure {
  margin: 0;
  max-width: 94vw;
  max-height: 92vh;
}

.image-gallery-lightbox__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 94vw;
  max-height: 90vh;
  object-fit: contain;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.image-gallery-lightbox-close,
.image-gallery-lightbox-nav {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.image-gallery-lightbox-close:hover,
.image-gallery-lightbox-nav:hover {
  background: var(--brand-accent-color);
  color: #fff;
}

.image-gallery-lightbox-close {
  top: 1.25rem;
  right: 1.25rem;
  width: 46px;
  height: 46px;
  font-size: 2rem;
  line-height: 1;
}

.image-gallery-lightbox-nav {
  top: 50%;
  width: 52px;
  height: 52px;
  transform: translateY(-50%);
  font-size: 3rem;
  line-height: 1;
}

.image-gallery-lightbox-prev,
.image-gallery-lightbox-next {
  position: absolute;
  z-index: 1;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background-image: url('/wp-content/themes/wmo/assets/images/arrow-right-orange.png');
  background-size: cover;
  background-position: center;
  color: var(--brand-accent-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  line-height: 1;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

.image-gallery-lightbox-prev:hover {
  transform: translateX(-2px);
}

.image-gallery-lightbox-next:hover {
  transform: translateX(2px);
}

.image-gallery-lightbox-prev {
  left: 1.25rem;
}

.image-gallery-lightbox-next {
  right: 1.25rem;
}

/* Lightbox zoom stage */
.image-gallery-lightbox__stage {
  position: relative;
  width: 94vw;
  height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.image-gallery-lightbox__figure {
  margin: 0;
  max-width: none;
  max-height: none;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: center center;
  will-change: transform;
  transition: transform 0.12s ease-out;
}

.image-gallery-lightbox__figure.is-dragging {
  transition: none;
  cursor: grabbing;
}

.image-gallery-lightbox__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 94vw;
  max-height: 88vh;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

/* When zoomed */
.image-gallery-lightbox.is-zoomed .image-gallery-lightbox__stage {
  cursor: grab;
}

.image-gallery-lightbox.is-zoomed .image-gallery-lightbox__image {
  max-width: none;
  max-height: none;
}

/* Zoom toolbar */
.image-gallery-lightbox__toolbar {
  position: absolute;
  left: 50%;
  bottom: 1.25rem;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transform: translateX(-50%);
}

.image-gallery-lightbox__toolbar button {
  min-width: 44px;
  height: 44px;
  padding: 0 0.9rem;
  border: 0;
  border-radius: 999px;
  /* background: rgba(255, 255, 255, 0.14); */
  background: #fff;
  color: var(--brand-accent-color);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.image-gallery-lightbox__toolbar button:hover {
  background: var(--brand-accent-color);
  color: #fff;
}

.image-gallery-lightbox-zoom-reset {
  min-width: 70px !important;
  font-size: 0.85rem !important;
}

/* Responsive */
@media (max-width: 991.98px) {
  .image-gallery__grid--columns-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767.98px) {
  .image-gallery__grid,
  .image-gallery__grid--columns-1,
  .image-gallery__grid--columns-2,
  .image-gallery__grid--columns-3 {
    grid-template-columns: 1fr;
  }

  .image-gallery-lightbox {
    padding: 1rem;
  }

  .image-gallery-lightbox__image {
    max-width: 96vw;
    max-height: 84vh;
  }

  .image-gallery-lightbox-close {
    top: 1rem;
    right: 1rem;
    width: 42px;
    height: 42px;
  }

  .image-gallery-lightbox-prev,
  .image-gallery-lightbox-next {
    width: 40px;
    height: 40px;
    font-size: 2.3rem;
    bottom: 24px;
  }

  .image-gallery-lightbox-prev {
    left: 7rem;
  }

  .image-gallery-lightbox-next {
    right: 7rem;
  }
  .image-gallery-lightbox__stage {
    width: 96vw;
    height: 84vh;
  }

  .image-gallery-lightbox__image {
    max-width: 96vw;
    max-height: 80vh;
  }

  .image-gallery-lightbox__toolbar {
    bottom: 1rem;
  }

  .image-gallery-lightbox__toolbar button {
    min-width: 40px;
    height: 40px;
    padding: 0 0.75rem;
  }

  .image-gallery-lightbox-zoom-reset {
    min-width: 62px !important;
  }
}

@media (max-width: 575.98px) {
  .image-gallery-lightbox-nav {
    top: auto;
    bottom: 1rem;
    transform: none;
  }
}
