/* STORE APP Patch 448 - Product/catalog grid desktop max 3 cards per row.
   Source-verified selectors:
   - /product uses .mp-category-products-grid.mp-product-catalog-grid inside .mp-product-catalog-main
   - category pages use .mp-category-products-grid inside .mp-category-layout
   This file is intentionally loaded after the dark/theme recovery patches so older
   responsive grid rules cannot restore 4+ desktop columns. */

/* Product catalog/search page: always max 3 desktop cards. */
body.site-masterpalm #site-main .mp-product-catalog-main .mp-category-products-grid,
body.site-masterpalm #site-main .mp-product-catalog-grid,
body.masterpalm-theme #site-main .mp-product-catalog-main .mp-category-products-grid,
body.masterpalm-theme #site-main .mp-product-catalog-grid,
body.masterpalm-store-dark #site-main .mp-product-catalog-main .mp-category-products-grid,
body.masterpalm-store-dark #site-main .mp-product-catalog-grid,
/* Category pages with side menu/sidebar: max 3 desktop cards. */
body.site-masterpalm #site-main .mp-category-layout .mp-category-products-grid,
body.masterpalm-theme #site-main .mp-category-layout .mp-category-products-grid,
body.masterpalm-store-dark #site-main .mp-category-layout .mp-category-products-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 18px !important;
  align-items: stretch !important;
  width: 100% !important;
  max-width: 100% !important;
}

/* Keep cards from expanding past their grid track. */
body.site-masterpalm #site-main .mp-product-catalog-grid > .mp-product-list-card,
body.site-masterpalm #site-main .mp-category-products-grid > .mp-product-list-card,
body.masterpalm-theme #site-main .mp-product-catalog-grid > .mp-product-list-card,
body.masterpalm-theme #site-main .mp-category-products-grid > .mp-product-list-card,
body.masterpalm-store-dark #site-main .mp-product-catalog-grid > .mp-product-list-card,
body.masterpalm-store-dark #site-main .mp-category-products-grid > .mp-product-list-card {
  min-width: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

/* The product image is background-image based; keep the media block sized. */
body.site-masterpalm #site-main .mp-product-list-card .mp-product-list-media,
body.masterpalm-theme #site-main .mp-product-list-card .mp-product-list-media,
body.masterpalm-store-dark #site-main .mp-product-list-card .mp-product-list-media {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  min-height: 220px !important;
  aspect-ratio: 4 / 3 !important;
  background-repeat: no-repeat !important;
  background-position: center center !important;
  background-size: contain !important;
}

/* Medium/tablet: 2 cards. */
@media (max-width: 1199.98px) {
  body.site-masterpalm #site-main .mp-product-catalog-main .mp-category-products-grid,
  body.site-masterpalm #site-main .mp-product-catalog-grid,
  body.site-masterpalm #site-main .mp-category-layout .mp-category-products-grid,
  body.masterpalm-theme #site-main .mp-product-catalog-main .mp-category-products-grid,
  body.masterpalm-theme #site-main .mp-product-catalog-grid,
  body.masterpalm-theme #site-main .mp-category-layout .mp-category-products-grid,
  body.masterpalm-store-dark #site-main .mp-product-catalog-main .mp-category-products-grid,
  body.masterpalm-store-dark #site-main .mp-product-catalog-grid,
  body.masterpalm-store-dark #site-main .mp-category-layout .mp-category-products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* Phone: 1 card. */
@media (max-width: 575.98px) {
  body.site-masterpalm #site-main .mp-product-catalog-main .mp-category-products-grid,
  body.site-masterpalm #site-main .mp-product-catalog-grid,
  body.site-masterpalm #site-main .mp-category-layout .mp-category-products-grid,
  body.masterpalm-theme #site-main .mp-product-catalog-main .mp-category-products-grid,
  body.masterpalm-theme #site-main .mp-product-catalog-grid,
  body.masterpalm-theme #site-main .mp-category-layout .mp-category-products-grid,
  body.masterpalm-store-dark #site-main .mp-product-catalog-main .mp-category-products-grid,
  body.masterpalm-store-dark #site-main .mp-product-catalog-grid,
  body.masterpalm-store-dark #site-main .mp-category-layout .mp-category-products-grid {
    grid-template-columns: 1fr !important;
  }

  body.site-masterpalm #site-main .mp-product-list-card .mp-product-list-media,
  body.masterpalm-theme #site-main .mp-product-list-card .mp-product-list-media,
  body.masterpalm-store-dark #site-main .mp-product-list-card .mp-product-list-media {
    min-height: 200px !important;
  }
}
