/* =========================================================================
   Mobile Product Gallery — CSS for ACF + Swiper.js (Mobile Only)
   -------------------------------------------------------------------------
   Notes:
   - Comments are English-only as requested.
   - No functional changes were made (values/selectors/order are untouched).
   - Arrows use :has() for conditional visibility; if :has() is unsupported,
     arrows simply won't appear (progressive enhancement).
   ========================================================================= */

/* ===== Reset spacing so Swiper controls layout via JS =====
   Remove padding/gaps so Swiper's JS parameters (e.g., spaceBetween)
   fully dictate inter-slide spacing and offsets. */
.mobile-product-gallery .mobile-gallery-swiper,
.mobile-product-gallery .mobile-gallery-swiper .swiper,
.mobile-product-gallery .mobile-gallery-swiper .swiper-wrapper{
  padding: 0;
  gap: 0;
}

/* Keep Swiper centered offsets at zero by default
   (these can be overridden by Swiper inline vars if needed). */
.mobile-product-gallery .mobile-gallery-swiper{
  --swiper-centered-offset-before: 0px;
  --swiper-centered-offset-after: 0px;
}

/* Thumbs wrapper: avoid CSS gap; let JS spaceBetween define spacing. */
.mobile-product-gallery .mobile-gallery-thumbs .swiper-wrapper{ gap: 0; }

/* ===== Root container: square main with LEFT-side vertical thumbs =====
   Design tokens:
   --thumb-size: thumbnail diameter (circle).
   --frame-radius: corner radius for main frame.
   --main-size: responsive side of the square main slider.
   --thumb-rail: computed offset to place the left rail.
   --main-bg-alpha/rgb: backdrop tint behind zoom-box. */
.mobile-product-gallery{
  position: relative;
  --thumb-size: 44px;
  --frame-radius: 14px;
  --main-size: clamp(240px, 72vw, 360px);
  --thumb-rail: calc(var(--thumb-size) + 12px);
  --main-bg-alpha: 0.14;
  --main-bg-rgb: 0,0,0;
  width: var(--main-size);
  margin: 0 auto;
}

/* ===== Main slider square =====
   Fixed square box; rounded corners; masked to avoid iOS overflow glitches. */
.mobile-product-gallery .mobile-gallery-swiper{
  position: relative;
  width: var(--main-size) !important;
  height: var(--main-size) !important;
  margin: 0 auto;
  overflow: hidden !important;
  box-sizing: border-box;
  border-radius: var(--frame-radius);
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  border: none;
  box-shadow: none;
  transition: border-color .3s ease, box-shadow .3s ease;
}

/* Keep visuals stable on press (no additional border/shadow changes). */
.mobile-product-gallery .mobile-gallery-swiper:active{
  border-color: #4b2e2e;
  box-shadow: none;
}

/* === Pinch icon (pulsating animation) ===
   Renders a pinch.svg hint in the top-right corner with a gentle pulse. */
.mobile-product-gallery .mobile-gallery-swiper::before{
  content:"";
  position:absolute;
  right:10px;
  top:10px;
  width:32px;
  height:32px;
  pointer-events:none;
  z-index:210;
  background:no-repeat center/contain url('/wp-content/themes/arcor/assets/svg/pinch.svg');
  opacity:0.95;
  animation: pinchPulse 1.8s ease-in-out infinite;
  filter: drop-shadow(0 0 7px rgba(255,255,255,1))
          drop-shadow(0 0 12px rgba(255,255,255,1))
          drop-shadow(0 0 18px rgba(255,255,255,0.9));
}

@keyframes pinchPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.25); }
}

/* === Conditional Left/Right arrows (extra bold) ===
   Draw both side arrows via a single ::after layer.
   Visibility is controlled with :has(.swiper-slide-prev/.swiper-slide-next).
   Note: :has() is a progressive enhancement; on older browsers, hints may not show. */
