/* ================================================================
   Variation Swatches Pro v2.2 — Frontend
   Design: Luxury Refined — clean cards, tactile selection states,
   glass labels, smooth micro-interactions
   ================================================================ */

/* ── Design tokens ── */
:root {
	/* Card dimensions — 2:3 portrait */
	--vsp-w:          68px;
	--vsp-h:         102px;   /* w × 1.5 = exact 2:3 */

	/* Gaps & radius */
	--vsp-gap:         8px;
	--vsp-radius:     10px;
	--vsp-radius-sm:   6px;

	/* Border */
	--vsp-border:     #e5e7eb;
	--vsp-border-w:     2px;

	/* Selection colours */
	--vsp-accent:     #6d28d9;
	--vsp-accent-rgb: 109,40,217;
	--vsp-ring:       0 0 0 3px rgba(var(--vsp-accent-rgb),.20);
	--vsp-ring-tight: 0 0 0 2px #fff, 0 0 0 4px var(--vsp-accent);

	/* Shadows */
	--vsp-shadow-rest: 0 1px 3px rgba(0,0,0,.08);
	--vsp-shadow-hover:0 6px 20px rgba(0,0,0,.14);

	/* Buttons */
	--vsp-btn-bg:     #f3f4f6;
	--vsp-btn-hover:  #ede9fe;
	--vsp-btn-sel-bg: var(--vsp-accent);
	--vsp-btn-color:  #374151;

	/* Label strip */
	--vsp-label-h:   22px;
	--vsp-label-fs:  9.5px;

	/* Easing */
	--vsp-ease:      cubic-bezier(.4,0,.2,1);
	--vsp-dur:       180ms;
}

/* ── Hide native select ── */
.vsp-hidden-select { display:none !important; }

/* ── Wrapper ── */
.vsp-swatches-wrapper { margin-bottom:18px; }

/* ── Swatch list ── */
.vsp-swatches {
	display:flex;
	flex-wrap:wrap;
	gap:var(--vsp-gap);
	align-items:flex-start;
	margin-top:8px;
}

/* ──────────────────────────────────────────────────────────────
   COMMON SWATCH BASE
   ────────────────────────────────────────────────────────────── */
.vsp-swatch {
	position:relative;
	display:inline-flex;
	align-items:center;
	justify-content:center;
	cursor:pointer;
	user-select:none;
	-webkit-tap-highlight-color:transparent;
	border:var(--vsp-border-w) solid var(--vsp-border);
	border-radius:var(--vsp-radius);
	background:transparent;
	outline:none;
	box-shadow:var(--vsp-shadow-rest);
	transition:
		border-color var(--vsp-dur) var(--vsp-ease),
		box-shadow   var(--vsp-dur) var(--vsp-ease),
		transform    var(--vsp-dur) var(--vsp-ease);
}

.vsp-swatch:hover {
	border-color:var(--vsp-accent);
	box-shadow:var(--vsp-shadow-hover);
	transform:translateY(-3px) scale(1.02);
	z-index:2;
}

.vsp-swatch.selected {
	border-color:var(--vsp-accent);
	box-shadow:var(--vsp-ring-tight);
	transform:translateY(-1px);
}

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

/* ──────────────────────────────────────────────────────────────
   COLOR SWATCH CARD
   Portrait 2:3 card with colour background + image + glass label
   ────────────────────────────────────────────────────────────── */

.vsp-type-color .vsp-swatch {
	width:  var(--vsp-w);
	height: var(--vsp-h);
	padding:0;
	overflow:hidden;
	flex-direction:column;
	align-items:stretch;
}

/* Card inner */
.vsp-color-card {
	display:flex;
	flex-direction:column;
	width:100%; height:100%;
	border-radius:calc(var(--vsp-radius) - var(--vsp-border-w));
	overflow:hidden;
	position:relative;
}

/* ── Image area ── */
.vsp-card-image {
	flex:1;
	overflow:hidden;
	position:relative;
	display:block;
	width:100%;
}

