/* Fabria Variation Swatches – front end.
 * Selectors are prefixed with .fvs-swatches and the button element so theme
 * button styles (Blocksy) do not leak in. Values from settings arrive as
 * custom properties printed inline after this file.
 */

.fvs-swatches {
	--fvs-radius: 4px;
	--fvs-height: 42px;
	--fvs-size: 32px;
	--fvs-accent: #a92d2d;
	--fvs-ink: #1b2b3a;
	--fvs-text: #252525;
	--fvs-border: #d8d8d8;
	--fvs-muted: #9a9a9a;
	/* Width of each colour slot when names are shown: swatch + room for the name. */
	--fvs-col: calc(var(--fvs-size) + 44px);
	width: 100%;
	margin: 0;
}

/* Tighter spacing in the variations table (only when swatches are active).
 * Blocksy default: 10px under each heading, 1.5em between attributes. */
form.variations_form.fvs-ready table.variations {
	margin-bottom: 16px;
}

form.variations_form.fvs-ready table.variations tr {
	gap: 8px;
}

form.variations_form.fvs-ready table.variations tr:not(:last-child) {
	margin-bottom: 16px;
}

/* Heading row: label left, Clear right. */
.variations_form .fvs-heading {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
}

.variations_form .fvs-heading label {
	margin-bottom: 0;
}

.fvs-swatches[hidden],
select.fvs-select-hidden {
	display: none !important;
}

.fvs-swatches .fvs-list {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0;
	padding: 0;
}

/* Reset theme button styling. */
.fvs-swatches button.fvs-swatch {
	-webkit-appearance: none;
	appearance: none;
	margin: 0;
	padding: 0;
	width: auto;
	height: auto;
	min-height: 0;
	border: 0;
	border-radius: var(--fvs-radius);
	background: transparent;
	box-shadow: none;
	color: var(--fvs-ink);
	font: inherit;
	line-height: 1.2;
	letter-spacing: normal;
	text-transform: none;
	text-decoration: none;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.fvs-swatches button.fvs-swatch:focus {
	outline: none;
}

.fvs-swatches button.fvs-swatch:focus-visible {
	outline: 2px solid var(--fvs-accent);
	outline-offset: 2px;
}

/* Size buttons (and colours without a hex mapping). */
.fvs-swatches button.fvs-swatch--text {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: var(--fvs-height);
	min-height: var(--fvs-height);
	padding: 0 14px;
	border: 1px solid var(--fvs-border);
	background: #fff;
	font-size: 14px;
	font-weight: 500;
	transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.fvs-swatches button.fvs-swatch--text:hover {
	border-color: var(--fvs-ink);
	background: #fff;
	color: var(--fvs-ink);
}

.fvs-swatches button.fvs-swatch--text.is-selected,
.fvs-swatches button.fvs-swatch--text.is-selected:hover {
	border-color: var(--fvs-accent);
	background: var(--fvs-accent);
	color: #fff;
}

.fvs-swatches button.fvs-swatch--text.is-disabled,
.fvs-swatches button.fvs-swatch--text.is-disabled:hover {
	border-color: #e5e5e5;
	background: #f7f7f7;
	color: var(--fvs-muted);
	text-decoration: line-through;
	cursor: not-allowed;
}

/* Colour swatches. */
.fvs-swatches button.fvs-swatch--color {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	min-width: 44px;
	min-height: 44px;
	padding: 4px 2px;
}

/* Equal-width colour slots so spacing is even whatever the name length. */
.fvs-swatches--color.fvs-has-labels .fvs-list {
	align-items: flex-start;
	column-gap: 4px;
	row-gap: 12px;
}

.fvs-swatches.fvs-has-labels button.fvs-swatch--color {
	justify-content: flex-start;
	width: var(--fvs-col);
	flex: 0 0 var(--fvs-col);
}

.fvs-swatches .fvs-swatch__dot {
	position: relative;
	display: block;
	width: var(--fvs-size);
	height: var(--fvs-size);
	border-radius: 50%;
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
	transition: box-shadow 0.15s;
}

.fvs-swatches .fvs-swatch--light .fvs-swatch__dot {
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
}

.fvs-swatches button.fvs-swatch--color:hover .fvs-swatch__dot {
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3), 0 0 0 2px #fff, 0 0 0 3px var(--fvs-border);
}

.fvs-swatches button.fvs-swatch--color.is-selected .fvs-swatch__dot {
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3), 0 0 0 2px #fff, 0 0 0 4px var(--fvs-accent);
}

.fvs-swatches .fvs-swatch__name {
	max-width: 100%;
	color: var(--fvs-text);
	font-size: 12px;
	line-height: 1.25;
	text-align: center;
	overflow-wrap: break-word;
}

.fvs-swatches .fvs-swatch--color.is-selected .fvs-swatch__name {
	color: var(--fvs-ink);
	font-weight: 600;
}

.fvs-swatches button.fvs-swatch--color.is-disabled {
	cursor: not-allowed;
}

.fvs-swatches button.fvs-swatch--color.is-disabled .fvs-swatch__dot,
.fvs-swatches button.fvs-swatch--color.is-disabled:hover .fvs-swatch__dot {
	opacity: 0.35;
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
}

/* Diagonal line through unavailable colours. */
.fvs-swatches .fvs-swatch--color.is-disabled .fvs-swatch__dot::after {
	content: "";
	position: absolute;
	top: -3px;
	bottom: -3px;
	left: 50%;
	width: 1px;
	background: var(--fvs-ink);
	transform: rotate(45deg);
}

.fvs-swatches .fvs-swatch--color.is-disabled .fvs-swatch__name {
	color: var(--fvs-muted);
}

.fvs-swatches .fvs-sr-only {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Clear link moved beside the last heading. */
.variations_form .fvs-reset-inline {
	display: inline-block;
	flex: 0 0 auto;
	margin-left: auto;
	color: inherit;
	font-size: 0.85em;
	font-weight: 400;
	text-decoration: underline;
	text-underline-offset: 3px;
	opacity: 0.75;
}

/* Selected colour name beside the heading (phones only). */
.variations_form .fvs-current {
	display: none;
	font-weight: 400;
}

/* Touch devices: comfortable targets. */
@media (max-width: 689px) {
	.fvs-swatches .fvs-list {
		gap: 6px;
	}

	.fvs-swatches button.fvs-swatch--text {
		min-width: max(44px, var(--fvs-height));
		min-height: max(44px, var(--fvs-height));
		padding: 0 10px;
	}
}

/* Phones: all colours in one compact row. */
@media (max-width: 689px) {
	.variations_form .fvs-current {
		display: inline;
	}

	.fvs-swatches--color.fvs-compact {
		--fvs-size: 30px;
	}

	.fvs-swatches--color.fvs-compact .fvs-list {
		column-gap: 2px;
		row-gap: 8px;
	}

	.fvs-swatches.fvs-compact button.fvs-swatch--color {
		width: 42px;
		min-width: 0;
		flex: 0 0 42px;
		min-height: 44px;
		padding: 7px 0;
		justify-content: center;
	}

	.fvs-swatches.fvs-compact .fvs-swatch__name {
		position: absolute !important;
		width: 1px;
		height: 1px;
		margin: -1px;
		padding: 0;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
		white-space: nowrap;
		border: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.fvs-swatches button.fvs-swatch--text,
	.fvs-swatches .fvs-swatch__dot {
		transition: none;
	}
}