.mobile-product-gallery .mobile-gallery-swiper::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index:205;
  background: none;
  opacity: 1; /* fully visible */
  background-size: 36px 28px, 36px 28px;
  background-repeat: no-repeat, no-repeat;
  background-position: left 5px center, right 5px center;
  filter: drop-shadow(0 0 7px rgba(255,255,255,1))
          drop-shadow(0 0 12px rgba(255,255,255,1))
          drop-shadow(0 0 18px rgba(255,255,255,0.9)); /* extra glow */
}

/* Only RIGHT arrow when there is a previous slide but no next slide. */
.mobile-product-gallery .mobile-gallery-swiper:has(.swiper-slide-prev):not(:has(.swiper-slide-next))::after{
  background-image: none, url('/wp-content/themes/arcor/assets/svg/swipe-right.svg');
}

/* Only LEFT arrow when there is a next slide but no previous slide. */
.mobile-product-gallery .mobile-gallery-swiper:has(.swiper-slide-next):not(:has(.swiper-slide-prev))::after{
  background-image: url('/wp-content/themes/arcor/assets/svg/swipe-left.svg'), none;
}

/* Both arrows when there are slides in both directions. */
.mobile-product-gallery .mobile-gallery-swiper:has(.swiper-slide-prev):has(.swiper-slide-next)::after{
  background-image: url('/wp-content/themes/arcor/assets/svg/swipe-left.svg'), url('/wp-content/themes/arcor/assets/svg/swipe-right.svg');
}

/* ===== Swiper internals =====
   Lock inner layers to the same square size; center slide content. */
.mobile-product-gallery .mobile-gallery-swiper .swiper{
  width: var(--main-size) !important;
  height: var(--main-size) !important;
}
.mobile-product-gallery .mobile-gallery-swiper .swiper-wrapper{
  height: var(--main-size) !important;
}
.mobile-product-gallery .mobile-gallery-swiper .swiper-slide{
  width: var(--main-size) !important;
  height: var(--main-size) !important;
  display:flex;
  align-items:center;
  justify-content:center;
}

/* Zoom container: make the zoom plane flexible and unclipped. */
.mobile-product-gallery .swiper-slide .swiper-zoom-container{
  width: 100%;
  height: 100%;
  overflow: visible;
  display:flex;
  align-items:center;
  justify-content:center;
  box-sizing: border-box;
}

/* Zoom box: flat backdrop (not rounded); keeps image centered while zooming. */
.mobile-product-gallery .swiper-slide .zoom-box.swiper-zoom-target{
  width: 100%;
  height: 100%;
  border-radius: 0 !important;
  background: rgba(var(--main-bg-rgb), var(--main-bg-alpha));
  display:flex;
  align-items:center;
  justify-content:center;
  box-sizing: border-box;
  transform-origin: center center !important;
  overflow: hidden;
}

/* Image: contain inside square, centered both axes, inherit radius (if any). */
.mobile-product-gallery .swiper-slide .zoom-box img{
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center center;
  border-radius: inherit;
}

/* Hide pagination bullets for a cleaner mobile look. */
.mobile-product-gallery .mobile-pagination,
.mobile-product-gallery .swiper-pagination{ display:none !important; }

/* ===== Thumbnails rail (LEFT side) =====
   Exactly 5 items tall (JS spaceBetween defines the gaps in between). */
