/* Store Weave managed product-list alignment.
 * Equalize metadata slots rather than forcing a fixed total card height: images,
 * titles, price and the swatch/action row share a stable baseline across mixed SKUs.
 * Scoped to WooCommerce product lists owned by Gutenberg blocks or Product Cards.
 */
:is(
  body .sw-display-slider--products ul.products.sw-display-slider__track,
  body .sw-display-product-grid ul.products.sw-display-product-grid__list,
  body.sw-display-archive-cards .site-main ul.products,
  body.sw-display-related-cards .related.products ul.products
) > li.product:not(.product-category) {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  align-self: stretch !important;
  min-width: 0 !important;
  height: 100% !important;
  box-sizing: border-box !important;
}
:is(
  body .sw-display-slider--products ul.products.sw-display-slider__track,
  body .sw-display-product-grid ul.products.sw-display-product-grid__list,
  body.sw-display-archive-cards .site-main ul.products,
  body.sw-display-related-cards .related.products ul.products
) > li.product:not(.product-category) .woocommerce-card__header {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;
  align-items: stretch !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}
/* Category labels are a one-line metadata slot. */
:is(
  body .sw-display-slider--products ul.products.sw-display-slider__track,
  body .sw-display-product-grid ul.products.sw-display-product-grid__list,
  body.sw-display-archive-cards .site-main ul.products,
  body.sw-display-related-cards .related.products ul.products
) > li.product:not(.product-category) p.product__categories {
  display: block !important;
  box-sizing: border-box !important;
  height: 1.4em !important;
  min-height: 1.4em !important;
  max-height: 1.4em !important;
  line-height: 1.4 !important;
  margin: 0 !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
}
/* Reserve the category-label slot only when at least one card in this same
 * product list actually renders a category. A list with categories disabled must
 * not gain an artificial blank row above every title. */
:is(
  body .sw-display-slider--products ul.products.sw-display-slider__track,
  body .sw-display-product-grid ul.products.sw-display-product-grid__list,
  body.sw-display-archive-cards .site-main ul.products,
  body.sw-display-related-cards .related.products ul.products
):has(> li.product:not(.product-category) p.product__categories) > li.product:not(.product-category) .woocommerce-card__header:not(:has(> p.product__categories)) .woocommerce-loop-product__title {
  margin-top: calc(1.4em + .25rem) !important;
}
/* If no card in the list has a category label, remove the reserved category gap. */
:is(
  body .sw-display-slider--products ul.products.sw-display-slider__track,
  body .sw-display-product-grid ul.products.sw-display-product-grid__list,
  body.sw-display-archive-cards .site-main ul.products,
  body.sw-display-related-cards .related.products ul.products
):not(:has(> li.product:not(.product-category) p.product__categories)) > li.product:not(.product-category) .woocommerce-loop-product__title {
  margin-top: 0 !important;
}
/* Default to natural title height. A one-line title must not reserve an empty
 * second line when the list has no visual swatches; this was the main source of
 * the excessive gap above attributes/reviews/price on DiyYarn. */
:is(
  body .sw-display-slider--products ul.products.sw-display-slider__track,
  body .sw-display-product-grid ul.products.sw-display-product-grid__list,
  body.sw-display-archive-cards .site-main ul.products,
  body.sw-display-related-cards .related.products ul.products
) > li.product:not(.product-category) .woocommerce-loop-product__title {
  display: block !important;
  box-sizing: border-box !important;
  height: auto !important;
  min-height: var(--sw-pc-title-row-height, 1.3em) !important;
  max-height: 2.6em !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  overflow: hidden !important;
  line-height: 1.3 !important;
}
/* Title slots are synchronized to the tallest NATURAL title in each visual row
 * by list-swatches.js. Do not reserve two lines for every swatch card: that created
 * a large blank gap under every one-line title. If the JS is unavailable, titles
 * fall back to natural height instead of leaving artificial whitespace. */
:is(
  body .sw-display-slider--products ul.products.sw-display-slider__track,
  body .sw-display-product-grid ul.products.sw-display-product-grid__list,
  body.sw-display-archive-cards .site-main ul.products,
  body.sw-display-related-cards .related.products ul.products
) > li.product:not(.product-category) .woocommerce-loop-product__title > a.woocommerce-loop-product__link {
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 2 !important;
  overflow: hidden !important;
  max-height: 2.6em !important;
  line-height: 1.3 !important;
  min-width: 0 !important;
  overflow-wrap: anywhere !important;
}
/* Prices stay on a single reserved line, including sale del/ins and variable ranges. */
:is(
  body .sw-display-slider--products ul.products.sw-display-slider__track,
  body .sw-display-product-grid ul.products.sw-display-product-grid__list,
  body.sw-display-archive-cards .site-main ul.products,
  body.sw-display-related-cards .related.products ul.products
) > li.product:not(.product-category) .price {
  display: block !important;
  box-sizing: border-box !important;
  height: 1.5em !important;
  min-height: 1.5em !important;
  max-height: 1.5em !important;
  margin-bottom: .75rem !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
  line-height: 1.5 !important;
}
/* Keep the swatch/placeholder action slot consistent when Shoptimizer wraps card content. */
:is(
  body .sw-display-slider--products ul.products.sw-display-slider__track,
  body .sw-display-product-grid ul.products.sw-display-product-grid__list,
  body.sw-display-archive-cards .site-main ul.products,
  body.sw-display-related-cards .related.products ul.products
) > li.product:not(.product-category) .sw-pc-list-swatches[data-sw-pc-list-swatches],
:is(
  body .sw-display-slider--products ul.products.sw-display-slider__track,
  body .sw-display-product-grid ul.products.sw-display-product-grid__list,
  body.sw-display-archive-cards .site-main ul.products,
  body.sw-display-related-cards .related.products ul.products
) > li.product:not(.product-category) .sw-pc-list-swatches--placeholder {
  flex-shrink: 0 !important;
}
