/* ========================================
   Variation Swatches

   Color, image, and label swatches that
   replace <select> dropdowns for variable
   products.
   ======================================== */


/* -------------------------------------------------------
   CONTAINER
   ------------------------------------------------------- */

.starter-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 0.5rem;
}


/* -------------------------------------------------------
   BASE SWATCH BUTTON
   ------------------------------------------------------- */

.starter-swatch {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 2px solid var(--starter-color-border, #ddd);
	border-radius: 6px;
	background: var(--starter-color-surface, #fff);
	cursor: pointer;
	transition:
		border-color 0.2s,
		box-shadow 0.2s,
		transform 0.1s,
		opacity 0.2s;
	font-family: inherit;
	line-height: 1;
	padding: 0;
}

.starter-swatch:hover:not(:disabled) {
	border-color: var(--starter-color-accent, var(--starter-color-accent, #0073aa));
}

.starter-swatch:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.2);
}

.starter-swatch:active:not(:disabled) {
	transform: scale(0.95);
}


/* -------------------------------------------------------
   COLOR SWATCH
   ------------------------------------------------------- */

.starter-swatch--color {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border-width: 2px;
	position: relative;
}

/* White/near-white colors need a visible border */
.starter-swatch--color[style*="background-color: #fff"],
.starter-swatch--color[style*="background-color: #ffffff"],
.starter-swatch--color[style*="background-color: white"] {
	border-color: var(--starter-color-border, #ccc);
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* Selected state — accent border + inner checkmark */
.starter-swatch--color.is-selected {
	border-color: var(--starter-color-accent, var(--starter-color-accent, #0073aa));
	box-shadow: 0 0 0 2px var(--starter-color-surface, #fff), 0 0 0 4px var(--starter-color-accent, var(--starter-color-accent, #0073aa));
}

.starter-swatch--color.is-selected::after {
	content: '';
	position: absolute;
	width: 12px;
	height: 6px;
	border-left: 2.5px solid #fff;
	border-bottom: 2.5px solid #fff;
	transform: rotate(-45deg);
	top: 45%;
	left: 50%;
	margin-left: -6px;
	margin-top: -1px;
	filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

/* Dark colors get white checkmark, light get dark */
.starter-swatch--color.is-selected[data-swatch-value*="black"]::after,
.starter-swatch--color.is-selected[data-swatch-value*="navy"]::after,
.starter-swatch--color.is-selected[style*="1a1a1a"]::after {
	border-color: #fff;
	filter: none;
}


/* -------------------------------------------------------
   IMAGE SWATCH
   ------------------------------------------------------- */

.starter-swatch--image {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	padding: 2px;
	overflow: hidden;
}

.starter-swatch--image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
}

.starter-swatch--image.is-selected {
	border-color: var(--starter-color-accent, var(--starter-color-accent, #0073aa));
	box-shadow: 0 0 0 2px var(--starter-color-surface, #fff), 0 0 0 4px var(--starter-color-accent, var(--starter-color-accent, #0073aa));
}


/* -------------------------------------------------------
   LABEL SWATCH
   ------------------------------------------------------- */

.starter-swatch--label {
	padding: 0.4rem 1rem;
	font-size: 0.85rem;
	font-weight: 500;
	border-radius: 20px;
	color: var(--starter-color-text, var(--starter-color-text, #1a1a1a));
	min-width: 44px;
}

.starter-swatch--label.is-selected {
	border-color: var(--starter-color-accent, var(--starter-color-accent, #0073aa));
	background: var(--starter-color-accent, var(--starter-color-accent, #0073aa));
	color: #fff;
}

.starter-swatch--label:hover:not(:disabled) {
	border-color: var(--starter-color-accent, var(--starter-color-accent, #0073aa));
	color: var(--starter-color-accent, var(--starter-color-accent, #0073aa));
}

.starter-swatch--label.is-selected:hover {
	background: var(--starter-color-accent-hover, var(--starter-color-accent-hover, #005a87));
	color: #fff;
}


/* -------------------------------------------------------
   UNAVAILABLE STATE
   ------------------------------------------------------- */

.starter-swatch.is-unavailable {
	opacity: 0.25;
	cursor: not-allowed;
	position: relative;
}

.starter-swatch.is-unavailable::before {
	content: '';
	position: absolute;
	inset: 2px;
	border-radius: inherit;
	background: var(--starter-color-surface, #fff);
	opacity: 0.6;
}

/* Diagonal line through unavailable color swatches */
.starter-swatch--color.is-unavailable::after {
	content: '';
	position: absolute;
	width: 70%;
	height: 1.5px;
	background: var(--starter-color-sale, #c53030);
	transform: rotate(-45deg);
	top: 50%;
	left: 15%;
	filter: none;
	opacity: 0.7;
}

.starter-swatch--label.is-unavailable {
	text-decoration: line-through;
}


/* -------------------------------------------------------
   SELECTED + UNAVAILABLE (edge case)
   ------------------------------------------------------- */

.starter-swatch.is-selected.is-unavailable {
	opacity: 1;
	border-color: var(--starter-color-accent, var(--starter-color-accent, #0073aa));
}


/* -------------------------------------------------------
   HIDE NATIVE SELECT
   ------------------------------------------------------- */

.variations_form .value select {
	/* Keep visible for WC JS but visually minimize */
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Reset label alignment when select is hidden */
.variations_form .label {
	padding-bottom: 0.25rem;
}


/* -------------------------------------------------------
   RESET BUTTON (Clear selection)
   ------------------------------------------------------- */

.starter-swatches__reset {
	display: inline-block;
	background: none;
	border: none;
	color: var(--starter-color-accent, var(--starter-color-accent, #0073aa));
	font-size: 0.8rem;
	cursor: pointer;
	padding: 0.25rem 0;
	margin-left: 0.5rem;
}

.starter-swatches__reset:hover {
	text-decoration: underline;
}


/* -------------------------------------------------------
   RESPONSIVE
   ------------------------------------------------------- */

@media (max-width: 639px) {
	.starter-swatch--color {
		width: 32px;
		height: 32px;
	}

	.starter-swatch--image {
		width: 42px;
		height: 42px;
	}

	.starter-swatch--label {
		padding: 0.35rem 0.8rem;
		font-size: 0.82rem;
	}

	.starter-swatches {
		gap: 0.4rem;
	}
}