.vsp-card-image img {
	display:block;
	width:100%;
	height:100%;
	/* Enforce 2:3 portrait on the image element */
	aspect-ratio:2/3;
	object-fit:cover;
	object-position:center top;
	pointer-events:none;
	transition:transform 320ms var(--vsp-ease);
}

.vsp-swatch:hover .vsp-card-image img { transform:scale(1.08); }

/* ── Solid colour dot (no image) ── */
.vsp-card-dot {
	display:block;
	flex:1;
	width:100%;
}

/* ── Glass label strip at bottom
   Text colour is SET via inline style from PHP (WCAG-computed).
   NO filter / mix-blend-mode overrides.                         ── */
.vsp-card-label {
	display:block;
	height:var(--vsp-label-h);
	line-height:var(--vsp-label-h);
	text-align:center;
	font-size:var(--vsp-label-fs);
	font-weight:700;
	letter-spacing:.05em;
	text-transform:uppercase;
	white-space:nowrap;
	overflow:hidden;
	text-overflow:ellipsis;
	padding:0 4px;
	flex-shrink:0;
	position:relative;
	/* Frosted-glass translucent strip */
	background:rgba(0,0,0,.22);
	backdrop-filter:blur(8px) saturate(180%);
	-webkit-backdrop-filter:blur(8px) saturate(180%);
}

/* ── Selected checkmark badge ── */
.vsp-type-color .vsp-swatch.selected::after,
.vsp-type-image  .vsp-swatch.selected::after {
	content:'✓';
	position:absolute;
	top:5px; right:5px;
	width:18px; height:18px;
	background:#fff;
	color:var(--vsp-accent);
	border-radius:50%;
	font-size:10px;
	font-weight:900;
	display:flex;
	align-items:center;
	justify-content:center;
	pointer-events:none;
	z-index:3;
	box-shadow:0 1px 6px rgba(0,0,0,.2);
	animation:vsp-pop .18s var(--vsp-ease) both;
}

@keyframes vsp-pop {
	0%   { transform:scale(0); opacity:0; }
	70%  { transform:scale(1.2); }
	100% { transform:scale(1); opacity:1; }
}

/* ── Shape variants ── */
.vsp-shape-square .vsp-type-color .vsp-swatch,
.vsp-shape-square .vsp-color-card { border-radius:4px !important; }

.vsp-shape-circle .vsp-type-color .vsp-swatch {
	border-radius:50% !important;
	width: 44px !important;
	height:44px !important;
}
.vsp-shape-circle .vsp-color-card  { border-radius:50% !important; }
.vsp-shape-circle .vsp-card-label  { display:none; }
.vsp-shape-circle .vsp-card-image  { flex:1; }
.vsp-shape-circle .vsp-card-image img { aspect-ratio:unset; }

/* ──────────────────────────────────────────────────────────────
   IMAGE SWATCH — same dimensions as color card
   ────────────────────────────────────────────────────────────── */

.vsp-type-image .vsp-swatch {
	width: var(--vsp-w);
	height:var(--vsp-h);
	padding:0;
	overflow:hidden;
}

.vsp-type-image .vsp-swatch img {
	display:block;
	width:100%; height:100%;
	aspect-ratio:2/3;
	object-fit:cover;
	object-position:center top;
	pointer-events:none;
	transition:transform 320ms var(--vsp-ease);
}
.vsp-type-image .vsp-swatch:hover img { transform:scale(1.08); }

/* ──────────────────────────────────────────────────────────────
   BUTTON SWATCH
   ────────────────────────────────────────────────────────────── */

.vsp-type-button .vsp-swatch,
.vsp-type-select .vsp-swatch {
	min-width:40px;
	height:38px;
	padding:0 15px;
	border-radius:var(--vsp-radius);
	background:var(--vsp-btn-bg);
}

