/* The data/template wrapper is rendered after the variations table by WooCommerce.
   JS moves its Colour 2 control into the native table directly below Blend. */
.muse-hair-options {
	display: none !important;
}

/* Let the new row behave exactly like a native WooCommerce/WoodMart variation row. */
tr.muse-hair-colour-two-row[hidden] {
	display: none !important;
}

tr.muse-hair-colour-three-row[hidden] {
	display: none !important;
}

tr.muse-hair-colour-two-row.is-visible {
	display: table-row;
}

tr.muse-hair-colour-three-row.is-visible {
	display: table-row;
}

.muse-hair-colour-two-control {
	min-width: 0;
}

.muse-selected-shade { color: #777; margin: 0 0 10px; min-height: 1.3em; }
.muse-selected-shade:empty { display: none; }
.muse-shade-tooltip { position: fixed; z-index: 999999; pointer-events: none; padding: 7px 11px; background: #191919; color: #fff; border-radius: 2px; font-size: 13px; line-height: 1.3; max-width: 220px; }

/* We copy the ORIGINAL WoodMart Colour swatch container classes and individual
   swatch markup in JS. Do not resize the cloned .wd-swatch elements here: WoodMart
   itself controls their size, shape, image treatment, gap and active style. */
.muse-hair-colour-two-swatches {
	margin: 0;
}

.muse-hair-colour-two-swatches .muse-colour2-swatch {
	cursor: pointer;
}

/* Fallback only: used if WoodMart markup changes and no original swatches can be cloned. */
.muse-colour2-fallback {
	display: inline-flex;
	width: 58px;
	height: 58px;
	margin: 0 8px 8px 0;
	padding: 3px;
	border: 1px solid rgba(0,0,0,.15);
	border-radius: 50%;
	background-color: #fff;
	background-position: center;
	background-repeat: no-repeat;
	background-size: cover;
	box-shadow: none;
	cursor: pointer;
	vertical-align: middle;
}

.muse-colour2-fallback.active,
.muse-colour2-fallback:focus-visible {
	outline: 1px solid currentColor;
	outline-offset: 3px;
}

.muse-hair-no-pairs {
	margin-top: 8px;
	padding: 10px 12px;
	background: rgba(0,0,0,.04);
	border-radius: 4px;
}

/* On a catalogue variation landing page the original Colour selector remains in
   the DOM for WooCommerce logic but is replaced visually by a fixed Colour row. */
.muse-hair-colour-locked .muse-hair-original-colour-row,
.muse-hair-colour-locked .muse-hair-reset-hidden {
	display: none !important;
}

.muse-blend-unavailable {
	opacity: .28 !important;
	pointer-events: none !important;
	filter: grayscale(1);
}

/* Retain the Rooted row when a non-Weft blend is selected, but make the
   rooted choices clearly unavailable. The help question mark remains usable. */
.muse-rooted-choice-unavailable {
	opacity: .28 !important;
	pointer-events: none !important;
	filter: grayscale(1);
}

.muse-hair-hidden {
	display: none !important;
}

form.variations_form table.variations tr.muse-hair-hidden {
	display: none !important;
}

.muse-hair-reset-row .muse-hair-reset-button {
	margin-top: 8px;
}

/* Compact selector help. The full explanation opens only when the question mark is selected. */
.muse-attribute-help-wrap {
	position: relative;
	display: inline-block;
	margin-left: 8px;
	vertical-align: middle;
}

.muse-info-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	padding: 0;
	border: 1px solid currentColor;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	font-size: 13px;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
}

.muse-info-toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.muse-info-tooltip {
	position: absolute;
	z-index: 20;
	top: calc(100% + 8px);
	left: 0;
	width: min(320px, 75vw);
	max-width: calc(100vw - 32px);
	box-sizing: border-box;
	padding: 10px 12px;
	border-radius: 4px;
	background: #250101;
	color: #fff;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.45;
	white-space: normal;
	overflow-wrap: anywhere;
	box-shadow: 0 8px 20px rgba(0,0,0,.18);
}

.muse-length-notice {
	margin: 8px 0 0;
	color: #250101;
	font-size: .9em;
	font-weight: 600;
	line-height: 1.45;
}

/* [muse_colour_carousel] — separate from the product selector. */
.muse-colour-carousel {
	position: relative;
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	gap: 10px;
}

.muse-colour-carousel-track {
	display: flex;
	gap: 12px;
	overflow-x: auto;
	padding: 4px 0;
	/* A free horizontal shade strip: drag/scroll naturally, without snapping
	   slides or exposing a browser scrollbar. */
	scroll-behavior: auto;
	scroll-snap-type: none;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	cursor: grab;
	touch-action: pan-x pan-y;
}

.muse-colour-carousel-track::-webkit-scrollbar { display: none; }
.muse-colour-carousel-track.is-dragging { cursor: grabbing; user-select: none; }

.muse-colour-carousel-item {
	flex: 0 0 132px;
	min-width: 132px;
	text-align: center;
}

.muse-colour-carousel-link {
	display: block;
	color: inherit;
	text-decoration: none;
}

.muse-colour-carousel-link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 4px;
	border-radius: 4px;
}

