/*
 * Shop filters: WooCommerce's Product Filters block in its drawer ("overlay") mode, for every width.
 * Specification: owner-approved mockup of 2026-11-11 (docs/ENVIRONMENT.md deploy log). Left drawer 320px
 * (never wider than 90% of the screen), full-screen sheet on phones, sticky Filter / Sort bar on phones.
 */
.mw-filters,
.mw-shop__tools {
	--mw-f-pad: 16px;
	--mw-f-gap: 10px;
}

/* ---------- Shop heading and intro (main shop page only) ---------- */
.mw-shop__intro {
	text-align: center;
	margin-block: var(--wp--preset--spacing--30) var(--wp--preset--spacing--40);
}

.mw-shop .mw-shop__title {
	margin: 0 0 var(--wp--preset--spacing--20) !important;
	font-size: clamp(0.9375rem, 0.5rem + 2.2vw, 2rem);
	font-weight: 500;
	letter-spacing: 0.04em;
	line-height: 1.2;
	white-space: nowrap;
}

.mw-shop .mw-shop__lead {
	max-width: 62ch;
	margin: 0 auto !important;
	color: var(--wp--preset--color--text-muted);
	font-size: var(--wp--preset--font-size--medium);
	line-height: 1.6;
}

/* Search results heading: same look as the shop heading (centred, uppercase, 500 weight, fluid size). It may wrap,
   because the words searched for can be long. Category pages keep their own title. */
body.search .mw-shop .wp-block-query-title {
	margin: var(--wp--preset--spacing--30) 0 var(--wp--preset--spacing--40);
	font-size: clamp(0.9375rem, 0.5rem + 2.2vw, 2rem);
	font-weight: 500;
	letter-spacing: 0.04em;
	line-height: 1.2;
	text-align: center;
	text-transform: uppercase;
	overflow-wrap: anywhere;
}

/* ---------- Toolbar ---------- */
.mw-shop__toolbar {
	flex-direction: row-reverse;
	align-items: center;
	margin-block-end: var(--wp--preset--spacing--30);
}

/* Tablet and desktop: the toolbar (result count, Filter, Sort, columns) sticks under the site header while
   scrolling, edge to edge like the phone bar. */
@media (min-width: 768px) {
	.mw-shop .mw-shop__toolbar.wp-block-group {
		position: sticky;
		top: calc(var(--mw-header-height, 0px) + var(--mw-admin-bar, 0px));
		z-index: 20;
		box-sizing: border-box;
		width: auto;
		max-width: none;
		margin-inline: calc(-1 * var(--wp--style--root--padding-left, 16px)) !important;
		margin-block-end: var(--wp--preset--spacing--30);
		padding: 8px var(--wp--style--root--padding-left, 16px);
		background-color: var(--wp--preset--color--surface);
		border-block: 1px solid var(--wp--preset--color--border-strong);
	}

	/* The sticky bar is its own stacking layer; lift it above the site header while the drawer is open. */
	body.mw-filters-open .mw-shop .mw-shop__toolbar.wp-block-group {
		z-index: 100000;
	}
}

.mw-shop__tools {
	align-items: center;
	gap: var(--mw-f-gap);
}

.mw-shop .wc-block-product-filters__open-overlay,
.mw-shop .wc-block-catalog-sorting select {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 36px;
	margin: 0;
	padding: 0 14px;
	background-color: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--border-strong);
	border-radius: 999px;
	color: var(--wp--preset--color--contrast);
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 400;
	cursor: pointer;
}

.mw-shop .wc-block-product-filters__open-overlay span {
	font-size: 0;
}

.mw-shop .wc-block-product-filters__open-overlay span::after {
	content: var(--mw-filter-label, "Filter");
	font-size: var(--wp--preset--font-size--small);
}

.mw-shop .wc-block-product-filters__open-overlay svg {
	width: 18px;
	height: 18px;
}

.mw-shop .wc-block-product-filters__open-overlay:hover,
.mw-shop .wc-block-catalog-sorting select:hover {
	border-color: var(--wp--preset--color--primary);
}

.mw-shop .wc-block-product-filters__open-overlay:focus-visible,
.mw-shop .wc-block-catalog-sorting select:focus-visible {
	outline: 2px solid var(--wp--preset--color--contrast);
	outline-offset: 2px;
}

.mw-shop .wc-block-catalog-sorting {
	margin: 0;
}

.mw-shop .woocommerce-ordering {
	margin: 0;
}

/* ---------- Columns switcher (desktop only: 2, 3, 4 or 5 products per row) ---------- */
.mw-cols {
	display: none;
}

