/* Controls never alter desktop gallery layout. Every image remains in the existing DOM. */
.zingies-gallery-controls,
.zingies-gallery-nav { display: none; }

@media (max-width: 921px) {
  /* Reserve the original Astra square before its synchronous tiny-slider initialization. */
  html.zingies-mobile-gallery-js .woocommerce div.product.ast-product-gallery-layout-first-image-large .woocommerce-product-gallery:not(.woocommerce-product-gallery--wpcvi) > .woocommerce-product-gallery__wrapper:not(.tns-slider),
  .woocommerce div.product.ast-product-gallery-layout-first-image-large .zingies-variation-carousel > .woocommerce-product-gallery__wrapper {
    display: flex;
    flex-wrap: nowrap;
    margin: 0;
  }

  html.zingies-mobile-gallery-js .woocommerce div.product.ast-product-gallery-layout-first-image-large .woocommerce-product-gallery:not(.woocommerce-product-gallery--wpcvi) > .woocommerce-product-gallery__wrapper:not(.tns-slider) {
    overflow: hidden;
  }

  .woocommerce div.product.ast-product-gallery-layout-first-image-large .zingies-variation-carousel > .woocommerce-product-gallery__wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .zingies-variation-carousel > .woocommerce-product-gallery__wrapper::-webkit-scrollbar { display: none; }

  html.zingies-mobile-gallery-js .woocommerce div.product.ast-product-gallery-layout-first-image-large .woocommerce-product-gallery:not(.woocommerce-product-gallery--wpcvi) > .woocommerce-product-gallery__wrapper:not(.tns-slider) > .woocommerce-product-gallery__image,
  .woocommerce div.product.ast-product-gallery-layout-first-image-large .zingies-variation-carousel > .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image {
    flex: 0 0 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    scroll-snap-align: start;
  }

  html.zingies-mobile-gallery-js .woocommerce div.product.ast-product-gallery-layout-first-image-large .woocommerce-product-gallery:not(.woocommerce-product-gallery--wpcvi) > .woocommerce-product-gallery__wrapper:not(.tns-slider) > .woocommerce-product-gallery__image > a,
  .woocommerce div.product.ast-product-gallery-layout-first-image-large .zingies-variation-carousel > .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image > a {
    display: block;
    position: relative;
    aspect-ratio: 1 / 1;
  }

  html.zingies-mobile-gallery-js .woocommerce div.product.ast-product-gallery-layout-first-image-large .woocommerce-product-gallery:not(.woocommerce-product-gallery--wpcvi) > .woocommerce-product-gallery__wrapper:not(.tns-slider) > .woocommerce-product-gallery__image > a > img:not(.zoomImg),
  .woocommerce div.product.ast-product-gallery-layout-first-image-large .zingies-variation-carousel > .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image > a > img:not(.zoomImg) {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* WPC previously showed complete images: preserve rectangular content inside the reserved square. */
  .woocommerce div.product.ast-product-gallery-layout-first-image-large .zingies-variation-carousel > .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image > a > img:not(.zoomImg) {
    object-fit: contain;
  }

  .zingies-variation-carousel { position: relative; }
  .zingies-variation-carousel .zingies-gallery-controls,
  .zingies-variation-carousel .zingies-gallery-nav { display: block; }
  .zingies-variation-carousel .zingies-gallery-controls button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 100%;
    background: var(--ast-global-color-5, #fff);
    color: var(--ast-global-color-0, #000);
    box-shadow: 0 0 5px #0004;
    z-index: 1;
  }
  .zingies-gallery-controls button[data-direction="previous"] { left: 10px; }
  .zingies-gallery-controls button[data-direction="next"] { right: 10px; }
  .zingies-gallery-controls button::after {
    content: "";
    position: absolute;
    top: 9px;
    left: 7px;
    width: 9px;
    height: 9px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: rotate(45deg);
  }
  .zingies-gallery-controls button[data-direction="previous"]::after {
    left: 11px;
    transform: rotate(-135deg);
  }
  .zingies-gallery-controls button:disabled { visibility: hidden; }
  .zingies-variation-carousel .zingies-gallery-nav {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 1em;
    text-align: center;
    z-index: 1;
  }
  .zingies-gallery-nav button {
    width: 10px;
    min-width: 0;
    height: 10px;
    padding: 0;
    margin: 0 5px;
    border: 0;
    border-radius: 100%;
    background: var(--ast-global-color-0, #000);
    opacity: .45;
  }
  .zingies-gallery-nav button[aria-current="true"] { opacity: 1; }
  .zingies-gallery-controls button:focus-visible,
  .zingies-gallery-nav button:focus-visible { outline: 2px solid #111; outline-offset: 3px; }
}
