/*
  Compatibility layer for Safari ~10 (macOS Sierra era).
  Load after styles.css. Modern browsers are gated with @supports.
*/

/* ---- Aspect-ratio boxes: absolute children collapse to 0 height without this ---- */
.hero {
  height: 0;
  padding-bottom: 28.57142857%; /* 3.5 / 1 */
}

.page-hero-image-only {
  height: 0;
  padding-bottom: 28.57142857%;
}

body .product-media,
body .home-hot-track .product-media {
  height: 0 !important;
  padding-bottom: 100% !important; /* 1 / 1 */
}

.product-media img,
.hero-slider,
.hero-slider picture,
.hero-slide,
.hero-overlay,
.hero-controls {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.hero-slider picture {
  position: absolute;
  display: block;
  width: 100%;
  height: 100%;
}

@media (max-width: 760px) {
  .hero,
  .page-hero-image-only {
    padding-bottom: 50%; /* 2 / 1 */
  }

  body .product-media,
  body .home-hot-track .product-media,
  #hotProductGrid .product-media,
  #categoryProductGrid .product-media,
  #categoryNavGrid .product-media,
  #subcategoryNavGrid .product-media {
    padding-bottom: 100% !important; /* 1 / 1 */
  }
}

@supports (aspect-ratio: 1 / 1) {
  .hero,
  .page-hero-image-only,
  body .product-media,
  body .home-hot-track .product-media {
    height: auto !important;
    padding-bottom: 0 !important;
  }
}

/* ---- Images that only used aspect-ratio for cropping ---- */
.home-gallery-item img,
.about-video-preview,
.about-video-preview img,
.factory-stage-hero img,
.video-preview img,
.detail-video-preview,
.detail-video-preview img,
.image-zoom img {
  height: auto;
  min-height: 1px;
}

/* ---- Gallery: container query / cqw not available ---- */
@supports not (width: 1cqw) {
  .home-gallery-viewport {
    width: 100%;
  }

  .home-gallery-item {
    flex: 0 0 31.5%;
    max-width: 360px;
  }
}

/* inset arrived in Safari 14.1 together with flex gap — use as flex-gap proxy */
@supports not (inset: 0) {
  .utility-bar a + a {
    margin-left: 22px;
  }

  .hot-products-actions > * + * {
    margin-left: 14px;
  }

  .split-heading > * + * {
    margin-left: 28px;
  }

  .home-hot-track > .product-card + .product-card {
    margin-left: 10px;
  }

  .container--catalog .home-hot-track > .product-card + .product-card {
    margin-left: 22px;
  }

  .home-gallery-track > .home-gallery-item + .home-gallery-item {
    margin-left: 14px;
  }

  .factory-thumb-strip > * + * {
    margin-left: 12px;
  }

  #thumbRow button + button,
  .detail-thumb-carousel button + button {
    margin-left: 12px;
  }

  .related-products-track > .product-card + .product-card {
    margin-left: 12px;
  }

  .nav-menu a + a {
    margin-left: 0;
  }
}

/* ---- Sticky + object-fit prefixes ---- */
.site-header {
  position: -webkit-sticky;
  position: sticky;
}

.product-media img {
  -o-object-fit: contain;
  object-fit: contain;
}

.home-category-grid .product-media img:nth-child(2),
.hero-slide,
.home-gallery-item img,
.image-zoom img,
.about-video-preview img,
.factory-stage-hero img,
.video-preview img {
  -o-object-fit: cover;
  object-fit: cover;
}

/* ---- Fixed overlays: reinforce longhand positioning ---- */
.home-gallery-viewer,
.factory-lightbox,
.video-modal,
.factory-stage-gradient,
.video-preview::after {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

/* ---- Width fallbacks when min() is ignored ---- */
@supports not (width: min(1px, 100%)) {
  .container {
    width: 96%;
    max-width: 1180px;
  }

  .container--catalog {
    width: calc(100% - 48px);
    max-width: 100%;
  }

  .home-gallery-viewer-panel {
    width: 96%;
    max-width: 1120px;
  }
}