.vsp-type-button .vsp-swatch:hover,
.vsp-type-select .vsp-swatch:hover {
	background:var(--vsp-btn-hover);
}

.vsp-type-button .vsp-swatch.selected,
.vsp-type-select .vsp-swatch.selected {
	background:var(--vsp-btn-sel-bg);
	border-color:var(--vsp-btn-sel-bg);
}

.vsp-btn-inner {
	font-size:12px;
	font-weight:700;
	letter-spacing:.03em;
	color:var(--vsp-btn-color);
	pointer-events:none;
	white-space:nowrap;
}

/* Selected button: text ALWAYS white regardless of theme */
.vsp-type-button .vsp-swatch.selected .vsp-btn-inner,
.vsp-type-select .vsp-swatch.selected .vsp-btn-inner {
	color:#fff !important;
}

/* ──────────────────────────────────────────────────────────────
   RADIO SWATCH
   ────────────────────────────────────────────────────────────── */

.vsp-type-radio .vsp-swatches {
	flex-direction:column;
	align-items:flex-start;
	gap:10px;
}

.vsp-type-radio .vsp-swatch {
	border:none !important;
	background:none;
	box-shadow:none !important;
	padding:0;
	height:auto;
}
.vsp-type-radio .vsp-swatch:hover {
	transform:none !important;
	box-shadow:none !important;
}

.vsp-radio-inner {
	display:flex;
	align-items:center;
	gap:10px;
	pointer-events:none;
}

.vsp-radio-dot {
	width:20px; height:20px;
	border-radius:50%;
	border:2px solid var(--vsp-border);
	flex-shrink:0;
	position:relative;
	transition:border-color var(--vsp-dur) var(--vsp-ease);
}
.vsp-radio-dot::after {
	content:'';
	position:absolute;
	inset:3px;
	border-radius:50%;
	background:transparent;
	transition:background var(--vsp-dur) var(--vsp-ease);
}
.vsp-type-radio .vsp-swatch:hover  .vsp-radio-dot,
.vsp-type-radio .vsp-swatch.selected .vsp-radio-dot { border-color:var(--vsp-accent); }
.vsp-type-radio .vsp-swatch.selected .vsp-radio-dot::after { background:var(--vsp-accent); }

.vsp-radio-text {
	font-size:14px;
	font-weight:500;
	color:#374151;
}

/* ──────────────────────────────────────────────────────────────
   DISABLED STATE
   ────────────────────────────────────────────────────────────── */

.vsp-swatch.disabled {
	opacity:.35;
	cursor:not-allowed;
	pointer-events:none;
	transform:none !important;
	box-shadow:var(--vsp-shadow-rest) !important;
}

.vsp-disabled-cross .vsp-swatch.disabled::before {
	content:'';
	position:absolute; inset:-1px;
	background:linear-gradient(
		to bottom right,
		transparent      calc(50% - 1px),
		rgba(220,38,38,.8) calc(50% - 1px),
		rgba(220,38,38,.8) calc(50% + 1px),
		transparent      calc(50% + 1px)
	);
	border-radius:inherit;
	z-index:4;
	pointer-events:none;
}
.vsp-disabled-blur .vsp-swatch.disabled { filter:blur(1.5px); opacity:.45; }
.vsp-disabled-hide .vsp-swatch.disabled { display:none !important; }

/* ──────────────────────────────────────────────────────────────
   TOOLTIP
   ────────────────────────────────────────────────────────────── */

