/**
 * Catalogue filters widget.
 *
 * Rows are 44px tall at 16px text so they work as thumb targets inside the
 * phone drawer; on desktop the same rows simply read as a tidy list. Colours
 * come from the storefront theme's tokens, with neutral fallbacks for any
 * other theme.
 */

.tcgc-filters {
	--tcgc-f-ink: var( --tcgsf-ink, #1c1c22 );
	--tcgc-f-soft: var( --tcgsf-ink-soft, #3c3c48 );
	--tcgc-f-muted: var( --tcgsf-muted, #62626e );
	--tcgc-f-border: var( --tcgsf-border, #dcdce3 );
	--tcgc-f-surface: var( --tcgsf-surface, #fff );
	--tcgc-f-surface-alt: var( --tcgsf-surface-alt, #f3f4f8 );
	--tcgc-f-primary: var( --tcgsf-primary, #1f6f6f );
	--tcgc-f-primary-soft: var( --tcgsf-primary-soft, #e2f1f1 );
	--tcgc-f-radius: var( --tcgsf-radius-sm, 8px );
	font-size: 16px;
	color: var( --tcgc-f-ink );
}

.tcgc-filters__active {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 44px;
	padding: 6px 12px;
	margin-bottom: 8px;
	border-radius: var( --tcgc-f-radius );
	background: var( --tcgc-f-primary-soft );
	font-size: 14px;
	font-weight: 600;
	color: var( --tcgc-f-soft );
}

.tcgc-filters__clear {
	display: inline-flex;
	align-items: center;
	min-height: 32px;
	padding: 0 4px;
	color: var( --tcgc-f-primary );
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 3px;
	white-space: nowrap;
}

.tcgc-filter {
	margin: 0;
	padding: 10px 0 12px;
	border: 0;
	border-bottom: 1px solid var( --tcgc-f-border );
	min-width: 0;
}

.tcgc-filter:last-child { border-bottom: 0; }

.tcgc-filter__title {
	display: block;
	padding: 0;
	margin: 0 0 4px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var( --tcgc-f-muted );
}

.tcgc-filter__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.tcgc-filter__list li { margin: 0; padding: 0; }

/* Each option is a link styled as a checkbox row: it works without
   JavaScript, and the storefront's AJAX catalogue intercepts it like any
   other filter link. */
.tcgc-filters .tcgc-filter__opt {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 44px;
	padding: 6px 4px 6px 0;
	color: var( --tcgc-f-soft );
	font-size: 16px;
	line-height: 1.3;
	text-decoration: none;
	border-radius: var( --tcgc-f-radius );
}

.tcgc-filters .tcgc-filter__opt:hover { color: var( --tcgc-f-ink ); text-decoration: none; }

.tcgc-filters .tcgc-filter__opt:focus-visible {
	outline: 2px solid var( --tcgc-f-primary );
	outline-offset: 2px;
}

.tcgc-filter__mark {
	position: relative;
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
	border: 2px solid var( --tcgc-f-border );
	border-radius: 6px;
	background: var( --tcgc-f-surface );
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.tcgc-filter__opt--radio .tcgc-filter__mark { border-radius: 50%; }

.tcgc-filter__opt.is-active .tcgc-filter__mark {
	border-color: var( --tcgc-f-primary );
	background: var( --tcgc-f-primary );
}

.tcgc-filter__opt.is-active .tcgc-filter__mark::after {
	content: '';
	position: absolute;
	left: 6px;
	top: 2px;
	width: 5px;
	height: 10px;
	border: solid #fff;
	border-width: 0 2.5px 2.5px 0;
	transform: rotate( 45deg );
}

.tcgc-filter__opt--radio.is-active .tcgc-filter__mark::after {
	left: 5px;
	top: 5px;
	width: 8px;
	height: 8px;
	border: 0;
	border-radius: 50%;
	background: #fff;
	transform: none;
}

.tcgc-filter__opt.is-active .tcgc-filter__label { color: var( --tcgc-f-ink ); font-weight: 600; }

.tcgc-filter__label { flex: 1 1 auto; min-width: 0; }

.tcgc-filter__count {
	flex: 0 0 auto;
	min-width: 28px;
	padding: 2px 8px;
	border-radius: 999px;
	background: var( --tcgc-f-surface-alt );
	color: var( --tcgc-f-muted );
	font-size: 13px;
	font-weight: 600;
	text-align: center;
}

/* ---- Price --------------------------------------------------------------- */

.tcgc-filter__price {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 4px 0 0;
}

.tcgc-filter__price-field {
	position: relative;
	display: block;
	flex: 1 1 0;
	min-width: 0;
	margin: 0;
}

.tcgc-filter__price-symbol {
	position: absolute;
	left: 10px;
	top: 50%;
	transform: translateY( -50% );
	color: var( --tcgc-f-muted );
	font-size: 15px;
	pointer-events: none;
}

.tcgc-filters .tcgc-filter__price input[type='number'] {
	width: 100%;
	min-height: 44px;
	padding: 8px 8px 8px 26px;
	border: 1px solid var( --tcgc-f-border );
	border-radius: var( --tcgc-f-radius );
	background: var( --tcgc-f-surface );
	color: var( --tcgc-f-ink );
	font-size: 16px;
	-moz-appearance: textfield;
	appearance: textfield;
}

.tcgc-filters .tcgc-filter__price input[type='number']::-webkit-outer-spin-button,
.tcgc-filters .tcgc-filter__price input[type='number']::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }

.tcgc-filter__price-dash { flex: 0 0 auto; color: var( --tcgc-f-muted ); }

.tcgc-filters .tcgc-filter__price-go {
	flex: 0 0 auto;
	min-width: 48px;
	min-height: 44px;
	padding: 8px 14px;
	border: 1px solid var( --tcgc-f-primary );
	border-radius: var( --tcgc-f-radius );
	background: var( --tcgc-f-primary );
	color: #fff;
	font: inherit;
	font-size: 15px;
	font-weight: 700;
	cursor: pointer;
}

.tcgc-filters .tcgc-filter__price-go:hover { filter: brightness( 0.92 ); }

/* Dark mode: the storefront theme sets these tokens on the root, so the
   widget follows; only the check glyph colour needs stating. */
:root[ data-tcgsf-theme='dark' ] .tcgc-filter__opt.is-active .tcgc-filter__mark::after { border-color: #0f1a1a; }
:root[ data-tcgsf-theme='dark' ] .tcgc-filter__opt--radio.is-active .tcgc-filter__mark::after { background: #0f1a1a; }
