/**
 * Garnr Core — Variation buttons.
 *
 * Ported from storefront-garnr (sass/components/_product-page-variable.scss).
 * Each option is a radio button whose label is drawn as a box; the radio
 * itself is hidden. Theme-neutral: Blocksy spacing lives in solvd-child.
 *
 * Colours are custom properties so the theme can retune them without
 * overriding selectors. The defaults are the old site's values; the old
 * site had a textured background, so a white "selected" box stood out. On
 * a white page, set --garnr-variation-checked-bg / -checked-border in the
 * theme so the chosen option is visible.
 */

form.variations_form {
	--garnr-variation-border: #ccc;
	--garnr-variation-bg: transparent;
	--garnr-variation-hover-bg: #fff;
	--garnr-variation-checked-bg: #fff;
	--garnr-variation-checked-border: var(--garnr-variation-border);
	--garnr-variation-checked-color: #111;
	--garnr-variation-disabled-opacity: 0.3;
}

form.variations_form table.variations {
	width: 100%;
}

form.variations_form table.variations .label {
	margin-bottom: 10px;
}

form.variations_form table.variations .label label {
	font-weight: 700;
	color: #111;
	font-size: 14px;
}

form.variations_form table.variations .value {
	display: flex;
	flex-wrap: wrap;
	margin-bottom: 10px;
}

form.variations_form table.variations .reset_variations {
	display: inline-block;
	padding: 3px 10px 0 10px;
	margin-left: 0;
	visibility: hidden;
}

/*
 * Hide the radio circle but keep it focusable, so keyboard users can still
 * tab to the group and use the arrow keys (the old theme used display:none).
 */
form.variations_form table.variations .value input[type=radio] {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
	opacity: 0;
}

form.variations_form table.variations .value input[type=radio] + label {
	display: block;
	min-width: 90px;
	padding: 0 8px;
	margin: 0 10px 10px 0;
	line-height: 31px;
	font-size: 14px;
	font-weight: 400;
	text-align: center;
	background-color: var(--garnr-variation-bg);
	border: 1px solid var(--garnr-variation-border) !important;
	transition: background-color 0.3s;
	cursor: pointer;
}

form.variations_form table.variations .value input[type=radio] + label:hover {
	background: var(--garnr-variation-hover-bg);
	color: var(--garnr-variation-checked-color);
}

form.variations_form table.variations .value input[type=radio]:checked + label {
	background: var(--garnr-variation-checked-bg);
	color: var(--garnr-variation-checked-color);
	border-color: var(--garnr-variation-checked-border) !important;
}

form.variations_form table.variations .value input[type=radio]:focus-visible + label {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/*
 * Unavailable options: hidden, except in the first attribute row where
 * they stay visible but faded, so customers can still see every colour or
 * size that exists. The script marks them disabled.
 */
form.variations_form table.variations tbody .value input[type=radio]:disabled + label {
	display: none;
}

form.variations_form table.variations tbody > tr:first-child .value input[type=radio]:disabled + label {
	display: block;
	opacity: var(--garnr-variation-disabled-opacity);
}

form.variations_form .woocommerce-variation-price .price {
	margin: 0;
}
