/**
 * CWRS responsive image system.
 *
 * Product imagery stays fully visible. Editorial imagery uses a predictable
 * crop so archive cards and content sections align across templates.
 */

:where(.cwrs-image-product-main, .cwr-product-hero .wp-block-post-featured-image) {
  aspect-ratio: 1 / 1;
  background: var(--wp--preset--color--surface);
  overflow: hidden;
}

:where(.cwrs-image-product-main, .cwr-product-hero .wp-block-post-featured-image) img {
  aspect-ratio: 1 / 1 !important;
  background: var(--wp--preset--color--surface);
  height: 100% !important;
  object-fit: contain !important;
  padding: clamp(.625rem, 2vw, 1.375rem);
  width: 100%;
}

:where(.cwrs-image-card, .cwr-card .wp-block-image, .cwr-card .wp-block-post-featured-image, .cwr-product-showcase .wp-block-post-featured-image) {
  aspect-ratio: 4 / 3;
  background: var(--wp--preset--color--surface);
  overflow: hidden;
}

:where(.cwrs-image-card, .cwr-card .wp-block-image, .cwr-card .wp-block-post-featured-image, .cwr-product-showcase .wp-block-post-featured-image) img {
  aspect-ratio: 4 / 3 !important;
  height: 100% !important;
  object-fit: contain !important;
  padding: clamp(.375rem, 1vw, .875rem);
  width: 100%;
}

:where(.cwrs-image-editorial, .cwr-visual-panel:not(.cwr-product-card) .wp-block-post-featured-image, .cwr-case-panel .wp-block-post-featured-image) {
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

:where(.cwrs-image-editorial, .cwr-visual-panel:not(.cwr-product-card) .wp-block-post-featured-image, .cwr-case-panel .wp-block-post-featured-image) img {
  aspect-ratio: 4 / 3 !important;
  height: 100% !important;
  object-fit: cover !important;
  width: 100%;
}

.cwrs-image-banner {
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.cwrs-image-banner img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

@media (max-width: 781px) {
  :where(.cwrs-image-product-main, .cwr-product-hero .wp-block-post-featured-image) {
    max-height: min(90vw, 42rem);
  }
}
