/* Material switcher on product cards. See swatches.php.
   Selectors are doubled up on purpose: the theme styles every div, button and
   img inside a product card, and these rules have to win. */

.mb-swatches.mb-swatches {
	--mb-swatch-size: 18px;
	--mb-swatch-ring: var(--mainColor, #000);
	display: block;
	width: 100%;
	margin: 0;
	text-align: inherit;
	line-height: 1;
}

.mb-swatches .mb-swatches__label {
	display: block;
	min-height: 1.35em;
	margin: 0;
	font-size: 12px;
	line-height: 1.35;
	letter-spacing: 0;
	text-transform: none;
	color: var(--mainColor, #000);
	opacity: .6;
	transition: opacity .2s ease;
}

.mb-swatches .mb-swatches__label.is-changing {
	opacity: 0;
}

.mb-swatches .mb-swatches__group {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 6px;
	width: auto;
	margin: 8px 0 0;
	vertical-align: top;
}

.mb-swatches .mb-swatches__group + .mb-swatches__group {
	margin-left: 14px;
}

.mb-swatches .mb-swatch {
	position: relative;
	display: block;
	flex: none;
	box-sizing: border-box;
	width: calc(var(--mb-swatch-size) + 6px);
	height: calc(var(--mb-swatch-size) + 6px);
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 2px;
	border: 1px solid transparent;
	border-radius: 50%;
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	line-height: 0;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	-webkit-tap-highlight-color: transparent;
	transition: border-color .3s ease;
}

/* Comfortable touch target around the small disc. */
.mb-swatches .mb-swatch::before {
	content: "";
	position: absolute;
	inset: -6px -3px;
}

.mb-swatches .mb-swatch .mb-swatch__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border-radius: 50%;
	object-fit: cover;
	transform: scale(.86);
	transition: transform .35s cubic-bezier(.2, .7, .2, 1);
}

/* Plain colour dots need an edge: a white one would vanish on the page. */
.mb-swatches .mb-swatch span.mb-swatch__img {
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14);
}

.mb-swatches .mb-swatch:hover .mb-swatch__img,
.mb-swatches .mb-swatch:focus-visible .mb-swatch__img,
.mb-swatches .mb-swatch.is-selected .mb-swatch__img {
	transform: scale(1);
}

.mb-swatches .mb-swatch:hover {
	border-color: rgba(0, 0, 0, .28);
}

.mb-swatches .mb-swatch:focus {
	outline: none;
}

.mb-swatches .mb-swatch:focus-visible {
	outline: 2px solid var(--mb-swatch-ring);
	outline-offset: 2px;
}

.mb-swatches .mb-swatch.is-selected,
.mb-swatches .mb-swatch.is-selected:hover {
	border-color: var(--mb-swatch-ring);
}

/* Picture still on its way: the ring breathes. */
.mb-swatches .mb-swatch.is-loading {
	animation: mb-swatch-wait .9s ease-in-out infinite;
}

@keyframes mb-swatch-wait {
	50% { border-color: transparent; }
}

/* Cross-fade between two card pictures. */
.mb-xfade.mb-xfade {
	position: relative;
	overflow: hidden;
}

/* The outgoing picture leaves first and fast, the incoming one follows: with
   transparent pictures the two never sit on top of each other at full strength. */
.mb-xfade > img.mb-xfade__prev {
	transition: opacity .28s ease;
}

.mb-xfade > img.mb-xfade__prev.is-out {
	opacity: 0;
}

.mb-xfade > img.mb-xfade__next {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transform: scale(1.035);
	transition: opacity .5s ease .16s, transform .9s cubic-bezier(.2, .7, .2, 1);
	z-index: 1;
}

.mb-xfade > img.mb-xfade__next.is-in {
	opacity: 1;
	transform: none;
}

.mb-price-swap {
	transition: opacity .2s ease;
}

.mb-price-swap.is-changing {
	opacity: 0;
}

@media (hover: none) {
	.mb-swatches.mb-swatches {
		--mb-swatch-size: 20px;
	}

	.mb-swatches .mb-swatches__group {
		gap: 10px;
	}

	.mb-swatches .mb-swatch::before {
		inset: -8px -5px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mb-swatches .mb-swatch,
	.mb-swatches .mb-swatch .mb-swatch__img,
	.mb-swatches .mb-swatches__label,
	.mb-price-swap,
	.mb-xfade > img.mb-xfade__prev,
	.mb-xfade > img.mb-xfade__next {
		transition-duration: .01s;
		transition-delay: 0s;
	}

	.mb-xfade > img.mb-xfade__next {
		transform: none;
	}

	.mb-swatches .mb-swatch.is-loading {
		animation: none;
	}
}
