/**
 * Front-end image gallery: 2x2 grid on desktop/tablet, one-image-per-view
 * swipe slider on mobile (dots added by js/image_gallery.js).
 *
 * Single source of truth for the gallery styles - do not restyle
 * .vinpearl-image-gallery in the theme: theme CSS loads after module CSS and
 * would silently override the mobile slider.
 */
.vp-image-gallery,
.vinpearl-image-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 746px;
  margin: 0 auto;
  box-sizing: border-box;
}

.vp-image-gallery > a,
.vinpearl-image-gallery > a {
  display: block;
  overflow: hidden;
  border-radius: 4px;
  background: #f2f2f2;
  aspect-ratio: 4 / 3;
}

/* Odd number of images: the last one spans the full row. */
.vp-image-gallery > a:last-child:nth-child(odd),
.vinpearl-image-gallery > a:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  aspect-ratio: 8 / 3;
}

.vp-image-gallery > a:focus-visible,
.vinpearl-image-gallery > a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.vp-image-gallery img,
.vinpearl-image-gallery img {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.vp-image-gallery > a:hover img,
.vinpearl-image-gallery > a:hover img {
  transform: scale(1.03);
}

@media (max-width: 767.98px) {
  .vp-image-gallery,
  .vinpearl-image-gallery {
    display: flex;
    gap: 0;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .vp-image-gallery::-webkit-scrollbar,
  .vinpearl-image-gallery::-webkit-scrollbar {
    display: none;
  }

  .vp-image-gallery > a,
  .vinpearl-image-gallery > a,
  .vp-image-gallery > a:last-child:nth-child(odd),
  .vinpearl-image-gallery > a:last-child:nth-child(odd) {
    flex: 0 0 100%;
    aspect-ratio: 4 / 3;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .vp-image-gallery > a:hover img,
  .vinpearl-image-gallery > a:hover img {
    transform: none;
  }

  /* Dots, added by js/image_gallery.js. */
  .image-gallery-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 8px 0 16px;
  }

  .image-gallery-dots button {
    width: 8px;
    height: 8px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #ccc;
    cursor: pointer;
  }

  .image-gallery-dots button.is-active {
    background: #E8952F;
  }
}

@media (min-width: 768px) {
  .image-gallery-dots {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vp-image-gallery img,
  .vinpearl-image-gallery img {
    transition: none;
  }

  .vp-image-gallery > a:hover img,
  .vinpearl-image-gallery > a:hover img {
    transform: none;
  }
}
