.jpfv3-product-gallery {
  --jpfv3-gallery-accent: #ed7900;
  --jpfv3-gallery-ink: #24180f;
  position: relative;
  width: 100%;
  min-width: 0;
}

.jpfv3-product-gallery__stage {
  position: relative;
  display: grid;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(232, 108, 0, 0.42);
  border-radius: 16px;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 164, 70, 0.2), transparent 34%),
    radial-gradient(circle at 50% 44%, #fff 0%, #f8f1e8 62%, #e8d5c2 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -12px 30px rgba(232, 108, 0, 0.1),
    0 0 0 1px rgba(255, 151, 51, 0.12),
    0 10px 22px rgba(64, 31, 8, 0.2),
    0 0 28px rgba(232, 108, 0, 0.2);
  cursor: grab;
  isolation: isolate;
  touch-action: pan-y;
  user-select: none;
}

.jpfv3-product-gallery__stage::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 180, 96, 0.18), transparent 28%, transparent 72%, rgba(232, 108, 0, 0.1));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
  content: "";
  pointer-events: none;
}

.jpfv3-product-gallery.is-dragging-image .jpfv3-product-gallery__stage {
  cursor: grabbing;
}

.jpfv3-product-gallery__main-link {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  -webkit-user-drag: none;
}

.jpfv3-product-gallery__image {
  position: absolute;
  inset: 0;
  display: block !important;
  box-sizing: border-box;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  object-position: center;
  -webkit-user-drag: none;
}

.jpfv3-product-gallery__thumbs {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  padding: 4px 3px 9px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-color: rgba(237, 121, 0, 0.7) transparent;
  scrollbar-width: thin;
}

.jpfv3-product-gallery__thumb {
  display: grid;
  flex: 0 0 76px;
  width: 76px;
  height: 76px;
  margin: 0;
  padding: 6px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(78, 50, 28, 0.18);
  border-radius: 12px;
  background: radial-gradient(circle at 50% 42%, #fff 0%, #f7f1e9 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 5px 12px rgba(35, 24, 16, 0.13);
  cursor: pointer;
  opacity: 0.68;
  transition: border-color 180ms ease, box-shadow 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.jpfv3-product-gallery__thumb:hover,
.jpfv3-product-gallery__thumb.is-active {
  border-color: var(--jpfv3-gallery-accent);
  box-shadow: inset 0 1px 0 #fff, 0 0 0 1px rgba(237, 121, 0, 0.16), 0 7px 15px rgba(35, 24, 16, 0.18);
  opacity: 1;
  transform: translateY(-2px);
}

.jpfv3-product-gallery__thumb:focus-visible,
.jpfv3-product-gallery__scrubber:focus-visible {
  outline: 3px solid rgba(237, 121, 0, 0.38);
  outline-offset: 3px;
}

.jpfv3-product-gallery__thumb img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
}

.jpfv3-product-gallery__scrubber {
  position: relative;
  height: 7px;
  margin: 12px 8px 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(70, 45, 27, 0.2), rgba(255, 255, 255, 0.68));
  box-shadow: inset 0 1px 2px rgba(45, 26, 14, 0.28), 0 1px 0 rgba(255, 255, 255, 0.82);
  cursor: grab;
  touch-action: none;
}

.jpfv3-product-gallery__scrubber::before {
  position: absolute;
  inset: -12px 0;
  content: "";
}

.jpfv3-product-gallery__scrubber-rail {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
}