.vsp-tooltip {
	position:absolute;
	bottom:calc(100% + 12px);
	left:50%;
	transform:translateX(-50%) translateY(6px);
	background:#0f172a;
	color:#f8fafc;
	border-radius:12px;
	padding:10px 13px 8px;
	pointer-events:none;
	opacity:0;
	transition:opacity var(--vsp-dur) var(--vsp-ease), transform var(--vsp-dur) var(--vsp-ease);
	z-index:9999;
	text-align:center;
	white-space:nowrap;
	box-shadow:0 10px 40px rgba(0,0,0,.28);
}
.vsp-tooltip::after {
	content:'';
	position:absolute; top:100%; left:50%;
	transform:translateX(-50%);
	border:7px solid transparent;
	border-top-color:#0f172a;
}
.vsp-tooltip img {
	display:block;
	width:54px;
	height:81px;  /* 2:3 */
	object-fit:cover;
	object-position:center top;
	border-radius:6px;
	margin:0 auto 6px;
}
.vsp-tooltip-text {
	display:block;
	font-size:11px;
	font-weight:700;
	letter-spacing:.05em;
}
.vsp-swatch:hover .vsp-tooltip {
	opacity:1;
	transform:translateX(-50%) translateY(0);
}

/* ──────────────────────────────────────────────────────────────
   SELECTED LABEL
   ────────────────────────────────────────────────────────────── */

.vsp-selected-label {
	margin-top:10px;
	font-size:13px;
	color:#6b7280;
	line-height:1.5;
}
.vsp-label-name  { font-weight:600; margin-right:4px; color:#111827; }
.vsp-label-value {
	color:var(--vsp-accent);
	font-weight:600;
	transition:color var(--vsp-dur) var(--vsp-ease);
}

/* ──────────────────────────────────────────────────────────────
   CLEAR BUTTON
   ────────────────────────────────────────────────────────────── */

.vsp-clear-btn {
	display:inline-flex;
	align-items:center;
	gap:5px;
	margin-top:9px;
	font-size:12px;
	color:#9ca3af;
	text-decoration:none;
	border-bottom:1px dashed currentColor;
	transition:color var(--vsp-dur) var(--vsp-ease);
	line-height:1.4;
}
.vsp-clear-btn::before {
	content:'×';
	font-size:15px;
	line-height:1;
	font-weight:300;
}
.vsp-clear-btn:hover { color:#ef4444; }

/* ──────────────────────────────────────────────────────────────
   IMAGE SWAP TRANSITION
   ────────────────────────────────────────────────────────────── */

.vsp-img-transitioning {
	opacity:.6;
	transition:opacity .22s var(--vsp-ease) !important;
}

/* Fade mode */
.vsp-gallery-fade-out {
	opacity:0 !important;
	transition:opacity .18s ease !important;
}
.vsp-gallery-fade-in {
	opacity:1 !important;
	transition:opacity .22s ease !important;
}

/* ──────────────────────────────────────────────────────────────
   LOOP / ARCHIVE SWATCHES
   ────────────────────────────────────────────────────────────── */

.vsp-loop-swatches {
	display:flex;
	flex-wrap:wrap;
	gap:5px;
	padding:7px 0 4px;
}

.vsp-loop-swatch {
	display:inline-flex;
	align-items:center;
	justify-content:center;
	width:24px; height:24px;
	border-radius:50%;
	border:1.5px solid #e5e7eb;
	overflow:hidden;
	cursor:default;
	transition:border-color .15s ease, transform .15s ease;
}
.vsp-loop-swatch:hover { border-color:var(--vsp-accent); transform:scale(1.12); }
.vsp-loop-swatch img   { width:100%; height:100%; object-fit:cover; }
.vsp-loop-btn { border-radius:var(--vsp-radius-sm); width:auto; padding:0 7px; height:20px; font-size:9px; font-weight:700; color:#374151; }
.vsp-loop-more {
	display:inline-flex; align-items:center; justify-content:center;
	width:24px; height:24px;
	background:#f3f4f6; border-radius:50%;
	font-size:9px; font-weight:700; color:#6b7280;
}

/* ──────────────────────────────────────────────────────────────
   RESPONSIVE
   ────────────────────────────────────────────────────────────── */

@media (max-width:600px) {
	:root { --vsp-w:58px; --vsp-h:87px; --vsp-gap:6px; }
}
@media (max-width:380px) {
	:root { --vsp-w:50px; --vsp-h:75px; }
}
