/*
 * Custom Woo Filters — frontend styles
 * Inherits the theme font (Dana/DanaVar on this site) and WoodMart's primary color.
 * Logical properties throughout, so RTL and LTR both work.
 */

/* Tokens are owned by the plugin (light/dark set in settings via inline CSS),
   never inherited from the theme — a dark theme must not turn options white. */
.cwf,
.cwf-drawer,
.cwf-mobile-trigger,
.cwf-page-loop {
	--cwf-accent: var(--wd-primary-color, #0f766e);
	--cwf-text: #1f2937;
	--cwf-muted: #6b7280;
	--cwf-line: rgba(17, 24, 39, 0.12);
	--cwf-soft: rgba(17, 24, 39, 0.05);
	--cwf-surface: #fff;
	--cwf-mark-bg: #fff;
	--cwf-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
	font-family: inherit;
	color: var(--cwf-text);
}

/* ---- Theme hardening (WoodMart styles every <button>, label and select) ---- */
.cwf.cwf,
.cwf.cwf label,
.cwf.cwf .cwf-name,
.cwf.cwf .cwf-name a,
.cwf.cwf .cwf-group__head,
.cwf.cwf select,
.cwf.cwf option,
.cwf-drawer.cwf-drawer .cwf-drawer__head {
	color: var(--cwf-text);
}

.cwf.cwf button,
.cwf-drawer.cwf-drawer button,
button.cwf-mobile-trigger.cwf-mobile-trigger {
	min-height: 0;
	height: auto;
	box-shadow: none;
	text-transform: none;
	letter-spacing: normal;
	line-height: 1.6;
	font-family: inherit;
}

.cwf.cwf .cwf-group__head,
.cwf.cwf .cwf-group__head:hover,
.cwf.cwf .cwf-group__head:focus,
.cwf.cwf .cwf-tree-toggle,
.cwf.cwf .cwf-tree-toggle:hover {
	background: transparent;
	border: 0;
	border-radius: 0;
}

.cwf.cwf select {
	background-color: var(--cwf-surface);
	border-color: var(--cwf-line);
}

.cwf {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 14px;
	line-height: 1.7;
	transition: opacity 0.2s var(--cwf-ease);
}

.cwf *,
.cwf *::before,
.cwf *::after {
	box-sizing: border-box;
}

.cwf.is-loading {
	opacity: 0.55;
	pointer-events: none;
}

/* ---------------------------------------------------------------- Chips */

.cwf-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding-block-end: 12px;
	border-block-end: 1px solid var(--cwf-line);
	margin-block-end: 4px;
}

.cwf.cwf .cwf-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px 4px 8px;
	border: 1px solid color-mix(in srgb, var(--cwf-accent) 35%, transparent);
	border-radius: 999px;
	background: color-mix(in srgb, var(--cwf-accent) 8%, transparent);
	color: var(--cwf-accent);
	font: inherit;
	font-size: 12.5px;
	line-height: 1.6;
	cursor: pointer;
	transition: background-color 0.15s, border-color 0.15s;
}

.cwf.cwf .cwf-chip:hover {
	background: color-mix(in srgb, var(--cwf-accent) 16%, transparent);
}

.cwf.cwf .cwf-chip--clear {
	border-color: var(--cwf-line);
	background: transparent;
	color: var(--cwf-muted);
}

/* --------------------------------------------------------------- Groups */

.cwf-group {
	border-block-end: 1px solid var(--cwf-line);
}

.cwf-group:last-child {
	border-block-end: 0;
}

.cwf-group__title {
	margin: 0;
	font-size: inherit;
	font-weight: inherit;
}

.cwf.cwf .cwf-group__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 12px 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-weight: 700;
	font-size: 14.5px;
	text-align: start;
	cursor: pointer;
}

