/**
 * Equal-height product cards for Hestia shop grids and WooCommerce archives.
 *
 * Overrides Hestia's .card .card-image { height: 60% }, which grows with equal-
 * height rows and creates whitespace under thumbnails. Spare height goes above
 * the price row only (footer margin-top: auto).
 */

.products .hestia-shop-content > .row,
.woocommerce ul.products {
	display: flex;
	flex-wrap: wrap;
	align-items: stretch;
}

.products .shop-item,
.woocommerce ul.products li.product:not(.product-category) {
	display: flex;
	flex-direction: column;
	float: none;
}

.products .shop-item .card.card-product,
.woocommerce ul.products li.product .card.card-product {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	width: 100%;
	height: 100%;
	min-height: 0;
}

/* Product Image Flip (or similar) — keep out of flex flow. */
.woocommerce ul.products li.product .card.card-product > .secondary-image {
	display: none !important;
}

/*
 * Hestia sets height: 60% on .card .card-image; when the row stretches cards,
 * that becomes a large empty band under the photo. Size to the image instead.
 */
.products .shop-item .card-product .card-image,
.woocommerce ul.products li.product .card.card-product .card-image {
	height: auto !important;
	flex-shrink: 0;
}

.products .shop-item .card-product .card-image a,
.woocommerce ul.products li.product .card.card-product .card-image a {
	display: block;
	line-height: 0;
	overflow: hidden;
}

.products .shop-item .card-product .card-image img,
.woocommerce ul.products li.product .card.card-product .card-image img {
	display: block;
	width: 100%;
	height: auto !important;
	max-width: 230px;
	margin-left: auto !important;
	margin-right: auto !important;
	aspect-ratio: 1;
	object-fit: cover;
	object-position: top center;
}

.products .shop-item .content,
.woocommerce ul.products li.product .card-product .content {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	justify-content: flex-start;
	min-height: 0;
}

.products .shop-item .footer,
.woocommerce ul.products li.product .card-product .footer {
	margin-top: auto;
}

.products .shop-item .card-description,
.woocommerce ul.products li.product .card-description {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	overflow: hidden;
}

/*
 * Shop shelf categories: 3 per row, same card/image size as the old 4-column grid.
 * (Product-card flex rules above must not apply to .product-category items.)
 */
@media (min-width: 992px) {
	body.post-type-archive-product ul.products.columns-3:has(> li.product-category) {
		display: grid;
		grid-template-columns: repeat(3, 1fr);
	}

	body.post-type-archive-product ul.products.columns-3:has(> li.product-category) li.product.product-category {
		display: block;
		width: auto;
		max-width: none;
		flex: none;
	}

	body.post-type-archive-product ul.products.columns-3:has(> li.product-category) li.product.product-category > a {
		display: block;
		width: 100%;
	}

	body.post-type-archive-product ul.products.columns-3:has(> li.product-category) li.product.product-category > a > img {
		width: 100%;
		height: auto;
		max-width: none;
	}
}
