/* ChromaLab Product Widget.
   The wheel block reuses the Filter widget's `.chromalab` markup + styles
   (chroma-filter.css), so this file only adds the product-specific bits:
   compact sizing, the reveal toggle, and the variation swatches. White
   surfaces, soft hairline swatches, theme typography (no bespoke font). */

.chromalab-product {
	/* Identity tokens mirror chroma-filter.css so both widgets read as one tool. */
	--cl-color-text: var(--un-text);
	--cl-color-muted: var(--un-text-2);
	--cl-color-border: var(--un-border);
	--cl-color-track: var(--un-bg-soft);

	width: 100%;
	box-sizing: border-box;
}

/* Empty-column collapse. In pill mode the variations render inline above the
   cart and the ChromaLab widget renders nothing — add the `un-wheel-col` class
   (Elementor → Advanced → CSS Classes) to the column/container holding the
   ChromaLab wheel widget and it collapses on pill products, freeing the space
   for a sibling set to grow. */
body.un-variations-inline .un-wheel-col {
	display: none !important;
}

.chromalab-product *, .chromalab-product *::before, .chromalab-product *::after {
	box-sizing: border-box;
}

/* --- Wheel toggle (ChromaLab pill, not a generic grey button) --- */

.chromalab-product__wheel-toggle {
	display: inline-block;
	padding: 6px 14px;
	border: 1px solid var(--cl-color-border);
	border-radius: var(--un-radius);
	background: var(--un-white);
	color: var(--un-text-2);
	font-size: 13px;
	cursor: pointer;
	transition: border-color 0.15s ease, color 0.15s ease;
	margin-bottom: 12px;
}

.chromalab-product__wheel-toggle:hover,
.chromalab-product__wheel-toggle:focus-visible {
	border-color: var(--cl-color-text);
	color: var(--cl-color-text);
	outline: none;
}

/* --- Wheel block: transparent show/hide wrapper around the reused .chromalab --- */

.chromalab-product__wheel-wrap {
	margin-bottom: 16px;
}

.chromalab-product__wheel-wrap[hidden] {
	display: none;
}

/* Compact tuning: the picker lives in the product summary, so trim padding and
   gaps a touch versus the full-width archive filter. Wheel size comes from the
   inline --cl-wheel (widget "Wheel size" control). */
.chromalab-product .chromalab--in-product {
	--cl-gap: 14px;
	--cl-gap-body: 16px;
	padding: 0;
}

/* --- Swatches --- */

.chromalab-product__swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 8px;
}

.chromalab-product__swatch {
	/* Soft hairline (matches Results swatches) — no heavy black frame. */
	position: relative;
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: 50%;
	cursor: pointer;
	transition: box-shadow 0.12s, opacity 0.15s;
	padding: 0;
	flex-shrink: 0;
}

/* Hover: subtle contained inset ring — no scale, no outer ring, so nothing
   grows over neighbours in the dense grid. */
.chromalab-product__swatch:hover {
	box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.95), inset 0 0 0 3px rgba(0, 0, 0, 0.3);
}

/* Selected: a CONTAINED inset ring + centered check, legible on any swatch
   colour (white glyph + dark drop-shadow halo). No scale / no outer ring, so a
   selected swatch never grows over its neighbours in the dense grid. */
.chromalab-product__swatch--selected {
	box-shadow: inset 0 0 0 2px var(--un-white), inset 0 0 0 3px rgba(0, 0, 0, 0.6);
}

.chromalab-product__swatch--selected::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 6px;
	height: 10px;
	border: solid var(--un-white);
	border-width: 0 2.5px 2.5px 0;
	transform: translate(-50%, -60%) rotate(45deg);
	filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.95));
	pointer-events: none;
}

/* Non-matching swatches when the wheel filter is active. 0.2 read as "broken";
   0.4 keeps them legible while clearly de-emphasised. */
.chromalab-product__swatch--dimmed {
	opacity: 0.4;
}

/* Out-of-stock colour. The pill mode already had this treatment; the swatch grid
   did not, so a sold-out colour looked identical to an available one and clicking
   it just did nothing (selectVariation refuses it). Faded + desaturated, with a
   diagonal bar so it reads as unavailable even at 20px and even for viewers who
   can't tell the colours apart. Tooltip carries the wording. */
.chromalab-product__swatch--oos {
	opacity: 0.45;
	filter: grayscale(0.65);
	cursor: not-allowed;
	pointer-events: none;
	/* Clip the bar below to the swatch disc (the swatch is border-radius: 50%). */
	overflow: hidden;
}

.chromalab-product__swatch--oos::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 150%;
	height: 2px;
	background: var(--un-white);
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
	transform: translate(-50%, -50%) rotate(-45deg);
	pointer-events: none;
}

/* --- Pills (text variations: contenance, taille…) --- */

/* Content-adaptive grid. Pills fill the full width (same as the Add-to-cart
   button below), packing as many equal columns as fit given the widest label:
   short labels (e.g. "#45") → many columns; long labels → fewer/one per row.
   `--pill-min` = widest label's natural width (+ check allowance), measured by
   JS (setPillGridMin); `1fr` then stretches columns to fill the row so edges
   stay flush. `min(…, 100%)` caps the min so a single very long label can never
   overflow the container — it wraps inside a full-width pill instead. */
