/* =============================================================================
   Darplay Tweaks - product grid (includes/product-grid.php)
   WooCommerce's Product Collection block: every card in a row is as tall as
   the tallest (the list is a grid), so price + button are pushed to the
   bottom of the card and line up whatever the length of the title.
   ============================================================================= */

.wc-block-product-template > li.wc-block-product {
	display: flex;
	flex-direction: column;
}

/* Price (and everything after it) at the bottom of the card. */
.wc-block-product-template > li.wc-block-product > .wp-block-woocommerce-product-price {
	margin-top: auto;
}

/* Same button width in every state ("Купи" / "1 в количката"). */
.wc-block-product-template .wc-block-components-product-button {
	align-items: stretch;
	width: 100%;
}

.wc-block-product-template .wc-block-components-product-button .wc-block-components-product-button__button {
	width: 100%;
	max-width: 240px; /* full card width on phones, not a long bar on desktop */
	margin-inline: auto;
	white-space: nowrap;
}

/* No "Преглед на количката" link under a button after adding: it made that
   card taller and pushed the other buttons in the row down. The button turns
   into "1 в количката" and the cart badge in the (sticky) header updates. */
.wc-block-product-template .wc-block-components-product-button .added_to_cart,
.wc-block-product-template .wc-block-components-product-button > span:has(> .added_to_cart) {
	display: none;
}

/* --- Older WooCommerce lists (cart "Може да се интересувате от...",
   related products): the price sits inside the product link, so the link
   grows and pushes the price to its bottom; buttons line up below. */
ul.products {
	display: flex;
	flex-wrap: wrap; /* WooCommerce floats the cards; keep its widths and gaps */
	align-items: stretch;
}

/* WooCommerce's clearfix pseudo-elements would become empty flex items. */
/* (".woocommerce ul.products::before" in WooCommerce's CSS, hence the doubled class.) */
.woocommerce ul.products.products::before,
.woocommerce ul.products.products::after,
ul.products.products::before,
ul.products.products::after {
	display: none;
}

ul.products li.product {
	display: flex;
	flex-direction: column;
}

ul.products li.product > a.woocommerce-LoopProduct-link {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
}

ul.products li.product > a.woocommerce-LoopProduct-link .price {
	margin-top: auto;
}

ul.products li.product > a.button {
	width: 100%;
	max-width: 240px;
	box-sizing: border-box;
	text-align: center;
	white-space: nowrap;
}

/* Phones: WooCommerce separates the two cards (48% each) by floating the
   second one right; in a flex row that gap needs space-between. */
@media (max-width: 768px) {
	ul.products {
		justify-content: space-between;
	}
}
