/*
 * Floating WhatsApp button.
 *
 * Ported from the inline <style> block in hub-child/qlwapp-x10/box.php.
 * Configurable values arrive as custom properties from wp_add_inline_style();
 * the fallbacks reproduce the original x10 design if they are ever missing.
 */

#tsl-wa-button {
	width: var(--tslwa-width, 108px);
	padding: 0 20px 20px 0;
	position: fixed;
	bottom: var(--tslwa-bottom, 80px);
	right: 0;
	z-index: 2;
}

#tsl-wa-button .tsl-wa-button-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

#tsl-wa-button .tsl-wa-button-link {
	background: linear-gradient(
		90deg,
		var(--tslwa-from, #a02ddf) 0%,
		var(--tslwa-to, #1867d3) 100%
	);
	width: 100%;
	height: auto;
	margin: 0;
	padding: 10px 4px;
	border-radius: var(--tslwa-radius, 10px);
	display: flex;
	gap: 5px;
	color: var(--tslwa-text, #ffffff);
	font-weight: bold;
	align-items: center;
	justify-content: center;
}

/*
 * Hover / keyboard focus.
 *
 * The gradient uses Elementor's global colour variables so the button tracks
 * the site palette. They resolve on the front end only, so each falls back to
 * the configured gradient reversed — an undefined var would otherwise make the
 * whole background-image declaration invalid and drop the hover entirely.
 */
#tsl-wa-button .tsl-wa-button-link {
	transition:
		background-image 0.2s ease,
		box-shadow 0.2s ease,
		transform 0.2s ease;
}

#tsl-wa-button .tsl-wa-button-link:hover,
#tsl-wa-button .tsl-wa-button-link:focus-visible {
	background-image: linear-gradient(
		90deg,
		var(--e-global-color-a3f3bc1, var(--tslwa-to, #1867d3)) 0%,
		var(--e-global-color-e8255b6, var(--tslwa-from, #a02ddf)) 100%
	);
	box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
	transform: translate3d(0, -2px, 0);
}

@media (prefers-reduced-motion: reduce) {
	#tsl-wa-button .tsl-wa-button-link {
		transition: none;
	}

	#tsl-wa-button .tsl-wa-button-link:hover,
	#tsl-wa-button .tsl-wa-button-link:focus-visible {
		transform: none;
	}
}

#tsl-wa-button .tsl-wa-button-link svg {
	width: 1.5em;
	height: 1.5em;
	vertical-align: middle;
	fill: currentColor;
}

#tsl-wa-button .tsl-wa-button-label {
	display: block;
	font-size: 1rem;
	margin-left: 0.3em;
}

/*
 * Default WhatsApp style.
 *
 * Reproduces the button TSL sites ran under the old whatsapp-button plugin
 * (0.x): a green pill sized to its text, with a soft shadow. Width and radius
 * belong to the Custom style and are ignored here. Stacked above theme sticky
 * bars and ad slots, as the old button was; Custom keeps x10's z-index.
 */
#tsl-wa-button.tsl-wa-button--whatsapp {
	width: auto;
	z-index: 99999;
}

#tsl-wa-button.tsl-wa-button--whatsapp .tsl-wa-button-list {
	align-items: flex-end;
}

#tsl-wa-button.tsl-wa-button--whatsapp .tsl-wa-button-link {
	/* The site's success green from TSL Foundry ("r, g, b" on :root), so the
	 * button matches the theme's WhatsApp buttons; WhatsApp green without it. */
	background: rgb(var(--fd-colors-success-500, 37, 211, 102));
	width: auto;
	padding: 12px 16px;
	border-radius: 50px;
	gap: 12px;
	font-size: 18px;
	font-weight: 600;
	line-height: 1;
	white-space: nowrap;
	text-decoration: none;
	box-shadow:
		0 4px 12px 0 rgba(0, 0, 0, 0.15),
		0 8px 24px 0 rgba(0, 0, 0, 0.12);
}

#tsl-wa-button.tsl-wa-button--whatsapp .tsl-wa-button-link svg {
	width: 1.15em;
	height: 1.15em;
}

#tsl-wa-button.tsl-wa-button--whatsapp .tsl-wa-button-label {
	font-size: inherit;
	margin-left: 0;
}

/* One colour, so x10's gradient swap would do nothing; darken slightly instead. */
#tsl-wa-button.tsl-wa-button--whatsapp .tsl-wa-button-link:hover,
#tsl-wa-button.tsl-wa-button--whatsapp .tsl-wa-button-link:focus-visible {
	background-image: none;
	background-color: rgb(var(--fd-colors-success-600, 30, 190, 91));
	color: var(--tslwa-text, #ffffff);
	box-shadow:
		0 6px 16px 0 rgba(0, 0, 0, 0.18),
		0 12px 32px 0 rgba(0, 0, 0, 0.16);
}

/* An icon-only button is a circle rather than a squashed pill. */
#tsl-wa-button.tsl-wa-button--whatsapp .tsl-wa-button-link:not(:has(.tsl-wa-button-label)) {
	padding: 12px;
}

/* Custom style with a solid fill: x10's hover swaps the two gradient colours,
 * which are the same colour here, so darken slightly instead. */
#tsl-wa-button.tsl-wa-button--solid .tsl-wa-button-link:hover,
#tsl-wa-button.tsl-wa-button--solid .tsl-wa-button-link:focus-visible {
	filter: brightness(0.92);
}

/* Custom style with no fixed width: each button sizes to its text, right-aligned. */
#tsl-wa-button.tsl-wa-button--fit .tsl-wa-button-list {
	align-items: flex-end;
}

#tsl-wa-button.tsl-wa-button--fit .tsl-wa-button-link {
	width: auto;
	padding: 12px 16px;
	white-space: nowrap;
}
