:root {
	--nvs-item-width: 30px;
	--nvs-item-height: 30px;
	--nvs-item-font-size: 16px;
	--nvs-accent: #7f54b3;
	--nvs-border-color: #dddddd;
	--nvs-tick: none;
	--nvs-cross: none;
}

/*
 * .nvs-raw-select and .nvs-live are hidden from the inline stylesheet the
 * plugin always prints, not from here — see NVS_Frontend::add_inline_style().
 * Hiding the replaced dropdown is functional, and this file is optional.
 */

ul.nvs-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	list-style: none;
	margin: 0 0 10px;
	padding: 0;
}

ul.nvs-swatches li {
	margin: 0;
}

.nvs-swatch {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: var(--nvs-item-width);
	height: var(--nvs-item-height);
	padding: 2px;
	border: 1px solid var(--nvs-border-color);
	border-radius: 4px;
	background: #fff;
	cursor: pointer;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
	transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.nvs-shape-rounded .nvs-swatch {
	border-radius: 50%;
}

/*
 * Scoped to the child on purpose.
 *
 * The item carries its type in a class too — build_item() puts
 * nvs-swatch-color on the <li> and on the <span> inside it, and
 * nvs-swatch-image on the <li> and on the <img>. Written flat, this rule
 * also matches the item and wins over .nvs-swatch above it (same
 * specificity, later in the file): the chip's display:block, width:100%
 * and height:100% land on the item, which then stretches to the full
 * width of the table cell and collapses to the height of its padding —
 * a row of hairline bars where the colours should be.
 */
.nvs-swatch > .nvs-swatch-color,
.nvs-swatch > .nvs-swatch-image {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 2px;
}

.nvs-shape-rounded .nvs-swatch > .nvs-swatch-color,
.nvs-shape-rounded .nvs-swatch > .nvs-swatch-image {
	border-radius: 50%;
}

.nvs-swatch > .nvs-swatch-image {
	object-fit: cover;
}

.nvs-swatch-button {
	width: auto;
	min-width: var(--nvs-item-width);
	padding: 2px 10px;
	font-size: var(--nvs-item-font-size);
	line-height: 1.2;
}

.nvs-swatch-label {
	white-space: nowrap;
}

.nvs-swatch:hover {
	border-color: var(--nvs-accent);
}

.nvs-swatch.selected {
	border-color: var(--nvs-accent);
	box-shadow: 0 0 0 2px var(--nvs-accent);
}

.nvs-swatch:focus-visible {
	outline: 2px solid var(--nvs-accent);
	outline-offset: 2px;
}

.nvs-swatch.selected:not(.nvs-swatch-button)::after {
	content: '';
	position: absolute;
	inset: 0;
	background: var(--nvs-tick) center center / 70% 70% no-repeat;
	pointer-events: none;
}

.nvs-behavior-blur .nvs-swatch.nvs-disabled {
	opacity: 0.3;
	cursor: not-allowed;
	pointer-events: none;
}

.nvs-behavior-cross .nvs-swatch.nvs-disabled {
	opacity: 0.6;
	cursor: not-allowed;
	pointer-events: none;
}

.nvs-behavior-cross .nvs-swatch.nvs-disabled::after {
	content: '';
	position: absolute;
	inset: 0;
	background: var(--nvs-cross) center center / 100% 100% no-repeat;
	pointer-events: none;
}

.nvs-behavior-hide .nvs-swatch.nvs-disabled {
	display: none;
}

/*
 * The bubble draws on ::before, and there is no arrow.
 *
 * ::after on the item is already taken twice over — the tick on a
 * selected swatch and the cross on an out-of-stock one both live there.
 * A tooltip sharing it inherited their inset:0 and collapsed into a black
 * slab lying across the swatch with its label spilling out sideways. One
 * pseudo-element each keeps them apart; the arrow is what the split cost,
 * and the bubble reads clearly enough without it.
 */
.nvs-tooltip .nvs-swatch[data-nvs-tooltip]::before {
	content: attr(data-nvs-tooltip);
	position: absolute;
	z-index: 99;
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
	padding: 4px 10px;
	border-radius: 3px;
	background: #1e1e1e;
	color: #fff;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.4;
	white-space: nowrap;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.15s ease, visibility 0.15s ease;
	pointer-events: none;
}

.nvs-tooltip .nvs-swatch[data-nvs-tooltip]:hover::before,
.nvs-tooltip .nvs-swatch[data-nvs-tooltip]:focus-visible::before {
	opacity: 1;
	visibility: visible;
}

/*
 * The overflow tail, and the counter that opens it.
 *
 * Server-rendered so the count is right before any script runs, and marked
 * on the items themselves rather than by position, because the chosen
 * option keeps its place in the visible row wherever it falls in the list.
 */
.nvs-swatches:not(.nvs-expanded) .nvs-overflow {
	display: none;
}

.nvs-swatches.nvs-expanded .nvs-more {
	display: none;
}

.nvs-more {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: var(--nvs-item-width);
	height: var(--nvs-item-height);
	padding: 2px 8px;
	border: 1px dashed var(--nvs-border-color);
	border-radius: 4px;
	background: none;
	color: inherit;
	font-size: calc(var(--nvs-item-font-size) * 0.8);
	line-height: 1.2;
	cursor: pointer;
	user-select: none;
}

.nvs-shape-rounded .nvs-more {
	border-radius: 50%;
}

.nvs-more:hover {
	border-color: var(--nvs-accent);
}

.nvs-more:focus-visible {
	outline: 2px solid var(--nvs-accent);
	outline-offset: 2px;
}

/*
 * Catalog previews.
 *
 * Smaller than the real thing on purpose: on a card these say "there are
 * other colours", they are not the control the shopper chooses with. The
 * link fills its swatch so the whole chip is the hit target.
 */
.nvs-swatches-archive {
	gap: 6px;
	margin: 6px 0 0;
}

.nvs-swatches-archive .nvs-swatch {
	width: calc(var(--nvs-item-width) * 0.6);
	height: calc(var(--nvs-item-height) * 0.6);
	cursor: pointer;
}

.nvs-swatches-archive .nvs-swatch > a {
	display: block;
	width: 100%;
	height: 100%;
	line-height: 0;
}

/*
 * The chip is a grandchild here, not a child: the link sits between it and
 * the item so the whole swatch is clickable. The single-product rules above
 * are scoped to the direct child and do not reach it.
 */
.nvs-swatches-archive .nvs-swatch > a > .nvs-swatch-color,
.nvs-swatches-archive .nvs-swatch > a > .nvs-swatch-image {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 2px;
}

.nvs-swatches-archive .nvs-swatch > a > .nvs-swatch-image {
	object-fit: cover;
}

.nvs-shape-rounded.nvs-swatches-archive .nvs-swatch > a > .nvs-swatch-color,
.nvs-shape-rounded.nvs-swatches-archive .nvs-swatch > a > .nvs-swatch-image {
	border-radius: 50%;
}

.nvs-swatches-archive .nvs-more {
	height: calc(var(--nvs-item-height) * 0.6);
	min-width: 0;
	padding: 0 6px;
	font-size: calc(var(--nvs-item-font-size) * 0.7);
}

.nvs-swatches-archive .nvs-more a {
	color: inherit;
	text-decoration: none;
}

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

table.variations .nvs-selected-name {
	margin-inline-start: 4px;
}

@media (max-width: 480px) {
	ul.nvs-swatches {
		gap: 8px;
	}
}
