/* VIA PARTS — one image fit standard for public product previews.
   Display rules only: do not rewrite Photo Hub or original supplier media.
   All main product cards: fixed size and full image visible (contain).
   Cart suggestions use a deliberately smaller, equally centred frame. */

:root {
  --via-photo-card-frame: 200px;
  --via-photo-card-image: 178px;
  --via-photo-offer-frame: 146px;
  --via-photo-offer-image: 126px;
  --via-photo-detail-frame: 480px;
  --via-photo-detail-image: 440px;
}

/* Product listings: homepage, catalog, search, vehicle, guide, related goods. */
.product-card .product-photo,
.market-product-card .market-product-photo,
.ref-product-card .ref-product-photo,
.buyer-catalog-card .buyer-catalog-image {
  position: relative;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--via-photo-card-frame);
  min-height: var(--via-photo-card-frame);
  aspect-ratio: auto;
  padding: 10px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  background: #fff;
  overflow: hidden;
}

.product-card .product-photo > img,
.market-product-card .market-product-photo > img,
.ref-product-card .ref-product-photo > img,
.buyer-catalog-card .buyer-catalog-image > img {
  display: block;
  flex: 0 1 auto;
  width: var(--via-photo-card-image);
  height: var(--via-photo-card-image);
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center center;
}

/* Main product-detail photo — consistent dimensions with and without thumbnails. */
.product-detail .gallery-main,
.product-detail .gallery-wrap.has-thumbs .gallery-main {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--via-photo-detail-frame);
  min-height: 0;
  padding: 20px;
  box-sizing: border-box;
  background: #fff;
  overflow: hidden;
}
.product-detail .gallery-main > img,
.product-detail .gallery-wrap.has-thumbs .gallery-main > img {
  display: block;
  flex: 0 1 auto;
  width: var(--via-photo-detail-image);
  height: var(--via-photo-detail-image);
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center center;
}
.product-detail .gallery-main > .no-photo.big {
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* Cart line image remains compact and square. */
.cart-item .cart-product > img {
  display: block;
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  padding: 5px;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  object-position: center;
  background: #fff;
  box-sizing: border-box;
}

/* Suggestions and optional add-ons: 146px versus 200px in ordinary cards. */
.via-cart-addon-card .via-cart-addon-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--via-photo-offer-frame);
  min-height: var(--via-photo-offer-frame);
  padding: 10px;
  margin: 0 auto;
  border-radius: 10px;
  background: #fff;
  box-sizing: border-box;
  overflow: hidden;
}
.via-cart-addon-card .via-cart-addon-photo > img {
  display: block;
  flex: 0 1 auto;
  width: var(--via-photo-offer-image);
  height: var(--via-photo-offer-image);
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center center;
}
.via-cart-addon-card .via-cart-addon-nophoto {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  text-align: center;
}

/* Other compact product visuals keep their local sizes, but never crop. */
.tab-analog-photo > img,
.bundle-photo > img,
.maintenance-product-photo > img,
.suggest-photo > img,
.gallery-thumb > img,
.photo-tab-item > img,
.home-maintenance-slot-photo > img {
  object-fit: contain;
  object-position: center center;
}

/* Responsive sizes are identical across each card type, not per product. */
@media (max-width: 900px) {
  :root {
    --via-photo-card-frame: 170px;
    --via-photo-card-image: 150px;
    --via-photo-offer-frame: 138px;
    --via-photo-offer-image: 120px;
    --via-photo-detail-frame: 370px;
    --via-photo-detail-image: 338px;
  }
  .product-detail .gallery-main,
  .product-detail .gallery-wrap.has-thumbs .gallery-main {
    padding: 14px;
  }
}
@media (max-width: 600px) {
  :root {
    --via-photo-card-frame: 142px;
    --via-photo-card-image: 126px;
    --via-photo-offer-frame: 128px;
    --via-photo-offer-image: 110px;
    --via-photo-detail-frame: 300px;
    --via-photo-detail-image: 276px;
  }
  .product-card .product-photo,
  .market-product-card .market-product-photo,
  .ref-product-card .ref-product-photo,
  .buyer-catalog-card .buyer-catalog-image {
    padding: 7px;
  }
  .product-detail .gallery-main,
  .product-detail .gallery-wrap.has-thumbs .gallery-main {
    padding: 9px;
  }
  .via-cart-addon-card .via-cart-addon-photo {
    padding: 8px;
  }
}
@media (max-width: 370px) {
  :root {
    --via-photo-card-frame: 125px;
    --via-photo-card-image: 112px;
    --via-photo-detail-frame: 265px;
    --via-photo-detail-image: 241px;
  }
}
