/*
 * Single product page: image strip and product video
 * (woocommerce/single-product/add-to-cart/variable.php, function/oba-product.php)
 */

/* ---------- Image strip: edge to edge, above the size section ---------- */

.oba-product-slider-cell {
  padding: 0 !important;
  border-left: 0 !important;
  border-right: 0 !important;
}

/*
 * One height for every image; each slide is as wide as its own image
 * (--ratio = width / height), so nothing is stretched or cropped.
 */
.oba-product-slider {
  --oba-slide-h: clamp(360px, 46vw, 720px);

  position: relative;
  width: 100%;
  height: var(--oba-slide-h);
  overflow: hidden;
}

/*
 * The strip sits inside the variations table. Taken out of the flow, its
 * long row of images cannot push the table wider than the page.
 */
.oba-product-slider__track {
  position: absolute;
  inset: 0;
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.oba-product-slider__track::-webkit-scrollbar {
  display: none;
}

.oba-product-slide {
  flex: 0 0 auto;
  width: calc(var(--oba-slide-h) * var(--ratio, 0.5625));
  height: var(--oba-slide-h);
  scroll-snap-align: start;
  background: #e9e9e9;
}

#primary .oba-product-slide img,
.oba-product-slide img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  /* Dragging the strip must not start a native image drag. */
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

/* Once Slick has started (js/oba.js) it owns the strip. */
.oba-product-slider__track.slick-initialized {
  display: block;
  overflow: visible;
  scroll-snap-type: none;
}

.oba-product-slider__track.slick-initialized .slick-list {
  height: 100%;
  overflow: hidden;
  cursor: grab;
}

.oba-product-slider__track.slick-initialized .slick-list.dragging {
  cursor: grabbing;
}

.oba-product-slider__track.slick-initialized .slick-track {
  display: flex;
  will-change: transform;
}

.oba-product-slider__track.slick-initialized .slick-slide {
  float: none;
  height: var(--oba-slide-h);
  outline: none;
}

/* Arrows lie over the strip, at its edges. */
.oba-product-slider .oba-product-slider__arrow {
  all: unset;
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  color: #fff;
  cursor: pointer;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.55));
  transition: opacity 0.2s ease;
}

.oba-product-slider .oba-product-slider__arrow--prev {
  left: 12px;
}

.oba-product-slider .oba-product-slider__arrow--next {
  right: 12px;
}

.oba-product-slider .oba-product-slider__arrow:hover {
  opacity: 0.7;
}

.oba-product-slider .oba-product-slider__arrow:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.oba-product-slider .oba-product-slider__arrow svg {
  display: block;
  width: 12px;
  height: auto;
  overflow: visible;
}

/* The theme fills every svg with the text colour: these are strokes only. */
.oba-product-slider .oba-product-slider__arrow svg path {
  fill: none !important;
  stroke: currentColor;
}

/* Slick writes an inline "display" on its arrows: keep ours in charge. */
.oba-product-slider .oba-product-slider__arrow.slick-arrow {
  display: grid !important;
}

.oba-product-slider .oba-product-slider__arrow.slick-hidden {
  display: none !important;
}

/* ---------- Video (or product image) beside the size options ---------- */

/* Fills its half of the row: no padding, margin or frame around it. */
#below-variation-row #bottom-image-carousel:has(.oba-product-media) {
  padding: 0;
}

/*
 * The row's negative gutter margins would push the now unpadded media past
 * the edge of the screen.
 */
#below-variation-row:has(.oba-product-media) {
  margin-left: 0;
  margin-right: 0;
}

/* The wrappers the old slider sat in must not inset or frame it either. */
#below-variation-row #bottom-image-carousel:has(.oba-product-media) .mobile-table-full-width,
#below-variation-row #bottom-image-carousel:has(.oba-product-media) .image-slider-desktop {
  width: 100%;
  max-width: none;
  padding: 0;
  border: 0;
}

.oba-product-media {
  width: 100%;
  margin: 0;
  border: 0;
  line-height: 0;
}

#primary .oba-product-media img,
.oba-product-media img,
.oba-product-media video {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
}

/* ---------- Mobile ---------- */

@media (max-width: 767px) {
  .oba-product-slider {
    --oba-slide-h: min(118vw, 560px);
  }

  /*
   * On phones js/script.js moves the media into the padded size column:
   * stretch it back out to the full width of the screen.
   */
  #below-variation-row #bottom-image-carousel:has(.oba-product-media) {
    width: 100vw;
    max-width: none;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    flex: 0 0 auto;
    /* The divider between the two desktop columns has no place here. */
    border: 0;
  }

  /* Swipe only. */
  .oba-product-slider .oba-product-slider__arrow,
  .oba-product-slider .oba-product-slider__arrow.slick-arrow {
    display: none !important;
  }

}
