/* BARICO product gallery · 2.3.12
 * Load AFTER jk.css and the existing product-gallery styles.
 * Default mobile breakpoint: 767px (keep JS breakpoint in sync if changed).
 * Tuning: gap, radius, image fit and desktop columns are below.
 */
.bpg-gallery,
.bpg-lightbox {
  --bpg-css-ready: 1;
  --bpg-gap: 8px;
  --bpg-radius: 2rem;
  --bpg-background: transparent;
  --bpg-text: #1a1a1a;
  --bpg-image-fit: cover;
  --bpg-glass: rgba(226, 226, 226, .66);
  --bpg-glass-border: rgba(255, 255, 255, .65);
  color: var(--bpg-text);
  font-family: inherit;
  box-sizing: border-box;
}
.bpg-gallery *,
.bpg-lightbox * { box-sizing: border-box; }

/* Keep both native columns and all product-panel dimensions untouched.
 * Only the contents of the original image column are replaced.
 */
.p-image-wrapper.bpg-hosted {
  padding: 0 !important;
  align-self: start;
}
.p-image-wrapper.bpg-hosted:not(.bpg-single-photo) {
  position: relative !important;
  /* Relative positioning must not retain the native sticky top offset. */
  inset: auto !important;
}
.p-image-wrapper.bpg-hosted > :not(.bpg-column) {
  display: none !important;
}
.p-image-wrapper.bpg-hosted > .bpg-column { display: block !important; }
.p-image-wrapper.bpg-hosted > .bpg-column[hidden],
.bpg-column[hidden],
.bpg-thumbnails[hidden],
.bpg-gallery[hidden],
dialog.bpg-lightbox:not([open]) { display: none !important; }

.p-detail-inner.bpg-active { overflow-anchor: none; }
.bpg-column {
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.bpg-gallery { position: relative; display: block; width: 100%; min-width: 0; margin: 0; padding: 0; background: transparent; border: 0; box-shadow: none; }
.bpg-gallery .bpg-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--bpg-gap);
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
}
.bpg-gallery .bpg-photo {
  position: relative;
  display: block;
  grid-column: span 1;
  width: 100%;
  min-width: 0;
  height: auto;
  aspect-ratio: 1 / 1;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(0 round var(--bpg-radius));
  border: 0;
  border-radius: var(--bpg-radius);
  background: var(--bpg-background);
  box-shadow: none;
  color: inherit;
  cursor: zoom-in;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}
.bpg-gallery .bpg-photo::before,
.bpg-gallery .bpg-photo::after { display: none; }
.bpg-gallery .bpg-photo-wide { grid-column: 1 / -1; aspect-ratio: 4 / 3; }
.bpg-gallery .bpg-photo-first .bpg-image { object-fit: contain !important; }
/* The script chooses one, two or three cells per row for the available area.
 * Minimum cell sizes prevent thin strips. The product photo stays contained.
 */
