/**
 * Perfamix product variation choices.
 *
 * Scope: main single-product variation form only.
 * - Existing Goldsmith button swatches keep Goldsmith/WooCommerce ownership.
 * - Select-only variation attributes are progressively enhanced into visible
 *   Perfamix choice buttons while the original select remains the data source.
 * Color/image swatches, loops, quick view, and sticky cart are untouched.
 */

.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations {
	--perfamix-choice-primary: #264e36;
	--perfamix-choice-secondary: #78947c;
	--perfamix-choice-gold-rgb: 200, 160, 90;
	--perfamix-choice-sand-rgb: 225, 210, 181;
}

.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations .goldsmith-terms.goldsmith-type-button,
.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .perfamix-select-choices {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

/*
 * Enhanced select-only rows use a two-column layout on non-mobile screens:
 * the attribute label owns a stable first column, while only the value column
 * is allowed to shrink. This prevents Goldsmith's flex row from wrapping the
 * entire value block below the label when a product has many choices. The
 * choices themselves remain a wrapping flex row, so only the overflowing
 * choices continue on the next line inside the value column.
 */
.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced,
.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced .variations-item,
.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced .value {
	box-sizing: border-box;
	min-inline-size: 0;
}

.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced .variations-item {
	display: grid !important;
	grid-template-columns: minmax(96px, 112px) minmax(0, 1fr);
	column-gap: 18px;
	row-gap: 8px;
	align-items: start !important;
	inline-size: 100%;
	max-inline-size: 100%;
}

.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced .goldsmith-small-title {
	box-sizing: border-box;
	inline-size: 100% !important;
	max-inline-size: 100%;
	min-inline-size: 0;
	padding-block-start: 12px;
}

.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced .value {
	display: block !important;
	inline-size: 100% !important;
	max-inline-size: 100% !important;
}

.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced .perfamix-select-choices {
	inline-size: 100%;
	max-inline-size: 100%;
	min-inline-size: 0;
}

.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced .perfamix-variation-choice {
	flex: 0 1 auto;
}

/*
 * Hide a native select only after JavaScript has successfully created its
 * replacement control. This keeps a no-JS/error fallback fully usable.
 */
.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced .value {
	position: relative;
	min-inline-size: 0;
}

.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced .perfamix-native-variation-select {
	position: absolute !important;
	inline-size: 1px !important;
	block-size: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	border: 0 !important;
	overflow: hidden !important;
	clip: rect(0 0 0 0) !important;
	clip-path: inset(50%) !important;
	white-space: nowrap !important;
	opacity: 0 !important;
	pointer-events: none !important;
}

.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .perfamix-select-choices {
	inline-size: 100%;
	min-inline-size: 0;
}

.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations .goldsmith-terms.goldsmith-type-button > .goldsmith-term,
.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .perfamix-select-choices > .perfamix-variation-choice {
	box-sizing: border-box;
	min-inline-size: 64px;
	min-block-size: 42px;
	padding: 10px 14px !important;
	border: 1px solid var(--perfamix-choice-secondary) !important;
	border-radius: 6px;
	background: #fff !important;
	box-shadow: 0 1px 2px rgba(38, 78, 54, 0.06);
	color: var(--perfamix-choice-primary) !important;
	cursor: pointer;
	font-family: inherit;
	font-size: 13px !important;
	font-weight: 600;
	letter-spacing: 0.02em;
	line-height: 1.2 !important;
	text-align: center;
	text-decoration: none;
	touch-action: manipulation;
	transition:
		background-color 160ms ease,
		border-color 160ms ease,
		box-shadow 160ms ease,
		color 160ms ease,
		transform 160ms ease;
	user-select: none;
	white-space: normal;
}

/* Long fragrance names can wrap naturally instead of forcing horizontal scroll. */
.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .perfamix-select-choices > .perfamix-variation-choice {
	max-inline-size: 100%;
}

/* Goldsmith nests an extra span only when its outline option is enabled. */
.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations .goldsmith-terms.goldsmith-type-button > .goldsmith-term > .type-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-inline-size: 100%;
	min-block-size: 100%;
	padding: 0 !important;
	background: transparent !important;
	color: inherit !important;
	font: inherit;
	letter-spacing: inherit;
	line-height: inherit;
}

.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations .goldsmith-terms.goldsmith-type-button > .goldsmith-term.goldsmith-selected,
.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .perfamix-select-choices > .perfamix-variation-choice.is-selected {
	border-color: var(--perfamix-choice-primary) !important;
	background: var(--perfamix-choice-primary) !important;
	box-shadow:
		0 0 0 2px rgba(var(--perfamix-choice-gold-rgb), 0.22),
		0 4px 12px rgba(38, 78, 54, 0.15);
	color: #fff !important;
}

