/**
 * Fiche produit : badges de déclinaison (taille, pointure, motif…) et ligne d'achat.
 * Fichier autonome (hors build Tailwind) : jetons de la charte recopiés ci-dessous.
 * Rendu : inc/woocommerce/variation-swatches.php ; comportement : assets/js/variation-swatches.js.
 */
:root {
	--ks-v-orange: #ff8000;
	--ks-v-orange-dark: #e56f00;
	--ks-v-ink: #2a2230;
	--ks-v-ink-soft: #5d5463;
	--ks-v-muted: #8c8391;
	--ks-v-line: #eee4d8;
	--ks-v-cream: #fff8f0;
	--ks-v-peach: #fff0e0;
	--ks-v-disabled: #efedf0;
	--ks-v-disabled-line: #e2dee4;
}

/* Liste native : conservée pour WooCommerce, plus affichée. */
.ks-product table.variations select[data-ks-swatched] {
	position: absolute !important;
	width: 1px !important;
	min-width: 0 !important;
	height: 1px !important;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
}

.ks-product table.variations td.value {
	position: relative;
}

/* Nom de l'attribut + valeur choisie : « Taille · 6/7 ans » */
.ks-product table.variations th.label label {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 6px;
	margin-bottom: 10px;
	font-size: 14px;
	font-weight: 700;
	color: var(--ks-v-ink);
}

.ks-swatches__current:not(:empty) {
	font-weight: 600;
	color: var(--ks-v-ink-soft);
}

.ks-swatches__current:not(:empty)::before {
	content: "·";
	margin-right: 6px;
	color: var(--ks-v-muted);
}

/* Groupe de badges */
.ks-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.ks-swatch {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-width: 56px;
	min-height: 44px;
	margin: 0;
	padding: 8px 16px;
	overflow: hidden;
	border: 1.5px solid var(--ks-v-line);
	border-radius: 999px;
	background: #fff;
	color: var(--ks-v-ink);
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
	transition:
		border-color 0.15s ease,
		background-color 0.15s ease,
		color 0.15s ease,
		box-shadow 0.15s ease,
		transform 0.1s ease;
	-webkit-tap-highlight-color: transparent;
}

.ks-swatch__check {
	display: none;
	flex-shrink: 0;
}

@media (hover: hover) {
	.ks-swatch:not(:disabled):not(.is-selected):not(.is-out-of-stock):hover {
		border-color: var(--ks-v-orange);
		color: var(--ks-v-orange-dark);
	}
}

.ks-swatch:not(:disabled):active {
	transform: scale(0.97);
}

.ks-swatch:focus-visible {
	outline: 2px solid var(--ks-v-orange);
	outline-offset: 2px;
}

/* État « choisi » */
.ks-swatch.is-selected {
	border-color: var(--ks-v-orange);
	background: var(--ks-v-peach);
	color: var(--ks-v-orange-dark);
	box-shadow: inset 0 0 0 1px var(--ks-v-orange);
}

.ks-swatch.is-selected .ks-swatch__check {
	display: block;
}

/* En rupture pour ce choix : aspect désactivé (fond gris), mais cliquable
   (affiche la rupture et l'alerte de retour en stock). */
.ks-swatch.is-out-of-stock {
	border-color: var(--ks-v-disabled-line);
	background: var(--ks-v-disabled);
	color: var(--ks-v-muted);
}

/* Choisi malgré la rupture : le contour indique la sélection, le fond reste gris. */
.ks-swatch.is-out-of-stock.is-selected {
	border-color: var(--ks-v-muted);
	color: var(--ks-v-ink-soft);
	box-shadow: inset 0 0 0 1px var(--ks-v-muted);
}

/* Combinaison inexistante avec les autres choix */
.ks-swatch:disabled {
	border-style: dashed;
	background: transparent;
	color: var(--ks-v-muted);
	opacity: 0.45;
	cursor: not-allowed;
}

/* Lien « Effacer » de WooCommerce */
.ks-product table.variations .reset_variations {
	display: inline-flex;
	align-items: center;
	margin-top: 10px;
	font-size: 13px;
	font-weight: 600;
	color: var(--ks-v-ink-soft);
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* Masqué par WooCommerce tant que rien n'est choisi : sans réserver de place. */
.ks-product table.variations .reset_variations[style*="hidden"] {
	display: none;
}

.ks-product table.variations .reset_variations:hover {
	color: var(--ks-v-orange-dark);
}

/* Prix et disponibilité de la déclinaison choisie */
.ks-product .woocommerce-variation.single_variation:not(:empty) {
	margin-bottom: 12px;
}

.ks-product .woocommerce-variation-availability .stock {
	margin-bottom: 0;
}

/* Rupture : espace entre la pastille « En rupture de stock » et le bouton d'alerte. */
.ks-product .woocommerce-variation-availability .stock.out-of-stock {
	margin-bottom: 14px;
}

/* Déclinaison en rupture ou indisponible : la ligne quantité + ajout au panier est inutilisable,
   l'alerte de retour en stock prend sa place. */
.ks-product form.cart .woocommerce-variation-add-to-cart:has(.wc-variation-is-unavailable) {
	display: none;
}

/* Bouton d'alerte de l'extension Back In Stock : flottant par défaut, il débordait de son conteneur. */
.ks-product .cwg_popup_submit {
	float: none !important;
	clear: both;
}

/* Ligne d'achat sur téléphone : le bouton ne passe plus sur deux lignes. */
@media (max-width: 480px) {
	.woocommerce div.product.ks-product form.cart .single_add_to_cart_button.button.alt,
	.ks-product .single_add_to_cart_button {
		padding-right: 18px;
		padding-left: 18px;
		white-space: nowrap;
	}
}
