/* Product detail imagery - one standard size for every product.

   Two problems this fixes:

   1. The main image box is a 1:1 square but the photo was `object-fit: cover`,
      so a portrait tile (600x1200) was cropped instead of shown. Shoppers open a
      product to see what the tile looks like, so the whole thing has to be
      visible - `contain` on a neutral panel gives every product the same frame
      whatever its aspect ratio.

   2. The zoom modal set `width: 100%` on the image with no height limit. Inside
      a 700px card a tall photo rendered ~700x1400 and ran off the bottom of the
      screen with no way to see the rest of it.

   Selectors are one level more specific than the per-template rules they
   override, so they win without needing !important. */

/* ---- Main image ------------------------------------------------------- */

.images-card .main-image {
  background: #f7f8fa;
}

.images-card .main-image .fixed-main-img,
.images-card .main-image img#mainImage {
  width: 100%;
  height: 100%;
  object-fit: contain;          /* show the whole tile, never crop it */
  display: block;
}

/* Thumbnails stay cropped - they are an index, not the product itself. */
.images-card .thumb .fixed-thumb-img {
  object-fit: cover;
}

/* ---- Zoom modal ------------------------------------------------------- */

.img-modal-card {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* The template toggles display:flex/block inline when opening; keep the
   centring either way. */
.img-modal-card[style*="flex"],
.img-modal-card[style*="block"] {
  align-items: center;
  justify-content: center;
}

.img-modal-card .img-card {
  width: auto;
  max-width: min(92vw, 1000px);
  max-height: 92vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: auto;
}

.img-modal-card .img-card-img {
  width: auto;
  max-width: 100%;
  /* Leave room for the card's padding and the close button. */
  max-height: 84vh;
  object-fit: contain;
  display: block;
}

@media (max-width: 767px) {
  .img-modal-card { padding: 12px; }
  .img-modal-card .img-card { max-width: 96vw; padding: 10px; }
  .img-modal-card .img-card-img { max-height: 78vh; }
}
