/**
 * PLP-FILTER — filter overlay.
 *
 * Spec: VATALY PLP Design Spec V4 §3; measurements from vataly-desktop-detail.md
 * §9 and vataly-mobile-detail.md §10.
 * Figma: Filter [D] 195:3171 — 562x880 drawer from the right, Paper, 40px
 * padding, header "FILTER" + "X", four collapsible sections, then SHOW ITEMS
 * (solid Ink) and CLEAR FILTER (Paper, Taupe border) 8px apart.
 * Mobile [M] 534:8176 — full screen, padding 60/40/40/40, rows 50px.
 *
 * Tokens only — Ink var(--ink_text) · Paper var(--bg_clr1) ·
 * Stone var(--bg_clr2) · Taupe var(--h_clr) · Sand var(--b_clr) ·
 * Manrope var(--font2). No raw hex.
 */

/* =========================================================================
   Trigger — Figma: "FILTER", Header 18 (Manrope Bold 18px), left gutter 42px.
   ========================================================================= */

.woocommerce-archive .vataly-filter-trigger {
	float: left;
	padding: 0;
	border: 0;
	background: none;
	font-family: var(--font2);
	font-weight: 700;
	font-size: 18px;
	line-height: normal;
	color: var(--ink_text);
	cursor: pointer;
	font-style: normal;
}

.woocommerce-archive .vataly-filter-trigger:hover {
	color: var(--h_clr);
}

/* =========================================================================
   Overlay + drawer (desktop)
   ========================================================================= */

.vataly-filter-overlay {
	--vataly-filter-row: 53px;   /* Figma cell row height, desktop */
	--vataly-filter-label: 14px; /* Body 14 */
	--vataly-filter-title: 18px; /* Header 18 */

	position: fixed;
	inset: 0;
	z-index: 10000;
}

.vataly-filter-overlay[hidden] {
	display: none;
}

/* Backdrop: not specified in Figma; matched to the screenshots' dimmed page. */
.vataly-filter-overlay__backdrop {
	position: absolute;
	inset: 0;
	background: var(--ink_text);
	opacity: 0;
	transition: opacity 0.3s ease;
}

.vataly-filter-overlay.is-open .vataly-filter-overlay__backdrop {
	opacity: 0.6;
}

body.vataly-filter-open {
	overflow: hidden;
}

.vataly-filter-panel {
	position: absolute;
	top: 0;
	right: 0;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	width: 562px;
	max-width: 100%;
	height: 100%;
	padding: 40px;
	background: var(--bg_clr1);
	color: var(--ink_text);
	transform: translateX(100%);
	transition: transform 0.3s ease;
}

.vataly-filter-overlay.is-open .vataly-filter-panel {
	transform: translateX(0);
}

/* ------------------------------------------------------------------ header */

.vataly-filter-panel__header {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-bottom: 26px;
	border-bottom: 1px solid var(--h_clr);
}

.vataly-filter-panel__title,
.vataly-filter-panel__close {
	font-family: var(--font2);
	font-weight: 700;
	font-size: var(--vataly-filter-title);
	line-height: 1;
	color: var(--ink_text);
}

.vataly-filter-panel__close {
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
}

/* ------------------------------------------------------------------ sections */

.vataly-filter-panel__body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.vataly-filter-section {
	border-bottom: 1px solid var(--h_clr);
}

.vataly-filter-section__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 36px 0;
	border: 0;
	background: none;
	font-family: var(--font2);
	font-weight: 700;
	font-size: 16px;
	color: var(--ink_text);
	text-align: left;
	cursor: pointer;
	font-style: normal;
	line-height: normal;
}

/* Figma's chevron is set in Inter Medium — a known font bug in the source
   component (V4 "KNOWN FONT BUG TO FIX"). Fixed at the source here: the
   glyph is set in Manrope, the same font every other PLP label uses
   (Components & Tokens, 3314:2), not the off-system Inter. Size 16 as Figma. */
.vataly-filter-section__chevron {
	display: inline-block;
	font-family: var(--font2);
	font-weight: 400;
	font-size: 16px;
	line-height: 1;
	color: var(--ink_text);
}

