/* Shared geometry for the storefront selection and the full inventory. */
.home-products-grid, .products-grid {
  --card-gap: clamp(12px, 1.6vw, 20px);
  --card-inset: clamp(12px, 1.5vw, 20px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--card-gap);
}

.home-products-card, .product-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-inline-size: 0;
  text-align: center;
}

.home-products-image, .product-image {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  align-self: stretch;
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: 5 / 4;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #fff;
}

/* Remove the packshot from intrinsic sizing so tall bottles cannot stretch the row. */
.home-products-image img, .product-image img {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  padding: clamp(12px, 1.5vw, 24px);
  margin: auto;
  object-fit: contain;
  object-position: center;
}

.home-products-copy, .product-card-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  padding: 0 var(--card-inset) var(--card-inset);
}
.product-card-identity {
  min-width: 0;
  padding-top: .85rem;
  overflow-wrap: anywhere;
}
.home-products-brand, .product-brand { display: block; }
.product-card-identity .product-image-note { margin: .5rem 0 0; }
.home-products-copy .home-products-price, .product-card-copy .product-price-block {
  padding-top: .75rem;
  margin: auto 0 .85rem;
}
.home-products-link, .product-card-copy .product-details-button {
  width: 100%;
  justify-content: center;
  align-self: stretch;
  margin: 0;
}

/* The four tracks align the picture, identity, price and action within each row.
   Longer names and sale units grow their own track without hiding text. */
@supports (grid-template-rows: subgrid) {
  .home-products-card, .product-card {
    display: grid;
    grid-row: span 4;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: subgrid;
    align-items: start;
    row-gap: 0;
  }
  .home-products-copy, .product-card-copy { display: contents; }
  .product-card-identity,
  .home-products-copy .home-products-price,
  .product-card-copy .product-price-block {
    padding-inline: var(--card-inset);
    margin: 0;
  }
  .home-products-copy .home-products-price, .product-card-copy .product-price-block {
    padding-bottom: .85rem;
  }
  .home-products-link, .product-card-copy .product-details-button {
    width: auto;
    margin: 0 var(--card-inset) var(--card-inset);
    align-self: end;
  }
}

.product-dialog-info { align-self: center; text-align: center; }
.product-dialog-image { align-self: center; overflow: hidden; }
.product-dialog-info .product-details > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: .5rem;
}
.product-dialog-info .product-details dd { margin-inline-start: 0; }

@media (max-width: 900px) {
  .home-products-grid, .products-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  .home-products-grid, .products-grid { --card-inset: 10px; --card-gap: 10px; }
  .product-card-identity { padding-top: .6rem; }
}
@media (max-width: 359px) {
  .home-products-grid, .products-grid { grid-template-columns: minmax(0, 1fr); }
  .home-products-image, .product-image { aspect-ratio: 3 / 2; }
}
