/* UX2 — standardized product card media frames (COSMOSKIN storefront) */

:root {
  --cs-card-media-ratio: 1 / 1;
  --cs-card-media-bg: radial-gradient(circle at 50% 38%, rgba(255, 255, 255, .82), transparent 46%),
    linear-gradient(180deg, #f8f2ec 0%, #efe4d7 100%);
  --cs-card-media-padding: clamp(12px, 2.8vw, 18px);
  --cs-product-card-price-size: clamp(15px, 1.18vw, 18px);
  --cs-product-card-price-weight: 700;
  --cs-product-card-price-letter-spacing: -.025em;
}

/* Card shell */
.product-card,
.cs-product-card,
.bestseller-card,
.pdp-related-card,
.cs-catalog-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

.product-card .product-body,
.cs-product-card__info,
.cs-product-card__body,
.bestseller-card__body,
.pdp-related-card .product-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  gap: 8px;
}

/* Shared media frame — legacy + BEM */
.product-card .product-media-wrap,
.product-card .product-media,
.cs-product-card__media,
.pdp-related-card .product-media,
.bestseller-card .product-media-wrap,
.bestseller-card .product-media,
.cs-catalog-card .product-media {
  position: relative;
  width: 100%;
  aspect-ratio: var(--cs-card-media-ratio);
  min-height: 0 !important;
  max-height: none !important;
  height: auto !important;
  flex: 0 0 auto;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: var(--cs-card-media-padding);
  background: var(--cs-card-media-bg);
  text-decoration: none;
  border-radius: inherit;
}

.product-card .product-media-wrap {
  aspect-ratio: var(--cs-card-media-ratio);
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 24px 24px 0 0;
}

.product-card .product-media-wrap > .product-media {
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
  padding: var(--cs-card-media-padding);
}

/* Images must never drive card height */
.product-card .product-media img,
.product-card .product-media-wrap img,
.cs-product-card__media img,
.pdp-related-card .product-media img,
.bestseller-card .product-media img,
.bestseller-card img,
.cs-catalog-card .product-media img {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  object-position: center center !important;
  display: block;
  margin: 0 auto;
  aspect-ratio: unset !important;
  border-radius: 0;
  padding: 0 !important;
  filter: drop-shadow(0 18px 24px rgba(24, 18, 12, .10));
}

/* Title clamp */
.product-card .product-body h3,
.product-card .product-body > a h3,
.cs-product-card__info strong,
.cs-product-card__title,
.bestseller-card h3,
.pdp-related-card .product-body h3,
.cs-catalog-card .product-body h3 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
  margin: 0;
}

/* Stable price + CTA row */
.product-card .price-row,
.cs-product-card__footer,
.bestseller-card__price-row,
.bestseller-card__cta-row,
.pdp-related-card .price-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  margin-top: auto;
  flex-wrap: wrap;
}

.product-card .price-row > div,
.bestseller-card__price-block,
.cs-product-card__price {
  min-width: 0;
  flex: 1 1 auto;
}

.product-card .price-row .cs-price,
.bestseller-card__price-block .cs-price,
.cs-product-card__footer .cs-price {
  flex-wrap: wrap;
  max-width: 100%;
}

.product-card .price-row .cs-price__current,
.cs-product-card__footer .cs-price__current,
.cs-product-card__price .cs-price__current,
.bestseller-card__price-block .cs-price__current,
.pdp-related-card .price-row .cs-price__current,
.cs-catalog-card .cs-price__current,
.cs-home-product-card__price .cs-price__current,
.cs-recent-card__price .cs-price__current {
  font-size: var(--cs-product-card-price-size) !important;
  font-weight: var(--cs-product-card-price-weight) !important;
  letter-spacing: var(--cs-product-card-price-letter-spacing) !important;
  line-height: 1.15;
}

.product-card .price-row .cs-price__compare,
.cs-product-card__footer .cs-price__compare,
.bestseller-card__price-block .cs-price__compare,
.pdp-related-card .price-row .cs-price__compare,
.cs-home-product-card__price .cs-price__compare,
.cs-recent-card__price .cs-price__compare {
  font-size: calc(var(--cs-product-card-price-size) * .72) !important;
}

.product-card .price-row .btn,
.cs-product-card__footer button {
  flex: 0 0 auto;
  align-self: flex-end;
}

.bestseller-card__cta-row .bestseller-btn {
  flex: 1 1 auto;
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
}

/* Mini cart / drawer recommendation thumbs */
.phase6-rec-card img,
#cartDrawer .phase6-rec-card img {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  object-position: center !important;
  aspect-ratio: 1 / 1;
  background: #f4eadf;
}

.phase6-rec-card img {
  width: 58px !important;
  height: 58px !important;
}

#cartDrawer .phase6-rec-card img {
  width: 64px !important;
  height: 64px !important;
}

/* Smart routine horizontal cards */
.smart-routine__product-media {
  aspect-ratio: 1 / 1;
  width: 100%;
  min-height: 0;
  max-height: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 10px;
  background: linear-gradient(180deg, #faf4ec, #efe4d7);
}

.smart-routine__product-media img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

.smart-routine__product-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-width: 0;
}

/* Routine builder cards */
.rt-product-card__media {
  aspect-ratio: 1 / 1;
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 10px;
  margin-bottom: 10px;
}

.rt-product-card__media img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

/* Mobile redesign cards (when active) */
body.cm-mobile-active .cm-product-card__media {
  aspect-ratio: 1 / 1;
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 12px;
}

body.cm-mobile-active .cm-product-card__media img,
body.cm-mobile-active .cm-product-card img {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  aspect-ratio: unset !important;
}

body.cm-mobile-active .cm-product-title h3 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-width: 0;
}

.cs-product-card__info .cs-cart-name,
.cs-product-card__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-width: 0;
  word-break: break-word;
  text-decoration: none;
  color: inherit;
}
.site-search-result__meta .cs-price,
.srch-item-price .cs-price {
  flex-wrap: wrap;
  max-width: 100%;
}

@media (max-width: 820px) {
  .bestseller-card .product-media-wrap,
  .bestseller-card .product-media {
    aspect-ratio: var(--cs-card-media-ratio);
    height: auto !important;
    min-height: 0 !important;
  }

  .bestseller-card img {
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
  }
}

@media (max-width: 760px) {
  #bestsellers .product-grid--phase4 > .product-card .product-media {
    aspect-ratio: var(--cs-card-media-ratio) !important;
    min-height: 0 !important;
    height: auto !important;
  }

  #bestsellers .product-grid--phase4 > .product-card .product-media img {
    max-height: 100% !important;
    height: 100% !important;
  }
}
