/**
 * Ecodle Variation Swatches — front-end.
 */

/* ---------- layout reset for the WooCommerce variations table ---------- */
.evs-form .variations,
.evs-form .variations tbody,
.evs-form .variations tr,
.evs-form .variations td,
.evs-form .variations th {
	display: block;
	width: 100%;
	border: 0;
	margin: 0;
	padding: 0;
	background: none;
}

.evs-form .variations {
	margin-bottom: 18px;
}

.evs-has-swatch > th.label,
.evs-has-swatch > td.label,
.evs-has-swatch > .label,
.evs-has-swatch > label {
	display: none;
}

.evs-form .variations td.value::before {
	content: none;
}

.evs-form .reset_variations {
	display: inline-block;
	margin-top: 4px;
	font-size: 12px;
	letter-spacing: 0.04em;
	opacity: 0.7;
}

/* ---------- price line ---------- */
.evs-price {
	margin: 0 0 20px;
	font-size: clamp(22px, 2.6vw, 28px);
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.01em;
}

.evs-price-hidden {
	display: none !important;
}

.evs-price .amount,
.evs-price bdi,
.evs-price ins {
	color: inherit;
	text-decoration: none;
}

.evs-price del {
	margin-right: 8px;
	font-size: 0.68em;
	font-weight: 400;
	opacity: 0.5;
}

.evs-price-changed {
	animation: evs-price-in 0.3s ease;
}

@keyframes evs-price-in {
	from {
		opacity: 0.35;
		transform: translateY(2px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* ---------- attribute block ---------- */
.evs-attribute {
	--evs-accent: #d4a95e;
	--evs-radius: 10px;
	--evs-min: 110px;
	--evs-card-bg: rgba(255, 255, 255, 0.03);
	--evs-card-border: rgba(212, 169, 94, 0.22);
	--evs-text: #efe6d8;
	--evs-muted: rgba(239, 230, 216, 0.62);
	--evs-tip-bg: #14100a;
	margin: 0 0 22px;
}

.evs-attribute.evs-theme-light {
	--evs-card-bg: #fff;
	--evs-card-border: rgba(0, 0, 0, 0.14);
	--evs-text: #1c1c1c;
	--evs-muted: rgba(0, 0, 0, 0.55);
	--evs-tip-bg: #1c1c1c;
}

.evs-attribute__head {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 10px;
}

.evs-attribute__title {
	font-size: 12px;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--evs-text);
}

.evs-step {
	margin-right: 6px;
	color: var(--evs-accent);
}

.evs-info {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	position: relative;
	width: 15px;
	height: 15px;
	padding: 0;
	border: 1px solid var(--evs-card-border);
	border-radius: 50%;
	background: transparent;
	color: var(--evs-muted);
	font-size: 9px;
	font-style: italic;
	font-weight: 700;
	line-height: 1;
	cursor: help;
}

.evs-info::after {
	content: attr(data-evs-tip);
	position: absolute;
	bottom: calc(100% + 9px);
	left: 50%;
	transform: translateX(-50%) translateY(4px);
	width: max-content;
	max-width: 230px;
	padding: 8px 10px;
	border: 1px solid var(--evs-card-border);
	border-radius: 8px;
	background: var(--evs-tip-bg);
	color: var(--evs-text);
	font-size: 11px;
	font-style: normal;
	font-weight: 400;
	line-height: 1.5;
	letter-spacing: 0.01em;
	text-transform: none;
	white-space: normal;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.15s ease, transform 0.15s ease;
	z-index: 20;
}

.evs-info:hover::after,
.evs-info:focus::after {
	opacity: 1;
	visibility: visible;
	transform: translateX(-50%) translateY(0);
}

/* ---------- swatch grid ---------- */
.evs-swatches {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--evs-min)), 1fr));
	gap: 12px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.evs-attribute--color .evs-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

/* ---------- swatch card ---------- */
.evs-swatch {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-height: 58px;
	padding: 12px 10px;
	border: 1px solid var(--evs-card-border);
	border-radius: var(--evs-radius);
	background: var(--evs-card-bg);
	text-align: center;
	cursor: pointer;
	-webkit-user-select: none;
	user-select: none;
	transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

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

.evs-swatch.is-selected {
	border-color: var(--evs-accent);
	background: linear-gradient(180deg, rgba(212, 169, 94, 0.12), rgba(212, 169, 94, 0.02));
	box-shadow: inset 0 0 0 1px var(--evs-accent);
}

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

.evs-swatch.is-disabled {
	cursor: not-allowed;
	opacity: 0.32;
	filter: grayscale(1);
}

.evs-swatch.is-disabled::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background: linear-gradient(
		to top right,
		transparent calc(50% - 0.5px),
		var(--evs-card-border) calc(50% - 0.5px),
		var(--evs-card-border) calc(50% + 0.5px),
		transparent calc(50% + 0.5px)
	);
}

.evs-swatch.is-hidden {
	display: none;
}

/* media */
.evs-swatch__media {
	display: block;
	width: 100%;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	border-radius: calc(var(--evs-radius) - 3px);
	background: rgba(0, 0, 0, 0.25);
}

.evs-swatch__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	margin: 0;
}

.evs-attribute--color .evs-swatch {
	min-height: 0;
	padding: 8px;
	gap: 6px;
}

.evs-attribute--color .evs-swatch__media--color {
	width: 30px;
	height: 30px;
	aspect-ratio: auto;
	border-radius: 50%;
	background: var(--evs-chip, #ccc);
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

/* text */
.evs-swatch__text {
	display: block;
}

.evs-swatch__label {
	display: block;
	color: var(--evs-text);
	font-size: 13px;
	line-height: 1.3;
	letter-spacing: 0.02em;
}

.evs-swatch__sub {
	display: block;
	margin-top: 3px;
	color: var(--evs-muted);
	font-size: 11px;
	line-height: 1.3;
}

/* tick */
.evs-swatch__tick {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--evs-accent);
	opacity: 0;
	transform: scale(0.6);
	transition: opacity 0.18s ease, transform 0.18s ease;
}

.evs-swatch__tick::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 5px;
	width: 3px;
	height: 6px;
	border: solid rgba(0, 0, 0, 0.75);
	border-width: 0 1.6px 1.6px 0;
	transform: rotate(45deg);
}

.evs-swatch.is-selected .evs-swatch__tick {
	opacity: 1;
	transform: none;
}

/* the real select stays in the DOM for WooCommerce */
.evs-native {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 480px) {
	.evs-attribute {
		--evs-min: 92px;
	}

	.evs-swatch__label {
		font-size: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.evs-swatch,
	.evs-swatch__tick,
	.evs-info::after {
		transition: none;
	}

	.evs-price-changed {
		animation: none;
	}
}
