/**
 * E-Grow Components: Swatches (product variations).
 *
 * The selected box uses the accent colour from Settings > E-Grow Components, or black when it is empty.
 */

.egc-has-sw {
	position: relative;
}

/* The WooCommerce dropdown stays in the page for the variation script, but is hidden. */
.egc-has-sw select,
.egc-has-sw .select2-container {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	opacity: 0 !important;
	pointer-events: none !important;
	overflow: hidden !important;
}

.egc-sw {
	--_on: var(--egc-accent, #111);
	--_r: var(--egc-sw-radius, 0px);
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 2px 0;
}

/* "all: unset" keeps theme button styles away from the boxes. */
.egc-sw .egc-sw__btn {
	all: unset;
	box-sizing: border-box;
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 46px;
	height: 40px;
	padding: 0 12px;
	border: 1px solid #d4d4d4;
	border-radius: var(--_r);
	background: #fff;
	color: #111;
	font-family: inherit;
	font-size: 14px;
	line-height: 1;
	letter-spacing: 0.02em;
	cursor: pointer;
	transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.egc-sw .egc-sw__btn:hover {
	border-color: var(--_on);
}

.egc-sw .egc-sw__btn.is-selected,
.egc-sw .egc-sw__btn.is-selected:hover {
	border-color: var(--_on);
	background: var(--_on);
	color: #fff;
}

.egc-sw .egc-sw__btn:focus {
	outline: none;
}

.egc-sw .egc-sw__btn:focus-visible {
	outline: 2px solid var(--_on);
	outline-offset: 2px;
}

/* Colours: round dots */
.egc-sw--color .egc-sw__btn {
	width: 36px;
	min-width: 36px;
	height: 36px;
	padding: 3px;
	border-radius: 50%;
}

.egc-sw--color .egc-sw__btn.is-selected,
.egc-sw--color .egc-sw__btn.is-selected:hover {
	background: #fff;
	border: 2px solid var(--_on);
	padding: 2px;
}

.egc-sw__dot {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

/* Combination that does not exist */
.egc-sw .egc-sw__btn.is-disabled {
	cursor: not-allowed;
	opacity: 0.4;
}

.egc-sw .egc-sw__btn.is-disabled::after {
	content: "";
	position: absolute;
	left: 50%;
	top: -2px;
	bottom: -2px;
	width: 1px;
	background: #888;
	transform: rotate(45deg);
}

.egc-sw__name {
	margin-top: 6px;
	font-size: 13px;
	color: #555;
	min-height: 1.2em;
}

.egc-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* "Please choose a colour": shown when Add to cart is pressed before this attribute is chosen. */
.egc-sw__hint {
	margin-top: 8px;
	font-size: 13px;
	line-height: 1.4;
	color: var(--egc-sw-hint, #111);
}

.egc-sw__hint[hidden] {
	display: none;
}

.egc-has-sw.is-missing .egc-sw {
	animation: egc-sw-nudge 0.4s ease;
}

.egc-has-sw.is-missing .egc-sw .egc-sw__btn:not(.is-disabled) {
	border-color: var(--egc-sw-hint, #111);
}

@keyframes egc-sw-nudge {
	0%, 100% { transform: none; }
	25% { transform: translateX(-4px); }
	75% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {

	.egc-has-sw.is-missing .egc-sw {
		animation: none;
	}
}