@media (min-width: 1024px) {
	.mw-cols {
		display: flex;
		align-items: center;
		gap: 2px;
		margin-inline-start: 6px;
	}

	.mw-cols button {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-width: 40px;
		min-height: 36px;
		padding: 0;
		background: none;
		border: 0;
		color: var(--wp--preset--color--border-strong);
		cursor: pointer;
	}

	.mw-cols button:hover {
		color: var(--wp--preset--color--text-muted);
	}

	.mw-cols button[aria-pressed="true"] {
		color: var(--wp--preset--color--contrast);
	}

	.mw-cols button:focus-visible {
		outline: 2px solid var(--wp--preset--color--contrast);
		outline-offset: 1px;
	}

	html[data-mw-cols="2"] .wp-block-woocommerce-product-collection .wc-block-product-template__responsive[class*="columns-"]:not(.wp-block-woocommerce-cart *) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	html[data-mw-cols="3"] .wp-block-woocommerce-product-collection .wc-block-product-template__responsive[class*="columns-"]:not(.wp-block-woocommerce-cart *) {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	html[data-mw-cols="4"] .wp-block-woocommerce-product-collection .wc-block-product-template__responsive[class*="columns-"]:not(.wp-block-woocommerce-cart *) {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	html[data-mw-cols="5"] .wp-block-woocommerce-product-collection .wc-block-product-template__responsive[class*="columns-"]:not(.wp-block-woocommerce-cart *) {
		grid-template-columns: repeat(5, minmax(0, 1fr));
	}
}

/* The result count message is small. */
.mw-shop__status {
	align-items: center;
	gap: 10px;
}

.mw-shop .mw-shop__status .wc-block-product-results-count,
.mw-shop .mw-shop__status .woocommerce-result-count {
	margin: 0;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.4;
}

/* ---------- Active filter chips ---------- */
.mw-shop .mw-active-filters {
	margin-block-end: var(--wp--preset--spacing--30);
}

.mw-shop .mw-active-filters.wc-block-product-filters {
	max-width: none;
	margin-inline: 0 !important;
}

.mw-shop .mw-active-filters,
.mw-shop .mw-active-filters .wc-block-product-filters__content,
.mw-shop .mw-active-filters .wp-block-woocommerce-product-filter-removable-chips {
	justify-content: flex-start;
	margin-inline: 0;
	padding-inline: 0;
	text-align: start;
}

.mw-shop .wc-block-product-filter-removable-chips__items {
	justify-content: flex-start;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.mw-shop .wc-block-product-filter-removable-chips__item {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin: 0;
	padding: 3px 4px 3px 12px;
	background-color: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 999px;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.4;
}

/* ---------- Drawer ---------- */
.mw-filters .wc-block-product-filters__overlay-dialog {
	width: 320px;
	max-width: 90vw;
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--small);
}

.mw-filters .wc-block-product-filters__overlay-header {
	flex-direction: row;
	box-sizing: border-box;
	flex: 0 0 auto;
	align-items: center;
	justify-content: space-between;
	min-height: 52px;
	padding: 0 var(--mw-f-pad);
	background-color: var(--wp--preset--color--surface);
	border-bottom: 1px solid var(--wp--preset--color--border-strong);
}

.mw-filters .wc-block-product-filters__overlay-header::before {
	content: "Filters";
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 500;
}

.mw-filters .wc-block-product-filters__close-overlay {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	margin-inline-end: -10px;
	padding: 0;
	background: none;
	border: 0;
	color: inherit;
	cursor: pointer;
}

.mw-filters .wc-block-product-filters__overlay-content {
	padding: 0 var(--mw-f-pad);
	gap: 0;
}

.mw-filters .wc-block-product-filters__overlay-content > * {
	padding-block: 14px;
	border-bottom: 1px solid var(--wp--preset--color--border);
}

.mw-filters .wc-block-product-filters__overlay-content h3 {
	margin: 0 0 10px;
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 500;
}

.mw-filters .wc-block-product-filters__overlay-footer {
	container: mwfoot / inline-size;
	box-sizing: border-box;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--mw-f-gap);
	flex: 0 0 auto;
	padding: 12px var(--mw-f-pad);
	background-color: var(--wp--preset--color--base);
	border-top: 1px solid var(--wp--preset--color--border);
}

/* Checkbox groups: no box around them; the price slider and its two inputs fit the drawer. */
.mw-filters fieldset {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.mw-filters .wc-block-product-filter-price-slider__content {
	grid-template-columns: minmax(0, 1fr) 0 minmax(0, 1fr);
	column-gap: 10px;
}

.mw-filters .wc-block-product-filter-price-slider__range {
	max-width: 100%;
}

.mw-filters .wc-block-product-filter-price-slider__left input,
.mw-filters .wc-block-product-filter-price-slider__right input {
	box-sizing: border-box;
	width: 100%;
	min-width: 0;
}

/* Footer buttons: equal-width pills with a 2px gold border. */
.mw-filters .wc-block-product-filters__apply,
.mw-clear-filters {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-width: 0;
	min-height: 36px;
	margin: 0;
	padding: 0 12px;
	border: 2px solid var(--wp--preset--color--secondary);
	border-radius: 999px;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
}

.mw-filters .wc-block-product-filters__apply {
	grid-column: 2;
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--base);
}

.mw-filters .wc-block-product-filters__apply span {
	font-size: 0;
}

.mw-filters .wc-block-product-filters__apply span::after {
	content: var(--mw-show-full, "Show results");
	font-size: var(--wp--preset--font-size--small);
}

/* Clear Filters: fixed over the left half of the drawer footer (it lives outside the filter markup) and
   slides in and out with the drawer (same distance, 0.5s ease as WooCommerce's drawer). */
.mw-clear-filters {
	--mw-drawer-w: min(320px, 90vw);
	position: fixed;
	z-index: 100002;
	bottom: 13px;
	left: 16px;
	display: inline-flex;
	visibility: hidden;
	width: calc((var(--mw-drawer-w) - 32px - 10px) / 2);
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	transform: translateX(calc(-1 * var(--mw-drawer-w)));
	transition: transform 0.5s ease, visibility 0s 0.5s;
}

body.mw-filters-open .mw-clear-filters {
	visibility: visible;
	transform: none;
	transition: transform 0.5s ease, visibility 0s;
}

@media (prefers-reduced-motion: reduce) {
	.mw-clear-filters,
	body.mw-filters-open .mw-clear-filters {
		transition: none;
	}
}

.mw-filters .wc-block-product-filters__apply:hover,
.mw-filters .wc-block-product-filters__apply:focus-visible {
	background-color: color-mix(in srgb, var(--wp--preset--color--primary) 82%, var(--wp--preset--color--contrast));
	color: var(--wp--preset--color--base);
}

.mw-clear-filters:hover,
.mw-clear-filters:focus-visible {
	background-color: var(--wp--preset--color--surface);
}

.mw-clear-filters[aria-disabled="true"] {
	opacity: 0.55;
	cursor: default;
}

.mw-filters .wc-block-product-filters__apply:focus-visible,
.mw-clear-filters:focus-visible {
	outline: 2px solid var(--wp--preset--color--contrast);
	outline-offset: 2px;
}

/* Very long counts: drop the word "results" when the buttons get tight. */
@container mwfoot (max-width: 250px) {
	.mw-filters .wc-block-product-filters__apply span::after {
		content: var(--mw-show-short, "Show");
	}
}

/* ---------- Phones ---------- */
@media (max-width: 767px) {
	.mw-filters .wc-block-product-filters__overlay-dialog {
		width: 100%;
		max-width: none;
	}

	.mw-clear-filters {
		--mw-drawer-w: 100vw;
	}

	/* Sticky Filter / Sort bar under the header, edge to edge, two equal halves. */
	/* The toolbar's children join the page flow so the bar can stay stuck for the whole list. */
	.mw-shop .mw-shop__toolbar.wp-block-group {
		display: contents;
	}

	.mw-shop .mw-shop__tools.wp-block-group {
		position: sticky;
		top: calc(var(--mw-header-height, 0px) + var(--mw-admin-bar, 0px));
		z-index: 20;
		display: grid;
		width: auto;
		max-width: none;
		grid-template-columns: 1fr 1fr;
		gap: 0;
		margin-inline: calc(-1 * var(--wp--style--root--padding-left, 16px)) !important;
		background-color: var(--wp--preset--color--surface);
		border-block: 1px solid var(--wp--preset--color--border-strong);
	}

	.mw-shop__tools > * {
		min-width: 0;
	}

	.mw-shop .mw-filters .wc-block-product-filters__open-overlay,
	.mw-shop .wc-block-catalog-sorting select {
		width: 100%;
		justify-content: center;
		min-height: 44px;
		border: 0;
		border-radius: 0;
		background-color: transparent;
	}

	.mw-shop .mw-filters {
		border-inline-end: 1px solid var(--wp--preset--color--border);
	}

	.mw-shop__status {
		margin-block: var(--wp--preset--spacing--30) 0;
	}

	body.mw-filters-open .mw-bottom-nav {
		display: none;
	}

	/* The sticky bar is its own stacking layer; lift it above the site header while the sheet is open. */
	body.mw-filters-open .mw-shop .mw-shop__tools.wp-block-group {
		z-index: 100000;
	}
}

body.mw-filters-open {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.mw-filters .wc-block-product-filters__overlay-dialog {
		transition: none;
	}
}
