/**
 * Advanced Product Swatches & FAQs for WooCommerce - variation swatches.
 *
 * Size, radius and selected color come from CSS variables generated from the
 * plugin settings (--apsf-thumb-w, --apsf-thumb-h, --apsf-radius, --apsf-selected).
 */

/* Native <select> stays in the DOM (WooCommerce needs it) but is visually hidden. */
.apsf-native-select {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	border: 0 !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	clip-path: inset(50%) !important;
	white-space: nowrap !important;
	opacity: 0 !important;
	pointer-events: none !important;
}

/* Hide select "enhancers" some themes/plugins render next to the native select. */
.apsf-has-swatches .nice-select,
.apsf-has-swatches .select2-container,
.apsf-has-swatches .selectric-wrapper,
.apsf-has-swatches .chosen-container {
	display: none !important;
}

.apsf-swatches {
	--apsf-border: rgba(128, 128, 128, 0.45);
	--apsf-hover: rgba(128, 128, 128, 0.9);
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0.25rem 0 0;
	padding: 0;
}

/* Specificity is intentionally above generic theme `button` rules. */
.apsf-swatches .apsf-swatch {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	gap: 0.3rem;
	box-sizing: border-box;
	width: auto;
	min-width: 0;
	height: auto;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none !important;
	box-shadow: none !important;
	color: inherit !important;
	font: inherit;
	line-height: 1;
	text-align: center;
	text-decoration: none;
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	-webkit-tap-highlight-color: transparent;
}

.apsf-swatches .apsf-swatch__thumb {
	position: relative;
	display: block;
	box-sizing: border-box;
	width: var(--apsf-thumb-w, 48px);
	height: var(--apsf-thumb-h, 48px);
	border: 2px solid var(--apsf-border);
	border-radius: var(--apsf-radius, 6px);
	overflow: hidden;
	background: rgba(128, 128, 128, 0.08);
	transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.apsf-swatches .apsf-swatch__img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	object-fit: cover;
	pointer-events: none;
	-webkit-user-select: none;
	user-select: none;
}

.apsf-swatches .apsf-swatch:hover .apsf-swatch__thumb {
	border-color: var(--apsf-hover);
}

.apsf-swatches .apsf-swatch.is-selected .apsf-swatch__thumb {
	border-color: var(--apsf-selected, #111);
	box-shadow: 0 0 0 1px var(--apsf-selected, #111);
}

.apsf-swatches .apsf-swatch:focus {
	outline: none;
}

.apsf-swatches .apsf-swatch:focus-visible .apsf-swatch__thumb {
	outline: 2px solid var(--apsf-selected, #111);
	outline-offset: 3px;
}

.apsf-swatches .apsf-swatch__label {
	display: block;
	max-width: calc(var(--apsf-thumb-w, 48px) + 1rem);
	font-size: 0.8125rem;
	line-height: 1.25;
	overflow-wrap: anywhere;
}

.apsf-swatches .apsf-swatch.is-selected .apsf-swatch__label {
	font-weight: 600;
}

/* Not selectable right now (no matching variation for the current choices). */
.apsf-swatches .apsf-swatch.is-disabled {
	cursor: not-allowed;
}

.apsf-swatches .apsf-swatch.is-disabled .apsf-swatch__thumb {
	opacity: 0.35;
}

.apsf-swatches .apsf-swatch.is-disabled:hover .apsf-swatch__thumb {
	border-color: var(--apsf-border);
}

.apsf-swatches .apsf-swatch.is-disabled.is-selected:hover .apsf-swatch__thumb {
	border-color: var(--apsf-selected, #111);
}

/* Out of stock: dimmed with a diagonal strike-through. */
.apsf-swatches .apsf-swatch.is-out-of-stock .apsf-swatch__thumb {
	opacity: 0.5;
}

.apsf-swatches .apsf-swatch.is-out-of-stock .apsf-swatch__thumb::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(to top right, transparent calc(50% - 1px), rgba(0, 0, 0, 0.6) 50%, transparent calc(50% + 1px));
	pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
	.apsf-swatches .apsf-swatch__thumb {
		transition: none;
	}
}