.vataly-filter-section__chevron::before {
	content: '\2228'; /* ∨ */
}

.vataly-filter-section__toggle[aria-expanded="true"] .vataly-filter-section__chevron::before {
	content: '\2227'; /* ∧ */
}

/* Figma: 24px between the heading and the grid, 24px below the grid. */
.vataly-filter-section__content {
	margin-top: -10px;
	padding-bottom: 24px;
}

.vataly-filter-section__content[hidden] {
	display: none;
}

/* ------------------------------------------------------------------ cell grids */

/* Collapsed 1px Taupe lines: each cell draws its top/left line inside and its
   right/bottom line outside, so neighbours share one line; the grid's own
   right/bottom border closes any empty cell in a short last row (Fabric). */
.vataly-filter-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	margin: 0;
	padding: 0;
	list-style: none;
	border-right: 1px solid var(--h_clr);
	border-bottom: 1px solid var(--h_clr);
}

.vataly-filter-grid > li {
	min-width: 0;
	margin: 0;
	padding: 0;
}

.vataly-filter-cell {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	height: var(--vataly-filter-row);
	padding: 16px;
	border: 0;
	border-radius: 0;
	background: var(--bg_clr1);
	box-shadow:
		inset 1px 1px 0 var(--h_clr),
		1px 0 0 var(--h_clr),
		0 1px 0 var(--h_clr),
		1px 1px 0 var(--h_clr);
	font-family: var(--font2);
	font-weight: 300;
	font-size: var(--vataly-filter-label);
	line-height: normal;
	font-style: normal;
	color: var(--ink_text);
	text-align: left;
	cursor: pointer;
	transition: none; /* Konte animates buttons; selection must show at once. */
}

.vataly-filter-cell:hover {
	background: var(--bg_clr2);
}

/* Selected — not in Figma; Sand fill agreed with the client. */
.vataly-filter-cell[aria-pressed="true"] {
	background: var(--b_clr);
}

.vataly-filter-cell:focus-visible {
	outline: 1px solid var(--ink_text);
	outline-offset: -4px;
}

.vataly-filter-cell__name {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: clip;
}

/* Colour: 3 across; a short last row stretches to fill the width
   (screenshot: WHITES / YELLOWS share the last row). */
.vataly-filter-section--colour .vataly-filter-grid {
	grid-template-columns: repeat(6, 1fr);
}

.vataly-filter-section--colour .vataly-filter-grid > li {
	grid-column: span 2;
}

.vataly-filter-section--colour .vataly-filter-grid > li:nth-last-child(2):nth-child(3n+1),
.vataly-filter-section--colour .vataly-filter-grid > li:last-child:nth-child(3n+2) {
	grid-column: span 3;
}

.vataly-filter-section--colour .vataly-filter-grid > li:last-child:nth-child(3n+1) {
	grid-column: span 6;
}

/* Figma colour swatch: 16x16 square chip. */
.vataly-filter-swatch {
	flex: 0 0 16px;
	width: 16px;
	height: 16px;
	background-size: cover;
	background-position: 50% 50%;
}

.vataly-filter-swatch--empty {
	background-color: var(--bg_clr2);
	box-shadow: inset 0 0 0 1px var(--b_clr);
}

/* Size: one row of equal cells, labels centred (Figma XS … XXL). */
.vataly-filter-section--size .vataly-filter-grid {
	grid-template-columns: repeat(min(var(--vataly-filter-count, 6), 6), 1fr);
}

.vataly-filter-section--size .vataly-filter-cell {
	justify-content: center;
	padding: 16px 4px;
}

/* ------------------------------------------------------------------ price */

/* Figma price slider: 12px tall, 2px Ink track inset 6px, 12x12 square Ink
   handles at the ends. Two overlaid range inputs; only the thumbs take input. */
.vataly-filter-price__slider {
	position: relative;
	height: 12px;
	margin-top: 4px;
}

.vataly-filter-price__slider::before {
	content: '';
	position: absolute;
	top: 5px;
	left: 6px;
	right: 6px;
	height: 2px;
	background: var(--ink_text);
}

