/* Bouton WhatsApp flottant — anti-collision sticky ATC / promo bas. */
:root {
	--c3-wa-size: 56px;
	--c3-wa-green: #25d366;
	--c3-wa-green-hover: #1ebe57;
	--c3-wa-surface: #fff;
	--c3-wa-surface-hover: #25d366;
	--c3-wa-side: max(16px, var(--c3-gutter, 16px));
	--c3-wa-offset-base: calc(16px + env(safe-area-inset-bottom, 0px));
	--c3-wa-offset-promo: 0px;
	--c3-wa-offset-sticky-atc: 0px;
	--z-whatsapp-float: 890;
}

@media (max-width: 767px) {
	:root {
		--c3-wa-size: 54px;
	}

	body.single-product {
		--c3-wa-offset-sticky-atc: 84px;
	}

	body.single-product .c3-wa-float,
	body.c3v-pdp .c3-wa-float,
	body.c3-v2.post-type-archive-product .c3-wa-float,
	body.c3-v2.tax-product_cat .c3-wa-float,
	body.post-type-archive-product .c3-wa-float,
	body.tax-product_cat .c3-wa-float {
		display: none !important;
	}
}

@media (min-width: 768px) {
	:root {
		--c3-wa-size: 60px;
	}
}

body.has-c3-promo-sticky {
	--c3-wa-offset-promo: calc(var(--c3-promo-sticky-h, 48px) + 8px);
}

.c3-wa-float {
	position: fixed;
	z-index: var(--z-whatsapp-float);
	right: var(--c3-wa-side);
	bottom: calc(
		var(--c3-wa-offset-base) + var(--c3-wa-offset-promo) + var(--c3-wa-offset-sticky-atc) +
			var(--c3-cookie-banner-height, 0px)
	);
	display: grid;
	width: var(--c3-wa-size);
	height: var(--c3-wa-size);
	place-items: center;
	border-radius: 50%;
	background: var(--c3-wa-surface);
	color: var(--c3-wa-green);
	border: 1px solid rgba(0, 0, 0, 0.1);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
	transition: transform var(--motion-fast) ease, background-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}

.c3-wa-float:hover,
.c3-wa-float:focus-visible {
	background: var(--c3-wa-surface-hover);
	color: #fff;
	box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
	transform: translateY(-1px);
}

.c3-wa-float:focus-visible {
	outline: 2px solid #000;
	outline-offset: 3px;
}

.c3-wa-float__icon {
	display: block;
	width: calc(var(--c3-wa-size) * .5);
	height: calc(var(--c3-wa-size) * .5);
}

body.woocommerce-checkout .c3-wa-float,
body.woocommerce-cart .c3-wa-float,
body.c3-cart-open .c3-wa-float,
body:has([data-c3-ritual-builder]) .c3-wa-float,
body.c3-footer-inview .c3-wa-float,
body:has(.c3-sticky-atc:not([hidden])) .c3-wa-float,
body.c3-hero-inview .c3-wa-float,
body.home .c3-wa-float,
body.woocommerce-shop .c3-wa-float,
body:has(.c3-shop-family) .c3-wa-float,
body:has(.c3-shop-by-need) .c3-wa-float {
	display: none !important;
}

/* V2 keeps a single persistent support affordance on storefront pages.
 * Checkout/cart remain intentionally excluded by the PHP visibility gate. */
body.c3-v2 .c3-wa-float {
	display: grid !important;
	background: var(--c3-wa-surface) !important;
	color: var(--c3-wa-green) !important;
	border: 1px solid var(--c3v-border, rgba(0, 0, 0, 0.12)) !important;
	box-shadow: 0 2px 14px rgba(0, 0, 0, 0.1);
}

body.c3-v2 .c3-wa-float .c3-wa-float__icon {
	color: inherit;
}

body.c3-v2 .c3-wa-float:hover,
body.c3-v2 .c3-wa-float:focus-visible {
	background: var(--c3-wa-surface-hover);
	color: #fff;
	border-color: var(--c3-wa-surface-hover);
}

/* P11 runtime: legacy page-specific hide rules are intentionally stronger than
 * the generic selector above. Keep the V2 support affordance persistent on
 * discovery surfaces while cart/checkout and open overlays stay excluded. */
body.c3-v2.home .c3-wa-float,
body.c3-v2.woocommerce-shop .c3-wa-float,
body.c3-v2.tax-product_cat .c3-wa-float,
body.c3-v2.search .c3-wa-float,
body.c3-v2.c3v-builder .c3-wa-float {
	display: grid !important;
}

body.c3-v2.c3-cart-open .c3-wa-float,
body.c3-v2:has(.c3v-cart-drawer[open]) .c3-wa-float,
body.c3-v2:has(.c3v-sheet[open]) .c3-wa-float,
body.c3-v2:has(.c3v-mobile-menu[open]) .c3-wa-float,
body.c3-v2:has(.c3v-search:not([hidden])) .c3-wa-float,
body.c3-v2:has(.c3v-mega-scrim:not([hidden])) .c3-wa-float {
	display: none !important;
}

/* V2 mobile: lift FAB above sticky PDP bar and composer mobile summary. */
@media (max-width: 1023px) {
	body.c3-v2.single-product {
		--c3-wa-offset-sticky-atc: 88px;
	}

	body.c3-v2.c3v-builder {
		--c3-wa-offset-sticky-atc: 80px;
	}

	body.c3-v2.single-product:has(.c3v-sticky-buy:not([hidden])) .c3-wa-float,
	body.c3-v2.single-product:has(.c3-sticky-atc:not([hidden])) .c3-wa-float,
	body.c3-v2.c3v-builder:has(.c3v-builder-mobile) .c3-wa-float {
		bottom: calc(
		var(--c3-wa-offset-base) + var(--c3-wa-offset-promo) + var(--c3-wa-offset-sticky-atc) +
			var(--c3-cookie-banner-height, 0px)
	);
		right: max(12px, var(--c3-wa-side, 16px));
	}

	/* QA-013: sticky ATC prime le pouce — masquer WA quand la barre V2 est visible. */
	body.c3-v2.single-product.c3v-pdp:has(.c3v-sticky-buy:not([hidden])) .c3-wa-float,
	body.c3-v2.c3v-builder:has(.c3v-builder-mobile .c3v-sticky-buy:not([hidden])) .c3-wa-float {
		display: none !important;
	}

	/* Mobile PDP and composer: the buy/summary bar owns the thumb zone. */
	body.c3-v2.single-product .c3-wa-float,
	body.c3-v2.c3v-builder .c3-wa-float,
	body.c3-v2.page-template-page-routine-quiz .c3-wa-float {
		display: none !important;
	}

	/* Lists and home: a fixed button always crosses a card or the hero while scrolling. */
	body.c3-v2.home .c3-wa-float,
	body.c3-v2.tax-product_cat .c3-wa-float,
	body.c3-v2.post-type-archive-product .c3-wa-float,
	body.c3-v2.woocommerce-shop .c3-wa-float,
	body.c3-v2.search .c3-wa-float {
		display: none !important;
	}
}

body.c3-v2.c3-footer-inview .c3-wa-float,
body.c3-v2.page-template-page-routine-quiz .c3-wa-float {
	display: none !important;
}

@media (max-width: 1023px) {
	body.c3-v2.page .c3-wa-float {
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.c3-wa-float {
		transition: none;
	}

	.c3-wa-float:hover,
	.c3-wa-float:focus-visible {
		transform: none;
	}
}