@media (min-width: 768px) {
  .p-image-wrapper.bpg-hosted.bpg-single-photo {
    position: sticky !important;
    top: var(--bpg-sticky-top, 85px);
    align-self: start;
  }
  .bpg-column.bpg-fit-height {
    align-self: start;
    /* The native flex row must get its height from the product panel alone.
     * Otherwise this mosaic stretches the panel it measures, creating a
     * pixel-by-pixel ResizeObserver feedback loop when a step collapses.
     * Children paint into that panel-sized row; single-photo sticky and
     * mobile galleries keep their normal in-flow height.
     */
    height: 0;
    min-height: 0;
    overflow: visible;
  }
  .bpg-column.bpg-fit-height > .bpg-gallery {
    position: relative;
    height: auto;
    min-height: 0;
  }
  .bpg-column .bpg-gallery .bpg-track {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    height: var(--bpg-desktop-height, auto);
    min-height: 0;
    align-content: start;
    grid-template-rows: var(--bpg-desktop-rows);
    row-gap: var(--bpg-desktop-row-gap, var(--bpg-gap));
  }
  .bpg-column .bpg-gallery .bpg-photo {
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
  }
  .bpg-gallery .bpg-photo-extra { display: none; }
}
.bpg-thumbnails {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  height: 80px;
  overflow-x: auto;
  scrollbar-width: none;
}
.bpg-thumbnails::-webkit-scrollbar { display: none; }
.bpg-gallery .bpg-thumbnail {
  position: relative;
  flex: 0 0 80px;
  width: 80px;
  height: 80px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  clip-path: inset(0 round 12px);
  background: transparent;
  box-shadow: none;
  cursor: zoom-in;
}
.bpg-thumbnail img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  border-radius: inherit;
}
.bpg-gallery .bpg-image {
  position: absolute !important;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0;
  box-shadow: none;
  border-radius: inherit;
  object-fit: var(--bpg-image-fit);
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}
.bpg-gallery .bpg-photo-hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--bpg-glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: opacity .15s;
}
.bpg-photo-hint svg { display: block; width: 18px; height: 18px; }
.bpg-gallery .bpg-infobar { display: none; }
.bpg-infobar {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  width: max-content;
  max-width: calc(100% - 24px);
  min-height: 40px;
  padding: 2px 10px;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  background: var(--bpg-glass);
  -webkit-backdrop-filter: blur(16px) saturate(135%);
  backdrop-filter: blur(16px) saturate(135%);
  box-shadow: none;
  line-height: 1;
}
.bpg-infobar .bpg-control,
.bpg-infobar .bpg-dot {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  color: var(--bpg-text);
  cursor: pointer;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}
.bpg-control svg { display: block; width: 18px; height: 18px; }
.bpg-infobar .bpg-control:disabled { opacity: .25; cursor: default; }
.bpg-dots {
  position: relative;
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  width: calc(var(--bpg-dot-count, 1) * 20px);
  min-width: 0;
  max-width: none;
  overflow: hidden;
  scrollbar-width: none;
}
.bpg-dots::-webkit-scrollbar { display: none; }
.bpg-infobar .bpg-dot { flex: 1 1 0; width: 20px; height: 36px; }
.bpg-dot::before {
  display: block;
  width: 6px;
  max-width: 90%;
  height: 6px;
  border-radius: 99px;
  background: currentColor;
  opacity: .24;
  content: '';
  transition: width .15s, opacity .15s;
}
.bpg-dot[aria-current="true"]::before { width: 16px; opacity: 1; }
.bpg-infobar.bpg-single { display: none !important; }
.bpg-gallery button:focus-visible,
.bpg-gallery .bpg-track:focus-visible,
.bpg-lightbox button:focus-visible,
.bpg-lightbox a:focus-visible,
.bpg-lightbox-track:focus-visible {
  outline: 2px solid var(--bpg-text);
  outline-offset: -3px;
}
.bpg-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.bpg-gallery .bpg-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  padding: 30px;
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

