/**
 * Variation swatches.
 *
 * Buttons rendered by inc/variation-swatches.php. The native <select> stays in
 * the DOM as WooCommerce's source of truth and is only hidden visually.
 * Colours are placeholders until the design tokens land.
 */

.pv-swatches {
	--pv-swatch-border: #d8d8e0;
	--pv-swatch-active: #111;
	--pv-swatch-radius: 999px;

	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0 0 0.75rem;
}

/*
 * Hidden from sight, not from WooCommerce: the script reads and writes this
 * select, and screen readers can still reach it.
 */
.pv-swatches + select,
.pv-swatches ~ .reset_variations {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* --- Swatch --------------------------------------------------------------- */

/*
 * Scoped under .pv-swatches throughout: the site's global button styling is
 * dark-on-white and would otherwise win, making every swatch look selected.
 */
.pv-swatches .pv-swatch {
	appearance: none;
	-webkit-appearance: none;
	min-width: 8.5rem;
	padding: 0.7em 1.4em;
	border: 1px solid var(--pv-swatch-border);
	border-radius: var(--pv-swatch-radius);
	background: #fff;
	color: #111;
	font: inherit;
	line-height: 1.2;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.pv-swatches .pv-swatch:hover:not(:disabled) {
	background: #fff;
	border-color: var(--pv-swatch-active);
	color: #111;
}

.pv-swatches .pv-swatch:focus-visible {
	outline: 2px solid var(--pv-swatch-active);
	outline-offset: 2px;
}

.pv-swatches .pv-swatch.is-selected {
	background: var(--pv-swatch-active);
	border-color: var(--pv-swatch-active);
	color: #fff;
}

/* Out of stock in the current combination: visible but clearly not choosable. */
.pv-swatches .pv-swatch.is-unavailable,
.pv-swatches .pv-swatch:disabled {
	background: #fff;
	color: #111;
	opacity: 0.4;
	cursor: not-allowed;
	text-decoration: line-through;
}

/* --- Colour / image swatches --------------------------------------------- */

/*
 * Used when a term carries native WooCommerce colour or image data. Text sits
 * beside the chip rather than inside it, so the label stays readable.
 */
.pv-swatch--color,
.pv-swatch--image {
	min-width: 0;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	border-radius: 50%;
	background-size: cover;
	background-position: center;
}

.pv-swatch--color .pv-swatch__label,
.pv-swatch--image .pv-swatch__label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}

.pv-swatch--color.is-selected,
.pv-swatch--image.is-selected {
	box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--pv-swatch-active);
}

@media (max-width: 480px) {
	.pv-swatch {
		flex: 1 1 auto;
		min-width: 0;
	}
}
