/* ================================================================
   RaceStage — Mobile gallery (product page)
   Affects ONLY @media (max-width: 767px). Desktop unchanged.
   To roll back: remove the two <link>/<script> lines in product.twig.
   ================================================================ */

/* Hidden on desktop — shown only via the @media block below */
.rs-mobile-gallery { display: none; }

@media (max-width: 767px) {

  /* Hide the existing gallery on mobile */
  .xzoom-container { display: none !important; }

  /* Show mobile gallery */
  .rs-mobile-gallery { display: block; }

  /* ── Main image wrapper ── */
  .rs-mobile-main-wrap {
    position: relative;
    width: 100%;
  }

  /* Slide: aspect-ratio locks proportions (no CLS), white bg so contain doesn't show gray borders */
  .rs-mobile-slides .rs-mobile-slide {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    background: #fff;
    cursor: pointer;
    display: block;
    overflow: hidden;
  }
  /* Override .owl-carousel img { width:60px !important; height:60px !important } from racestage-product.css:526 */
  .rs-mobile-gallery .rs-mobile-slide img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    object-fit: contain !important;
    display: block !important;
    pointer-events: none;
  }
  /* Prevent Owl from locking a calculated px height on the stage */
  .rs-mobile-gallery .owl-stage-outer { height: auto !important; }

  /* ── Counter badge (bottom-right) ── */
  .rs-mobile-counter {
    position: absolute;
    bottom: 8px;
    right: 10px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 12px;
    line-height: 1.4;
    padding: 3px 8px;
    border-radius: 10px;
    pointer-events: none;
    z-index: 2;
  }

  /* ── Thumbnail strip ── */
  .rs-mobile-thumbs {
    display: flex;
    gap: 6px;
    padding: 8px 0 4px;
  }
  .rs-mobile-thumb {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    background: none;
    padding: 0;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    outline: none;
  }
  .rs-mobile-thumb.rs-active {
    border-color: #ff5000;
  }
  .rs-mobile-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
  }

  /* ── "+N photos" overlay on last visible thumbnail ── */
  .rs-thumb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    pointer-events: none;
  }
  .rs-thumb-n {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.1;
  }
  .rs-thumb-label {
    font-size: 10px;
    opacity: .85;
    line-height: 1.2;
  }

  /* ── Owl Carousel dots (shown only if ≤8 images, controlled by JS) ── */
  .rs-mobile-gallery .owl-dots {
    text-align: center;
    padding: 4px 0 0;
  }
  .rs-mobile-gallery .owl-dot span {
    background: #ccc;
  }
  .rs-mobile-gallery .owl-dot.active span {
    background: #ff5000;
  }

  /* ── Owl nav arrows: min 44×44 px touch target ── */
  .rs-mobile-gallery .owl-nav {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
  }
  .rs-mobile-gallery .owl-nav button {
    pointer-events: all;
    min-width: 44px !important;
    min-height: 44px !important;
    width: 44px !important;
    height: 44px !important;
    background: rgba(0, 0, 0, .4) !important;
    color: #fff !important;
    border-radius: 50% !important;
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 3;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    margin: 0 !important;
  }
  .rs-mobile-gallery .owl-nav button.owl-prev { left: 4px !important; }
  .rs-mobile-gallery .owl-nav button.owl-next { right: 4px !important; }
  .rs-mobile-gallery .owl-nav button span {
    font-size: 14px !important;
    color: #fff !important;
    line-height: 1 !important;
    display: block !important;
  }
}