/* Full-screen image viewer. Close button matches BARICO's delivery/cart popup. */
dialog.bpg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: block;
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  overscroll-behavior: contain;
}
dialog.bpg-lightbox::backdrop { background: #fff; }
.bpg-lightbox .bpg-close,
.bpg-lightbox .bpg-zoom {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(235, 235, 235, .70);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  box-shadow: none;
  color: #1a1a1a;
  cursor: pointer;
  appearance: none;
}
.bpg-lightbox .bpg-zoom { right: max(68px, calc(env(safe-area-inset-right) + 48px)); }
.bpg-lightbox .bpg-close svg,
.bpg-lightbox .bpg-zoom svg { display: block; width: 20px; height: 20px; }
.bpg-lightbox-track {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  gap: 0;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.bpg-lightbox-track::-webkit-scrollbar { display: none; }
.bpg-lightbox-slide {
  position: relative;
  display: flex;
  flex: 0 0 100%;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.bpg-lightbox-viewport {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: none;
  border-radius: var(--bpg-radius);
  clip-path: inset(0 round var(--bpg-radius));
  overflow: hidden;
  margin: 0 auto;
  scrollbar-width: none;
}
.bpg-lightbox .bpg-lightbox-image {
  display: block;
  flex: 0 1 auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
  object-fit: contain;
  border-radius: inherit;
  user-select: none;
  -webkit-user-drag: none;
}
.bpg-lightbox.bpg-zoomed .bpg-lightbox-track { overflow: hidden; }
.bpg-lightbox.bpg-zoomed .bpg-lightbox-viewport {
  display: block;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto !important;
  touch-action: pinch-zoom;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}
.bpg-lightbox.bpg-zoomed .bpg-lightbox-image { width: 200%; height: 200%; max-width: none; max-height: none; margin: 0; }
.bpg-lightbox .bpg-infobar { bottom: max(18px, env(safe-area-inset-bottom)); }
@media (min-width: 768px) {
  .bpg-lightbox-slide { padding: 24px 0; }
  .bpg-lightbox .bpg-infobar {
    left: var(--bpg-modal-bar-left, 50%);
    bottom: var(--bpg-modal-bar-bottom, 72px);
    max-width: var(--bpg-modal-bar-width, calc(100% - 24px));
  }
}
.bpg-load-error {
  position: absolute;
  inset: 80px 20px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  background: #fff;
  font-size: 14px;
  text-align: center;
}
.bpg-load-error a { color: inherit; text-decoration: underline; }

@media (hover: hover) {
  .bpg-gallery .bpg-photo-hint { opacity: 0; }
  .bpg-gallery .bpg-photo:hover .bpg-photo-hint,
  .bpg-gallery .bpg-photo:focus-visible .bpg-photo-hint { opacity: 1; }
  .bpg-infobar .bpg-control:not(:disabled):hover { background: rgba(255, 255, 255, .6); }
  .bpg-lightbox .bpg-close:hover,
  .bpg-lightbox .bpg-zoom:hover { background: rgba(218, 218, 218, .70); }
}
@media (max-width: 767px) {
  .p-image-wrapper.bpg-hosted { order: 0 !important; }
  .p-image-wrapper.bpg-hosted > .bpg-column {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    align-self: stretch;
  }
  .bpg-gallery {
    --bpg-image-fit: contain;
    /* Keep a real gap above the next banner; padding cannot collapse. */
    padding-bottom: var(--bpg-mobile-footer-space, 86px);
  }
  .bpg-gallery .bpg-track {
    display: flex;
    gap: 12px;
    padding: 0 12px;
    height: var(--bpg-mobile-height, auto);
    transition: none;
    touch-action: pan-y pinch-zoom;
    scroll-behavior: auto !important;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: 0;
    clip-path: none;
    scroll-snap-type: none;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }
  .bpg-gallery .bpg-track::-webkit-scrollbar { display: none; }
  .bpg-gallery .bpg-photo,
  .bpg-gallery .bpg-photo-wide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: var(--bpg-radius);
    scroll-snap-align: start;
    scroll-snap-stop: always;
    isolation: isolate;
    transform: translateZ(0);
  }
  /* Match the visible image to its rounded card while the carousel height
   * changes between aspect ratios; contain would expose square inner edges.
   */
  .bpg-gallery .bpg-photo:not(.bpg-photo-first) .bpg-image {
    object-fit: cover;
    clip-path: inset(0 round var(--bpg-radius));
  }
  .bpg-gallery .bpg-photo-hint { display: none; }
  .bpg-gallery .bpg-thumbnails { display: none; }
  .bpg-gallery .bpg-infobar {
    position: absolute;
    display: flex;
    left: 50%;
    top: calc(var(--bpg-mobile-height, 0px) + var(--bpg-mobile-bar-offset, 16px));
    bottom: auto;
    transform: translateX(-50%);
    gap: 6px;
    min-height: 46px;
    padding: 4px 12px;
    margin: 0;
  }
  .bpg-lightbox .bpg-close,
  .bpg-lightbox .bpg-zoom {
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
  }
  .bpg-lightbox .bpg-zoom {
    left: max(16px, env(safe-area-inset-left));
    right: auto;
  }
  /* Gutters travel with each slide, not with the scroll viewport. */
  .bpg-lightbox-slide { padding: 10px; }
}
@media (max-width: 359px) {
  .bpg-infobar { gap: 1px; padding: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .bpg-gallery *, .bpg-lightbox * { transition: none !important; scroll-behavior: auto !important; }
}
