/*
 * Base Store variation swatches. Look "A, round chips" (ruling 2026-11-16).
 *
 * Restyle from a child theme by setting these tokens (on :root, a page, or
 * .bs-swatches) or by targeting the classes below. Every token falls back to
 * a base-theme token, so dark mode comes with the theme.
 *
 *   --bs-swatch-text         selected ring, box text       (--base-text)
 *   --bs-swatch-muted        sold-out text and strike      (--base-text-muted)
 *   --bs-swatch-outline      chip and box borders          (--base-outline)
 *   --bs-swatch-surface      box background                (--base-surface)
 *   --bs-swatch-surface-1    sold-out box background       (--base-surface-1)
 *   --bs-swatch-primary      keyboard focus ring           (--base-primary)
 *   --bs-swatch-radius       box and image chip radius     (--base-radius-s)
 *   --bs-swatch-font         font                          (--base-font)
 *   --bs-swatch-chip         color chip size (32px)
 *   --bs-swatch-image        image chip size (40px)
 *   --bs-swatch-image-radius image chip radius (radius; 50% for round)
 *   --bs-swatch-tap          tap area of a chip (48px)
 *   --bs-swatch-box-w / -h   smallest box (48px x 44px)
 *   --bs-swatch-gap          space between choices
 *   --bs-swatch-loop-chip    shop-card chip size (20px), --bs-swatch-loop-tap (28px)
 *
 * Classes: .bs-swatches (one attribute; --color, --image, --label, --select)
 *   .bs-swatches__label > .bs-swatches__name + .bs-swatches__chosen
 *   .bs-swatches__list (role=group) > .bs-swatch (button)
 *   .bs-swatch--color | --image | --box, .bs-swatch__chip, .bs-swatch__text,
 *   .bs-swatch__check, .is-light / .is-dark (chip tone), state
 *   [aria-pressed="true"] = chosen, [aria-disabled="true"] = cannot be bought,
 *   .is-soldout (exists but out of stock).
 *   Shop cards: .bs-loop-swatches > .bs-loop-swatch, .bs-loop-swatches__more.
 *   The chip color is the inline custom property --bs-swatch-color.
 */

.bs-swatches,
.bs-loop-swatches {
	font-family: var(--bs-swatch-font, var(--base-font, inherit));
}

/* WooCommerce's select stays as the source of truth, hidden. */
select[data-bs-swatched] {
	display: none !important; /* Themes style selects with stronger rules. */
}

/* The swatch group carries its own label above the choices. */
table.variations tr:has(.bs-swatches),
table.variations tr:has(.bs-swatches) > td {
	display: block;
	padding-inline: 0;
}
table.variations tr:has(.bs-swatches) > th.label {
	display: none;
}

.bs-swatches {
	margin-block: 0 16px;
	color: var(--bs-swatch-text, var(--base-text, #1B1C1E));
}

.bs-swatches__label {
	display: block;
	margin-block-end: 8px;
	font-weight: 600;
	line-height: 1.4;
}
.bs-swatches__chosen {
	font-weight: 400;
}
.bs-swatches__chosen:not(:empty)::before {
	content: ": ";
	font-weight: 600;
}

.bs-swatches__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--bs-swatch-gap, 8px);
}
.bs-swatches--color .bs-swatches__list,
.bs-swatches--image .bs-swatches__list {
	gap: calc(var(--bs-swatch-gap, 8px) / 2);
}

