/**
 * Universal archive density, shelf alignment and contextual-navigation layout (v4.1.4).
 *
 * Loaded only on WooCommerce catalogue archives. The selectors deliberately
 * target the real archive product list rather than assuming WooCommerce adds an
 * inner .woocommerce wrapper: on this theme the .woocommerce class normally
 * lives on the body element.
 */

/*
 * Stable selector boundary for the main WooCommerce archive loop.
 * The loop marker is preferred; the direct archive-container selector is a
 * compatibility fallback for cached/custom WooCommerce loop markup.
 */
body.wk-archive-system-v410 ul.products.wk-archive-products-v410,
body.wk-archive-system-v410 .wk-shop-archive-container > ul.products {
	display: grid !important;
	align-items: stretch !important;
	justify-content: center !important;
	justify-items: stretch !important;
	clear: both !important;
	float: none !important;
	box-sizing: border-box !important;
}

body.wk-archive-system-v410 ul.products.wk-archive-products-v410 > li.product,
body.wk-archive-system-v410 .wk-shop-archive-container > ul.products > li.product {
	float: none !important;
	width: 100% !important;
	max-width: none !important;
	margin: 0 !important;
}

@media (min-width: 761px) {
	body.wk-archive-density-single ul.products.wk-archive-products-v410,
	body.wk-archive-density-single .wk-shop-archive-container > ul.products {
		width: min(390px, 100%) !important;
		max-width: 390px !important;
		grid-template-columns: minmax(0, 1fr) !important;
		margin-left: auto !important;
		margin-right: auto !important;
	}

	body.wk-archive-density-pair ul.products.wk-archive-products-v410,
	body.wk-archive-density-pair .wk-shop-archive-container > ul.products {
		width: min(780px, 100%) !important;
		max-width: 780px !important;
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		margin-left: auto !important;
		margin-right: auto !important;
	}

	body.wk-archive-density-trio ul.products.wk-archive-products-v410,
	body.wk-archive-density-trio .wk-shop-archive-container > ul.products {
		width: min(1120px, 100%) !important;
		max-width: 1120px !important;
		grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
		margin-left: auto !important;
		margin-right: auto !important;
	}
}

body.wk-archive-density-single .wk-shop-discovery-v3484,
body.wk-archive-density-pair .wk-shop-discovery-v3484,
body.wk-archive-density-trio .wk-shop-discovery-v3484 {
	margin-bottom: clamp(1rem, 2vw, 1.45rem) !important;
}

body.wk-archive-density-single .wk-shop-chip-row-v3484,
body.wk-archive-density-pair .wk-shop-chip-row-v3484,
body.wk-archive-density-trio .wk-shop-chip-row-v3484 {
	justify-content: flex-start !important;
}

body.wk-archive-density-single .wk-shop-edit-note,
body.wk-archive-density-pair .wk-shop-edit-note,
body.wk-archive-density-trio .wk-shop-edit-note {
	max-width: 900px !important;
}

body.wk-archive-system-v410 .wk-archive-growing-range-links-v38171 .wk-smart-related-nav-v3818__links {
	grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)) !important;
}

@media (max-width: 760px) {
	body.wk-archive-density-single ul.products.wk-archive-products-v410,
	body.wk-archive-density-single .wk-shop-archive-container > ul.products,
	body.wk-archive-density-pair ul.products.wk-archive-products-v410,
	body.wk-archive-density-pair .wk-shop-archive-container > ul.products,
	body.wk-archive-density-trio ul.products.wk-archive-products-v410,
	body.wk-archive-density-trio .wk-shop-archive-container > ul.products {
		width: min(390px, 100%) !important;
		max-width: 390px !important;
		grid-template-columns: minmax(0, 1fr) !important;
		margin-left: auto !important;
		margin-right: auto !important;
	}
}

/*
 * Standard archives keep the approved WooCommerce grid and use a six-track
 * layout to centre incomplete final rows without changing product-card markup.
 * Each card spans two tracks: three cards fill a row; two cards begin on track
 * two; one card begins on track three. The loop marker is the authority so the
 * rule does not depend on body-class timing or affect secondary product shelves.
 */
ul.products.wk-archive-products-v410--standard {
	--wk-archive-standard-gap: clamp(1.4rem, 2.6vw, 2rem);
	display: grid !important;
	grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
	gap: var(--wk-archive-standard-gap) !important;
	justify-content: stretch !important;
	align-items: stretch !important;
	width: min(1120px, 100%) !important;
	margin-left: auto !important;
	margin-right: auto !important;
}

ul.products.wk-archive-products-v410--standard::before,
ul.products.wk-archive-products-v410--standard::after {
	content: none !important;
	display: none !important;
}

