/**
 * Product Detail Page - Responsive Styles
 * All media queries consolidated for easier maintenance
 */

/* Below lg (992px) — columns stack, match home page section-card gap (20px) */
@media (max-width: 991.98px) {
  .product-detail-row {
    --bs-gutter-x: 0;
  }

  .product-detail-row > [class*='col-'] {
    margin-bottom: 20px !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .product-detail-row > [class*='col-']:last-child {
    margin-bottom: 0 !important;
  }
}

/* Tablet: 768px and below */
@media (max-width: 768px) {
  .main-image-container {
    aspect-ratio: auto;
    height: auto;
    width: 100%;
    overflow: hidden;
  }

  /* Let Tiny Slider wrappers shrink to content height */
  .main-image-container .tns-outer,
  .main-image-container .tns-inner,
  .main-image-container .tns-slider,
  .main-image-container .tns-item {
    height: auto !important;
  }

  /* Hide stacked slides before TinySlider initializes on mobile.
     height:auto on .main-image-container means overflow:hidden can't clip them —
     the container just grows to fit all images. display:none is the only reliable guard. */
  #productModal:not(.tns-slider) .zoom { display: none; }
  #productModal:not(.tns-slider) .zoom:first-child { display: block; }

  /* Disable zoom effect on touch/small screens */
  .zoom {
    width: 100%;
    height: auto !important;
    cursor: default !important;
    background-image: none !important;
  }

  .zoom img {
    width: 100%;
    height: auto !important;
    object-fit: contain;
    display: block;
    opacity: 1 !important;
  }

  /* Video slide — match .zoom behaviour on mobile */
  .gallery-video-slide {
    height: auto !important;
    aspect-ratio: 4 / 3;
  }

  .gallery-video-slide video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    display: block;
  }

  /* Show video slides in pre-init state same as images */
  #productModal:not(.tns-slider) .gallery-video-slide { display: none; }
  #productModal:not(.tns-slider) .gallery-video-slide:first-child { display: block; }

  /* Video nav thumbnails — match image thumbnail height */
  .gallery-nav-item video {
    width: 100%;
    height: 80px;
    object-fit: cover;
    display: block;
  }

  .gallery-nav-item img {
    height: 80px;
  }

  .gallery-controls button {
    width: 32px;
    height: 32px;
  }

  /* Product card and form */
  .modern-product-card {
    padding: var(--space-md);
  }

  .order-form-frame {
    padding: var(--space-md);
  }

}

/* Mobile: 576px and below */
@media (max-width: 576px) {
  .image-gallery-wrapper {
    min-height: 74px; /* 70px image + 4px padding (2px top + 2px bottom) */
    margin-top: 10px;
  }

  .image-gallery-nav {
    gap: 0;
  }

  .gallery-nav-item {
    padding: 2px;
    /* Reduce container radius to match the smaller thumbnail size */
    border-radius: 3px;
  }

  .gallery-nav-item img,
  .gallery-nav-item video {
    height: 70px;
  }

  .gallery-controls {
    padding: 0 20px;
    /* No top override — base top: 50% + translateY(-50%) centers arrows correctly
       now that the container height is set by aspect-ratio instead of a fixed px value. */
  }

  .gallery-controls button {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
}

/* Small Mobile: 400px and below */
@media (max-width: 400px) {
  .image-gallery-wrapper {
    min-height: 62px; /* 60px image + 2px padding (1px top + 1px bottom) */
  }

  .gallery-nav-item {
    padding: 1px;
    border-radius: 2px;
  }

  .gallery-nav-item img,
  .gallery-nav-item video {
    height: 60px;
  }

  .gallery-controls button {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }

  /* Price options collapse to single column */
  .price-option {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
    text-align: center;
  }

  /* Smaller buttons */
  .btn-action {
    padding: 6px 10px;
    font-size: var(--font-xs);
  }
}