/* ── Every choice ── */
.bs-swatch {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--bs-swatch-text, var(--base-text, #1B1C1E));
	font: inherit;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
.bs-swatch:focus {
	outline: none;
}
.bs-swatch:focus-visible {
	outline: 2px solid var(--bs-swatch-primary, var(--base-primary, #0B57D0));
	outline-offset: 2px;
}
.bs-swatch[aria-disabled="true"] {
	cursor: not-allowed;
}

/* ── Color and image chips ── */
.bs-swatch--color,
.bs-swatch--image {
	inline-size: var(--bs-swatch-tap, 48px);
	block-size: var(--bs-swatch-tap, 48px);
	border-radius: 50%;
}
.bs-swatch--image {
	border-radius: var(--bs-swatch-radius, var(--base-radius-s, 8px));
}
.bs-swatch__chip {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	inline-size: var(--bs-swatch-chip, 32px);
	block-size: var(--bs-swatch-chip, 32px);
	border: 1px solid var(--bs-swatch-outline, var(--base-outline, #74777A));
	border-radius: 50%;
	background: var(--bs-swatch-color, transparent);
	overflow: hidden;
}
.bs-swatch--image .bs-swatch__chip {
	inline-size: var(--bs-swatch-image, 40px);
	block-size: var(--bs-swatch-image, 40px);
	border-radius: var(--bs-swatch-image-radius, var(--bs-swatch-radius, var(--base-radius-s, 8px)));
}
.bs-swatch--image img {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
}
.bs-swatch[aria-pressed="true"] .bs-swatch__chip {
	outline: 2px solid var(--bs-swatch-text, var(--base-text, #1B1C1E));
	outline-offset: 3px;
}
.bs-swatch__check {
	display: none;
	position: relative;
	z-index: 1;
}
.bs-swatch[aria-pressed="true"] .bs-swatch__check {
	display: block;
}
.bs-swatch--color.is-light .bs-swatch__check {
	color: #1B1C1E;
}
.bs-swatch--color.is-dark .bs-swatch__check {
	color: #fff;
}
.bs-swatch--image .bs-swatch__check {
	position: absolute;
	color: #fff;
	filter: drop-shadow(0 0 1px rgba(0, 0, 0, .9));
}
.bs-swatch--image[aria-pressed="true"] .bs-swatch__chip::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	background: rgba(0, 0, 0, .35);
}

/* Cannot be bought: crossed out, dashed. */
.bs-swatch--color[aria-disabled="true"] .bs-swatch__chip,
.bs-swatch--image[aria-disabled="true"] .bs-swatch__chip {
	border-style: dashed;
	border-color: var(--bs-swatch-muted, var(--base-text-muted, #474A4D));
	opacity: .55;
}
.bs-swatch--color[aria-disabled="true"] .bs-swatch__chip::after,
.bs-swatch--image[aria-disabled="true"] .bs-swatch__chip::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 2;
	/* Strike in text color with a surface halo, so it shows on black and white chips. */
	background: linear-gradient(to top right, transparent calc(50% - 2.5px), var(--bs-swatch-surface, var(--base-surface, #fff)) calc(50% - 2.5px), var(--bs-swatch-surface, var(--base-surface, #fff)) calc(50% - 1px), var(--bs-swatch-text, var(--base-text, #1B1C1E)) calc(50% - 1px), var(--bs-swatch-text, var(--base-text, #1B1C1E)) calc(50% + 1px), var(--bs-swatch-surface, var(--base-surface, #fff)) calc(50% + 1px), var(--bs-swatch-surface, var(--base-surface, #fff)) calc(50% + 2.5px), transparent calc(50% + 2.5px));
}

/* ── Boxes (sizes, labels, custom attributes, colors without a hex) ── */
.bs-swatch--box {
	box-sizing: border-box;
	min-inline-size: var(--bs-swatch-box-w, 48px);
	min-block-size: var(--bs-swatch-box-h, 44px);
	padding-block: 8px;
	padding-inline: 14px;
	border: 1px solid var(--bs-swatch-outline, var(--base-outline, #74777A));
	border-radius: var(--bs-swatch-radius, var(--base-radius-s, 8px));
	background: var(--bs-swatch-surface, var(--base-surface, #fff));
	line-height: 1.2;
}
/* Reserve the bold width, so choosing does not move the row. */
.bs-swatch__text {
	display: inline-grid;
}
.bs-swatch__text::after {
	content: attr(data-text);
	block-size: 0;
	overflow: hidden;
	visibility: hidden;
	font-weight: 700;
}
.bs-swatch--box[aria-pressed="true"] {
	border-color: var(--bs-swatch-text, var(--base-text, #1B1C1E));
	box-shadow: inset 0 0 0 1px var(--bs-swatch-text, var(--base-text, #1B1C1E));
	font-weight: 700;
}
.bs-swatch--box[aria-disabled="true"] {
	border-style: dashed;
	border-color: var(--bs-swatch-muted, var(--base-text-muted, #474A4D));
	background: var(--bs-swatch-surface-1, var(--base-surface-1, #F1F3F4));
	color: var(--bs-swatch-muted, var(--base-text-muted, #474A4D));
	text-decoration: line-through;
}

@media (hover: hover) {
	.bs-swatch--box:not([aria-disabled="true"]):not([aria-pressed="true"]):hover {
		border-color: var(--bs-swatch-text, var(--base-text, #1B1C1E));
	}
	.bs-swatch--color:not([aria-disabled="true"]):not([aria-pressed="true"]):hover .bs-swatch__chip,
	.bs-swatch--image:not([aria-disabled="true"]):not([aria-pressed="true"]):hover .bs-swatch__chip {
		outline: 1px solid var(--bs-swatch-outline, var(--base-outline, #74777A));
		outline-offset: 3px;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.bs-swatch--box,
	.bs-swatch__chip {
		transition: border-color .15s ease, box-shadow .15s ease, outline-color .15s ease;
	}
}

@media (forced-colors: active) {
	.bs-swatch[aria-pressed="true"] .bs-swatch__chip,
	.bs-swatch--box[aria-pressed="true"] {
		outline: 3px solid Highlight;
	}
}

/* ── Shop cards ── */
.bs-loop-swatches {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: inherit;
	gap: 2px;
	margin-block: 4px 0;
}
.bs-loop-swatch {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	inline-size: var(--bs-swatch-loop-tap, 28px);
	block-size: var(--bs-swatch-loop-tap, 28px);
	border-radius: 50%;
}
.bs-loop-swatch .bs-swatch__chip {
	inline-size: var(--bs-swatch-loop-chip, 20px);
	block-size: var(--bs-swatch-loop-chip, 20px);
}
.bs-loop-swatch:focus-visible {
	outline: 2px solid var(--bs-swatch-primary, var(--base-primary, #0B57D0));
	outline-offset: 0;
}
.bs-loop-swatches__more {
	min-inline-size: var(--bs-swatch-loop-tap, 28px);
	line-height: var(--bs-swatch-loop-tap, 28px);
	color: var(--bs-swatch-muted, var(--base-text-muted, #474A4D));
	font-size: .875em;
	text-align: center;
	text-decoration: none;
}
.bs-loop-swatches__more:hover {
	color: var(--bs-swatch-text, var(--base-text, #1B1C1E));
	text-decoration: underline;
}