.mobile-product-gallery .mobile-gallery-thumbs{
  position: absolute;
  top: 50%;
  left: calc(-1 * var(--thumb-rail));
  transform: translateY(-50%);
  z-index: 50;
  width: var(--thumb-size);
  height: calc(var(--thumb-size) * 5 + 8px * 4);
  overflow: hidden;
}
.mobile-product-gallery .mobile-gallery-thumbs .swiper-wrapper{
  flex-direction: column !important;
  align-items: center;
}
.mobile-product-gallery .mobile-gallery-thumbs .swiper-slide{
  width: var(--thumb-size) !important;
  height: var(--thumb-size) !important;
  display:flex;
  align-items:center;
  justify-content:center;
  opacity: .6;
  border-radius: 50%;
  cursor:pointer;
  overflow: visible !important;
  border: 2px solid #4b2e2e;
  box-shadow: 0 0 0 rgba(212,175,55,0);
  transition: opacity .25s ease, transform .25s ease, border-color .3s ease, box-shadow .3s ease;
}
.mobile-product-gallery .mobile-gallery-thumbs .swiper-slide:hover{
  border-color: #d4af37;
  box-shadow: 0 0 8px rgba(212,175,55,0.18);
}
.mobile-product-gallery .mobile-gallery-thumbs .swiper-slide-thumb-active{
  opacity: 1;
  transform: scale(1.02);
  border-color: #d4af37;
  box-shadow: 0 0 12px rgba(212,175,55,0.28);
}
.mobile-product-gallery .mobile-gallery-thumbs img{
  width:100%;
  height:100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Hide legacy single-image block (unused on mobile). */
.mobile-product-image{ display:none !important; }

/* ===== Responsive =====
   Desktop (≥768px): hide the mobile gallery entirely.
   Narrow phones (≤480px): pull the left rail slightly closer. */
@media (min-width:768px){
  .mobile-product-gallery{ display:none; }
}

@media (max-width: 480px){
  .mobile-product-gallery .mobile-gallery-thumbs{
    left: calc(-1 * var(--thumb-size) - 4px);
  }
}

/* Ultra-narrow phones (≤360px):
   - Smaller thumbs
   - Closer rail
   - Slightly smaller main square */
@media (max-width: 360px){
  .mobile-product-gallery{
    --thumb-size: 30px;
    --thumb-rail: calc(var(--thumb-size) + 4px);
    --main-size: clamp(220px, 74vw, 340px);
  }
  .mobile-product-gallery .mobile-gallery-thumbs{
    position: absolute !important;
    top: 50% !important;
    left: calc(-1 * var(--thumb-rail)) !important;
    transform: translateY(-50%) !important;
    width: var(--thumb-size) !important;
    height: calc(var(--thumb-size) * 5 + 8px * 4) !important;
    overflow: hidden !important;
  }
  .mobile-product-gallery .mobile-gallery-thumbs .swiper-wrapper{
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 0 !important;
  }
  .mobile-product-gallery .mobile-gallery-thumbs .swiper-slide{
    width: var(--thumb-size) !important;
    height: var(--thumb-size) !important;
    border-width: 1px;
  }
  .mobile-product-gallery .mobile-gallery-thumbs .swiper-slide-thumb-active{
    box-shadow: 0 0 8px rgba(212,175,55,0.24);
  }
}

/* ===== Single-image mode (no-thumbs) =====
   Same square box; zoom clipped inside; no extra frame/shadow. */
.mobile-product-gallery.no-thumbs{
  width: var(--main-size);
  margin-inline: auto !important;
}
.mobile-product-gallery.no-thumbs .mobile-gallery-swiper{
  margin-left: auto !important;
  margin-right: auto !important;
  overflow: hidden !important;
  border-radius: var(--frame-radius);
  -webkit-mask-image: -webkit-radial-gradient(white, black) !important;
  border: none;
  box-shadow: none;
}
.mobile-product-gallery.no-thumbs .mobile-gallery-swiper .swiper,
.mobile-product-gallery.no-thumbs .mobile-gallery-swiper .swiper-wrapper,
.mobile-product-gallery.no-thumbs .mobile-gallery-swiper .swiper-slide{
  overflow: hidden !important;
  border-radius: var(--frame-radius);
}
.mobile-product-gallery.no-thumbs .swiper-slide .swiper-zoom-container{
  overflow: visible !important;
}
.mobile-product-gallery.no-thumbs .swiper-slide .zoom-box{
  background: rgba(var(--main-bg-rgb), var(--main-bg-alpha));
  border-radius: 0 !important;
  overflow: hidden !important;
}
.mobile-product-gallery.no-thumbs .swiper-slide .zoom-box img{
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center center;
  border-radius: inherit;
}

/* Hide the custom mobile gallery on desktop */
@media (min-width:768px){
  .mobile-product-gallery { display:none; }
}

/* Hide WooCommerce's default gallery on phones to avoid duplication */
@media (max-width: 767.98px){
  .woocommerce-product-gallery { display:none !important; }
}