.chromalab-product[data-mode="pill"] .chromalab-product__swatches {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(var(--pill-min, 8rem), 100%), 1fr));
	gap: 12px;
}

/* Square chips. Default state: white, primary-text hairline + primary text.
   Overrides the round fixed-size geometry meant for colour dots. Width comes
   from the grid track (1fr) — no per-pill width; the grid owns sizing. */
.chromalab-product__pill {
	/* Full width of its grid cell; height follows content (wraps if a label is
	   too long to fit one line — rare, only for very long names). */
	width: auto;
	height: auto;
	box-sizing: border-box;
	text-align: center;
	border-radius: 0;
	border: 1px solid var(--un-text);
	background: var(--un-white);
	color: var(--un-text);
	padding: 8px 16px;
	font-family: "Public Sans", sans-serif;
	font-size: 14px;
	line-height: 1.2;
	font-weight: 400;
	white-space: normal;
	transition: background 0.12s, color 0.12s, border-color 0.12s;
}

/* Check appears only when selected (SVG mask, inherits text colour); unselected
   pills have no check so their text stays centred. */
.chromalab-product__pill.chromalab-product__swatch--selected::before {
	content: "";
	display: inline-block;
	width: 12px;
	height: 12px;
	margin-right: 6px;
	vertical-align: -2px;
	background-color: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' d='M5 13l4 4L19 7'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' d='M5 13l4 4L19 7'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* The base `.chromalab-product__swatch--selected::after` draws a centred check
   glyph sized for round dots — suppress it on pills (they use ::before instead).
   The matching inset-ring box-shadows are cleared in the rules below. */
.chromalab-product__pill.chromalab-product__swatch--selected::after {
	content: none;
}

/* Hover on an unselected chip: shift to the rose accent (text + border). */
.chromalab-product__pill:not(.chromalab-product__swatch--selected):hover {
	border-color: var(--un-rose);
	color: var(--un-rose);
	box-shadow: none;
}

/* Neutral selected: solid rose fill + border, white text/check. */
.chromalab-product__pill:not(.chromalab-product__pill--tinted).chromalab-product__swatch--selected {
	background: var(--un-rose);
	color: var(--un-white);
	border-color: var(--un-rose);
	box-shadow: none;
}

/* Tinted pills keep their variation colour (inline bg + auto text colour). The
   check carries the same colour; selection only deepens the single border — no
   nested rings. */
.chromalab-product__pill--tinted.chromalab-product__swatch--selected {
	border-color: var(--un-text-2);
	box-shadow: none;
}

/* Out-of-stock pill: same size + position in the grid, greyed + struck + disabled
   so it can't be picked (no add-to-cart attempt → no ugly WC alert). Colours per
   the theme: out-of-stock hairline border + text-secondary label. Compound
   selector (.pill.pill--oos) so it beats the base .pill border/color regardless
   of stylesheet load order. */
.chromalab-product__pill.chromalab-product__pill--oos {
	background: var(--un-white);
	border-color: var(--un-text-3);
	color: var(--un-text-2);
	text-decoration: line-through;
	cursor: not-allowed;
	pointer-events: none;
}

.chromalab-product__pill.chromalab-product__pill--oos:hover {
	border-color: var(--un-text-3);
	color: var(--un-text-2);
	box-shadow: none;
}

/* --- Selected-variation price --- */

/* chroma-product.js swaps the picked variation's price into Elementor's Product
   Price widget in place (between the notice and Add-to-cart button), so the
   range/parent price "resolves" to the selected variation right where it sits. It
   keeps that widget's own styling, so range↔variation read identically ("même
   styling"). Here we only hide WC's native in-form price (below the swatches,
   inside .single_variation_wrap) so the variation price isn't duplicated;
   availability/description in .single_variation are left untouched. Gated on the
   JS-set flag so we never hide it unless there's a summary price to swap into. */
.un-variation-price-relocated .chromalab-product ~ .single_variation_wrap .woocommerce-variation-price {
	display: none;
}

/* WC slides its availability line ("34 en stock") in and out on every
   selection (jQuery inline height/display), pushing the swatches below it
   around — and back again when a selection is re-committed. Pin it instead:
   always shown, one line reserved, so picking a colour never moves the page. */
.un-chroma-variations .variations_form .single_variation {
	display: block !important;
	height: auto !important;
	overflow: visible !important;
	min-height: 1.5em;
}

/* --- Variation info --- */

.chromalab-product__variation-info {
	/* Always-reserved one-line zone: hovering a swatch fills/empties the text
	   without ever shifting the content below (price, add-to-cart). */
	display: flex;
	align-items: center;
	min-height: 28px;
	padding: 4px 0;
}

.chromalab-product__variation-name {
	font-size: 13px;
	line-height: 1.3;
	color: var(--cl-color-text);
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	min-width: 0;
}

/* --- Mobile --- */

@media (max-width: 600px) {
	.chromalab-product__swatches {
		gap: 4px;
	}
}
