/**
 * Shortcodes de la fiche produit ([ctbt_product_*]) - maquette mockup/produit.html.
 * Voir elementor-globals-map.md pour la correspondance hash <-> couleur/typo.
 * Typographies utilisées :
 * - e951257 : Mako, 2.5rem         (prix principal)
 * - 61d3dcb : Inter 600, 0.875rem  (note moyenne, libellés d'options)
 * - 4bf239c : Inter 400, 0.875rem  (lien avis, articles disponibles, valeur choisie)
 * - 657a611 : Inter 600, 0.75rem   (pastilles)
 * - f8a4213 : Inter 400, 0.75rem   (difficulté)
 * - 6687ff8 : Inter 500, 0.875rem  (chips d'options)
 * - 6fc88fd : Inter 500, 1rem      (bouton "Ajouter au panier")
 * - 51c5324 : Inter 400, 1rem      (prix barré)
 * - d6225fb : Inter 600, 1rem      (champ quantité)
 *
 * Note spécificité CSS : Elementor style globalement button/input via
 * "body.elementor-kit-X button" - tous les boutons/champs ci-dessous sont scopés avec au
 * moins deux classes, sans !important (voir GUIDELINES.md).
 */

/* ── Widgets Shortcode vides (Elementor) ──
   Un shortcode qui ne renvoie rien (pas d'avis, pas de thème, pas de difficulté...) laisse
   quand même son widget dans la page : le gap du conteneur parent crée un espace vide.
   On masque le widget, puis tout conteneur dont les enfants directs sont tous des widgets
   Shortcode vides. Jamais dans l'éditeur Elementor (body.elementor-editor-active), sinon ces
   widgets ne seraient plus sélectionnables. */
body:not(.elementor-editor-active) .elementor-widget-shortcode:has(.elementor-shortcode:empty) {
	display: none;
}

body:not(.elementor-editor-active) .e-con:has(> .elementor-widget-shortcode):not(:has(> .elementor-element:not(.elementor-widget-shortcode:has(.elementor-shortcode:empty)))) {
	display: none;
}

/* ── Pastilles (stock, thèmes, réduction) ── */
.ctbt-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 3px 12px;
	border-radius: 9999px;
	font-family: var(--e-global-typography-657a611-font-family, Inter);
	font-size: var(--e-global-typography-657a611-font-size, 0.75rem);
	font-weight: var(--e-global-typography-657a611-font-weight, 600);
	line-height: 1.2;
	white-space: nowrap;
}

