/*
 * Color swatches – same look as the replaced plugins:
 * - "--b2c" and the product page: "Variation Swatches for WooCommerce" (style "rounded",
 *   settings of the B2C shops: 30px in lists, 40px on the product page),
 * - "--b2b": the shop loop of "DP PulseID" (32px).
 */

.dpwc-anq-swatches {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-start;
	align-items: center;
	margin: 0;
	padding: 0;
	list-style: none;
}

.dpwc-anq-swatch {
	position: relative;
	box-sizing: border-box;
	display: flex;
	justify-content: center;
	align-items: center;
	margin: 0;
	padding: 0;
	list-style: none;
	cursor: pointer;
	user-select: none;
	outline: none;
}

.dpwc-anq-swatch__contents {
	position: relative;
	display: flex;
	justify-content: center;
	align-items: center;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

.dpwc-anq-swatches .dpwc-anq-swatch .dpwc-anq-swatch__image,
.dpwc-anq-swatches .dpwc-anq-swatch .dpwc-anq-swatch__color {
	display: block;
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border-radius: 100%;
	object-fit: cover;
	pointer-events: none;
}

.dpwc-anq-swatch__text {
	font-size: 10px;
	line-height: 1;
	text-align: center;
	overflow: hidden;
	pointer-events: none;
}

/* ------------------------------------------------------------------
 * Variation Swatches (B2C lists, product page)
 * ---------------------------------------------------------------- */

.dpwc-anq-swatches--b2c,
.dpwc-anq-swatches--single {
	width: 100%;
}

.dpwc-anq-swatches--b2c {
	margin: 5px 0;
}

.dpwc-anq-swatches--b2c .dpwc-anq-swatch,
.dpwc-anq-swatches--single .dpwc-anq-swatch {
	width: 30px;
	height: 30px;
	margin: 4px;
	padding: 2px;
	border-radius: 100%;
	background-color: #fff;
	color: #000;
	box-shadow: 0 0 0 1px #a8a8a8;
	transition: all 200ms ease;
}

.dpwc-anq-swatches--single .dpwc-anq-swatch {
	width: 40px;
	height: 40px;
}

.dpwc-anq-swatches--b2c .dpwc-anq-swatch:last-child,
.dpwc-anq-swatches--single .dpwc-anq-swatch:last-child {
	margin-right: 0;
}

.dpwc-anq-swatches--b2c .dpwc-anq-swatch:hover,
.dpwc-anq-swatches--b2c .dpwc-anq-swatch:focus,
.dpwc-anq-swatches--single .dpwc-anq-swatch:hover,
.dpwc-anq-swatches--single .dpwc-anq-swatch:focus {
	box-shadow: 0 0 0 3px #000;
}

.dpwc-anq-swatches--b2c .dpwc-anq-swatch.is-selected,
.dpwc-anq-swatches--single .dpwc-anq-swatch.is-selected {
	box-shadow: 0 0 0 2px #000;
}

/* tick on the selected color */
.dpwc-anq-swatches--b2c .dpwc-anq-swatch.is-selected .dpwc-anq-swatch__contents::before,
.dpwc-anq-swatches--single .dpwc-anq-swatch.is-selected:not(.is-disabled):not(.is-unavailable) .dpwc-anq-swatch__contents::before {
	content: " ";
	position: absolute;
	inset: 0;
	background: url("data:image/svg+xml;utf8,%3Csvg filter='drop-shadow(0px 0px 2px rgb(0 0 0 / .8))' xmlns='http://www.w3.org/2000/svg'  viewBox='0 0 30 30'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='4' d='M4 16L11 23 27 7'/%3E%3C/svg%3E") center / 60% no-repeat;
	pointer-events: none;
}

.dpwc-anq-swatches--b2c .dpwc-anq-swatch:not([data-src]) {
	cursor: default;
}

/* colors without stock, combinations that are not available */
.dpwc-anq-swatch.is-disabled .dpwc-anq-swatch__contents > *,
.dpwc-anq-swatch.is-unavailable .dpwc-anq-swatch__contents > * {
	opacity: .6;
}

.dpwc-anq-swatch.is-disabled .dpwc-anq-swatch__contents::before,
.dpwc-anq-swatch.is-unavailable .dpwc-anq-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") center no-repeat;
	pointer-events: none;
}

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

