/*
 * Shared storefront product-grid contract.
 *
 * Route styles own only the outer shell/gutter. The product list always stays
 * inside the content box of its immediate parent and uses one responsive
 * column/gap contract on the home page and product-category archives.
 */
:is(
  body.home .storefront-home-products-section:not(.storefront-home-gear-section) ul.products,
  body.storefront-product-archive ul.products.storefront-category-products
) {
  align-items: start;
  column-gap: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  list-style: none;
  margin-left: 0;
  margin-right: 0;
  max-width: 100%;
  padding-left: 0;
  padding-right: 0;
  position: relative;
  row-gap: 0;
  width: 100%;
}

:is(
  body.home .storefront-home-products-section:not(.storefront-home-gear-section) ul.products,
  body.storefront-product-archive ul.products.storefront-category-products
)::before,
:is(
  body.home .storefront-home-products-section:not(.storefront-home-gear-section) ul.products,
  body.storefront-product-archive ul.products.storefront-category-products
)::after {
  content: none;
}

:is(
  body.home .storefront-home-products-section:not(.storefront-home-gear-section) ul.products,
  body.storefront-product-archive ul.products.storefront-category-products
) > li.storefront-product-card {
  align-self: start;
  box-sizing: border-box;
  flex: none;
  float: none;
  margin: 0;
  max-width: none;
  min-width: 0;
  padding-left: 0;
  padding-right: 0;
  width: auto;
}

body.home .storefront-home-products-section:not(.storefront-home-gear-section)
ul.products > li.storefront-product-card {
  margin-bottom: 10px;
  padding-left: 5px;
  padding-right: 5px;
}

@media (min-width: 768px) and (max-width: 1024px) {
  :is(
    body.home .storefront-home-products-section:not(.storefront-home-gear-section) ul.products,
    body.storefront-product-archive ul.products.storefront-category-products
  ) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 321px) and (max-width: 767px) {
  :is(
    body.home .storefront-home-products-section:not(.storefront-home-gear-section) ul.products,
    body.storefront-product-archive ul.products.storefront-category-products
  ) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 550px) {
  body.home .storefront-home-products-section:not(.storefront-home-gear-section)
  ul.products > li.storefront-product-card {
    margin-bottom: 0;
  }
}

@media (max-width: 320px) {
  :is(
    body.home .storefront-home-products-section:not(.storefront-home-gear-section) ul.products,
    body.storefront-product-archive ul.products.storefront-category-products
  ) {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Product-category archives use the collection's fluid card
 * gutters and breakpoints. Keep this route-specific so the independently
 * independent home rails retain their existing grid contract. */
body.storefront-product-archive ul.products.storefront-category-products {
  column-gap: 0 !important;
  max-width: none !important;
  row-gap: 0 !important;
}

body.storefront-product-archive
ul.products.storefront-category-products
> li.storefront-category-card {
  padding: 0 15px 13px !important;
}

body.storefront-product-archive
ul.products.storefront-category-products
> li.storefront-category-card
> .storefront-category-card__inner {
  padding: 0 !important;
}

body.storefront-product-archive
ul.products.storefront-category-products
.storefront-category-card__title {
  margin: 15px 0 8px !important;
}

body.storefront-product-archive
ul.products.storefront-category-products
.storefront-category-card__price {
  margin-bottom: 0 !important;
}

@media (max-width: 1200px) {
  body.storefront-product-archive ul.products.storefront-category-products {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    margin-left: -15px !important;
    width: calc(100% + 30px) !important;
  }
}

@media (max-width: 1025px) {
  body.storefront-product-archive ul.products.storefront-category-products {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 1024px) {
  body.storefront-product-archive ul.products.storefront-category-products {
    margin-left: -8px !important;
    width: calc(100% + 16px) !important;
  }

  body.storefront-product-archive
  ul.products.storefront-category-products
  > li.storefront-category-card {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
}

@media (max-width: 575px) {
  body.storefront-product-archive ul.products.storefront-category-products {
    margin-left: -13px !important;
    width: calc(100% + 26px) !important;
  }

  body.storefront-product-archive
  ul.products.storefront-category-products
  .storefront-category-card__title {
    margin: 8px 0 !important;
  }
}

@media (max-width: 320px) {
  body.storefront-product-archive ul.products.storefront-category-products {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    margin-left: -5px !important;
    width: calc(100% + 10px) !important;
  }

  body.storefront-product-archive
  ul.products.storefront-category-products
  > li.storefront-category-card {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}