.cwf-group.is-active .cwf-group__head span::after {
	content: "";
	display: inline-block;
	width: 6px;
	height: 6px;
	margin-inline-start: 8px;
	border-radius: 50%;
	background: var(--cwf-accent);
	vertical-align: middle;
}

.cwf-caret {
	flex: none;
	color: var(--cwf-muted);
	transition: transform 0.25s var(--cwf-ease);
}

.cwf-group__head[aria-expanded="false"] .cwf-caret {
	transform: rotate(90deg);
}

[dir="rtl"] .cwf-group__head[aria-expanded="false"] .cwf-caret,
.rtl .cwf-group__head[aria-expanded="false"] .cwf-caret {
	transform: rotate(-90deg);
}

.cwf-group__body {
	padding-block-end: 14px;
	animation: cwf-reveal 0.22s var(--cwf-ease);
}

@keyframes cwf-reveal {
	from { opacity: 0; transform: translateY(-4px); }
	to { opacity: 1; transform: none; }
}

.cwf-search {
	width: 100%;
	margin-block-end: 8px;
	padding: 7px 10px;
	border: 1px solid var(--cwf-line);
	border-radius: 8px;
	background: var(--cwf-soft);
	font: inherit;
	font-size: 13px;
}

/* -------------------------------------------------------------- Options */

.cwf-list {
	margin: 0;
	padding: 0;
	list-style: none;
	max-height: 280px;
	overflow-y: auto;
	scrollbar-width: thin;
}

.cwf-list .cwf-sub {
	max-height: none;
	overflow: visible;
	padding-inline-start: 22px;
}

.cwf-opt {
	position: relative;
	margin: 0;
}

.cwf-opt > label {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 5px 2px;
	cursor: pointer;
	border-radius: 6px;
	transition: background-color 0.15s;
}

.cwf-opt > label:hover {
	background: var(--cwf-soft);
}

.cwf-opt.is-disabled > label {
	opacity: 0.4;
	cursor: default;
}

.cwf-opt input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	pointer-events: none;
}

.cwf-mark {
	flex: none;
	position: relative;
	width: 18px;
	height: 18px;
	border: 1.5px solid color-mix(in srgb, var(--cwf-text) 35%, transparent);
	border-radius: 5px;
	background: var(--cwf-mark-bg);
	transition: background-color 0.15s, border-color 0.15s;
}

.cwf-mark::after {
	content: "";
	position: absolute;
	inset: 3px 5px 5px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg) scale(0);
	transition: transform 0.18s var(--cwf-ease);
}

input[type="radio"] + .cwf-mark {
	border-radius: 50%;
}

input[type="radio"] + .cwf-mark::after {
	inset: 4px;
	border: 0;
	border-radius: 50%;
	background: #fff;
	transform: scale(0);
}

.cwf-opt input:checked + .cwf-mark {
	border-color: var(--cwf-accent);
	background: var(--cwf-accent);
}

.cwf-opt input:checked + .cwf-mark::after {
	transform: rotate(45deg) scale(1);
}

.cwf-opt input[type="radio"]:checked + .cwf-mark::after {
	transform: scale(1);
}

.cwf-opt input:focus-visible ~ .cwf-mark,
.cwf-opt input:focus-visible ~ .cwf-swatch {
	outline: 2px solid var(--cwf-accent);
	outline-offset: 2px;
}

.cwf-name {
	flex: 1;
	min-width: 0;
}

.cwf-name a {
	color: inherit;
	text-decoration: none;
}

.cwf-opt.is-selected .cwf-name {
	font-weight: 600;
}

.cwf-count {
	flex: none;
	min-width: 26px;
	padding: 0 6px;
	border-radius: 999px;
	background: var(--cwf-soft);
	color: var(--cwf-muted);
	font-size: 11.5px;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

/* Labels view: pill buttons */
.cwf-view-labels .cwf-list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	max-height: none;
}

.cwf-view-labels .cwf-mark {
	display: none;
}