.vataly-filter-price__slider input[type="range"] {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 12px;
	margin: 0;
	padding: 0;
	border: 0; /* Konte underlines inputs. */
	box-shadow: none;
	background: none;
	-webkit-appearance: none;
	appearance: none;
	pointer-events: none;
}

.vataly-filter-price__slider input[type="range"]::-webkit-slider-runnable-track {
	height: 12px;
	background: none;
	border: 0;
}

.vataly-filter-price__slider input[type="range"]::-moz-range-track {
	height: 12px;
	background: none;
	border: 0;
}

.vataly-filter-price__slider input[type="range"]::-webkit-slider-thumb {
	width: 12px;
	height: 12px;
	border: 0;
	border-radius: 0;
	background: var(--ink_text);
	-webkit-appearance: none;
	appearance: none;
	pointer-events: auto;
	cursor: pointer;
}

.vataly-filter-price__slider input[type="range"]::-moz-range-thumb {
	width: 12px;
	height: 12px;
	border: 0;
	border-radius: 0;
	background: var(--ink_text);
	pointer-events: auto;
	cursor: pointer;
}

.vataly-filter-price__slider input[type="range"]:disabled::-webkit-slider-thumb {
	cursor: default;
}

.vataly-filter-price__slider input[type="range"]:disabled::-moz-range-thumb {
	cursor: default;
}

.vataly-filter-price__slider input[type="range"]:focus-visible::-webkit-slider-thumb {
	outline: 1px solid var(--ink_text);
	outline-offset: 2px;
}

.vataly-filter-price__labels {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	margin: 22px 0 0;
	font-family: var(--font2);
	font-weight: 300;
	font-size: var(--vataly-filter-label);
	line-height: 1;
	color: var(--ink_text);
	text-transform: uppercase;
}

/* ------------------------------------------------------------------ actions */

.vataly-filter-panel__actions {
	flex: 0 0 auto;
	display: grid;
	gap: 8px;
	padding-top: 24px;
}

.vataly-filter-show,
.vataly-filter-clear {
	width: 100%;
	height: 44px;
	padding: 0;
	border-radius: 0;
	font-family: var(--font2);
	font-weight: 700;
	font-size: 14px;
	line-height: 1;
	letter-spacing: 0.04em;
	cursor: pointer;
}

/* Figma: SHOW ITEMS — solid Ink background, Paper text. */
.vataly-filter-show {
	border: 1px solid var(--ink_text);
	background: var(--ink_text);
	color: var(--bg_clr1);
}

/* Figma: CLEAR FILTER — Paper background, Taupe border and text. */
.vataly-filter-clear {
	border: 1px solid var(--h_clr);
	background: var(--bg_clr1);
	color: var(--h_clr);
}

/* =========================================================================
   Mobile — full screen, not a drawer. Figma [M] 534:8176.
   ========================================================================= */

@media (max-width: 767px) {

	.woocommerce-archive .vataly-filter-trigger
	{
		float: left;
	padding: 0;
	border: 0;
	background: none;
	font-family: var(--font2);
	font-weight: 700;
	font-size: 14px;
	line-height: normal;
	color: var(--ink_text);
	cursor: pointer;
	font-style: normal;
	}

	.vataly-filter-overlay {
		--vataly-filter-row: 50px;
		--vataly-filter-label: 12px; /* Body 12 */
		--vataly-filter-title: 16px;
	}

	.vataly-filter-panel {
		inset: 0;
		width: 100%;
		height: 100%;
		height: 100dvh;
		padding: 60px 40px 40px;
		opacity: 0;
		transform: none;
		transition: opacity 0.3s ease;
	}

	.vataly-filter-overlay.is-open .vataly-filter-panel {
		opacity: 1;
		transform: none;
	}

	.vataly-filter-panel__header {
		padding-bottom: 24px;
	}

	/* Figma mobile colour labels: Manrope Regular 12. */
	.vataly-filter-section--colour .vataly-filter-cell {
		font-weight: 400;
	}

	.vataly-filter-cell {
		padding: 0 12px;
	}

	.vataly-filter-section--fabric .vataly-filter-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (prefers-reduced-motion: reduce) {
	.vataly-filter-panel,
	.vataly-filter-overlay__backdrop {
		transition: none;
	}
}