ul.products.wk-archive-products-v410--standard > li.product {
	grid-column: span 2;
	width: auto !important;
	max-width: none !important;
	margin: 0 !important;
	float: none !important;
}

/* One card in the final three-column row. */
ul.products.wk-archive-products-v410--standard > li.product:nth-child(3n + 1):last-child {
	grid-column: 3 / span 2;
}

/* Two cards in the final three-column row. */
ul.products.wk-archive-products-v410--standard > li.product:nth-child(3n + 1):nth-last-child(2) {
	grid-column: 2 / span 2;
}

@media (max-width: 980px) and (min-width: 581px) {
	ul.products.wk-archive-products-v410--standard {
		grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
	}

	ul.products.wk-archive-products-v410--standard > li.product {
		grid-column: span 2;
	}

	ul.products.wk-archive-products-v410--standard > li.product:nth-child(3n + 1):last-child,
	ul.products.wk-archive-products-v410--standard > li.product:nth-child(3n + 1):nth-last-child(2) {
		grid-column: span 2;
	}

	/* One card in the final two-column row. */
	ul.products.wk-archive-products-v410--standard > li.product:nth-child(2n + 1):last-child {
		grid-column: 2 / span 2;
	}
}

@media (max-width: 580px) {
	ul.products.wk-archive-products-v410--standard {
		grid-template-columns: minmax(0, 1fr) !important;
		width: min(390px, 100%) !important;
	}

	ul.products.wk-archive-products-v410--standard > li.product,
	ul.products.wk-archive-products-v410--standard > li.product:nth-child(3n + 1):last-child,
	ul.products.wk-archive-products-v410--standard > li.product:nth-child(3n + 1):nth-last-child(2),
	ul.products.wk-archive-products-v410--standard > li.product:nth-child(2n + 1):last-child {
		grid-column: 1 !important;
	}
}

/*
 * Universal archive product-shelf alignment (v4.1.4).
 *
 * Archive recommendation shelves use a four-card desktop rhythm that is
 * independent of the main WooCommerce loop. A dedicated eight-track grid lets
 * every card retain its approved width while incomplete final rows are centred:
 * one card leaves three tracks on either side, two cards leave two tracks, and
 * three cards leave one track. The selectors rely only on card position, so the
 * rule works for every product count without category or product exceptions.
 */
body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid {
	display: grid !important;
	grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
	gap: clamp(.8rem, 1.7vw, 1.05rem) !important;
	width: 100% !important;
	max-width: none !important;
	margin-inline: auto !important;
	align-items: stretch !important;
	justify-content: stretch !important;
}

body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid > .wk-smart-product-card-v3737 {
	grid-column: span 2;
	min-width: 0 !important;
	width: auto !important;
	max-width: none !important;
	margin: 0 !important;
}

/* One card in the final four-column shelf row. */
body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid > .wk-smart-product-card-v3737:nth-child(4n + 1):last-child {
	grid-column: 4 / span 2;
}

/* Two cards in the final four-column shelf row. */
body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid > .wk-smart-product-card-v3737:nth-child(4n + 1):nth-last-child(2) {
	grid-column: 3 / span 2;
}

/* Three cards in the final four-column shelf row. */
body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid > .wk-smart-product-card-v3737:nth-child(4n + 1):nth-last-child(3) {
	grid-column: 2 / span 2;
}

@media (max-width: 1020px) and (min-width: 641px) {
	body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid {
		grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
	}

	body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid > .wk-smart-product-card-v3737,
	body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid > .wk-smart-product-card-v3737:nth-child(4n + 1):last-child,
	body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid > .wk-smart-product-card-v3737:nth-child(4n + 1):nth-last-child(2),
	body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid > .wk-smart-product-card-v3737:nth-child(4n + 1):nth-last-child(3) {
		grid-column: span 2;
	}

	/* One card in the final two-column shelf row. */
	body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid > .wk-smart-product-card-v3737:nth-child(2n + 1):last-child {
		grid-column: 2 / span 2;
	}
}

@media (max-width: 640px) {
	body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid {
		grid-template-columns: minmax(0, 1fr) !important;
		width: min(420px, 100%) !important;
		max-width: 420px !important;
	}

	body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid > .wk-smart-product-card-v3737,
	body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid > .wk-smart-product-card-v3737:nth-child(4n + 1):last-child,
	body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid > .wk-smart-product-card-v3737:nth-child(4n + 1):nth-last-child(2),
	body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid > .wk-smart-product-card-v3737:nth-child(4n + 1):nth-last-child(3),
	body.wk-archive-system-v410 .wk-archive-smart-recommendations-v3737 .wk-smart-recs-v3737__grid > .wk-smart-product-card-v3737:nth-child(2n + 1):last-child {
		grid-column: 1 !important;
	}
}

