/* Variation swatches (includes/class-kw-swatches.php), with the look of the live site's Variation Swatches
   settings: squared 30 × 30 px colour values with a tooltip, a tick on the chosen colour, a cross on
   values that are not available; radio values as a list of radio buttons. */
.kw-swatches {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-start;
	margin: 0;
	padding: 0;
}

.kw-swatch {
	position: relative;
	margin: 0;
	cursor: pointer;
	user-select: none;
}

.kw-swatch.is-disabled {
	cursor: not-allowed;
}

/* Colour values: the radio button is visually hidden; the square is its label. */
.kw-swatch--color {
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	margin: 4px;
	padding: 2px;
	border-radius: 2px;
	background-color: #fff;
	box-shadow: 0 0 0 1px #a8a8a8;
	transition: box-shadow 200ms ease;
}

.kw-swatch--color:last-child {
	margin-right: 0;
}

.kw-swatch--color .kw-swatch__input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: 0;
	opacity: 0;
	pointer-events: none;
}

.kw-swatch--color:hover {
	box-shadow: 0 0 0 3px #ddd;
}

.kw-swatch--color.is-selected,
.kw-swatch--color.is-selected:hover {
	box-shadow: 0 0 0 2px #000;
}

/* Keyboard focus: a clear ring around the value. */
.kw-swatch--color:has(.kw-swatch__input:focus-visible) {
	outline: 2px solid #000;
	outline-offset: 4px;
}

.kw-swatch__contents,
.kw-swatch__color {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
}

.kw-swatch--color.is-selected:not(.is-disabled) .kw-swatch__color::after {
	content: "";
	position: absolute;
	inset: 0;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30' filter='drop-shadow(0px 0px 2px rgb(0 0 0 / .8))'%3E%3Cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='4' d='M4 16L11 23 27 7'/%3E%3C/svg%3E") no-repeat center / 60%;
}

/* Not available: a thin red cross from corner to corner under the colour, the colour faded inside a
   faded box (0.6 × 0.6), as the plugin drew it. */
.kw-swatch--color.is-disabled .kw-swatch__contents,
.kw-swatch--color.is-disabled .kw-swatch__color {
	opacity: 0.6;
}

.kw-swatch--color.is-disabled .kw-swatch__contents::before {
	content: "";
	position: absolute;
	inset: 0;
	background: url("data:image/svg+xml;utf8,%3Csvg filter='drop-shadow(0px 0px 5px rgb(255 255 255 / .6))' xmlns='http://www.w3.org/2000/svg' width='72px' height='72px' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23ff0000' stroke-linecap='round' stroke-width='0.6' d='M5 5L19 19M19 5L5 19'/%3E%3C/svg%3E") no-repeat center;
}

/* Tooltip with the value's name (hover, and keyboard focus). */
.kw-swatch[data-tooltip]::before,
.kw-swatch[data-tooltip]::after {
	position: absolute;
	left: 50%;
	z-index: 3;
	visibility: hidden;
	opacity: 0;
	pointer-events: none;
	transition: opacity 200ms ease, visibility 200ms ease;
}

.kw-swatch[data-tooltip]::before {
	content: attr(data-tooltip);
	bottom: calc(100% + 8px);
	padding: 0.3em 0.6em;
	transform: translateX(-50%);
	border-radius: 3px;
	background-color: #333;
	color: #fff;
	font-size: 14px;
	line-height: 1.3;
	white-space: nowrap;
}

.kw-swatch[data-tooltip]::after {
	content: "";
	bottom: calc(100% + 2px);
	margin-left: -6px;
	border: 6px solid transparent;
	border-top-color: #333;
	border-bottom-width: 0;
}

.kw-swatch[data-tooltip]:hover::before,
.kw-swatch[data-tooltip]:hover::after,
.kw-swatch[data-tooltip]:has(.kw-swatch__input:focus-visible)::before,
.kw-swatch[data-tooltip]:has(.kw-swatch__input:focus-visible)::after {
	visibility: visible;
	opacity: 1;
}

/* Radio values: a list of radio buttons. */
.kw-swatches--radio {
	flex-direction: column;
	align-items: flex-start;
}

/* One line of text: the button sits on it as the plugin's did (2px + 5px in from the side). */
.kw-swatch--radio {
	display: block;
	padding: 2px 7px;
}

.kw-swatch--radio .kw-swatch__input {
	width: 20px;
	height: 20px;
	margin: 3px 3px 0 5px;
	cursor: inherit;
	vertical-align: middle;
}

.kw-swatch--radio .kw-swatch__text {
	margin-inline: 10px;
}

/* Not available: faded as the plugin faded it (the button twice over, 0.5 × 0.5). */
.kw-swatch--radio.is-disabled .kw-swatch__text {
	opacity: 0.5;
}

.kw-swatch--radio.is-disabled .kw-swatch__input {
	opacity: 0.25;
}

.kw-swatch--radio .kw-swatch__input:focus-visible {
	outline: 2px solid #000;
	outline-offset: 2px;
}

/* The spacing WooCommerce and the theme give labels in the variations table does not apply to swatches. */
.variations td.value .kw-swatches label.kw-swatch--color {
	margin: 4px;
}

.variations td.value .kw-swatches label.kw-swatch--color:last-child {
	margin-right: 0;
}

.variations td.value .kw-swatches label.kw-swatch--radio {
	margin: 0;
}

/* The attribute name and the chosen value next to it (": Γκρι") as Variation Swatches lays them out: inline
   blocks 2px apart, on every variable product (that plugin's rule applies to all product pages). */
.variations th label,
.variations th .kw-selected-name {
	display: inline-block;
	margin: 0 2px;
}

.kw-selected-name {
	font-weight: 600;
}