.cwf-view-labels .cwf-opt > label {
	padding: 5px 12px;
	border: 1px solid var(--cwf-line);
	border-radius: 999px;
	gap: 6px;
}

.cwf-view-labels .cwf-opt.is-selected > label {
	border-color: var(--cwf-accent);
	background: color-mix(in srgb, var(--cwf-accent) 10%, transparent);
	color: var(--cwf-accent);
}

.cwf-view-labels .cwf-count {
	background: none;
	padding: 0;
	min-width: 0;
}

/* Color & image swatches */
.cwf-view-color .cwf-list,
.cwf-view-image .cwf-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
	gap: 2px 8px;
}

.cwf-swatch {
	flex: none;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--cwf-swatch, #ddd);
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
	transition: box-shadow 0.18s var(--cwf-ease);
}

.cwf-swatch--img {
	overflow: hidden;
	border-radius: 7px;
	width: 32px;
	height: 32px;
	background: var(--cwf-soft);
}

.cwf-swatch--img img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cwf-opt.is-selected .cwf-swatch {
	box-shadow: 0 0 0 2px var(--cwf-surface), 0 0 0 4px var(--cwf-accent);
}

/* Stars */
.cwf-stars {
	--cwf-star: #f5a524;
	position: relative;
	display: inline-block;
	width: 80px;
	height: 16px;
	background: linear-gradient(90deg, var(--cwf-star) calc(var(--cwf-stars) * 20%), #d9dce1 0);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.2l2.1 4.3 4.7.7-3.4 3.3.8 4.7L8 12l-4.2 2.2.8-4.7L1.2 6.2l4.7-.7z'/%3E%3C/svg%3E") left/16px 16px repeat-x;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.2l2.1 4.3 4.7.7-3.4 3.3.8 4.7L8 12l-4.2 2.2.8-4.7L1.2 6.2l4.7-.7z'/%3E%3C/svg%3E") left/16px 16px repeat-x;
}

[dir="rtl"] .cwf-stars,
.rtl .cwf-stars {
	transform: scaleX(-1);
}

.cwf-view-rating .cwf-name {
	color: var(--cwf-muted);
	font-size: 12.5px;
}

/* Hierarchy */
.cwf.cwf .cwf-tree-toggle {
	position: absolute;
	inset-block-start: 6px;
	inset-inline-end: 34px;
	width: 22px;
	height: 22px;
	border: 0;
	border-radius: 6px;
	background: transparent;
	cursor: pointer;
}

.cwf-tree-toggle::before {
	content: "";
	position: absolute;
	inset: 7px;
	border: solid var(--cwf-muted);
	border-width: 0 1.5px 1.5px 0;
	transform: rotate(45deg);
	transition: transform 0.2s var(--cwf-ease);
}

.cwf-tree-toggle[aria-expanded="false"] + .cwf-sub {
	display: none;
}

.cwf-tree-toggle[aria-expanded="true"]::before {
	transform: rotate(-135deg);
}

/* Dropdown */
.cwf-select select {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--cwf-line);
	border-radius: 10px;
	background-color: var(--cwf-surface);
	font: inherit;
	color: inherit;
}

/* ---------------------------------------------------------------- Range */

.cwf-range {
	padding-block: 8px 2px;
}

.cwf-range__track {
	position: relative;
	height: 26px;
}

.cwf-range__track::before,
.cwf-range__fill {
	content: "";
	position: absolute;
	inset-block-start: 11px;
	height: 4px;
	border-radius: 4px;
}

.cwf-range__track::before {
	inset-inline: 0;
	background: var(--cwf-line);
}

.cwf-range__fill {
	background: var(--cwf-accent);
}

.cwf-range input[type="range"] {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 26px;
	margin: 0;
	background: none;
	pointer-events: none;
	-webkit-appearance: none;
	appearance: none;
}

.cwf-range input[type="range"]::-webkit-slider-runnable-track {
	background: none;
	border: 0;
}

