/**
 * Lubiwood — size swatches with per-variation prices + meta + chooser (50+ friendly)
 * Uses --lwd-* tokens from product-page.css on body.lubiwood-product-page.
 */

.variations_form.lubiwood-swatch-prices-active {
	--lw-swatch-radius: var(--lwd-radius, 12px);
	--lw-swatch-brd: var(--lwd-brd, #e3e6e4);
	--lw-swatch-brd-active: var(--lwd-green, #3d6b47);
	--lw-swatch-bg: #fff;
	--lw-swatch-bg-active: var(--lwd-green-soft, #dceee0);
	--lw-swatch-text: var(--lwd-text, #1f2421);
	--lw-swatch-muted: var(--lwd-text-muted, #3a3f3c);
	--lw-swatch-accent: var(--lwd-green-dark, #2f5c38);
	--lw-swatch-gap: 10px;
	max-width: 100%;
}

/* "Choose your size" instruction banner — high visibility, stays visible after selection */
.variations_form.lubiwood-chooser-active .lubiwood-chooser-banner {
	margin: 0 0 18px;
	padding: 18px 18px 20px;
	border: 2px solid var(--lwd-green-line, #b8d4be);
	border-radius: var(--lwd-radius, 12px);
	background: var(--lwd-green-soft, #f0f7f2);
	color: var(--lw-swatch-text);
	box-shadow: var(--lwd-shadow, 0 1px 3px rgba(15, 23, 18, 0.05));
}

.variations_form.lubiwood-chooser-active .lubiwood-chooser-banner--hidden {
	display: none;
}

.variations_form.lubiwood-chooser-active .lubiwood-chooser-banner__title {
	margin: 0 0 10px;
	font-size: clamp(1.3125rem, 4.8vw, 1.5625rem);
	font-weight: 800;
	line-height: 1.25;
	letter-spacing: -0.01em;
}

.variations_form.lubiwood-chooser-active .lubiwood-chooser-banner__hint {
	margin: 0;
	font-size: clamp(1.0625rem, 3.4vw, 1.1875rem);
	font-weight: 500;
	line-height: 1.45;
	color: var(--lw-swatch-muted);
}

/* Hide redundant Size rows — swatch cards (+ Step 1 banner) are self-explanatory.
   Applies on page load for every variable puzzle with WoodMart swatches, not only
   after JS adds .lubiwood-swatch-prices-active. Also hides the WoodMart product
   attributes table (Size | A3, A4… or Size | M ?) that sits above the form. */
body.lubiwood-swatch-chooser-page:has(.wd-swatches-product) table.shop_attributes,
body.lubiwood-swatch-chooser-page:has(.wd-swatches-product) .woocommerce-product-attributes-item--attribute_pa_size,
body.lubiwood-swatch-chooser-page:has(.wd-swatches-product) .variations_form table.variations .label,
body.lubiwood-swatch-chooser-page:has(.wd-swatches-product) .variations_form table.variations th.label,
.variations_form.lubiwood-swatch-prices-active table.variations .label,
.variations_form.lubiwood-swatch-prices-active table.variations th.label {
	display: none !important;
}

body.lubiwood-swatch-chooser-page:has(.wd-swatches-product) .variations_form table.variations tr .value,
.variations_form.lubiwood-swatch-prices-active table.variations tr .value {
	padding-top: 0 !important;
}

/* Hide native dropdown — swatches replace it */
body.lubiwood-swatch-chooser-page:has(.wd-swatches-product) .variations_form table.variations select,
.variations_form.lubiwood-swatch-prices-active table.variations select {
	display: none !important;
}

/* Highlight swatches when user taps disabled Add to cart */
.variations_form.lubiwood-chooser-highlight .wd-swatches-product {
	outline: 3px solid #3d6b47;
	outline-offset: 4px;
	border-radius: 12px;
}

/* Hide confusing “Clear” on chooser pages */
.variations_form.lubiwood-chooser-active .reset_variations,
.variations_form.lubiwood-chooser-active .wd-reset-var {
	display: none !important;
}

/* Hide duplicate price range above the form */
body.lubiwood-swatch-chooser-page:has(.lubiwood-chooser-active) .summary-inner > .price,
body.lubiwood-swatch-chooser-page:has(.lubiwood-chooser-active) .wd-single-price .price,
body.lubiwood-swatch-chooser-page:has(.lubiwood-chooser-active) .product-image-summary > .price {
	display: none !important;
}

.variations_form.lubiwood-swatch-prices-active table.variations td.value {
	width: 100%;
	max-width: 100%;
	padding-top: 0.25em;
}

.variations_form.lubiwood-swatch-prices-active .wd-swatches-single.wd-swatches-product {
	flex-direction: column;
	align-items: stretch;
	gap: var(--lw-swatch-gap);
	width: 100%;
	max-width: 100%;
}

/* Card grid: head (size + price) / meta row */
.variations_form.lubiwood-swatch-prices-active .wd-swatches-single > .wd-swatch.wd-text {
	display: grid !important;
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-rows: auto auto;
	align-items: center;
	column-gap: 12px;
	row-gap: 8px;
	width: 100% !important;
	min-width: 0 !important;
	max-width: 100% !important;
	min-height: 58px !important;
	height: auto !important;
	margin: 0 !important;
	padding: 14px 18px !important;
	border: 1.5px solid var(--lw-swatch-brd) !important;
	border-radius: var(--lw-swatch-radius) !important;
	background: var(--lw-swatch-bg) !important;
	color: var(--lw-swatch-text) !important;
	box-shadow: none !important;
	box-sizing: border-box;
	cursor: pointer;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	transition:
		border-color 0.2s ease,
		background-color 0.2s ease,
		box-shadow 0.2s ease;
}

.variations_form.lubiwood-swatch-prices-active .wd-swatches-single > .wd-swatch.wd-text:hover {
	border-color: #b8c4bb !important;
	background: #f8faf9 !important;
}

/* Selected — very obvious for 50+ */
.variations_form.lubiwood-swatch-prices-active .wd-swatches-single > .wd-swatch.wd-text.wd-active {
	border-color: var(--lw-swatch-brd-active) !important;
	border-width: 2px !important;
	background: var(--lw-swatch-bg-active) !important;
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--lwd-green, #3d6b47) 18%, transparent) !important;
	color: var(--lw-swatch-text) !important;
}

/* Card top row: size label (left) | badge + price (top-right) */
.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-head {
	grid-column: 1 / -1;
	grid-row: 1;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px 16px;
	min-width: 0;
}

.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-label {
	flex: 1 1 auto;
	min-width: 0;
	align-self: center;
	padding-right: 4px;
}

.variations_form.lubiwood-swatch-prices-active .wd-swatch.wd-text .wd-swatch-text {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.2em 0.35em;
	margin: 0 !important;
	padding: 0 !important;
	font-size: clamp(1.0625rem, 3.2vw, 1.25rem) !important;
	font-weight: 700 !important;
	line-height: 1.3 !important;
	color: inherit !important;
	text-transform: none;
	letter-spacing: 0;
}

.variations_form.lubiwood-swatch-prices-active .lubiwood-size-name {
	font-size: clamp(1.125rem, 3.6vw, 1.3125rem);
	font-weight: 700;
	text-transform: none;
	letter-spacing: 0;
	white-space: nowrap;
}

.variations_form.lubiwood-swatch-prices-active .lubiwood-size-code {
	font-size: clamp(1rem, 3vw, 1.125rem);
	font-weight: 600;
	color: var(--lw-swatch-muted);
	text-transform: uppercase;
	white-space: nowrap;
}

/* Top-right: badge above price */
.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-aside {
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	justify-content: flex-start;
	gap: 6px;
	max-width: 52%;
	text-align: right;
}

.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-badge {
	display: inline-block;
	margin: 0;
	padding: 4px 10px;
	border-radius: var(--lwd-radius-sm, 10px);
	background: var(--lwd-green, #3d6b47);
	color: #fff;
	font-size: 0.6875rem;
	font-weight: 700;
	line-height: 1.25;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	white-space: nowrap;
}

.variations_form.lubiwood-swatch-prices-active .wd-swatch.wd-text.wd-active .lubiwood-swatch-badge {
	background: var(--lwd-green-dark, #2f5c38);
}

/* Keep every size card the same height regardless of the "Most popular" badge.
   The badge adds a row to its card's aside; reserve the identical space on the
   badge-less cards in the same group so all cards line up. Scoped via :has() to
   groups that actually contain a popular card (single-size groups have none).
   The badge has a fixed font-size/padding, so its height is constant:
   line 0.6875rem × 1.25 + 8px vertical padding. The aside's flex `gap` spaces
   this placeholder from the price exactly as it does the real badge. */
.variations_form.lubiwood-swatch-prices-active .wd-swatches-product:has(.lubiwood-swatch--popular) .lubiwood-swatch-aside:not(:has(.lubiwood-swatch-badge))::before {
	content: "";
	display: block;
	flex: 0 0 auto;
	height: calc(0.6875rem * 1.25 + 8px);
}

.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-price {
	flex: 0 0 auto;
	min-width: 0;
	margin: 0 !important;
	padding: 0 !important;
	text-align: right;
	line-height: 1.2;
}

.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-price .price {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	justify-content: center;
	gap: 2px;
	margin: 0 !important;
	font-size: clamp(1.125rem, 3.8vw, 1.3125rem) !important;
	line-height: 1.2 !important;
	color: var(--lw-swatch-text) !important;
}

.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-price .price del {
	order: 1;
	font-size: clamp(0.9375rem, 2.8vw, 1.0625rem) !important;
	font-weight: 500 !important;
	color: var(--lw-swatch-muted) !important;
	opacity: 1 !important;
}

.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-price .price del .amount {
	color: inherit !important;
}

.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-price .price ins {
	order: 2;
	font-size: clamp(1.3125rem, 4.5vw, 1.5625rem) !important;
	font-weight: 800 !important;
	text-decoration: none !important;
	color: var(--lw-swatch-accent) !important;
	background: none !important;
	letter-spacing: -0.02em;
}

/* Simple price (no sale): single amount is prominent */
.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-price .price > .amount,
.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-price .price > bdi {
	font-size: clamp(1.3125rem, 4.5vw, 1.5625rem) !important;
	font-weight: 800 !important;
	color: var(--lw-swatch-accent) !important;
}

.variations_form.lubiwood-swatch-prices-active .wd-swatch.wd-text.wd-active .lubiwood-swatch-price .price ins {
	color: #3d5c43 !important;
}

/* Piece count — prominent line inside the label column */
.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-pieces {
	display: block;
	margin-top: 5px;
	font-size: clamp(1rem, 3.2vw, 1.125rem);
	font-weight: 700;
	color: var(--lw-swatch-accent);
	letter-spacing: 0;
	line-height: 1.3;
}

.variations_form.lubiwood-swatch-prices-active .wd-swatch.wd-text.wd-active .lubiwood-swatch-pieces {
	color: #1f4428;
}

/* ── Pieces-count headline layout ───────────────────────────────────────────
   When a swatch's variation has a defined puzzle pieces count, the JS adds
   `lubiwood-swatch--has-pieces`. The count becomes the headline; the size name
   (.wd-swatch-text) drops to a small muted eyebrow above it. Dimensions stay in
   the meta row. Placed after the base rules so source order wins (equal
   specificity for .wd-swatch-text). Swatches without the class are unaffected. */
.variations_form.lubiwood-swatch-prices-active .wd-swatch.lubiwood-swatch--has-pieces .wd-swatch-text {
	font-size: clamp(0.8125rem, 2.4vw, 0.9375rem) !important;
	font-weight: 600 !important;
	color: var(--lw-swatch-muted) !important;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	line-height: 1.25 !important;
}

/* Nested size name/code inherit the eyebrow sizing instead of their own larger sizes. */
.variations_form.lubiwood-swatch-prices-active .wd-swatch.lubiwood-swatch--has-pieces .lubiwood-size-name,
.variations_form.lubiwood-swatch-prices-active .wd-swatch.lubiwood-swatch--has-pieces .lubiwood-size-code {
	font-size: inherit;
	font-weight: inherit;
	color: inherit;
	text-transform: inherit;
	letter-spacing: inherit;
}

/* In the pieces-headline layout the eyebrow shows only the role name (e.g. "Small");
   the parenthetical size code (e.g. "(A5)") is redundant with the dimensions row. */
.variations_form.lubiwood-swatch-prices-active .wd-swatch.lubiwood-swatch--has-pieces .lubiwood-size-code {
	display: none;
}

/* The count is now the headline: large + bold, tight under the eyebrow. */
.variations_form.lubiwood-swatch-prices-active .wd-swatch.lubiwood-swatch--has-pieces .lubiwood-swatch-pieces {
	margin-top: 2px;
	font-size: clamp(1.3125rem, 4.5vw, 1.625rem);
	font-weight: 800;
	line-height: 1.2;
	letter-spacing: -0.01em;
}

/* Out of stock: dim the pieces headline like the other text. */
.variations_form.lubiwood-swatch-prices-active .wd-swatch.lubiwood-swatch--oos .lubiwood-swatch-pieces {
	opacity: 0.55;
}

/* Single-size products: nothing to choose, so the size-name eyebrow is hidden
   entirely (no "Single size" label). The piece count (if any), dimensions, and
   price still render. */
.variations_form.lubiwood-swatch-prices-active .wd-swatch.lubiwood-swatch--single .wd-swatch-text {
	display: none;
}

/* Meta row: dimensions, time (inside card) */
.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-meta {
	grid-column: 1 / -1;
	grid-row: 2;
	min-width: 0;
	font-size: clamp(0.875rem, 2.6vw, 0.9375rem);
	line-height: 1.45;
	color: var(--lw-swatch-muted);
	border-top: 1px solid rgba(31, 36, 33, 0.08);
	padding-top: 8px;
	margin-top: 2px;
}

.variations_form.lubiwood-swatch-prices-active .wd-swatch.wd-text.wd-active .lubiwood-swatch-meta {
	border-top-color: rgba(95, 127, 102, 0.2);
	color: #4a5550;
}

.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-meta p {
	margin: 0 !important;
	padding: 0 !important;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5em 1em;
}

.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-meta p:empty {
	display: none;
}

/* Out of stock */
.variations_form.lubiwood-swatch-prices-active .wd-swatch.lubiwood-swatch--oos {
	opacity: 1 !important;
}

.variations_form.lubiwood-swatch-prices-active .wd-swatch.lubiwood-swatch--oos .wd-swatch-text,
.variations_form.lubiwood-swatch-prices-active .wd-swatch.lubiwood-swatch--oos .lubiwood-swatch-price .price,
.variations_form.lubiwood-swatch-prices-active .wd-swatch.lubiwood-swatch--oos .lubiwood-swatch-meta {
	opacity: 0.55;
}

/* Hide duplicate blocks below (shown on each card) */
.variations_form.lubiwood-swatch-prices-active .single_variation_wrap .woocommerce-variation-price,
.variations_form.lubiwood-swatch-prices-active .single_variation_wrap .woocommerce-variation-description {
	display: none !important;
}

/* —— Single size: one option, auto-selected — present it, don't ask to "choose" —— */
.variations_form.lubiwood-swatch-prices-active.lubiwood-single-size .wd-swatches-single > .wd-swatch.wd-text {
	cursor: default;
}

.variations_form.lubiwood-swatch-prices-active.lubiwood-single-size .wd-swatches-single > .wd-swatch.wd-text:hover {
	border-color: var(--lw-swatch-brd-active) !important;
	background: var(--lw-swatch-bg-active) !important;
}

/* —— Tablet —— */
@media (max-width: 1024px) {
	.variations_form.lubiwood-swatch-prices-active {
		--lw-swatch-gap: 8px;
		--lw-swatch-radius: 13px;
	}
}

/* —— Mobile —— */
@media (max-width: 767px) {
	.variations_form.lubiwood-swatch-prices-active {
		--lw-swatch-radius: 12px;
	}

	.variations_form.lubiwood-swatch-prices-active .wd-swatches-single > .wd-swatch.wd-text {
		padding: 12px 14px !important;
		column-gap: 10px;
		row-gap: 6px;
	}

	.variations_form.lubiwood-swatch-prices-active table.variations tr {
		display: block;
	}

	.variations_form.lubiwood-swatch-prices-active table.variations .value {
		display: block;
		width: 100%;
		padding-inline: 0;
	}
}

/* —— Narrow phones: keep size left, price top-right —— */
@media (max-width: 479px) {
	.variations_form.lubiwood-swatch-prices-active .wd-swatches-single > .wd-swatch.wd-text {
		grid-template-columns: minmax(0, 1fr);
		padding: 14px 14px !important;
	}

	.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-head {
		grid-column: 1;
		gap: 8px 10px;
	}

	.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-aside {
		max-width: 55%;
	}

	.variations_form.lubiwood-swatch-prices-active .lubiwood-swatch-meta {
		grid-column: 1;
	}

	.variations_form.lubiwood-swatch-prices-active .lubiwood-chooser-banner {
		padding: 18px 16px 20px;
	}
}

@media (max-width: 359px) {
	.variations_form.lubiwood-swatch-prices-active .wd-swatches-single > .wd-swatch.wd-text {
		padding: 10px 12px !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.variations_form.lubiwood-swatch-prices-active .wd-swatches-single > .wd-swatch.wd-text {
		transition: none;
	}
}
