/* Match repeated product images to the square format of the catalog originals. */
#main :is(.coin-card, .home-product-card, .gallery-card, .mcp-card,
  .mgmrf-family-card, .mcl-collection-grid > a, .mcl-gallery-grid > figure,
  .mcp-gallery-photos > figure, .mep-gallery-rail > a, .sm-cards > article,
  .mm-project-card) > img,
#main :is(.product-image, .mgmha-range__media, .about-product-photo,
  :is(.mcp-card, .mgmrf-family-card, .coin-card, .mgmcb-card > a) > .mgmrf-media,
  .mkc-card > .mkc-media, .mcp-card > .mcp-card-illustration,
  .mcp-card > .mgm-placeholder-visual, .mcp-gallery-photos .mcp-diagram) {
  box-sizing: border-box;
  width: 100%;
  height: auto !important;
  min-height: 0;
  max-height: none;
  aspect-ratio: 1;
}

#main :is(.coin-card, .home-product-card, .gallery-card, .mcp-card,
  .mgmrf-family-card, .mcl-collection-grid > a, .mcl-gallery-grid > figure,
  .mcp-gallery-photos > figure, .mep-gallery-rail > a, .sm-cards > article,
  .mm-project-card) > img {
  display: block;
  padding: 0;
  object-fit: contain;
  object-position: center;
}

#main :is(.product-image, .mgmha-range__media, .about-product-photo,
  :is(.mcp-card, .mgmrf-family-card, .coin-card, .mgmcb-card > a) > .mgmrf-media,
  .mkc-card > .mkc-media) {
  position: relative;
  overflow: hidden;
}

#main :is(.product-image, .mgmha-range__media, .about-product-photo,
  :is(.mcp-card, .mgmrf-family-card, .coin-card, .mgmcb-card > a) > .mgmrf-media,
  .mkc-card > .mkc-media) > img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  padding: 0;
  object-fit: contain;
  object-position: center;
}

/* Reference media follows its column width, including on two-column phones. */
#main :is(.template-grid > .design-template, .collections-grid > .collection-tile,
  .event-grid > article, .project-cases > article, .discover-grid > a, .blog-grid > a,
  .resource-cards > article, .mep-templates > article, .mep-upgrades > article,
  .manufacture-card-photo, .mcp-gallery-promos > a, .materials-card > a,
  .mep-feature-rail > *, .mep-craft, .mm-step-card,
  .upgrade-card > .feature-launch, .video-tip-grid > .feature-launch,
  .coin-video-grid .feature-launch) > img {
  box-sizing: border-box;
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
  max-height: none;
  aspect-ratio: 5 / 4;
  object-fit: contain;
  object-position: center;
}

#main :is(.manufacture-card-photo, .materials-card > a:has(> img)) {
  height: auto;
  min-height: 0;
  aspect-ratio: 5 / 4;
}

#main :is(.support-template-card, .support-reference-grid > a) > img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: contain;
}

#main :is(.option-item > .sample, .co-option-image) {
  height: auto;
  min-height: 0;
  aspect-ratio: 1;
}

#main :is(.option-item > .sample, .co-option-image) > img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  object-position: center;
}