.cwf-range input[type="range"]::-moz-range-track {
	background: none;
	border: 0;
}

.cwf-range input[type="range"]::-webkit-slider-thumb {
	pointer-events: auto;
	-webkit-appearance: none;
	width: 20px;
	height: 20px;
	margin-top: 3px;
	border: 2px solid var(--cwf-accent);
	border-radius: 50%;
	background: var(--cwf-surface);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
	cursor: grab;
	transition: transform 0.15s var(--cwf-ease);
}

.cwf-range input[type="range"]::-moz-range-thumb {
	pointer-events: auto;
	width: 16px;
	height: 16px;
	border: 2px solid var(--cwf-accent);
	border-radius: 50%;
	background: var(--cwf-surface);
	cursor: grab;
}

.cwf-range input[type="range"]:active::-webkit-slider-thumb {
	transform: scale(1.15);
	cursor: grabbing;
}

.cwf-range input[type="range"]:focus-visible::-webkit-slider-thumb {
	outline: 2px solid var(--cwf-accent);
	outline-offset: 2px;
}

.cwf-range__fields {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-block-start: 10px;
}

.cwf-range__fields label {
	flex: 1;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 5px 10px;
	border: 1px solid var(--cwf-line);
	border-radius: 8px;
	font-size: 12px;
	color: var(--cwf-muted);
}

.cwf-range__fields input {
	width: 100%;
	min-width: 0;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--cwf-text);
	font-variant-numeric: tabular-nums;
	box-shadow: none;
}

.cwf-range__unit {
	font-style: normal;
	font-size: 12px;
	color: var(--cwf-muted);
}

/* ----------------------------------------------------------------- H1 */

.cwf-h1 {
	margin: 0 0 18px;
	line-height: 1.5;
}

/* --------------------------------------------------- Loop & skeleton */

.cwf-loop {
	position: relative;
	min-height: 200px;
}

.cwf-loop.is-loading > :not(.cwf-skeleton) {
	visibility: hidden;
}

.cwf-skeleton {
	position: absolute;
	inset: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
	align-content: start;
	gap: 20px;
}

