/**
 * Portico — WooCommerce catalog layered navigation.
 *
 * Markup is rendered by gdo-core (includes/modules/product-filter.php); this
 * file is the Portico presentation layer. Desktop: sticky two-column sidebar.
 * Mobile (<=920px, matching product-filter.js): off-canvas bottom-sheet drawer.
 */

/* Two-column shell: filter sidebar + results. */
.gdo-shop-layout {
	display: grid;
	grid-template-columns: 264px minmax(0, 1fr);
	gap: var(--wp--preset--spacing--50, 24px);
	align-items: start;
}

.gdo-shop-results {
	min-width: 0;
}

/* Desktop: panel is a sticky card; mobile-only controls stay hidden. */
.gdo-filter-panel {
	position: sticky;
	top: 24px;
	align-self: start;
	border: 1px solid var(--wp--preset--color--line, #e2e5e4);
	border-radius: var(--wp--custom--radius--lg, 16px);
	background: var(--wp--preset--color--surface, #fff);
	box-shadow: var(--wp--custom--shadow--card, 0 10px 28px rgba(13, 74, 68, 0.12));
	padding: var(--wp--preset--spacing--40, 20px);
}

.gdo-filter-toggle,
.gdo-filter-backdrop,
.gdo-filter-panel__close,
.gdo-filter-panel__actions {
	display: none;
}

.gdo-filter-panel__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 6px;
}

.gdo-filter-panel h2 {
	margin: 0;
	color: var(--wp--preset--color--ink, #313131);
	font-family: var(--wp--preset--font-family--heading, inherit);
	font-size: 16px;
	font-weight: 800;
}

.gdo-filter-panel__head a {
	color: var(--wp--preset--color--primary, #006166);
	font-size: 13px;
	font-weight: 700;
	text-decoration: none;
}

.gdo-filter-panel__head a:hover,
.gdo-filter-panel__head a:focus-visible {
	text-decoration: underline;
	outline: 0;
}

.gdo-filter-group {
	margin-top: 14px;
	border-top: 1px solid var(--wp--preset--color--line, #e2e5e4);
	padding-top: 14px;
}

.gdo-filter-group h3 {
	margin: 0 0 8px;
	color: var(--wp--preset--color--muted, #6b6e6e);
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.gdo-filter-options {
	display: grid;
	gap: 4px;
}

.gdo-filter-option {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 40px;
	border-radius: var(--wp--custom--radius--sm, 8px);
	color: var(--wp--preset--color--ink-2, #4a4c4c);
	padding: 0 10px;
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.gdo-filter-option:hover,
.gdo-filter-option:focus-visible {
	background: var(--wp--preset--color--primary-tint, #e9f1f0);
	color: var(--wp--preset--color--primary, #006166);
	outline: 0;
}

.gdo-filter-option:focus-visible {
	box-shadow: 0 0 0 2px var(--wp--preset--color--surface, #fff),
		0 0 0 4px var(--wp--preset--color--primary, #006166);
}

/* Size / collection use a checkbox marker. */
.gdo-filter-option__check {
	width: 18px;
	height: 18px;
	flex: 0 0 18px;
	border: 1.5px solid var(--wp--preset--color--line-strong, #cfd4d3);
	border-radius: 4px;
	background: var(--wp--preset--color--surface, #fff);
}

.gdo-filter-option.is-active .gdo-filter-option__check {
	border-color: var(--wp--preset--color--primary, #006166);
	background: var(--wp--preset--color--primary, #006166);
	box-shadow: inset 0 0 0 3px var(--wp--preset--color--surface, #fff);
}

/* Color uses a round swatch driven by the --swatch custom property. */
.gdo-filter-option__swatch {
	width: 20px;
	height: 20px;
	flex: 0 0 20px;
	border-radius: 999px;
	background: var(--swatch, #c9cccc);
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
}

.gdo-filter-option.is-active .gdo-filter-option__swatch {
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14),
		0 0 0 2px var(--wp--preset--color--surface, #fff),
		0 0 0 4px var(--wp--preset--color--primary, #006166);
}

.gdo-filter-option__label {
	min-width: 0;
	flex: 1;
}

.gdo-filter-option__count {
	display: inline-grid;
	place-items: center;
	min-width: 24px;
	height: 22px;
	border-radius: 999px;
	background: var(--wp--preset--color--surface-alt, #f4f6f6);
	color: var(--wp--preset--color--muted, #6b6e6e);
	padding: 0 7px;
	font-size: 11px;
	font-weight: 700;
}

.gdo-filter-option.is-active {
	background: var(--wp--preset--color--primary-tint, #e9f1f0);
	color: var(--wp--preset--color--primary, #006166);
}

.gdo-filter-option.is-active .gdo-filter-option__count {
	background: var(--wp--preset--color--primary, #006166);
	color: #fff;
}

/* Active-filter chips sit at the top of the results column. */
.gdo-active-filters {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 var(--wp--preset--spacing--40, 20px);
}

.gdo-active-filters a {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 32px;
	border: 1px solid var(--wp--preset--color--line, #e2e5e4);
	border-radius: 999px;
	background: var(--wp--preset--color--surface, #fff);
	color: var(--wp--preset--color--primary, #006166);
	padding: 0 12px;
	font-size: 12px;
	font-weight: 700;
	text-decoration: none;
}

.gdo-active-filters a:hover,
.gdo-active-filters a:focus-visible {
	border-color: var(--wp--preset--color--primary, #006166);
	outline: 0;
}

.gdo-active-filters__clear {
	border-color: transparent !important;
	background: transparent !important;
	color: var(--wp--preset--color--muted, #6b6e6e) !important;
}

/* ---- Mobile: toggle + off-canvas drawer (matches product-filter.js 920px) ---- */
@media (max-width: 920px) {
	.gdo-shop-layout {
		grid-template-columns: 1fr;
	}

	/* Put the toggle on the page-title row, aligned right (compact icon). */
	.woocommerce-products-header {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 12px;
	}

	.woocommerce-products-header__title {
		margin: 0;
		flex: 1 1 auto;
	}

	/* Any description keeps its own full-width row below the title. */
	.woocommerce-products-header > :not(.woocommerce-products-header__title):not(.gdo-filter-toggle) {
		flex: 1 1 100%;
	}

	.gdo-filter-toggle {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		gap: 6px;
		margin-left: auto;
		min-height: 44px;
		min-width: 44px;
		border: 1px solid var(--wp--preset--color--line-strong, #cfd4d3);
		border-radius: var(--wp--custom--radius--sm, 8px);
		background: var(--wp--preset--color--surface, #fff);
		color: var(--wp--preset--color--ink, #313131);
		padding: 0 12px;
		font: inherit;
		font-weight: 700;
		cursor: pointer;
		touch-action: manipulation;
	}

	/* Icon-only on mobile; label stays for screen readers. */
	.gdo-filter-toggle__label {
		position: absolute;
		width: 1px;
		height: 1px;
		margin: -1px;
		padding: 0;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
		border: 0;
	}

	.gdo-filter-toggle .gdo-toolbar-icon {
		flex: 0 0 20px;
		width: 20px;
		height: 20px;
	}

	.gdo-filter-toggle__count {
		display: inline-grid;
		place-items: center;
		min-width: 20px;
		height: 20px;
		border-radius: 999px;
		background: var(--wp--preset--color--primary, #006166);
		color: #fff;
		padding: 0 6px;
		font-size: 11px;
	}

	.gdo-filter-toggle:focus-visible {
		outline: 2px solid var(--wp--preset--color--primary, #006166);
		outline-offset: 2px;
	}

	.gdo-filter-backdrop {
		position: fixed;
		inset: 0;
		z-index: 90;
		background: rgba(8, 20, 18, 0.55);
	}

	.gdo-filter-backdrop:not([hidden]) {
		display: block;
	}

	.gdo-filter-panel {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		top: auto;
		z-index: 100;
		display: block;
		max-height: min(82vh, 760px);
		border: 0;
		border-radius: 16px 16px 0 0;
		box-shadow: 0 -8px 30px rgba(8, 20, 18, 0.25);
		padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
		overflow-y: auto;
		overscroll-behavior: contain;
		transform: translateY(105%);
		transition: transform 0.2s ease;
		visibility: hidden;
	}

	.has-gdo-filter-open .gdo-filter-panel {
		transform: translateY(0);
		visibility: visible;
	}

	.has-gdo-filter-open {
		overflow: hidden;
	}

	.gdo-filter-panel[aria-hidden="true"] {
		pointer-events: none;
	}

	.gdo-filter-panel__head {
		position: sticky;
		top: -18px;
		z-index: 1;
		margin: -18px -18px 8px;
		border-bottom: 1px solid var(--wp--preset--color--line, #e2e5e4);
		background: var(--wp--preset--color--surface, #fff);
		padding: 16px 18px;
	}

	.gdo-filter-panel__close {
		display: inline-grid;
		place-items: center;
		width: 34px;
		height: 34px;
		border: 1px solid var(--wp--preset--color--line, #e2e5e4);
		border-radius: 8px;
		background: var(--wp--preset--color--surface, #fff);
		color: var(--wp--preset--color--ink, #313131);
		padding: 0;
		font: inherit;
		font-size: 22px;
		line-height: 1;
		cursor: pointer;
	}

	.gdo-filter-panel__actions {
		position: sticky;
		bottom: calc(-18px - env(safe-area-inset-bottom));
		display: block;
		margin: 18px -18px calc(-18px - env(safe-area-inset-bottom));
		border-top: 1px solid var(--wp--preset--color--line, #e2e5e4);
		background: var(--wp--preset--color--surface, #fff);
		padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
	}

	.gdo-filter-panel__actions .gdo-button {
		width: 100%;
		min-height: 48px;
		border: 0;
		border-radius: var(--wp--custom--radius--sm, 8px);
		background: var(--wp--preset--color--primary, #006166);
		color: #fff;
		font: inherit;
		font-weight: 700;
		cursor: pointer;
	}

	.gdo-filter-panel__close:focus-visible,
	.gdo-filter-panel__actions .gdo-button:focus-visible {
		outline: 2px solid var(--wp--preset--color--primary, #006166);
		outline-offset: 2px;
	}
}