/* The filled state is the indicator; suppress Goldsmith's floating tick. */
.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations .goldsmith-terms.goldsmith-type-button > .goldsmith-term.goldsmith-selected::before {
	content: none !important;
	display: none !important;
}

.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations .goldsmith-terms.goldsmith-type-button > .goldsmith-term.goldsmith-disabled,
.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .perfamix-select-choices > .perfamix-variation-choice.is-disabled,
.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .perfamix-select-choices > .perfamix-variation-choice:disabled {
	border-color: rgba(38, 78, 54, 0.22) !important;
	border-style: dashed !important;
	background: #f4f4f1 !important;
	box-shadow: none;
	color: #6d746f !important;
	cursor: not-allowed;
	opacity: 0.54 !important;
	text-decoration: line-through;
	transform: none;
}

.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations .goldsmith-terms.goldsmith-type-button > .goldsmith-term[role="radio"]:focus-visible,
.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .perfamix-select-choices > .perfamix-variation-choice:focus-visible {
	outline: 2px solid var(--perfamix-choice-primary);
	outline-offset: 3px;
	box-shadow: 0 0 0 5px rgba(var(--perfamix-choice-gold-rgb), 0.22);
}

@media (hover: hover) and (pointer: fine) {
	.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations .goldsmith-terms.goldsmith-type-button > .goldsmith-term:not(.goldsmith-selected):not(.goldsmith-disabled):hover,
	.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .perfamix-select-choices > .perfamix-variation-choice:not(.is-selected):not(.is-disabled):not(:disabled):hover {
		border-color: var(--perfamix-choice-primary) !important;
		background: rgba(var(--perfamix-choice-sand-rgb), 0.24) !important;
		box-shadow: 0 4px 10px rgba(38, 78, 54, 0.10);
		transform: translateY(-1px);
	}
}

@media (max-width: 767px) {
	/*
	 * Select-enhanced rows become self-contained mobile blocks. Goldsmith uses
	 * flex wrappers around the label/value pair; leaving those wrappers in
	 * their desktop sizing mode lets a long set of fragrance choices establish
	 * an intrinsic width wider than the viewport. That is what caused the
	 * product/footer layout to appear squeezed on phones.
	 *
	 * Scope this reset only to rows enhanced by Perfamix. Native Goldsmith
	 * size/color/image swatches keep their own responsive behavior unchanged.
	 */
	.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced,
	.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced .variations-item,
	.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced .value {
		box-sizing: border-box;
		inline-size: 100% !important;
		max-inline-size: 100% !important;
		min-inline-size: 0 !important;
	}

	.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced .variations-item {
		display: block !important;
	}

	.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced .goldsmith-small-title {
		display: block;
		inline-size: auto !important;
		max-inline-size: 100%;
		margin-block-end: 8px;
		padding-block-start: 0;
	}

	.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations-items.perfamix-select-choice-enhanced .value {
		display: block !important;
	}

	/*
	 * Mobile-first fluid grid: typically 3 columns on narrower phones and 4
	 * when the actual content width can support them. minmax() keeps every
	 * track inside the parent; no choice can increase document scroll width.
	 */
	.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .perfamix-select-choices {
		display: grid !important;
		grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
		align-items: stretch;
		gap: 8px;
		inline-size: 100% !important;
		max-inline-size: 100% !important;
		min-inline-size: 0 !important;
	}

	.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .perfamix-select-choices > .perfamix-variation-choice {
		inline-size: 100%;
		max-inline-size: 100%;
		min-inline-size: 0 !important;
		min-block-size: 44px;
		padding: 10px 8px !important;
		font-size: 12px !important;
		overflow-wrap: anywhere;
		word-break: normal;
	}

	/* Preserve the existing Goldsmith-native swatch sizing from 1.7.8. */
	.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations .goldsmith-terms.goldsmith-type-button {
		gap: 10px;
	}

	.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations .goldsmith-terms.goldsmith-type-button > .goldsmith-term {
		min-inline-size: 70px;
		min-block-size: 44px;
		padding: 11px 15px !important;
		font-size: 13px !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .goldsmith-variations .goldsmith-terms.goldsmith-type-button > .goldsmith-term,
	.single-product .goldsmith-product-summary:not(.goldsmith-product-bottom-popup-cart) .variations_form .perfamix-select-choices > .perfamix-variation-choice {
		transition: none;
	}
}