.cwf-skel-card {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.cwf-skel-img,
.cwf-skel-line {
	display: block;
	border-radius: 10px;
	background: linear-gradient(90deg, #eef0f3 0%, #f7f8fa 45%, #eef0f3 90%);
	background-size: 250% 100%;
	animation: cwf-shimmer 1.2s linear infinite;
}

.cwf-skel-img {
	aspect-ratio: 1 / 1;
}

.cwf-skel-line {
	height: 12px;
	width: 85%;
}

.cwf-skel-line--short {
	width: 45%;
}

@keyframes cwf-shimmer {
	from { background-position: 100% 0; }
	to { background-position: -150% 0; }
}

.cwf.is-loading .cwf-count {
	color: transparent;
	background: linear-gradient(90deg, #eef0f3 0%, #f7f8fa 45%, #eef0f3 90%);
	background-size: 250% 100%;
	animation: cwf-shimmer 1.2s linear infinite;
}

/* ------------------------------------------------------ Mobile trigger */

button.cwf-mobile-trigger.cwf-mobile-trigger {
	display: none;
	align-items: center;
	gap: 8px;
	margin-block-end: 16px;
	padding: 9px 16px;
	border: 1px solid var(--cwf-line);
	border-radius: 999px;
	background: var(--cwf-surface, #fff);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.cwf-mobile-trigger__n {
	display: inline-grid;
	place-items: center;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	border-radius: 999px;
	background: var(--cwf-accent);
	color: #fff;
	font-size: 11px;
}

.cwf-mobile-trigger__n[hidden] {
	display: none;
}

/* ---------------------------------------------------------------- Drawer */

.cwf-drawer[hidden] {
	display: none;
}

.cwf-drawer {
	position: fixed;
	inset: 0;
	z-index: 99999;
}

.cwf-drawer__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.45);
	opacity: 0;
	transition: opacity 0.28s var(--cwf-ease);
}

.cwf-drawer__panel {
	position: absolute;
	inset-block: 0;
	inset-inline-start: 0;
	display: flex;
	flex-direction: column;
	width: min(88vw, 380px);
	background: var(--cwf-surface);
	box-shadow: 0 0 40px rgba(0, 0, 0, 0.18);
	transform: translateX(100%);
	transition: transform 0.28s var(--cwf-ease);
	outline: none;
}

:root:not([dir="rtl"]) .cwf-drawer__panel {
	transform: translateX(-100%);
}

.cwf-drawer.is-open .cwf-drawer__backdrop {
	opacity: 1;
}

.cwf-drawer.is-open .cwf-drawer__panel {
	transform: none;
}

.cwf-drawer__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 18px;
	border-block-end: 1px solid var(--cwf-line);
	font-size: 16px;
}

.cwf-drawer.cwf-drawer .cwf-drawer__close {
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 50%;
	background: var(--cwf-soft);
	color: inherit;
	cursor: pointer;
}

.cwf-drawer__body {
	flex: 1;
	overflow-y: auto;
	padding: 6px 18px 18px;
	overscroll-behavior: contain;
}

.cwf-drawer__body .cwf-list {
	max-height: none;
}

.cwf-drawer__foot {
	padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
	border-block-start: 1px solid var(--cwf-line);
}

.cwf-drawer.cwf-drawer .cwf-drawer__apply {
	width: 100%;
	padding: 12px;
	border: 0;
	border-radius: 12px;
	background: var(--cwf-accent);
	color: #fff;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

html.cwf-lock,
html.cwf-lock body {
	overflow: hidden;
}

.cwf-drawer__grip {
	display: none;
}

/* Phones: bottom sheet instead of a side drawer — opened from the bottom toolbar,
   so the panel rises from where the thumb already is. */
@media (max-width: 767px) {
	.cwf-drawer__panel,
	:root:not([dir="rtl"]) .cwf-drawer__panel {
		inset-block: auto 0;
		inset-inline: 0;
		width: 100%;
		max-height: 86vh;
		border-radius: 18px 18px 0 0;
		transform: translateY(100%);
	}

	.cwf-drawer.is-open .cwf-drawer__panel {
		transform: none;
	}

	.cwf-drawer__grip {
		display: block;
		width: 40px;
		height: 4px;
		margin: 8px auto 0;
		border-radius: 4px;
		background: var(--cwf-line);
	}

	.cwf-drawer__head {
		padding-block: 8px 12px;
	}

	/* Bigger touch targets */
	.cwf-drawer .cwf-opt > label {
		padding-block: 9px;
	}

	.cwf-drawer .cwf-group__head {
		padding-block: 14px;
	}
}

/* Before JS runs the default breakpoint (1024px) applies; afterwards JS sets .cwf-is-mobile from the configured value. */
@media (max-width: 1024px) {
	html:not(.cwf-js) button.cwf-mobile-trigger.cwf-mobile-trigger {
		display: inline-flex;
	}
}

html.cwf-js.cwf-is-mobile button.cwf-mobile-trigger.cwf-mobile-trigger {
	display: inline-flex;
}

/* Custom pages: result count + trigger row */
.cwf-page-tools {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-block-end: 16px;
}

.cwf-page-tools .woocommerce-result-count {
	margin: 0;
}

.cwf-seo-content {
	margin-block-start: 32px;
}

.cwf-placeholder {
	padding: 16px;
	border: 1px dashed var(--cwf-line, #ccc);
	border-radius: 8px;
	text-align: center;
	color: #6b7280;
}

/* ------------------------------------------------------------ Motion */

@media (prefers-reduced-motion: reduce) {
	.cwf *,
	.cwf-drawer *,
	.cwf-skel-img,
	.cwf-skel-line {
		animation: none !important;
		transition: none !important;
	}
}
