/**
 * OptionGravity Variation Swatches - frontend styles.
 *
 * Anti-flash: the original <select> kept inside .og-swatches-wrap is hidden
 * immediately so the dropdown never appears before the swatches render.
 */

.og-swatches-wrap > select {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/*
 * Attribute rows with no real values (only the "Choose an option"
 * placeholder) are dead ends — hide them outright. `:has()` removes the row
 * with no flash; a JS fallback in swatches.js covers older browsers.
 */
tr:has(> td > .og-empty-attribute) {
	display: none;
}

.og-swatches {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
}

.og-swatch {
	position: relative;
	box-sizing: border-box;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 2px solid #dfe1e4;
	border-radius: 8px;
	background: #fff;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
	-webkit-user-select: none;
	user-select: none;
	overflow: hidden;
}

.og-swatch:hover {
	border-color: #9a9fa6;
	transform: translateY(-1px);
}

.og-swatch:focus-visible {
	outline: 2px solid #2563eb;
	outline-offset: 2px;
}

.og-swatch--selected {
	border-color: #111;
	box-shadow: 0 0 0 1px #111;
}

/* Colour swatches: circular, with a clear outer ring once selected. */
.og-swatch--color {
	width: 36px;
	height: 36px;
	padding: 3px;
	border-radius: 50%;
}

.og-swatch--color .og-swatch-color {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.08 );
}

.og-swatch--color.og-swatch--selected {
	border-color: #fff;
	box-shadow: 0 0 0 2px #111;
	transform: scale( 1.06 );
}

/* Image swatches. */
.og-swatch--image {
	width: 46px;
	height: 46px;
	padding: 2px;
	border-radius: 8px;
}

.og-swatch--image .og-swatch-image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 6px;
}

/* Button / label swatches (and degraded colour/image fallbacks) — used for
   sizes and other short text choices; styled as a clean segmented control. */
.og-swatch--button,
.og-swatch--no-value {
	min-width: 42px;
	height: 40px;
	padding: 0 14px;
	border-radius: 999px;
}

.og-swatch--button.og-swatch--selected,
.og-swatch--no-value.og-swatch--selected {
	background: #111;
}

.og-swatch--button.og-swatch--selected .og-swatch-label,
.og-swatch--no-value.og-swatch--selected .og-swatch-label {
	color: #fff;
}

.og-swatch--button .og-swatch-label,
.og-swatch--no-value .og-swatch-label {
	font-size: 13px;
	font-weight: 500;
	line-height: 1;
	white-space: nowrap;
}

/* Unavailable (out-of-stock / impossible) combinations. */
.og-swatch.og-swatch--disabled {
	opacity: 0.4;
	cursor: not-allowed;
	pointer-events: none;
}

.og-swatch--color.og-swatch--disabled::before {
	content: "";
	position: absolute;
	top: 50%;
	left: -4px;
	right: -4px;
	height: 1.5px;
	background: #c0392b;
	transform: rotate(-45deg);
}
