/* 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;
}

/* Keep the wide featured layout and fill its image column at every height. */
@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: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    object-fit: cover;
  }
}

/* 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; }
}

/* Recommendation thumbnails use the same 4:3 framing as the catalogue. */
.sm-body .sm-checkout-page .sm-checkout-recommendation {
  grid-template-columns: 72px minmax(0, 1fr) 24px;
}
.sm-body .sm-checkout-page .sm-checkout-recommendation-image {
  width: 72px;
  height: 54px;
  min-height: 0;
  aspect-ratio: 4 / 3;
  align-self: center;
  border-radius: 8px;
  overflow: hidden;
}
.sm-body .sm-checkout-page .sm-checkout-recommendation-image > img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  aspect-ratio: 4 / 3;
  object-fit: cover !important;
  object-position: center;
  border-radius: inherit;
}
@media (max-width: 480px) {
  .sm-body .sm-checkout-page .sm-checkout-recommendation {
    grid-template-columns: 64px minmax(0, 1fr) 24px;
    gap: 9px;
  }
  .sm-body .sm-checkout-page .sm-checkout-recommendation-image {
    width: 64px;
    height: 48px;
  }
}

/* Available for preorder only on sold-out catalogue cards. */
.sm-body .cm-product-art .cm-preorder-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  max-width: calc(100% - 24px);
  padding: 12px 17px;
  border: 1px solid rgba(192, 132, 252, .75);
  border-radius: 999px;
  background: linear-gradient(125deg, rgba(46, 20, 69, .98), rgba(71, 30, 99, .97));
  color: #eedbff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(233, 213, 255, .14);
  font-family: var(--sm-mono, monospace);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .22em;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -50%);
}
.sm-body .cm-product-art .cm-preorder-badge::before {
  content: '';
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d28bff;
  box-shadow: 0 0 10px rgba(192, 132, 252, .45);
}
@media (max-width: 480px) {
  .sm-body .cm-product-art .cm-preorder-badge {
    gap: 7px;
    padding: 10px 12px;
    font-size: 11px;
    letter-spacing: .16em;
  }
}
