/* ==========================================================
   WonderLab archive faceted filters — desktop rail (Phase 2b)
   Brand tokens: burgundy #851625, ivory #fbf9f6, ink #2b2622.
   Mobile bottom-sheet styling lands in Phase 2c.
   ========================================================== */

/* ---- Full-width archive: drop Divi's theme sidebar so it's [rail | grid].
   body.et_full_width_page (set in PHP) already handles this via Divi CSS;
   these rules are a belt-and-braces fallback scoped to our archives. ---- */
.wlpp-af-archive #sidebar { display: none !important; }
.wlpp-af-archive #left-area {
	width: 100% !important;
	float: none !important;
	padding: 0 !important;
}

/* Hide the Home / … breadcrumb on filtered archives. */
.wlpp-af-archive .woocommerce-breadcrumb { display: none !important; }

/* Breathing room under the archive H1 so it doesn't crowd the rail. */
.wlpp-af-archive .woocommerce-products-header,
.wlpp-af-archive .woocommerce-products-header__title {
	margin-bottom: 26px;
}

.wlpp-af-wrap {
	display: grid;
	grid-template-columns: 248px minmax(0, 1fr);
	gap: 34px;
	align-items: start;
}

/* Visually-hidden live region for AJAX result announcements. */
.wlpp-af-sr-status {
	position: absolute !important;
	width: 1px; height: 1px;
	margin: -1px; padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* ---- Mobile-only controls: hidden on desktop ---- */
.wlpp-af-toggle,
.wlpp-af-close,
.wlpp-af-overlay,
.wlpp-af-sort-slot { display: none; }

/* ---- Rail ---- */
.wlpp-af-rail {
	position: sticky;
	top: 24px;
	font-size: 14px;
	color: #2b2622;
}
.wlpp-af-rail-head {
	display: flex;
	align-items: center;
	gap: 14px;
	margin: 0 0 14px;
	padding-bottom: 12px;
	border-bottom: 1px solid #ece6dd;
}
.wlpp-af-title {
	font-size: 17px;
	font-weight: 700;
	margin: 0 auto 0 0;   /* push Clear all / close to the right, with gap */
	letter-spacing: .01em;
}
.wlpp-af-clear,
.wlpp-af-chip-clear {
	font-size: 12.5px;
	color: #851625;
	text-decoration: none;
	font-weight: 600;
}
.wlpp-af-clear:hover { text-decoration: underline; }

.wlpp-af-facet { margin: 0 0 22px; }
.wlpp-af-facet-title {
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: #6b6359;
	margin: 0 0 10px;
}

/* ---- Checkbox options ---- */
.wlpp-af-options {
	list-style: none !important;
	margin: 0;
	padding: 0 18px 0 0;          /* right gutter so counts clear the scrollbar/edge */
	max-height: 264px;
	overflow-y: auto;
	overscroll-behavior: contain;
	/* Custom scrollbar — Firefox */
	scrollbar-width: thin;
	scrollbar-color: #cbb9a6 transparent;
}
/* Custom scrollbar — WebKit/Chromium */
.wlpp-af-options::-webkit-scrollbar { width: 6px; }
.wlpp-af-options::-webkit-scrollbar-track { background: #f1ece4; border-radius: 999px; }
.wlpp-af-options::-webkit-scrollbar-thumb { background: #cbb9a6; border-radius: 999px; }
.wlpp-af-options::-webkit-scrollbar-thumb:hover { background: #851625; }
/* Kill theme/Divi content bullets that leak onto our <li> options. */
.wlpp-af-options li {
	list-style: none !important;
	margin: 0;
	padding-left: 0;
}
.wlpp-af-options li::marker,
.wlpp-af-options li::before { content: none !important; display: none; }
.wlpp-af-option { margin: 0; }
.wlpp-af-option label {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 6px 2px;
	cursor: pointer;
	line-height: 1.3;
}
.wlpp-af-option input { position: absolute; opacity: 0; width: 0; height: 0; }
.wlpp-af-box {
	flex: 0 0 auto;
	width: 17px;
	height: 17px;
	border: 1.5px solid #cbb9a6;
	border-radius: 4px;
	background: #fff;
	position: relative;
	transition: border-color .12s, background .12s;
}
.wlpp-af-option input:checked + .wlpp-af-box {
	background: #851625;
	border-color: #851625;
}
.wlpp-af-option input:checked + .wlpp-af-box::after {
	content: "";
	position: absolute;
	left: 5px; top: 1.5px;
	width: 4px; height: 9px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}
.wlpp-af-option input:focus-visible + .wlpp-af-box {
	outline: 2px solid #851625;
	outline-offset: 2px;
}
.wlpp-af-option-name { flex: 1 1 auto; }
.wlpp-af-option-count { color: #9a8f82; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.wlpp-af-option.is-empty label { opacity: .45; }

/* ---- Price slider ---- */
.wlpp-af-slider {
	position: relative;
	height: 28px;
	margin: 4px 6px 8px;
}
.wlpp-af-slider-track,
.wlpp-af-slider-fill {
	position: absolute;
	top: 50%;
	height: 4px;
	border-radius: 4px;
	transform: translateY(-50%);
}
.wlpp-af-slider-track { left: 0; right: 0; background: #e3d9cc; }
.wlpp-af-slider-fill { background: #851625; left: 0; right: 0; }
.wlpp-af-range {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 28px;
	margin: 0;
	background: none;
	pointer-events: none;
	-webkit-appearance: none;
	appearance: none;
}
.wlpp-af-range::-webkit-slider-thumb {
	-webkit-appearance: none;
	pointer-events: all;
	width: 18px; height: 18px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid #851625;
	box-shadow: 0 1px 3px rgba(0,0,0,.2);
	cursor: pointer;
}
.wlpp-af-range::-moz-range-thumb {
	pointer-events: all;
	width: 18px; height: 18px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid #851625;
	box-shadow: 0 1px 3px rgba(0,0,0,.2);
	cursor: pointer;
}
.wlpp-af-price-inputs {
	display: flex;
	align-items: center;
	gap: 8px;
}
.wlpp-af-price-field {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	flex: 1 1 0;
	border: 1px solid #d9d2c8;
	border-radius: 7px;
	padding: 5px 8px;
	font-size: 13px;
	background: #fff;
}
.wlpp-af-price-field input {
	border: 0;
	padding: 0;
	width: 100%;
	font-size: 13px;
	background: none;
	-moz-appearance: textfield;
}
.wlpp-af-price-field input::-webkit-outer-spin-button,
.wlpp-af-price-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.wlpp-af-price-dash { color: #9a8f82; }

/* ---- Apply button ---- */
.wlpp-af-apply {
	display: block;
	width: 100%;
	margin-top: 6px;
	padding: 10px 16px;
	background: #851625;
	color: #fff;
	border: 0;
	border-radius: 8px;
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	transition: background .12s;
}
.wlpp-af-apply:hover { background: #6d1019; }

/* ---- Active chips ---- */
.wlpp-af-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 18px;
}
.wlpp-af-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 10px;
	background: #f3ece2;
	border: 1px solid #e3d9cc;
	border-radius: 999px;
	font-size: 12.5px;
	color: #2b2622;
	text-decoration: none;
	line-height: 1;
}
.wlpp-af-chip:hover { background: #ece2d4; }
.wlpp-af-chip-x { font-size: 15px; color: #851625; line-height: 1; }
.wlpp-af-chip-clear {
	background: none;
	border: 0;
	color: #851625;
	font-weight: 600;
}
.wlpp-af-chip-clear:hover { background: none; text-decoration: underline; }

/* ---- Toolbar: [Filter btn] [result count] [sort] ---- */
.wlpp-af-toolbar {
	display: flex;
	align-items: center;
	gap: 14px;
	margin: 0 0 16px;
	flex-wrap: wrap;
}
.wlpp-af-toolbar .woocommerce-result-count {
	margin: 0;
	color: #6b6359;
	font-size: 13.5px;
	float: none;
}
.wlpp-af-toolbar .woocommerce-ordering {
	margin: 0 0 0 auto;   /* push sort to the right */
	float: none;
}
/* Brand-styled sort dropdown (overrides Divi/WC default select chrome).
   Scoped to the whole wrap so it stays styled when JS relocates the sort
   control into the mobile drawer. */
.wlpp-af-wrap .woocommerce-ordering select,
.wlpp-af-wrap select.orderby {
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	max-width: 240px;
	padding: 9px 38px 9px 14px;
	background-color: #fff;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%23851625' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	background-size: 16px;
	border: 1px solid #d9d2c8;
	border-radius: 8px;
	color: #2b2622;
	font-size: 13.5px;
	font-weight: 500;
	line-height: 1.2;
	height: auto;
	cursor: pointer;
	transition: border-color .12s, box-shadow .12s;
}
.wlpp-af-wrap .woocommerce-ordering select:hover { border-color: #851625; }
.wlpp-af-wrap .woocommerce-ordering select:focus {
	outline: none;
	border-color: #851625;
	box-shadow: 0 0 0 3px rgba(133,22,37,.12);
}

/* Filter trigger button (mobile only — base look defined here, shown in MQ) */
.wlpp-af-toggle {
	align-items: center;
	gap: 8px;
	padding: 9px 16px;
	background: #fff;
	border: 1px solid #d9d2c8;
	border-radius: 8px;
	font-size: 13.5px;
	font-weight: 600;
	color: #2b2622;
	cursor: pointer;
	line-height: 1;
}
.wlpp-af-toggle:hover { border-color: #851625; }
.wlpp-af-toggle-ico {
	width: 16px; height: 16px;
	background: currentColor;
	-webkit-mask: no-repeat center / contain;
	mask: no-repeat center / contain;
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 5h18M6 12h12M10 19h4' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 5h18M6 12h12M10 19h4' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}
.wlpp-af-toggle-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px; height: 18px;
	padding: 0 5px;
	background: #851625;
	color: #fff;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 700;
}

/* Rail close button (mobile drawer only) */
.wlpp-af-close {
	width: 32px; height: 32px;
	border: 0;
	background: none;
	font-size: 26px;
	line-height: 1;
	color: #6b6359;
	cursor: pointer;
}

/* ---- Responsive: rail becomes a left off-canvas drawer ---- */
@media (max-width: 980px) {
	.wlpp-af-wrap { display: block; }

	.wlpp-af-toggle { display: inline-flex; }
	.wlpp-af-close  { display: block; }

	/* Drawer = flex column: fixed header, scrollable body, pinned footer.
	   (Avoids the sticky-button-floating-mid-content bug.) */
	.wlpp-af-rail {
		position: fixed;
		top: 0;
		left: 0;
		z-index: 100000;
		width: 320px;
		max-width: 86vw;
		height: 100%;
		height: 100dvh;
		margin: 0;
		padding: 0;
		background: #fff;
		box-shadow: 0 0 40px rgba(0,0,0,.18);
		overflow: hidden;            /* the body scrolls, not the whole rail */
		display: flex;
		flex-direction: column;
		transform: translateX(-100%);
		transition: transform .26s ease;
	}
	.wlpp-af-wrap.is-open .wlpp-af-rail { transform: translateX(0); }

	.wlpp-af-rail-head {
		flex: 0 0 auto;
		margin: 0;
		padding: 16px 18px 12px;
	}
	.wlpp-af-scroll {
		flex: 1 1 auto;
		min-height: 0;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		padding: 14px 18px 18px;
	}
	.wlpp-af-apply {
		flex: 0 0 auto;
		margin: 0;
		width: 100%;
		border-radius: 0;
		padding: 15px 16px;
		font-size: 15px;
	}

	/* Dim overlay — only paints + catches clicks when JS removes [hidden] */
	.wlpp-af-overlay:not([hidden]) {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 99999;
		background: rgba(28,24,20,.5);
	}
	body.wlpp-af-lock { overflow: hidden; }

	.wlpp-af-options { max-height: none; }
	.wlpp-af-toolbar .woocommerce-result-count { width: 100%; order: 3; }

	/* Sort moved into the drawer (JS) — show the slot once it's filled.
	   Padded divider so it doesn't crowd the Price facet title below. */
	.wlpp-af-sort-slot.is-filled {
		display: block;
		margin: 0 0 34px;
		padding: 0 0 28px;
		border-bottom: 1px solid #ece6dd;
	}
	/* Belt-and-braces: also push the first facet down from the divider. */
	.wlpp-af-sort-slot.is-filled + .wlpp-af-form .wlpp-af-facet:first-child { margin-top: 6px; }
	.wlpp-af-sort-slot .wlpp-af-sort-label { display: block; margin: 0 0 8px; }
	.wlpp-af-sort-slot .woocommerce-ordering { margin: 0; width: 100%; }
	.wlpp-af-sort-slot .woocommerce-ordering select { width: 100%; max-width: none; }
}

@media (max-width: 480px) {
	.wlpp-af-toolbar { gap: 10px; }
	.wlpp-af-toggle { flex: 1 1 100%; justify-content: center; }
	.wlpp-af-toolbar .woocommerce-ordering { margin-left: 0; flex: 1 1 100%; }
	.wlpp-af-toolbar .woocommerce-ordering select { max-width: none; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
	.wlpp-af-rail, .wlpp-af-overlay { transition: none; }
}

/* ---- AJAX loading state (Phase 2c) ---- */
.wlpp-af-results { position: relative; }
.wlpp-af-wrap.is-loading .wlpp-af-results {
	opacity: .45;
	pointer-events: none;
	transition: opacity .15s;
}
.wlpp-af-wrap.is-loading .wlpp-af-results::after {
	content: "";
	position: absolute;
	top: 90px;
	left: 50%;
	width: 34px; height: 34px;
	margin-left: -17px;
	border: 3px solid #e3d9cc;
	border-top-color: #851625;
	border-radius: 50%;
	animation: wlpp-af-spin .7s linear infinite;
}
@keyframes wlpp-af-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
	.wlpp-af-wrap.is-loading .wlpp-af-results::after { animation: none; }
}

/* ---- Product grid: even CSS grid (Divi's float layout staggers when
   cards have different heights — ratings vs none, price vs price-range).
   Grid keeps rows aligned regardless of card height. ---- */
.wlpp-af-archive ul.products {
	display: grid !important;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 52px 26px;   /* generous row gap so prices clear the next row's image/badge */
	margin: 0 0 34px !important;
}
.wlpp-af-archive ul.products::before,
.wlpp-af-archive ul.products::after { content: none !important; display: none !important; } /* kill Divi float clearfix */
.wlpp-af-archive ul.products li.product {
	width: auto !important;
	margin: 0 !important;
	padding: 0 !important;
	float: none !important;
	clear: none !important;
}
/* Larger desktops: a touch more breathing room, still 3-up beside the rail */
@media (max-width: 1100px) {
	.wlpp-af-archive ul.products { gap: 28px 20px; }
}
@media (max-width: 768px) {
	.wlpp-af-archive ul.products {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 32px 14px;
		margin: 0 0 24px !important;
	}
}

/* ---- Breathing room above the rail (under the H1) + before the footer ---- */
.wlpp-af-wrap { margin-top: 20px; margin-bottom: 56px; }

/* ---- Branded pagination ----
   The <ul> ALSO carries the .page-numbers class, so theme rules on
   .page-numbers can paint an outer box behind the buttons. Hard-reset
   the nav / ul / li chrome so only the individual buttons show a box. */
.wlpp-af-results .woocommerce-pagination,
.wlpp-af-results .woocommerce-pagination ul.page-numbers,
.wlpp-af-results .woocommerce-pagination ul.page-numbers > li {
	background: none !important;
	border: 0 !important;
	box-shadow: none !important;
}
.wlpp-af-results .woocommerce-pagination { margin: 8px 0 0; text-align: center; }
.wlpp-af-results .woocommerce-pagination ul {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 6px;
	list-style: none;
	margin: 0;
	padding: 0;
}
.wlpp-af-results .woocommerce-pagination ul li {
	display: flex;
	list-style: none;
	margin: 0;
	padding: 0;
}
.wlpp-af-results .woocommerce-pagination ul li .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 8px;
	border: 1px solid #e3d9cc;
	border-radius: 8px;
	background: #fff;
	color: #2b2622;
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	transition: background .12s, border-color .12s, color .12s;
}
.wlpp-af-results .woocommerce-pagination ul li a.page-numbers:hover {
	border-color: #851625;
	color: #851625;
}
.wlpp-af-results .woocommerce-pagination ul li .page-numbers.current {
	background: #851625;
	border-color: #851625;
	color: #fff;
}
.wlpp-af-results .woocommerce-pagination ul li .page-numbers.dots {
	border-color: transparent;
	background: none;
}