.jpfv3-product-gallery__scrubber-thumb {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(180deg, #ffb35c 0%, #e86c00 60%, #b14f00 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48), 0 0 13px rgba(232, 108, 0, 0.48);
  transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 180ms ease;
  will-change: transform;
}

.jpfv3-product-gallery__scrubber:hover .jpfv3-product-gallery__scrubber-thumb,
.jpfv3-product-gallery__scrubber.is-dragging .jpfv3-product-gallery__scrubber-thumb {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 0 20px rgba(255, 140, 40, 0.78);
}

.jpfv3-product-gallery__scrubber.is-dragging {
  cursor: grabbing;
}

.jpfv3-product-gallery__scrubber.is-dragging .jpfv3-product-gallery__scrubber-thumb {
  transition-duration: 0ms;
}

.jpfv3-product-gallery--card .jpfv3-product-gallery__stage {
  height: calc(var(--jpfv3-product-media-height, 220px) - 22px);
  border-radius: 12px;
}

.jpfv3-product-gallery--card .jpfv3-product-gallery__thumbs {
  display: none;
}

.jpfv3-product-gallery--card .jpfv3-product-gallery__scrubber {
  margin: 11px 7px 4px;
}

.jpfv3-shell .jpf-product-card__media--gallery {
  display: block;
}

.jpfv3-product-gallery--page .jpfv3-product-gallery__stage,
.jpfv3-product-gallery--quick-view .jpfv3-product-gallery__stage {
  aspect-ratio: 1 / 1;
}

.jpfv3-product-gallery--page .jpfv3-product-gallery__image,
.jpfv3-product-gallery--quick-view .jpfv3-product-gallery__image {
  inset: auto;
  top: 50%;
  left: 50%;
  width: auto !important;
  height: auto !important;
  max-width: calc(100% - 44px) !important;
  max-height: calc(100% - 44px) !important;
  padding: 0;
  transform: translate(-50%, -50%);
}

.jpfv3-product-gallery--quick-view {
  width: min(100%, 520px);
  margin-inline: auto;
}

body.single-product .fusion-woo-product-images:has(.jpfv3-fitment-product-gallery),
body.single-product .fusion-woo-product-images:has(.jpfv3-fitment-product-gallery) .avada-single-product-gallery-wrapper,
body.single-product .woocommerce-product-gallery.jpfv3-fitment-product-gallery {
  flex: 1 1 100%;
  width: 100% !important;
  max-width: 100%;
  min-width: 0;
  margin-bottom: 0 !important;
}

/* Do not let Avada stretch the gallery to match the taller product-details column. */
body.single-product .fusion-woo-product-images:has(.jpfv3-fitment-product-gallery) {
  flex: 0 0 auto;
}

/* Keep the fitment CTA and product references compact on the details side. */
body.single-product .jps-product-fitment-link + .fusion-separator {
  margin-top: 30px !important;
  margin-bottom: 30px !important;
}

body.single-product .woocommerce-product-gallery.jpfv3-fitment-product-gallery .woocommerce-product-gallery__wrapper,
body.single-product .woocommerce-product-gallery.jpfv3-fitment-product-gallery .jpfv3-product-gallery-slide,
body.single-product .woocommerce-product-gallery.jpfv3-fitment-product-gallery .jpfv3-product-gallery {
  flex: 1 1 100%;
  width: 100% !important;
  max-width: 100%;
  min-width: 0;
}

body.single-product .woocommerce-product-gallery.jpfv3-fitment-product-gallery .jpfv3-product-gallery-slide {
  margin: 0;
}

body.single-product .woocommerce-product-gallery.jpfv3-fitment-product-gallery .jpfv3-product-gallery--page {
  width: min(100%, 480px) !important;
  max-width: 480px;
  margin-inline: auto;
}

body.single-product .jpf-secondary-product-image {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  max-height: 440px;
  margin: 10px auto 0;
  padding: clamp(12px, 2vw, 22px);
  border: 1px solid rgba(78, 50, 28, 0.14);
  border-radius: 18px;
  background: radial-gradient(circle at 50% 42%, #fff 0%, #f7f1e9 62%, #e8dbcc 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 12px 24px rgba(28, 18, 10, 0.18);
  object-fit: contain;
}

@media (max-width: 720px) {
  .jpfv3-product-gallery__thumb {
    flex-basis: 64px;
    width: 64px;
    height: 64px;
  }

  body.single-product .jpf-secondary-product-image {
    max-height: 360px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .jpfv3-product-gallery__thumb,
  .jpfv3-product-gallery__scrubber-thumb {
    transition: none;
  }
}
