/**
 * Universal Variation Swatches — front-end styles.
 * All sizes/colours come from CSS custom properties printed by the plugin,
 * so the settings screen never needs a stylesheet rebuild.
 */

.uvs-attribute {
	display: block;
	width: 100%;
}

/* WooCommerce's own <select> stays in the DOM (hidden) so every script that
   talks to it keeps working — themes, quick views, analytics, add-to-cart. */
.uvs-attribute .uvs-select-holder,
.uvs-attribute .select2-container,
.uvs-attribute .nice-select,
.uvs-attribute .selectric-wrapper {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	overflow: hidden !important;
	clip: rect(0 0 0 0) !important;
	clip-path: inset(50%) !important;
	border: 0 !important;
	white-space: nowrap !important;
}

.uvs-head {
	margin: 0 0 6px;
	font-size: 0.95em;
	line-height: 1.3;
}

.uvs-selected-value {
	font-weight: 600;
}

/* "Above" mode: the theme's own <label> is moved in here, on top of the grid. */
.uvs-attribute.uvs-stacked {
	width: 100%;
}

.uvs-attribute.uvs-stacked .uvs-head {
	display: block;
	margin-bottom: 8px;
}

.uvs-attribute.uvs-stacked .uvs-head label {
	display: inline;
	float: none;
	width: auto;
	margin: 0;
	padding: 0;
	font-weight: 600;
	line-height: inherit;
}

/* The row keeps its own label cell; hiding it lets the swatches use full width. */
.uvs-attribute.uvs-stacked .uvs-head .uvs-selected-value {
	font-weight: 400;
}

.uvs-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: var(--uvs-gap, 10px);
	margin: 0 0 10px;
	padding: 0;
	list-style: none;
}

/* ------------------------------------------------------------------ swatch */

.uvs-swatch {
	position: relative;
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--uvs-size, 45px);
	height: var(--uvs-size, 45px);
	padding: 0;
	overflow: visible;
	background-color: #f1f1f1;
	background-clip: padding-box;
	border: var(--uvs-border-width, 2px) solid var(--uvs-border, #ddd);
	border-radius: var(--uvs-radius, 50%);
	cursor: pointer;
	transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
	-webkit-user-select: none;
	user-select: none;
}