.dpwc-anq-swatches--b2c .dpwc-anq-swatches__more {
	margin: 4px 0 4px 4px;
	font-size: small;
}

/* list of the product page: the dropdown stays in the form, hidden */
.dpwc-anq-swatches-select {
	display: none;
}

/* tooltip (product page) */
.dpwc-anq-swatches--single .dpwc-anq-swatch[data-tooltip]::after {
	content: attr(data-tooltip);
	visibility: hidden;
	opacity: 0;
	position: absolute;
	bottom: calc(100% + 10px);
	left: 50%;
	z-index: 999;
	box-sizing: border-box;
	min-width: 100px;
	width: max-content;
	height: 30px;
	padding-inline: 10px;
	border-radius: 3px;
	background-color: #333;
	box-shadow: 0 0 5px 1px rgba(0, 0, 0, .3);
	color: #fff;
	font-size: 14px;
	line-height: 30px;
	text-align: center;
	transform: translateX(-50%);
	transition: opacity 500ms ease-in-out;
	pointer-events: none;
}

.dpwc-anq-swatches--single .dpwc-anq-swatch[data-tooltip]::before {
	content: " ";
	visibility: hidden;
	opacity: 0;
	position: absolute;
	bottom: 100%;
	left: 50%;
	z-index: 999;
	border: 5px solid transparent;
	border-top-color: #333;
	transform: translateX(-50%);
	transition: opacity 500ms ease-in-out;
	pointer-events: none;
}

.dpwc-anq-swatches--single .dpwc-anq-swatch[data-tooltip]:hover::after,
.dpwc-anq-swatches--single .dpwc-anq-swatch[data-tooltip]:hover::before {
	visibility: visible;
	opacity: 1;
}

/* ------------------------------------------------------------------
 * DP PulseID (B2B lists)
 * ---------------------------------------------------------------- */

.dpwc-anq-swatches--b2b {
	display: block;
	margin-top: 5px;
	font-size: .9em;
	color: #666;
}

.dpwc-anq-swatches--b2b .dpwc-anq-swatch {
	display: inline-block;
	width: 32px;
	height: 32px;
	margin: 0 4px 0 0;
	vertical-align: middle;
	border: 1px solid #ccc;
	border-radius: 50%;
	background: #f0f0f0;
	overflow: hidden;
	transition: transform .15s ease, box-shadow .15s ease;
}

.dpwc-anq-swatches--b2b .dpwc-anq-swatch:hover {
	transform: scale(1.1);
	box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}

.dpwc-anq-swatches--b2b .dpwc-anq-swatch.is-selected {
	outline: 2px solid #333;
	outline-offset: 1px;
	transform: scale(1.05);
}

.dpwc-anq-swatches--b2b .dpwc-anq-swatch .dpwc-anq-swatch__image,
.dpwc-anq-swatches--b2b .dpwc-anq-swatch .dpwc-anq-swatch__color {
	border-radius: 0;
}

.dpwc-anq-swatches--b2b .dpwc-anq-swatches__more {
	margin-left: 4px;
	vertical-align: middle;
	white-space: nowrap;
	color: #666;
	font-size: small;
}

/* variation table of the product page as with the plugin ("show label"): label above the values,
   selected color next to the label */
.dpwc-anq-swatches-label .variations th,
.dpwc-anq-swatches-label .variations td {
	display: block;
	width: auto !important;
	text-align: start;
}

.dpwc-anq-swatches-label .variations th label,
.dpwc-anq-swatches-label .variations th .dpwc-anq-swatches__selected {
	display: inline-block;
	margin: 0 2px;
}

.dpwc-anq-swatches__selected {
	font-weight: 600;
}

/* swatches inside the product link of a list: WooCommerce styles every image there
   (".woocommerce ul.products li.product a img": width, height auto, margin 0 0 1em) */
.products .product .dpwc-anq-swatches .dpwc-anq-swatch img.dpwc-anq-swatch__image {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	box-shadow: none;
}
