.wp-block-woocommerce-product-collection {
  --wc-product-gap: clamp(1.15rem, 2.2vw, 2rem);
}

.wp-block-woocommerce-product-template {
  align-items: stretch;
  gap: var(--wc-product-gap) !important;
}

.wp-block-woocommerce-product-template > li,
.wc-block-product-template > li {
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.wc-block-components-product-image,
.wc-block-grid__product-image {
  aspect-ratio: 4 / 5;
  background: transparent;
  display: grid;
  overflow: hidden;
  place-items: center;
  position: relative;
}

.wc-block-components-product-image > a,
.wc-block-grid__product-image > a {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 0;
  position: absolute;
}

.wc-block-components-product-image img,
.wc-block-grid__product-image img {
  aspect-ratio: auto !important;
  display: block;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  transition: transform 320ms ease !important;
  width: 100% !important;
}

.wc-block-components-product-image > a:hover img,
.wc-block-grid__product-image > a:hover img {
  transform: scale(1.018);
}

.wc-block-product-template .wp-block-post-title,
.wc-block-grid__product-title {
  font-family: var(--wp--preset--font-family--cormorant-garamond);
  font-size: clamp(1.375rem, 1.2rem + 0.55vw, 1.5rem) !important;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.15;
  margin-bottom: 0.4rem !important;
  margin-top: 1rem !important;
}

.wc-block-product-template .wp-block-post-title a,
.wc-block-grid__product-title a {
  text-decoration: none;
  text-underline-offset: 0.22em;
}

.wc-block-product-template .wp-block-post-title a:hover,
.wc-block-grid__product-title a:hover {
  text-decoration: underline;
  text-decoration-color: var(--wp--preset--color--gold);
  text-decoration-thickness: 1px;
}

.wc-block-components-product-price,
.wc-block-grid__product-price {
  color: var(--wp--preset--color--olive);
  font-size: clamp(1.125rem, 1.08rem + 0.18vw, 1.25rem);
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 0.7rem !important;
}

.wc-block-components-product-price del,
.wc-block-grid__product-price del {
  color: var(--wp--preset--color--muted);
  font-weight: 400;
  margin-right: 0.45rem;
  opacity: 0.78;
}

.wc-block-components-product-price ins,
.wc-block-grid__product-price ins {
  color: var(--wp--preset--color--olive);
  text-decoration: none;
}

.wc-block-components-product-price :is(del, ins),
.wc-block-grid__product-price :is(del, ins) {
  display: inline-block;
}

.wc-block-components-product-image .wp-block-woocommerce-product-sale-badge {
  position: static;
}

.wc-block-components-product-image .wc-block-components-product-sale-badge {
  align-items: center;
  background: var(--wp--preset--color--olive);
  border: 0;
  border-radius: 0;
  color: var(--wp--preset--color--white);
  display: inline-flex;
  font-family: var(--wp--preset--font-family--inter);
  font-size: 0.75rem;
  font-weight: 600;
  left: 0.75rem;
  letter-spacing: 0.02em;
  line-height: 1;
  min-height: 28px;
  padding: 0.45rem 0.6rem;
  position: absolute;
  top: 0.75rem;
  text-transform: none;
  z-index: 3;
}

.wp-block-woocommerce-product-collection .wp-block-woocommerce-product-button,
.woocommerce ul.products .product > .button {
  display: none !important;
}

.elantique-catalog__products .wc-block-product-template {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

.elantique-home-products .wc-block-product-template {
  display: grid;
  gap: clamp(0.7rem, 1.25vw, 1rem) !important;
  grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  list-style: none;
  margin: 0;
  padding: 0;
}

/*
 * WooCommerce calculates flex item widths for its default 1.25em gap. The
 * ELANTIQUE spacing is deliberately wider, which can push the fifth related
 * product onto a new row in Safari. Grid keeps all five cards aligned without
 * coupling their width to the gap calculation.
 */
.wp-block-woocommerce-product-collection[data-collection="woocommerce/product-collection/related"] .wc-block-product-template {
  display: grid !important;
  gap: var(--wc-product-gap) !important;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
}

.wp-block-woocommerce-product-collection[data-collection="woocommerce/product-collection/related"] .wc-block-product-template > li {
  width: auto !important;
}

.elantique-home-products .wc-block-product-template > li {
  background: transparent;
}

.elantique-home-products :is(.wp-block-post-terms, .wp-block-post-title, .wc-block-components-product-price) {
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.elantique-home-products .wp-block-post-terms {
  color: var(--wp--preset--color--muted);
  font-size: 0.7rem !important;
  line-height: 1.35;
  margin-bottom: 0 !important;
  margin-top: 0.75rem !important;
}

.elantique-home-products .wp-block-post-terms a {
  color: inherit;
}

.elantique-home-products .wp-block-post-title {
  font-size: clamp(1.25rem, 1.1rem + 0.35vw, 1.4rem) !important;
}

.elantique-home-products .wc-block-components-product-price {
  margin-top: auto !important;
  padding-top: 0.3rem;
}

@media (max-width: 1100px) {
  .elantique-catalog__products .wc-block-product-template {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .elantique-home-products .wc-block-product-template {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .wp-block-woocommerce-product-collection[data-collection="woocommerce/product-collection/related"] .wc-block-product-template {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 760px) {
  .elantique-home-products .wc-block-product-template {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .wp-block-woocommerce-product-collection[data-collection="woocommerce/product-collection/related"] .wc-block-product-template {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 599px) {
  .wp-block-woocommerce-product-collection[data-collection="woocommerce/product-collection/related"] .wc-block-product-template {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 640px) {
  .elantique-catalog__products .wc-block-product-template {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 420px) {
  .elantique-catalog__products .wc-block-product-template {
    grid-template-columns: 1fr !important;
  }
}