.uvs-swatch:hover {
	border-color: var(--uvs-border-hover, #aaa);
}

.uvs-swatch:focus-visible {
	outline: 2px solid var(--uvs-border-selected, #111);
	outline-offset: 2px;
}

/* Colour swatch: the background colour is set inline per term. */
.uvs-swatch-color {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: inherit;
}

/* Image swatch. */
.uvs-swatch.uvs-item-image {
	background-color: transparent;
	overflow: hidden;
}

.uvs-swatch-img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
	border-radius: inherit;
}

/* Label / button swatch. */
.uvs-swatch.uvs-item-button {
	width: auto;
	min-width: var(--uvs-label-min, 45px);
	height: var(--uvs-size, 45px);
	padding: 0 var(--uvs-label-pad, 12px);
	background-color: var(--uvs-label-bg, #f7f7f7);
	color: var(--uvs-label-color, #222);
}

.uvs-swatch-text {
	display: block;
	font-size: var(--uvs-label-font, 13px);
	font-weight: 600;
	line-height: 1.1;
	text-align: center;
	text-transform: var(--uvs-label-transform, none);
	white-space: nowrap;
}

/* --------------------------------------------------------------- selected */

.uvs-swatch.is-selected {
	border-color: var(--uvs-border-selected, #111);
}

.uvs-sel-border .uvs-swatch.is-selected {
	border-width: calc(var(--uvs-border-width, 2px) + 2px);
}

.uvs-sel-ring .uvs-swatch.is-selected {
	box-shadow: 0 0 0 2px #fff inset, 0 0 0 2px var(--uvs-border-selected, #111);
}

.uvs-sel-check .uvs-swatch.is-selected::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 40%;
	height: 22%;
	border: solid #fff;
	border-width: 0 0 3px 3px;
	transform: translate(-50%, -65%) rotate(-45deg);
	filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.65));
	pointer-events: none;
}

.uvs-swatch.uvs-item-button.is-selected {
	background-color: var(--uvs-label-bg-selected, #111);
	color: var(--uvs-label-color-selected, #fff);
}

.uvs-sel-check .uvs-swatch.uvs-item-button.is-selected::before {
	content: none;
}

/* ----------------------------------------------------------- out of stock */

.uvs-swatch.uvs-oos {
	cursor: not-allowed;
}

.uvs-oos-fade .uvs-swatch.uvs-oos,
.uvs-oos-cross .uvs-swatch.uvs-oos,
.uvs-oos-x .uvs-swatch.uvs-oos {
	opacity: 0.55;
}

/* Diagonal line. */
.uvs-oos-cross .uvs-swatch.uvs-oos::after {
	content: "";
	position: absolute;
	top: 50%;
	left: -8%;
	width: 116%;
	height: 2px;
	background: #e02b2b;
	box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.75);
	transform: rotate(-45deg);
	transform-origin: center;
	pointer-events: none;
}

/* Red cross. */
.uvs-oos-x .uvs-swatch.uvs-oos::after {
	content: "\2716";
	position: absolute;
	top: 50%;
	left: 50%;
	color: #e02b2b;
	font-size: calc(var(--uvs-size, 45px) * 0.5);
	font-weight: 700;
	line-height: 1;
	text-shadow: 0 0 2px #fff;
	transform: translate(-50%, -50%);
	pointer-events: none;
}

.uvs-oos-hide .uvs-swatch.uvs-oos {
	display: none;
}

.uvs-swatch.uvs-blocked {
	pointer-events: none;
}

/* Combination not possible with the current selection (synced from the select). */
.uvs-swatch.uvs-unavailable {
	opacity: 0.35;
	filter: grayscale(100%);
}

/* ------------------------------------------------------------ collapsing  */

.uvs-attribute.uvs-has-js .uvs-extra {
	display: none;
}

.uvs-attribute.uvs-has-js.uvs-show-all .uvs-extra {
	display: inline-flex;
}

.uvs-more {
	display: inline-block;
	margin: 0 0 10px;
	padding: 0;
	background: none;
	border: 0;
	color: inherit;
	font-size: 0.9em;
	text-decoration: underline;
	cursor: pointer;
}

.uvs-attribute:not(.uvs-has-js) .uvs-more {
	display: none;
}

/* ---------------------------------------------------------------- tooltip */

.uvs-tip {
	position: absolute;
	bottom: calc(100% + 8px);
	left: 50%;
	z-index: 99;
	display: block;
	max-width: 160px;
	padding: 5px 8px;
	background: #1d1d1d;
	border-radius: 4px;
	color: #fff;
	font-size: 12px;
	font-weight: 400;
	line-height: 1.35;
	text-align: center;
	text-transform: none;
	white-space: nowrap;
	opacity: 0;
	transform: translate(-50%, 4px);
	transition: opacity 0.12s ease, transform 0.12s ease;
	pointer-events: none;
}

.uvs-tip::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	border: 5px solid transparent;
	border-top-color: #1d1d1d;
	transform: translateX(-50%);
}

.uvs-tip img {
	display: block;
	width: 100px;
	height: 100px;
	margin: 0 auto 4px;
	object-fit: cover;
	border-radius: 3px;
}

.uvs-swatch:hover > .uvs-tip,
.uvs-swatch:focus-visible > .uvs-tip {
	opacity: 1;
	transform: translate(-50%, 0);
}

/* ------------------------------------------------------------- shop loop  */

.uvs-loop {
	margin: 6px 0 10px;
	--uvs-size: 24px;
	--uvs-border-width: 1px;
}

.uvs-loop .uvs-swatch {
	cursor: pointer;
}

.uvs-loop .uvs-swatch-text {
	font-size: 11px;
}

.uvs-loop-more {
	align-self: center;
	font-size: 12px;
	text-decoration: none;
	opacity: 0.7;
}

/* ------------------------------------------------------------ responsive  */

@media (max-width: 767px) {
	.uvs-swatch {
		width: var(--uvs-size-mobile, 38px);
		height: var(--uvs-size-mobile, 38px);
	}

	.uvs-swatch.uvs-item-button {
		width: auto;
		height: var(--uvs-size-mobile, 38px);
	}

	.uvs-oos-x .uvs-swatch.uvs-oos::after {
		font-size: calc(var(--uvs-size-mobile, 38px) * 0.5);
	}

	.uvs-loop .uvs-swatch {
		width: 22px;
		height: 22px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.uvs-swatch,
	.uvs-tip {
		transition: none;
	}
}
