/* ==========================================================================
   LW Product Gallery — Vertical Thumbnail Strip Left of Main Image
   Layout: [‹ Thumb Thumb Thumb Thumb ›] [Main Image]
   ========================================================================== */

/* ── Variables ─────────────────────────────────────────────────────── */
:root {
  --lw-thumb-size: 110px;
  /* width & height of each thumb image area */
  --lw-thumb-gap: 8px;
  /* gap between thumbnails                  */
  --lw-thumb-count: 3;
  /* visible thumbnails on desktop           */
  --lw-thumb-pad: 4px;
  /* padding inside each thumb button        */
}

/* ── Outer wrapper — stacks horizontally ──────────────────────────── */
.lw-product-gallery {
  display: flex;
  flex-direction: row-reverse;
  gap: 16px;
  width: 100%;
  position: relative;
  align-items: flex-start;
}

/* ── Main image wrapper ────────────────────────────────────────────── */
.lw-gallery__main-wrap {
  width: 100%;
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: #f7f7f7;
}

/* ── Slides ────────────────────────────────────────────────────────── */
.lw-gallery__slides {
  width: 100%;
  background: #f9f9f9;
}

.lw-gallery__slide {
  display: none;
  width: 100%;
}

.lw-gallery__slide.is-active {
  display: block;
  animation: lw-fade-in 0.3s ease;
}

.lw-gallery__slide-inner {
  display: block;
  line-height: 0;
}

.lw-gallery__slide-img {
  width: 100%;
  aspect-ratio: 3 / 4;
  display: block;
  object-fit: contain;
  transition: transform 0.4s ease;
}

/* Constrain video height to match image size */
.lw-gallery__slide-inner .wggv-video-wrapper {
  width: 100%;
  aspect-ratio: 3 / 4;
  min-height: 0 !important;
  height: auto !important;
}

.lw-gallery__slide-inner .wggv-video-wrapper .wggv-player,
.lw-gallery__slide-inner .wggv-video-wrapper .wggv-video-poster {
  object-fit: cover !important;
}

.lw-gallery__main-wrap:hover .lw-gallery__slide-img {
  transform: scale(1.012);
}

/* ── Zoom icon ─────────────────────────────────────────────────────── */
.lw-gallery__zoom {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #444;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: background 0.2s, color 0.2s;
}

.lw-gallery__zoom:hover {
  background: var(--lw-primary, #2c8779);
  color: #fff;
  border-color: transparent;
}

/* Hide zoom button if active slide contains a video */
.lw-gallery__main-wrap:has(.lw-gallery__slide.is-active .wggv-gallery-video) .lw-gallery__zoom {
  display: none !important;
}

/* ── Fullscreen Zoom Mode ─────────────────────────────────────────── */
.lw-gallery__main-wrap.is-zoomed {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999999;
  background: rgba(0, 0, 0, 0.95);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.lw-gallery__main-wrap.is-zoomed .lw-gallery__zoom {
  display: none; /* Hide zoom button when already zoomed */
}

.lw-gallery__main-wrap.is-zoomed .lw-gallery__slides,
.lw-gallery__main-wrap.is-zoomed .lw-gallery__slide,
.lw-gallery__main-wrap.is-zoomed .lw-gallery__slide-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.lw-gallery__main-wrap.is-zoomed .lw-gallery__slide-img {
  max-width: 95vw;
  max-height: 95vh;
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: zoom-out;
  transform: none !important; /* disable hover scale */
}

.lw-gallery__main-wrap.is-zoomed .lw-gallery__arrow {
  position: fixed;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 50px;
  height: 50px;
}

.lw-gallery__main-wrap.is-zoomed .lw-gallery__arrow:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lw-gallery__main-wrap.is-zoomed .lw-gallery__arrow--prev {
  left: 20px;
}

.lw-gallery__main-wrap.is-zoomed .lw-gallery__arrow--next {
  right: 20px;
}

/* ── Prev / Next Arrows on Main Image ──────────────────────────────── */
.lw-gallery__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.10);
  opacity: 0;
  transition: opacity 0.25s ease, background 0.2s, color 0.2s;
  color: #333;
  padding: 0;
  line-height: 1;
}

.lw-gallery__main-wrap:hover .lw-gallery__arrow {
  opacity: 1;
}

.lw-gallery__arrow:hover {
  background: var(--lw-primary, #2c8779);
  color: #fff;
  border-color: transparent;
}

.lw-gallery__arrow--prev {
  left: 14px;
}

.lw-gallery__arrow--next {
  right: 14px;
}

/* ── Thumbnail Column (nav + viewport + nav) ───────────────────────── */
.lw-gallery__thumbs-col {
  width: var(--lw-thumb-size);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* ── Top / Bottom Thumbnail Nav Buttons ────────────────────────────── */
.lw-gallery__thumb-nav {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #555;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
  padding: 0;
  line-height: 1;
}

.lw-gallery__thumb-nav svg {
  transform: rotate(90deg); /* Make horizontal arrows point vertical */
}

.lw-gallery__thumb-nav:hover:not(:disabled) {
  background: var(--lw-primary, #2c8779);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(44, 135, 121, 0.3);
}

.lw-gallery__thumb-nav:disabled {
  opacity: 0.25;
  cursor: default;
  box-shadow: none;
}

/* ── Viewport: clips exactly 4 thumbnails, no scrollbar ────────────── */
.lw-gallery__thumbs-viewport {
  width: 100%;
  height: calc( (var(--lw-thumb-size) * var(--lw-thumb-count)) + (var(--lw-thumb-gap) * (var(--lw-thumb-count) - 1)) );
  overflow: hidden;
  flex: 0 0 auto;
}

/* ── Track: slides vertically via transform ────────────────────────── */
.lw-gallery__thumbs-track {
  display: flex;
  flex-direction: column;
  gap: var(--lw-thumb-gap);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

/* ── Each Thumbnail Button ─────────────────────────────────────────── */
.lw-gallery__thumb {
  flex: 0 0 var(--lw-thumb-size);
  width: 100%;
  min-height: 0;
  padding: var(--lw-thumb-pad);
  background: none;
  border: 1.5px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.lw-gallery__thumb:hover {
  border-color: rgba(44, 135, 121, 0.35);
}

.lw-gallery__thumb.is-active {
  border-color: var(--lw-primary, #2c8779);
  box-shadow: 0 0 0 1px var(--lw-primary, #2c8779);
}

.lw-gallery__thumb img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  display: block;
  border-radius: 3px;
  pointer-events: none;
}

/* ── Fade animation ────────────────────────────────────────────────── */
@keyframes lw-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ── Suppress old theme gallery duplicates ─────────────────────────── */
.images.cmsmasters_product_images {
  display: none !important;
}

/* ── Suppress WooCommerce default wrapper ──────────────────────────── */
.woocommerce-product-gallery {
  opacity: 1 !important;
  display: none !important;
}

/* =========================================================================
   MOBILE (≤767px) — show 4 thumbnails, slightly smaller
   ========================================================================= */
@media (max-width: 767px) {
  :root {
    --lw-thumb-count: 4;
  }

  .lw-gallery__main-wrap {
    min-height: 220px;
  }

  .lw-gallery__arrow {
    opacity: 0.85;
    width: 34px;
    height: 34px;
  }
}

/* =========================================================================
   SMALL MOBILE (≤480px) — show 3 thumbnails
   ========================================================================= */
@media (max-width: 480px) {
  :root {
    --lw-thumb-count: 3;
  }

  .lw-gallery__main-wrap {
    min-height: 180px;
  }

  .lw-gallery__thumb-nav {
    width: 26px;
    height: 26px;
  }
}