/* Product artwork across commerce surfaces. Load after the other theme assets.
   Target product components rather than upload paths: remote/new images receive
   the same framing, while logos, payment icons, banners and QR codes are untouched. */

/* Catalogue cards, related products, home feed and cart recommendations. */
.sm-body .cm-product-tile .cm-product-art {
  aspect-ratio: 4 / 3;
  overflow: hidden;
}
.sm-body .cm-catalogue-grid .cm-product-tile .cm-product-art > img:not(.cm-product-art-backdrop),
.sm-body .cm-product-tile .cm-product-art > img:not(.cm-product-art-backdrop) {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center;
}
.sm-body .cm-feed-product > img,
.sm-body .cm-cart-recommendation > img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center;
}
.sm-body .cm-home-pack-art {
  aspect-ratio: 4 / 3;
  overflow: hidden;
}
.sm-body .cm-home-pack-art > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* The wide featured card retains its two-column layout. Keep the 4:3 image
   centered over its existing blurred backdrop, which fills the whole column. */
@media (min-width: 1350px) {
  .sm-body .cm-catalogue-featured .cm-product-tile .cm-product-art {
    align-self: stretch;
    min-height: 100%;
    height: auto;
    aspect-ratio: auto;
  }
  .sm-body .cm-catalogue-featured .cm-product-tile .cm-product-art > img:not(.cm-product-art-backdrop) {
    position: relative;
    inset: auto;
    height: auto;
  }
}

/* Older product/group components can still be selected in the theme editor.
   These important dimensions replace their earlier important auto sizing. */
.sm-body .sm-product-card .sm-product-card-media,
.sm-body .sm-product-group-card .sm-product-card-media {
  aspect-ratio: 4 / 3 !important;
  overflow: hidden;
}
.sm-body .sm-product-card .sm-product-card-media > img,
.sm-body .sm-product-group-card .sm-product-card-media > img {
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center;
}
.sm-body .sm-group-product-preview > img,
.sm-body [x-data="cartPage"] img.object-product-image {
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center;
}
.sm-body .sm-group-product-preview { width: 48px; height: 36px; }
.sm-body .sm-group-modal-product .sm-group-modal-product-media {
  align-self: center;
  height: auto;
  min-height: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}
.sm-body .sm-group-modal-product .sm-group-modal-product-media > img {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center;
}

/* Cart drawer uses an img; the full cart page uses a span containing an img. */
.sm-body .sm-cart-item {
  grid-template-columns: 96px minmax(0, 1fr) auto;
}
.sm-body .sm-cart-item-image {
  display: grid;
  place-items: center;
  align-self: center;
  width: 96px;
  height: 72px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 12px;
  object-fit: cover;
  object-position: center;
}
.sm-body .sm-cart-item-image > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: inherit;
}

/* Checkout has later inline styles; the scoped selector keeps the thumbnail
   framed without changing the payment controls or their imagery. */
.sm-body .sm-checkout-page .sm-checkout-line {
  grid-template-columns: 72px minmax(0, 1fr) auto;
}
.sm-body .sm-checkout-page .sm-checkout-line-image {
  display: grid;
  place-items: center;
  align-self: center;
  flex: 0 0 72px;
  width: 72px;
  height: 54px;
  min-height: 0;
  padding: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 12px;
}
.sm-body .sm-checkout-page .sm-checkout-line-image > img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: cover !important;
  object-position: center;
  border-radius: inherit;
}
.sm-body .sm-checkout-carousel-item > img {
  flex-basis: 56px;
  width: 56px;
  height: 42px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center;
}

/* Pending and completed invoice line items. Keep the paid quantity badge
   outside the image clipping region. */
.sm-body .cm-paid-invoice .cm-paid-summary-item {
  grid-template-columns: 64px minmax(0, 1fr) auto;
}
.sm-body .sm-inv-thumb,
.sm-body .cm-paid-invoice .cm-paid-thumb,
.sm-body .cm-paid-invoice .cm-paid-item-image {
  flex: 0 0 64px;
  width: 64px;
  height: 48px;
  aspect-ratio: 4 / 3;
}
.sm-body .cm-paid-invoice .cm-paid-item-image { border-radius: 9px; }
.sm-body .sm-inv-thumb > img,
.sm-body .cm-paid-invoice .cm-paid-thumb > img,
.sm-body .cm-paid-invoice .cm-paid-item-image > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: inherit;
}

/* Plan selectors, bundle contents and small product previews. */
.sm-body .cm-plan > img,
.sm-body .cm-pack-heading > img,
.sm-body .cm-pack-member > img {
  flex: 0 0 56px;
  width: 56px;
  height: 42px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center;
}
.sm-body .cm-showcase-product-image {
  width: 88px;
  height: 66px;
  aspect-ratio: 4 / 3;
}
.sm-body .cm-showcase-product-image > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.sm-body .cm-product-thumbnails img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center;
}

/* Larger previews retain the complete artwork at its natural aspect ratio.
   Do not reset transforms or inline styles configured by the owner. */
.sm-body .cm-product-main-image > img,
.sm-body .cm-quick-art > img,
.sm-body .cm-pack-art > img,
.sm-body .sm-product-gallery > img {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: none;
  aspect-ratio: auto;
  object-fit: contain;
}

@media (min-width: 560px) and (max-width: 1199px) {
  .sm-body .cm-paid-invoice .cm-paid-summary-item { grid-template-columns: 64px minmax(0, 1fr); }
}

@media (max-width: 480px) {
  .sm-body .sm-cart-item { grid-template-columns: 80px minmax(0, 1fr) auto; }
  .sm-body .sm-cart-item-image { width: 80px; height: 60px; }
  .sm-body .sm-checkout-page .sm-checkout-line { grid-template-columns: 64px minmax(0, 1fr) auto; }
  .sm-body .sm-checkout-page .sm-checkout-line-image { flex-basis: 64px; width: 64px; height: 48px; }
  .sm-body .cm-showcase-product-image { width: 64px; height: 48px; }
}
