/**
 * Shared category listing contract, independent of category depth or template ID.
 * Native archive products and AJAX category results retain their existing data
 * handlers and use the global product card; this module owns their rail and grid.
 */
body.tax-product_cat {
	--cie-category-products-rail: clamp(320px, 79.167vw, 1520px);
	--cie-category-products-columns: 4;
}

/* Reuse the parent archive's rail for the complete AJAX controls/results block. */
body.tax-product_cat .elementor-location-archive :is(.cie-category-product-grid__inner, .s3i-apf-wrap) {
	box-sizing: border-box;
	width: min(100%, var(--cie-category-products-rail)) !important;
	min-width: 0 !important;
	max-width: var(--cie-category-products-rail) !important;
	margin-inline: auto !important;
}

/* These are the two adapters into the same layout, including appended results. */
body.tax-product_cat .elementor-location-archive :is(.elementor-widget-wc-archive-products ul.products, .s3i-apf-results) {
	display: grid !important;
	grid-template-columns: repeat(var(--cie-category-products-columns), minmax(0, 1fr)) !important;
	gap: var(--cie-product-card-grid-gap, clamp(20px, 1.5625vw, 30px)) !important;
	width: 100% !important;
	min-width: 0 !important;
	max-width: 100% !important;
	padding: 0 !important;
	margin-inline: 0 !important;
	box-sizing: border-box;
}

/* WooCommerce clearfix pseudo-elements must not consume grid cells. */
body.tax-product_cat .elementor-location-archive :is(.elementor-widget-wc-archive-products ul.products, .s3i-apf-results)::before,
body.tax-product_cat .elementor-location-archive :is(.elementor-widget-wc-archive-products ul.products, .s3i-apf-results)::after {
	display: none !important;
}

/* Reset legacy percentage widths and min-content sizing at each card boundary. */
body.tax-product_cat .elementor-location-archive :is(.elementor-widget-wc-archive-products ul.products, .s3i-apf-results) > li.product {
	float: none !important;
	width: 100% !important;
	min-width: 0 !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	box-sizing: border-box;
}

body.tax-product_cat .elementor-location-archive :is(.elementor-widget-wc-archive-products ul.products, .s3i-apf-results) > li.product > .elementor,
body.tax-product_cat .elementor-location-archive :is(.elementor-widget-wc-archive-products ul.products, .s3i-apf-results) > li.product .cie-elementor-product-card {
	width: 100% !important;
	min-width: 0 !important;
	max-width: none !important;
}

@media (max-width: 1024px) {
	body.tax-product_cat {
		--cie-category-products-columns: 2;
	}
}

@media (max-width: 767px) {
	body.tax-product_cat {
		--cie-category-products-columns: 1;
	}
}
