/* Attribute Swatches for WooCommerce - swatches and pills. Product cards: product-cards.css. Cart: cart-drawer.css */

/* ---------- Base tokens (light, the default) ---------- */

.wcas-swatches {
	--wcas-accent: #111827;
	--wcas-ink: #1f2933;
	--wcas-muted: #6b7280;
	--wcas-line: #e5e7eb;
	--wcas-surface: #ffffff;
	--wcas-subtle: #f4f5f7;
	--wcas-tip-bg: #111827;
	--wcas-tip-ink: #ffffff;

	--wcas-d: 34px;
	--wcas-font: 13px;
	--wcas-gap: 10px;
	--wcas-pad-x: 14px;

	display: flex;
	flex-direction: column;
	font-family: inherit;
	color: var(--wcas-ink);
	line-height: 1.3;
}

/* Sizes */
.wcas-size-sm { --wcas-d: 28px; --wcas-font: 12px; --wcas-gap: 8px;  --wcas-pad-x: 12px; }
.wcas-size-md { --wcas-d: 34px; --wcas-font: 13px; --wcas-gap: 10px; --wcas-pad-x: 14px; }
.wcas-size-lg { --wcas-d: 42px; --wcas-font: 14px; --wcas-gap: 12px; --wcas-pad-x: 16px; }

/* Themes */
.wcas-theme-dark {
	--wcas-ink: #f3f4f6;
	--wcas-muted: #9ca3af;
	--wcas-line: #374151;
	--wcas-surface: #1f2937;
	--wcas-subtle: #111827;
	--wcas-tip-bg: #f9fafb;
	--wcas-tip-ink: #111827;
}

.wcas-theme-inherit {
	--wcas-ink: currentColor;
	--wcas-muted: color-mix(in srgb, currentColor 60%, transparent);
	--wcas-line: color-mix(in srgb, currentColor 16%, transparent);
	--wcas-surface: transparent;
	--wcas-subtle: color-mix(in srgb, currentColor 6%, transparent);
}

/* ---------- Groups ---------- */

.wcas-group + .wcas-group {
	margin-top: 22px;
	padding-top: 22px;
	border-top: 1px solid var(--wcas-line);
}

.wcas-title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 0 0 12px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--wcas-muted);
}

.wcas-count {
	display: inline-flex;
	align-items: center;
	min-width: 22px;
	justify-content: center;
	padding: 2px 8px;
	border-radius: 999px;
	background: var(--wcas-subtle);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0;
	color: var(--wcas-muted);
}

.wcas-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--wcas-gap);
}

.wcas-list li {
	margin: 0;
}

/* ---------- Colour circles ---------- */

.wcas-circle {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	border-radius: 999px;
	cursor: default;
	outline: none;
	-webkit-tap-highlight-color: transparent;
}

.wcas-dot {
	display: block;
	flex: 0 0 auto;
	width: var(--wcas-d);
	height: var(--wcas-d);
	border-radius: 50%;
	background: var(--wcas-color);
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
	transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s ease;
}

.wcas-circle:hover .wcas-dot,
.wcas-circle:focus .wcas-dot {
	transform: scale(1.08);
	box-shadow:
		0 0 0 2px var(--wcas-surface),
		0 0 0 4px var(--wcas-accent);
}

.wcas-circle:focus-visible .wcas-dot {
	box-shadow:
		0 0 0 2px var(--wcas-surface),
		0 0 0 4px #3b82f6;
}

.wcas-text {
	font-size: var(--wcas-font);
	font-weight: 500;
	color: var(--wcas-ink);
}

/* Tooltip for circles without a visible label */
.wcas-circle:not(.wcas-labelled)::after {
	content: attr(data-tip);
	position: absolute;
	bottom: calc(100% + 10px);
	left: 50%;
	transform: translate(-50%, 4px);
	padding: 6px 10px;
	border-radius: 8px;
	background: var(--wcas-tip-bg);
	color: var(--wcas-tip-ink);
	font-size: 12px;
	font-weight: 500;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.2s ease, transform 0.2s ease;
	z-index: 10;
}

.wcas-circle:not(.wcas-labelled):hover::after,
.wcas-circle:not(.wcas-labelled):focus::after {
	opacity: 1;
	transform: translate(-50%, 0);
}

/* ---------- Pills ---------- */

.wcas-pill {
	display: inline-flex;
	align-items: center;
	min-height: var(--wcas-d);
	padding: 0 var(--wcas-pad-x);
	border: 1px solid var(--wcas-line);
	border-radius: 999px;
	background: var(--wcas-subtle);
	transition: border-color 0.2s ease, background-color 0.2s ease;
}

.wcas-pill .wcas-text {
	white-space: nowrap;
}

.wcas-radius-rounded .wcas-pill {
	border-radius: 10px;
}

.wcas-pill:hover {
	border-color: var(--wcas-accent);
}

/* "+N more" summary pill */
.wcas-pill.wcas-more {
	background: transparent;
	border-style: dashed;
}

.wcas-pill.wcas-more .wcas-text {
	color: var(--wcas-muted);
}

/* ---------- Clickable swatches (switch the product image) ---------- */

.wcas-clickable {
	cursor: pointer;
}

.wcas-clickable.is-active .wcas-dot {
	box-shadow:
		0 0 0 2px var(--wcas-surface),
		0 0 0 4px var(--wcas-accent);
}

.wcas-clickable.wcas-pill.is-active {
	background: var(--wcas-accent);
	border-color: var(--wcas-accent);
}

.wcas-clickable.wcas-pill.is-active .wcas-text {
	color: var(--wcas-surface);
}

.wcas-theme-dark .wcas-clickable.wcas-pill.is-active .wcas-text {
	color: #111827;
}

.wcas-clickable:focus-visible {
	outline: 2px solid #3b82f6;
	outline-offset: 3px;
	border-radius: 999px;
}

/* ---------- Errors (only shown to shop managers) ---------- */

.wcas-error {
	margin: 0;
	padding: 10px 14px;
	border-radius: 8px;
	background: #fef2f2;
	color: #991b1b;
	font-size: 13px;
}

/* ---------- Mobile ---------- */

@media (max-width: 600px) {
	.wcas-group + .wcas-group {
		margin-top: 18px;
		padding-top: 18px;
	}

	.wcas-size-md { --wcas-d: 30px; --wcas-gap: 8px; --wcas-pad-x: 12px; }
	.wcas-size-lg { --wcas-d: 36px; --wcas-gap: 10px; --wcas-pad-x: 14px; }
	.wcas-size-sm { --wcas-d: 26px; --wcas-gap: 6px; --wcas-pad-x: 10px; }
}

/* Touch: keep tap targets comfortable */
@media (hover: none) and (pointer: coarse) {
	.wcas-circle {
		padding: 2px;
	}
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.wcas-dot,
	.wcas-pill,
	.wcas-circle:not(.wcas-labelled)::after {
		transition: none;
	}
}
