/* Custom product image zoom — desktop side-panel zoom + mobile pinch/pan modal */

/* --- Desktop hover zoom (side panel, not a floating lens) --- */
@media (hover: hover) and (pointer: fine) {
  .product-cover {
    cursor: zoom-in;
  }
}

.ilze-zoom-panel {
  position: fixed;
  z-index: 2000;
  background: #fff;
  background-repeat: no-repeat;
  border-radius: 6px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(0, 0, 0, 0.06);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  display: none;
}

.ilze-zoom-panel.is-active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.ilze-zoom-panel-frame {
  position: absolute;
  inset: 0;
  border: 2px solid #fff;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
  border-radius: 6px;
  pointer-events: none;
}

/* subtle cursor-follow crop indicator on the base image */
.ilze-zoom-cursor-box {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  display: none;
}

.ilze-zoom-cursor-box.is-active {
  display: block;
}

@media (max-width: 991px) {
  .ilze-zoom-panel,
  .ilze-zoom-cursor-box {
    display: none !important;
  }
}

/* --- Mobile: pinch/double-tap zoom directly on the cover image, no modal ---
   The zoomed view is a separate div stacked on top of the original photo,
   not a transform on the photo itself -- see custom-zoom.js for why (the
   original <img> carries a lot of pre-existing CSS from ilze-product-page.css
   that turned out to disagree with a live transform on at least one real
   device, in ways that never reproduced anywhere it could be debugged). */
@media (hover: none), (pointer: coarse) {
  .product-cover.ilze-pinch-zoom {
    /* ilze-product-page.css already sets position:relative and
       overflow:hidden on #ilze-product .product-cover; repeated here so the
       overlay below still positions and clips correctly if that rule (or
       the #ilze-product wrapper) isn't present, e.g. the mini cover inside
       the "write a review" modal. */
    position: relative;
    overflow: hidden;
    /* One finger scrolls the page (vertical) and swipes the gallery
       (horizontal) natively; 2-finger pinches are left to JS (pinch-zoom is
       not in the list, and the touchmove handler cancels them). "none" here
       used to block page scrolling over the whole photo on phones -- the page
       only scrolled when the finger started below it (Kornelija, 2026-10-20).
       Once the photo is zoomed in, every gesture is ours again (panning). */
    touch-action: pan-x pan-y;
  }

  .product-cover.ilze-pinch-zoom.is-zoomed {
    touch-action: none;
  }

  .ilze-pinch-overlay {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transform-origin: center center;
    transition: transform 0.22s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.15s ease;
    opacity: 0;
    pointer-events: none;
    z-index: 2;
  }

  .ilze-pinch-overlay.is-active {
    opacity: 1;
  }

  .ilze-pinch-overlay.is-gesture {
    transition: none;
  }
}

/* --- Modal --- */
.js-product-images-modal .modal-dialog {
  max-width: 96vw;
}

/* The theme's own CSS puts an unconditional margin-left:-35% on
   .modal-body (only reset back to 0 inside a max-width:991px media
   query), sized as a percentage of the dialog's width. That was a minor,
   easy-to-miss few-hundred-pixel overflow at the theme's original small
   default dialog width, but widening the dialog above (for a proper full
   view) turns that same percentage into a huge negative offset that
   shoves the whole image + thumbnail row off-screen to the left. Neutralize
   it at every width, not just the mobile breakpoint the theme covers. */
#product-modal .modal-content .modal-body {
  margin-left: 0 !important;
}

.js-product-images-modal .modal-content {
  background: #fff;
}

.js-product-images-modal .modal-body figure {
  overflow: hidden;
  touch-action: none;
  position: relative;
  background: #fafafa;
}

.js-product-images-modal .product-cover-modal {
  transform-origin: center center;
  transition: transform 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
}

.js-product-images-modal .product-cover-modal.is-zoomed {
  cursor: grab;
}

.js-product-images-modal .product-cover-modal.is-panning {
  cursor: grabbing;
  transition: none;
}

.js-product-images-modal .product-cover-modal.is-gesture {
  transition: none;
}

/* Close button */
.ilze-zoom-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.ilze-zoom-close:hover {
  background: #fff;
  transform: scale(1.06);
}

.ilze-zoom-close .material-icons {
  font-size: 22px;
  color: #232323;
}

/* Image counter */
.ilze-zoom-counter {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 20;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 12px;
  letter-spacing: 0.02em;
}

/* Zoom +/- controls */
.ilze-zoom-controls {
  position: absolute;
  bottom: 18px;
  right: 18px;
  z-index: 20;
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 24px;
  padding: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.ilze-zoom-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.ilze-zoom-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.ilze-zoom-btn .material-icons {
  font-size: 20px;
  color: #232323;
}

@media (max-width: 575px) {
  .ilze-zoom-close {
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
  }
  .ilze-zoom-counter {
    top: 14px;
    left: 14px;
    font-size: 12px;
  }
  .ilze-zoom-controls {
    bottom: 14px;
    right: 14px;
  }
}

.ilze-zoom-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 12px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease;
  white-space: nowrap;
  z-index: 20;
}

.ilze-zoom-hint.is-hidden {
  opacity: 0;
}

/* Smooth entrance for the modal image */
.js-product-images-modal.fade .modal-body figure img {
  transition: opacity 0.25s ease, transform 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Align the comments block's left/right edges with the description tab
   above it -- see the comment in product.tpl's product_footer block for
   the padding math (58px tabs indent minus the module's own 15px). */
.ilze-comments-align {
  padding-left: 43px;
  padding-right: 43px;
}

@media (max-width: 767px) {
  .ilze-comments-align {
    /* mobile tabs indent is 30px (.tabs) + 16px (.tab-content) = 46px,
       minus the module's own 15px */
    padding-left: 31px;
    padding-right: 31px;
  }
}