.muse-colour-carousel-swatch {
	display: block;
	aspect-ratio: 1;
	border: 1px solid rgba(0,0,0,.12);
	border-radius: 50%;
	background: #f6f4f2 center / cover no-repeat;
	overflow: hidden;
}

.muse-colour-carousel-swatch img { display: block; width: 100%; height: 100%; object-fit: cover; }
.muse-colour-carousel-name { display: block; margin-top: 6px; color: inherit; font-size: 12px; line-height: 1.25; }

.muse-colour-carousel-prev,
.muse-colour-carousel-next {
	width: 34px;
	height: 34px;
	padding: 0;
	border: 1px solid currentColor;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
}

/* Desktop: fill the visible track with ten complete shades. This avoids a
   clipped, half-visible shade at either end of the carousel. */
@media (min-width: 1025px) {
	.muse-colour-carousel-track { gap: 12px; }
	.muse-colour-carousel-item {
		flex: 0 0 calc((100% - 108px) / 10);
		min-width: 0;
	}
}

@media (max-width: 1024px), (pointer: coarse) {
	/* Product selectors: label first, full-width swatches underneath. */
	form.variations_form table.variations {
		border-spacing: 0 !important;
		border-collapse: collapse !important;
		table-layout: auto !important;
	}

	form.variations_form table.variations,
	form.variations_form table.variations tbody,
	form.variations_form table.variations tr,
	form.variations_form table.variations th.label,
	form.variations_form table.variations td.value {
		display: block !important;
		width: 100% !important;
		box-sizing: border-box;
	}

	form.variations_form table.variations th.label {
		padding: 0 0 8px !important;
		text-align: left !important;
	}

	/* The general mobile table rule above must not reveal inactive Colour 2/3
	   rows. They only appear after the customer has chosen a valid blend. */
	form.variations_form table.variations tr.muse-hair-colour-two-row[hidden],
	form.variations_form table.variations tr.muse-hair-colour-three-row[hidden] {
		display: none !important;
	}

	form.variations_form table.variations td.value {
		padding: 0 0 18px !important;
		text-align: left !important;
	}

	form.variations_form table.variations .wd-swatches-product,
	form.variations_form table.variations .wd-swatches-single,
	form.variations_form table.variations .muse-hair-colour-two-swatches,
	form.variations_form table.variations .muse-hair-colour-three-swatches {
		display: flex !important;
		width: 100% !important;
		flex-direction: row !important;
		flex-wrap: wrap !important;
		align-items: flex-start;
	}

	/* Keep five swatches across on phone widths. WoodMart gives the original
	   circles a desktop fixed size, which otherwise makes the fifth wrap at
	   roughly 440px. These rules intentionally cover Colour 1, 2 and 3 alike. */
	form.variations_form table.variations .wd-swatches-product,
	form.variations_form table.variations .wd-swatches-single,
	form.variations_form table.variations .muse-hair-colour-two-swatches,
	form.variations_form table.variations .muse-hair-colour-three-swatches {
		gap: 8px !important;
	}

	form.variations_form table.variations .wd-swatches-product > .wd-swatch,
	form.variations_form table.variations .wd-swatches-single > .wd-swatch,
	form.variations_form table.variations .muse-hair-colour-two-swatches > .wd-swatch,
	form.variations_form table.variations .muse-hair-colour-three-swatches > .wd-swatch {
		flex: 0 0 calc((100% - 32px) / 5) !important;
		width: calc((100% - 32px) / 5) !important;
		height: auto !important;
		margin: 0 !important;
	}

	form.variations_form table.variations .wd-swatches-product > .wd-swatch > *,
	form.variations_form table.variations .wd-swatches-single > .wd-swatch > *,
	form.variations_form table.variations .muse-hair-colour-two-swatches > .wd-swatch > *,
	form.variations_form table.variations .muse-hair-colour-three-swatches > .wd-swatch > * {
		width: 100% !important;
		height: auto !important;
		aspect-ratio: 1;
	}

	form.variations_form .muse-hair-reset-row .label {
		display: none !important;
	}

	/* The shortcode is drag-scrollable on mobile. Hide arrows here so the
	   swatches have the whole screen width and four can be seen at once. */
	.muse-colour-carousel {
		display: block;
		width: 100%;
		max-width: 100%;
		overflow: hidden;
	}
	.muse-colour-carousel-prev,
	.muse-colour-carousel-next { display: none !important; }
	.muse-colour-carousel-track { width: 100%; gap: 10px; padding: 4px 0; }
	.muse-colour-carousel-item { flex: 0 0 calc((100% - 30px) / 3.5); min-width: 0; }
	.muse-colour-carousel-name { font-size: 11px; }

	/* On phones the help popup is a viewport-contained panel, rather than a
	   small tooltip that can run off the edge or below the visible area. */
	.muse-info-tooltip {
		position: fixed;
		z-index: 999999;
		top: 50%;
		left: 16px;
		width: auto;
		right: 16px;
		max-width: none;
		max-height: calc(100dvh - 32px);
		overflow-y: auto;
		transform: translateY(-50%);
	}
}
