/*
 * Aartif Swatches — frontend
 * Everything hangs off namespaced classes + CSS custom properties so any
 * theme can retheme with a few variable overrides.
 */

.aartif-swatches {
	--aartif-size: var(--aartif-size, 32px);
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--aartif-gap, 8px);
	vertical-align: middle;
	line-height: 1;
}

.aartif-select-wrap { display: none !important; }

/* ---------- Base swatch ---------- */

.aartif-swatch {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: var(--aartif-size, 32px);
	height: var(--aartif-size, 32px);
	border: var(--aartif-border-w, 1px) solid var(--aartif-border, #e2e2e2);
	border-radius: var(--aartif-radius, 50%);
	cursor: pointer;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
	overflow: hidden;
	background-clip: padding-box;
}

.aartif-swatch:focus-visible {
	outline: 2px solid var(--aartif-selected, #111);
	outline-offset: 2px;
}

/* Per-attribute shape overrides */
.aartif-shape-circle .aartif-swatch { border-radius: 50%; }
.aartif-shape-rounded .aartif-swatch { border-radius: 26%; }
.aartif-shape-square .aartif-swatch { border-radius: 3px; }

/* ---------- Hover effects ---------- */

.aartif-hover-scale .aartif-swatch:not(.is-disabled):hover { transform: scale(1.1); }
.aartif-hover-lift .aartif-swatch:not(.is-disabled):hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

@media (prefers-reduced-motion: reduce) {
	.aartif-swatch, .aartif-fade-img { transition: none !important; }
	.aartif-hover-scale .aartif-swatch:hover,
	.aartif-hover-lift .aartif-swatch:hover { transform: none; }
}

/* ---------- Selected states ---------- */

.aartif-sel-ring .aartif-swatch.is-selected {
	box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--aartif-selected, #111);
	border-color: transparent;
}

.aartif-sel-border .aartif-swatch.is-selected {
	border: 2px solid var(--aartif-selected, #111);
}

.aartif-sel-check .aartif-swatch.is-selected::after {
	content: "";
	position: absolute;
	inset: 0;
	background:
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E")
		center / 55% no-repeat,
		rgba(0, 0, 0, 0.28);
}
.aartif-sel-check .aartif-swatch--light.is-selected::after,
.aartif-sel-check .aartif-swatch--label.is-selected::after,
.aartif-sel-check .aartif-swatch--fallback.is-selected::after {
	background:
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23111' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E")
		center / 55% no-repeat,
		rgba(255, 255, 255, 0.4);
}

/* Light colors always need a visible edge */
.aartif-swatch--light { border-color: #d4d4d4; }

/* ---------- Color / image / fallback ---------- */

.aartif-swatch--image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	margin: 0;
}

.aartif-swatch--fallback {
	background: #f3f4f6;
	color: #374151;
}

.aartif-swatch__init {
	font-size: calc(var(--aartif-size, 32px) * 0.34);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

/* ---------- Label pills ---------- */

.aartif-type-label .aartif-swatch,
.aartif-swatch--label {
	width: auto;
	min-width: var(--aartif-size, 32px);
	height: auto;
	min-height: calc(var(--aartif-size, 32px) * 0.92);
	padding: 0.3em 0.85em;
	border-radius: 6px;
	background: #fff;
	color: #1f2937;
	font-size: max(13px, calc(var(--aartif-size, 32px) * 0.42));
}

.aartif-sel-ring .aartif-swatch--label.is-selected,
.aartif-sel-border .aartif-swatch--label.is-selected,
.aartif-sel-check .aartif-swatch--label.is-selected {
	background: var(--aartif-selected, #111);
	color: #fff;
	border-color: var(--aartif-selected, #111);
	box-shadow: none;
}
.aartif-sel-check .aartif-swatch--label.is-selected::after { content: none; }

/* ---------- Radio list ---------- */

.aartif-type-radio { flex-direction: column; align-items: flex-start; }

.aartif-swatch--radio {
	width: auto;
	height: auto;
	border: 0;
	padding: 0.2em 0;
	gap: 0.55em;
	background: transparent;
	font-size: 15px;
	color: inherit;
	overflow: visible;
}

.aartif-radio__dot {
	width: 18px;
	height: 18px;
	border: 2px solid var(--aartif-border, #cbd5e1);
	border-radius: 50%;
	flex: 0 0 auto;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.aartif-swatch--radio.is-selected .aartif-radio__dot {
	border-color: var(--aartif-selected, #111);
	box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 12px var(--aartif-selected, #111);
}
.aartif-swatch--radio.is-selected { box-shadow: none; }

/* ---------- Out of stock ---------- */

.aartif-swatch.is-disabled { cursor: not-allowed; }

.aartif-oos-fade .aartif-swatch.is-disabled { opacity: 0.28; }
.aartif-oos-blur .aartif-swatch.is-disabled { opacity: 0.55; filter: blur(1.4px) grayscale(0.9); }
.aartif-oos-hide .aartif-swatch.is-disabled { display: none; }

.aartif-oos-cross .aartif-swatch.is-disabled { opacity: 0.45; }
.aartif-oos-cross .aartif-swatch.is-disabled::before {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(
		to top right,
		transparent calc(50% - 1.2px),
		rgba(220, 38, 38, 0.9) calc(50% - 1.2px),
		rgba(220, 38, 38, 0.9) calc(50% + 1.2px),
		transparent calc(50% + 1.2px)
	);
	z-index: 2;
}

/* ---------- Selected value label ---------- */

.aartif-selected-label {
	display: inline-block;
	margin-left: 10px;
	font-size: 0.86em;
	font-weight: 600;
	opacity: 0.75;
	vertical-align: middle;
}

/* ---------- Tooltip ---------- */

.aartif-tooltip {
	position: absolute;
	z-index: 99999;
	pointer-events: none;
	background: #111827;
	color: #fff;
	font-size: 12.5px;
	line-height: 1.35;
	padding: 6px 10px;
	border-radius: 7px;
	max-width: 220px;
	text-align: center;
	opacity: 0;
	transform: translateY(4px);
	transition: opacity 0.14s ease, transform 0.14s ease;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.aartif-tooltip.is-visible { opacity: 1; transform: translateY(0); }

.aartif-tooltip::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	margin-left: -5px;
	border: 5px solid transparent;
	border-top-color: #111827;
}

.aartif-tooltip img {
	display: block;
	width: 120px;
	height: 90px;
	object-fit: cover;
	border-radius: 5px;
	margin: 0 auto 5px;
}

/* ---------- Archive (shop cards) ---------- */

.aartif-archive {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
	margin: 8px 0 6px;
}

.aartif-swatches--archive { --aartif-gap: 6px; }

.aartif-more {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: var(--aartif-size, 24px);
	height: var(--aartif-size, 24px);
	padding: 0 6px;
	border-radius: 999px;
	background: #f3f4f6;
	color: #374151 !important;
	font-size: 12px;
	font-weight: 600;
	text-decoration: none !important;
	transition: background 0.15s ease;
}
.aartif-more:hover { background: #e5e7eb; }

.aartif-card .attachment-woocommerce_thumbnail,
.aartif-card .wp-post-image { transition: opacity 0.22s ease; }
.aartif-card .aartif-img-fading { opacity: 0; }

.aartif-quickbuy-btn.is-loading { opacity: 0.6; pointer-events: none; }
.aartif-quickbuy-btn.is-added { background: #16a34a !important; border-color: #16a34a !important; color: #fff !important; }

/* Keep table-based variation layouts tidy */
.variations td.value { vertical-align: middle; }
.variations .aartif-swatches { padding: 2px 0; }

/* ---------- Sheen finish (color swatches) ---------- */

.aartif-sheen .aartif-swatch--color::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 45%);
	pointer-events: none;
	z-index: 1;
}

/* ---------- Image fit ---------- */

.aartif-fit-contain .aartif-swatch--image img { object-fit: contain; background: #fff; }

/* ---------- Uppercase labels ---------- */

.aartif-upper .aartif-swatch__text { text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.92em; }

/* ---------- Per-swatch price hints ---------- */

.aartif-swatch__price {
	display: block;
	width: 100%;
	margin-top: 2px;
	font-size: 0.72em;
	font-weight: 500;
	opacity: 0.62;
	line-height: 1.1;
	white-space: nowrap;
}
.aartif-type-label .aartif-swatch { flex-direction: column; }
.aartif-type-label .aartif-swatch.is-selected .aartif-swatch__price { opacity: 0.85; }

/* ---------- Popular badge ---------- */

.aartif-swatch.is-popular::after {
	content: "";
	position: absolute;
	top: -3px;
	right: -3px;
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: #d4af37;
	border: 1.5px solid #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
	z-index: 3;
}
.aartif-swatch--label.is-popular::after,
.aartif-swatch--radio.is-popular::after { top: -4px; right: -4px; }

/* ---------- Live price bar ---------- */

.aartif-price-bar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 12px;
	margin: 10px 0 4px;
	padding: 10px 14px;
	border: 1px solid var(--aartif-border, #e7e5e4);
	border-radius: 10px;
	background: rgba(0, 0, 0, 0.018);
	animation: aartif-bar-in 0.2s ease;
}

@keyframes aartif-bar-in {
	from { opacity: 0; transform: translateY(3px); }
	to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
	.aartif-price-bar { animation: none; }
}

.aartif-price-bar__price { font-size: 1.15em; font-weight: 700; }
.aartif-price-bar__price del { opacity: 0.5; font-weight: 400; margin-right: 4px; }
.aartif-price-bar__price ins { text-decoration: none; }

.aartif-price-bar__save {
	background: #dcfce7;
	color: #15803d;
	font-size: 0.78em;
	font-weight: 700;
	padding: 3px 9px;
	border-radius: 999px;
	letter-spacing: 0.02em;
}

.aartif-price-bar__stock { font-size: 0.82em; font-weight: 600; }
.aartif-price-bar__stock.is-in { color: #15803d; }
.aartif-price-bar__stock.is-in::before { content: "●"; font-size: 0.7em; margin-right: 5px; vertical-align: 1px; }
.aartif-price-bar__stock.is-out { color: #b91c1c; }
.aartif-price-bar__stock.is-out::before { content: "●"; font-size: 0.7em; margin-right: 5px; vertical-align: 1px; }

/* Share button */
.aartif-share {
	margin-left: auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 1px solid var(--aartif-border, #e2e2e2);
	border-radius: 8px;
	background: #fff;
	color: #444;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.aartif-share svg { width: 15px; height: 15px; }
.aartif-share:hover { background: #f5f5f4; color: #111; }
.aartif-share.is-copied { background: #16a34a; border-color: #16a34a; color: #fff; }
.aartif-share:focus-visible { outline: 2px solid var(--aartif-selected, #111); outline-offset: 2px; }

/* ---------- Archive card price ---------- */

.aartif-card-price {
	display: inline-flex;
	align-items: center;
	font-size: 12.5px;
	font-weight: 700;
	padding: 2px 8px;
	border-radius: 999px;
	background: #f3f4f6;
}
.aartif-card-price del { opacity: 0.5; font-weight: 400; margin-right: 4px; }
.aartif-card-price ins { text-decoration: none; }