.ctbt-badge--success {
	background-color: var(--e-global-color-bcbeb73, #EAF4EE);
	color: var(--e-global-color-7a8d18d, #4A7C59);
}

.ctbt-badge--warning {
	background-color: var(--e-global-color-4017354, #FEF3DC);
	color: var(--e-global-color-4a67fd4, #C8820A);
}

.ctbt-badge--error {
	background-color: var(--e-global-color-9e93abc, #FDECEA);
	color: var(--e-global-color-dcdcb41, #C0392B);
}

.ctbt-badge--oak {
	background-color: var(--e-global-color-0d245fd, #F9F2EA);
	color: var(--e-global-color-b4f7cc1, #6B3D18);
}

.ctbt-product-stock {
	display: inline-flex;
}

.ctbt-product-themes {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

/* ── Avis ── */
.ctbt-product-rating {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
}

.ctbt-product-rating__stars {
	display: flex;
	gap: 2px;
}

.ctbt-product-rating__star {
	position: relative;
	display: inline-block;
	width: 13px;
	height: 13px;
	line-height: 0;
}

.ctbt-product-rating__star svg {
	width: 13px;
	height: 13px;
}

.ctbt-product-rating__star-empty {
	color: var(--e-global-color-712aa72, #D4C8A8);
}

.ctbt-product-rating__star-fill {
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	overflow: hidden;
	color: var(--e-global-color-48bb2e7, #D4956A);
}

.ctbt-product-rating__average {
	font-family: var(--e-global-typography-61d3dcb-font-family, Inter);
	font-size: var(--e-global-typography-61d3dcb-font-size, 0.875rem);
	font-weight: var(--e-global-typography-61d3dcb-font-weight, 600);
	color: var(--e-global-color-3f56ae9, #2C1810);
}

.ctbt-product-rating .ctbt-product-rating__link,
.ctbt-product-rating .ctbt-product-rating__link:hover,
.ctbt-product-rating .ctbt-product-rating__link:focus {
	font-family: var(--e-global-typography-4bf239c-font-family, Inter);
	font-size: var(--e-global-typography-4bf239c-font-size, 0.875rem);
	font-weight: var(--e-global-typography-4bf239c-font-weight, 400);
	color: var(--e-global-color-4f69e6c, #8B5A2B);
	text-decoration: underline;
}

.ctbt-product-rating .ctbt-product-rating__link:hover {
	color: var(--e-global-color-b4f7cc1, #6B3D18);
}

/* ── Difficulté ── */
.ctbt-product-difficulty {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-family: var(--e-global-typography-f8a4213-font-family, Inter);
	font-size: var(--e-global-typography-f8a4213-font-size, 0.75rem);
	font-weight: var(--e-global-typography-f8a4213-font-weight, 400);
	color: var(--e-global-color-6cd5322, #7A6A5A);
}

.ctbt-product-difficulty__prefix {
	margin-right: 4px;
}

.ctbt-product-difficulty__dots {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.ctbt-product-difficulty__dot {
	flex-shrink: 0;
	width: 9px;
	height: 9px;
	border-radius: 9999px;
	background-color: var(--e-global-color-83c69f4, #E0D4A8);
}

.ctbt-product-difficulty__dot.is-filled {
	background-color: var(--e-global-color-4f69e6c, #8B5A2B);
}

.ctbt-product-difficulty__label {
	margin-left: 8px;
}

/* ── Prix ── */
.ctbt-product-price__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 8px 12px;
}

.ctbt-product-price .ctbt-product-price__main {
	font-family: var(--e-global-typography-e951257-font-family, "Mako");
	font-size: var(--e-global-typography-e951257-font-size, 2.5rem);
	font-weight: var(--e-global-typography-e951257-font-weight, 400);
	line-height: 1;
	color: var(--e-global-color-b4f7cc1, #6B3D18);
	background: none;
	text-decoration: none;
}

.ctbt-product-price .ctbt-product-price__orig {
	font-family: var(--e-global-typography-51c5324-font-family, Inter);
	font-size: var(--e-global-typography-51c5324-font-size, 1rem);
	font-weight: var(--e-global-typography-51c5324-font-weight, 400);
	color: var(--e-global-color-6cd5322, #7A6A5A);
	text-decoration: line-through;
}

/* Produit variable : "À partir de" sur sa propre ligne, au-dessus du prix (le conteneur est
   en flex-wrap, flex-basis: 100% force le passage à la ligne). */
.ctbt-product-price__from {
	flex-basis: 100%;
	line-height: 1.2;
	font-family: var(--e-global-typography-4bf239c-font-family, Inter);
	font-size: var(--e-global-typography-4bf239c-font-size, 0.875rem);
	color: var(--e-global-color-6cd5322, #7A6A5A);
}

/* Aligné sur la ligne de base des prix (bas des chiffres), comme le prix barré. */
.ctbt-product-price__discount {
	align-self: baseline;
}

/* ── Options de variation ── */
.ctbt-product-options__group {
	margin-bottom: 16px;
}

/* Nom de l'attribut puis option choisie juste à côté : "Couleur : Rouge". */
.ctbt-product-options__label {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: flex-start;
	gap: 4px;
	margin-bottom: 12px;
	font-family: var(--e-global-typography-61d3dcb-font-family, Inter);
	font-size: var(--e-global-typography-61d3dcb-font-size, 0.875rem);
	font-weight: var(--e-global-typography-61d3dcb-font-weight, 600);
	color: var(--e-global-color-3f56ae9, #2C1810);
}

.ctbt-product-options__selected {
	font-weight: 400;
	color: var(--e-global-color-6cd5322, #7A6A5A);
}

/* Séparateur affiché uniquement quand une option est choisie (span vide sinon). */
.ctbt-product-options__selected:not(:empty)::before {
	content: ": ";
}

.ctbt-product-options__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.ctbt-product-options__chips .ctbt-product-options__chip,
.ctbt-product-options__chips .ctbt-product-options__chip:hover,
.ctbt-product-options__chips .ctbt-product-options__chip:focus {
	padding: 8px 16px;
	border: 1.5px solid var(--e-global-color-712aa72, #D4C8A8);
	border-radius: 4px;
	background-color: var(--e-global-color-01d5930, #FDFAF2);
	font-family: var(--e-global-typography-6687ff8-font-family, Inter);
	font-size: var(--e-global-typography-6687ff8-font-size, 0.875rem);
	font-weight: var(--e-global-typography-6687ff8-font-weight, 500);
	line-height: 1.2;
	color: var(--e-global-color-3f56ae9, #2C1810);
	text-decoration: none;
	box-shadow: none;
	cursor: pointer;
	transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.ctbt-product-options__chips .ctbt-product-options__chip:hover {
	border-color: var(--e-global-color-8c866dc, #C4895A);
}

.ctbt-product-options__chips .ctbt-product-options__chip:focus-visible {
	outline: 2px solid var(--e-global-color-4f69e6c, #8B5A2B);
	outline-offset: 2px;
}

.ctbt-product-options__chips .ctbt-product-options__chip.is-selected,
.ctbt-product-options__chips .ctbt-product-options__chip.is-selected:hover,
.ctbt-product-options__chips .ctbt-product-options__chip.is-selected:focus {
	border-color: var(--e-global-color-4f69e6c, #8B5A2B);
	background-color: var(--e-global-color-0d245fd, #F9F2EA);
	color: var(--e-global-color-b4f7cc1, #6B3D18);
}

.ctbt-product-options__chips .ctbt-product-options__chip.is-unavailable,
.ctbt-product-options__chips .ctbt-product-options__chip.is-unavailable:hover {
	opacity: 0.4;
	text-decoration: line-through;
	cursor: not-allowed;
}

/* ── Quantité ── */
.ctbt-product-atc__qty-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
}

.ctbt-qty-stepper {
	display: inline-flex;
	align-items: center;
	box-sizing: border-box;
	height: 44px;
	overflow: hidden;
	border: 1px solid var(--e-global-color-712aa72, #D4C8A8);
	border-radius: 8px;
	background-color: var(--e-global-color-01d5930, #FDFAF2);
}

.ctbt-qty-stepper .ctbt-qty-stepper__btn,
.ctbt-qty-stepper .ctbt-qty-stepper__btn:hover,
.ctbt-qty-stepper .ctbt-qty-stepper__btn:focus {
	display: flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 100%;
	padding: 0;
	border: none;
	border-radius: 0;
	background: transparent;
	font-size: 1.25rem;
	font-weight: 400;
	line-height: 1;
	color: var(--e-global-color-3f56ae9, #2C1810);
	box-shadow: none;
	cursor: pointer;
	transition: background-color 150ms ease, color 150ms ease;
}

.ctbt-qty-stepper .ctbt-qty-stepper__btn:hover:not(:disabled) {
	background-color: var(--e-global-color-75caaa8, #EDE3C4);
	color: var(--e-global-color-4f69e6c, #8B5A2B);
}

.ctbt-qty-stepper .ctbt-qty-stepper__btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.ctbt-qty-stepper .ctbt-qty-stepper__input,
.ctbt-qty-stepper .ctbt-qty-stepper__input:focus {
	width: 48px;
	height: 100%;
	margin: 0;
	padding: 0!important;
	border: none;
	border-left: 1px solid var(--e-global-color-712aa72, #D4C8A8);
	border-right: 1px solid var(--e-global-color-712aa72, #D4C8A8);
	border-radius: 0!important;
	background: transparent;
	font-family: var(--e-global-typography-d6225fb-font-family, Inter);
	font-size: var(--e-global-typography-d6225fb-font-size, 1rem);
	font-weight: var(--e-global-typography-d6225fb-font-weight, 600);
	text-align: center;
	color: var(--e-global-color-3f56ae9, #2C1810)!important;
	box-shadow: none;
	outline: none;
	-moz-appearance: textfield;
	appearance: textfield;
}

.ctbt-qty-stepper .ctbt-qty-stepper__input::-webkit-outer-spin-button,
.ctbt-qty-stepper .ctbt-qty-stepper__input::-webkit-inner-spin-button {
	margin: 0;
	-webkit-appearance: none;
}

.ctbt-product-atc__available {
	font-family: var(--e-global-typography-4bf239c-font-family, Inter);
	font-size: var(--e-global-typography-4bf239c-font-size, 0.875rem);
	color: var(--e-global-color-6cd5322, #7A6A5A);
}

.ctbt-product-atc__available[hidden] {
	display: none;
}

/* ── Ajout au panier + favoris ── */
.ctbt-product-atc__row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
}

.ctbt-product-atc .ctbt-product-atc__btn,
.ctbt-product-atc .ctbt-product-atc__btn:hover,
.ctbt-product-atc .ctbt-product-atc__btn:focus {
	position: relative;
	display: inline-flex;
	flex: 1;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: 200px;
	height: 52px;
	padding: 0 32px;
	border: 1.5px solid var(--e-global-color-4f69e6c, #8B5A2B);
	border-radius: 8px;
	background-color: var(--e-global-color-4f69e6c, #8B5A2B);
	background-image: none;
	font-family: var(--e-global-typography-6fc88fd-font-family, Inter);
	font-size: var(--e-global-typography-6fc88fd-font-size, 1rem);
	font-weight: var(--e-global-typography-6fc88fd-font-weight, 500);
	line-height: 1;
	white-space: nowrap;
	color: var(--e-global-color-e0ac0bc, #FFFFFF);
	text-decoration: none;
	box-shadow: none;
	cursor: pointer;
	transition: background-color 250ms ease, border-color 250ms ease, box-shadow 250ms ease, transform 150ms ease;
}

.ctbt-product-atc .ctbt-product-atc__btn:hover:not(:disabled) {
	background-color: var(--e-global-color-b4f7cc1, #6B3D18);
	border-color: var(--e-global-color-b4f7cc1, #6B3D18);
	box-shadow: 0 4px 20px rgba(139, 90, 43, 0.35);
}

.ctbt-product-atc .ctbt-product-atc__btn:active:not(:disabled) {
	transform: scale(0.98);
}

.ctbt-product-atc .ctbt-product-atc__btn:focus-visible {
	outline: 2px solid var(--e-global-color-4f69e6c, #8B5A2B);
	outline-offset: 2px;
}

.ctbt-product-atc .ctbt-product-atc__btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.ctbt-product-atc__state {
	display: none;
	align-items: center;
	gap: 8px;
}

.ctbt-product-atc__btn .ctbt-product-atc__state--default,
.ctbt-product-atc__btn.is-added .ctbt-product-atc__state--added,
.ctbt-product-atc__btn.is-out .ctbt-product-atc__state--out {
	display: inline-flex;
}

.ctbt-product-atc__btn.is-added .ctbt-product-atc__state--default,
.ctbt-product-atc__btn.is-out .ctbt-product-atc__state--default {
	display: none;
}

.ctbt-product-atc__btn.is-added .ctbt-product-atc__state--added {
	animation: ctbt-atc-added 400ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Chargement : texte masqué, spinner centré. */
.ctbt-product-atc__btn.is-loading {
	pointer-events: none;
}

.ctbt-product-atc__btn.is-loading .ctbt-product-atc__state {
	visibility: hidden;
}

.ctbt-product-atc__btn.is-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 18px;
	height: 18px;
	margin: -9px 0 0 -9px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: var(--e-global-color-e0ac0bc, #FFFFFF);
	border-radius: 9999px;
	animation: ctbt-atc-spin 0.7s linear infinite;
}

.ctbt-product-atc .ctbt-product-atc__wishlist,
.ctbt-product-atc .ctbt-product-atc__wishlist:hover,
.ctbt-product-atc .ctbt-product-atc__wishlist:focus {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 52px;
	height: 52px;
	padding: 0;
	border: 1.5px solid var(--e-global-color-4f69e6c, #8B5A2B);
	border-radius: 8px;
	background-color: transparent;
	background-image: none;
	color: var(--e-global-color-4f69e6c, #8B5A2B);
	box-shadow: none;
	cursor: pointer;
	transition: background-color 250ms ease, color 250ms ease;
}

.ctbt-product-atc .ctbt-product-atc__wishlist:hover {
	background-color: var(--e-global-color-0d245fd, #F9F2EA);
	color: var(--e-global-color-b4f7cc1, #6B3D18);
}

.ctbt-product-atc .ctbt-product-atc__wishlist:focus-visible {
	outline: 2px solid var(--e-global-color-4f69e6c, #8B5A2B);
	outline-offset: 2px;
}

.ctbt-product-atc__wishlist svg {
	width: 20px;
	height: 20px;
	transition: transform 150ms ease;
}

.ctbt-product-atc__wishlist.is-active svg path {
	fill: currentColor;
}

.ctbt-product-atc__wishlist.is-active svg {
	animation: ctbt-atc-added 400ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.ctbt-product-atc__wishlist.is-loading {
	opacity: 0.6;
	pointer-events: none;
}

.ctbt-product-atc__message {
	margin: 12px 0 0;
	font-family: var(--e-global-typography-4bf239c-font-family, Inter);
	font-size: var(--e-global-typography-4bf239c-font-size, 0.875rem);
	color: var(--e-global-color-dcdcb41, #C0392B);
}

.ctbt-product-atc__message[hidden] {
	display: none;
}

@keyframes ctbt-atc-added {
	from { transform: scale(0.6); opacity: 0; }
	to { transform: scale(1); opacity: 1; }
}

@keyframes ctbt-atc-spin {
	to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
	.ctbt-product-atc__btn.is-added .ctbt-product-atc__state--added,
	.ctbt-product-atc__wishlist.is-active svg {
		animation: none;
	}
}

/* ── Barre "Ajouter au panier" sticky (mobile uniquement) ──
   Typographies : 0225c9e (Mako 1.5rem, prix), 6fc88fd (Inter 500 1rem, bouton),
   4bf239c (Inter 400 0.875rem, "À partir de" / prix barré).
   Rendue dans le shortcode puis déplacée en fin de <body> par le JS. Masquée hors mobile. */
.ctbt-sticky-atc {
	display: none;
}

@media (max-width: 767px) {
	.ctbt-sticky-atc {
		position: fixed;
		right: 0;
		bottom: 0;
		left: 0;
		z-index: 990;
		display: flex;
		align-items: center;
		gap: 12px;
		box-sizing: border-box;
		padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
		border-top: 1px solid var(--e-global-color-712aa72, #D4C8A8);
		background-color: var(--e-global-color-01d5930, #FDFAF2);
		box-shadow: 0 -4px 16px rgba(44, 24, 16, 0.08);
		transform: translateY(110%);
		visibility: hidden;
		transition: transform 250ms ease, visibility 0s linear 250ms;
	}

	.ctbt-sticky-atc.is-visible {
		transform: translateY(0);
		visibility: visible;
		transition: transform 250ms ease, visibility 0s linear 0s;
	}

	/* Réserve la hauteur de la barre en bas de page : le pied de page n'est jamais masqué. */
	html.ctbt-has-sticky-atc body {
		padding-bottom: 76px;
	}

	.ctbt-sticky-atc__price {
		display: flex;
		flex-direction: column;
		flex-shrink: 0;
		min-width: 0;
		line-height: 1.1;
	}

	.ctbt-sticky-atc__price .ctbt-product-price__main {
		font-family: var(--e-global-typography-0225c9e-font-family, "Mako");
		font-size: var(--e-global-typography-0225c9e-font-size, 1.5rem);
		font-weight: var(--e-global-typography-0225c9e-font-weight, 400);
		color: var(--e-global-color-b4f7cc1, #6B3D18);
		background: none;
		text-decoration: none;
	}

	.ctbt-sticky-atc__price .ctbt-product-price__orig,
	.ctbt-sticky-atc__price .ctbt-product-price__from {
		order: -1;
		font-family: var(--e-global-typography-4bf239c-font-family, Inter);
		font-size: 0.75rem;
		color: var(--e-global-color-6cd5322, #7A6A5A);
	}

	.ctbt-sticky-atc__price .ctbt-product-price__discount {
		display: none;
	}

	.ctbt-sticky-atc .ctbt-sticky-atc__btn,
	.ctbt-sticky-atc .ctbt-sticky-atc__btn:hover,
	.ctbt-sticky-atc .ctbt-sticky-atc__btn:focus {
		position: relative;
		display: inline-flex;
		flex: 1;
		align-items: center;
		justify-content: center;
		min-width: 0;
		height: 48px;
		padding: 0 16px;
		border: 1.5px solid var(--e-global-color-4f69e6c, #8B5A2B);
		border-radius: 8px;
		background-color: var(--e-global-color-4f69e6c, #8B5A2B);
		background-image: none;
		font-family: var(--e-global-typography-6fc88fd-font-family, Inter);
		font-size: var(--e-global-typography-6fc88fd-font-size, 1rem);
		font-weight: var(--e-global-typography-6fc88fd-font-weight, 500);
		line-height: 1;
		white-space: nowrap;
		color: var(--e-global-color-e0ac0bc, #FFFFFF);
		box-shadow: none;
		cursor: pointer;
	}

	.ctbt-sticky-atc .ctbt-sticky-atc__btn:disabled {
		opacity: 0.45;
		cursor: not-allowed;
	}

	/* "Choisir une option" : bouton secondaire (contour), l'action est de remonter. */
	.ctbt-sticky-atc .ctbt-sticky-atc__btn.is-choose,
	.ctbt-sticky-atc .ctbt-sticky-atc__btn.is-choose:hover,
	.ctbt-sticky-atc .ctbt-sticky-atc__btn.is-choose:focus {
		background-color: transparent;
		color: var(--e-global-color-4f69e6c, #8B5A2B);
	}

	.ctbt-sticky-atc__btn.is-loading {
		pointer-events: none;
	}

	.ctbt-sticky-atc__btn.is-loading [data-ctbt-sticky-label] {
		visibility: hidden;
	}

	.ctbt-sticky-atc__btn.is-loading::after {
		content: "";
		position: absolute;
		top: 50%;
		left: 50%;
		width: 18px;
		height: 18px;
		margin: -9px 0 0 -9px;
		border: 2px solid rgba(255, 255, 255, 0.4);
		border-top-color: var(--e-global-color-e0ac0bc, #FFFFFF);
		border-radius: 9999px;
		animation: ctbt-atc-spin 0.7s linear infinite;
	}
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
	.ctbt-sticky-atc,
	.ctbt-sticky-atc.is-visible {
		transition: none;
	}
}
