/**
 * Floating WhatsApp button — see inc/whatsapp.php.
 *
 * Colour: WhatsApp green (#25D366) for the glow/pulse; the button face uses
 * a slightly deeper WhatsApp green so the white glyph keeps ≥3:1 contrast.
 */

.tawa-wa {
	--tawa-wa-green: #25d366;
	--tawa-wa-face: #1da851;
	--tawa-wa-face-hover: #178c43;
	--tawa-wa-size: 60px;
	--tawa-wa-offset: 24px;

	position: fixed;
	left: calc(var(--tawa-wa-offset) + env(safe-area-inset-left, 0px));
	bottom: calc(var(--tawa-wa-offset) + env(safe-area-inset-bottom, 0px));
	z-index: 9990; /* Above content + Astra sticky header (≤ 999), below WP admin bar popups / modals. */
	display: flex;
	align-items: center;
	/*
	 * Entrance (fade/rise once) then a gentle float. Both live on the wrapper
	 * so the button's own transform stays free for hover / press scaling.
	 * No layout impact: the element is fixed.
	 */
	animation:
		tawa-wa-in 400ms cubic-bezier(0.2, 0, 0, 1) 600ms both,
		tawa-wa-float 4s ease-in-out 1.2s infinite;
}

.tawa-wa:hover,
.tawa-wa:focus-within {
	animation-play-state: running, paused;
}

.tawa-wa__btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--tawa-wa-size);
	height: var(--tawa-wa-size);
	border-radius: 50%;
	background: var(--tawa-wa-face);
	color: #fff;
	text-decoration: none;
	box-shadow: 0 6px 18px rgba(18, 140, 67, 0.35), 0 2px 6px rgba(36, 51, 42, 0.18);
	transition:
		transform 200ms cubic-bezier(0.2, 0, 0, 1),
		background-color 150ms ease-out,
		box-shadow 200ms ease-out;
	-webkit-tap-highlight-color: transparent;
}

.tawa-wa__btn:hover,
.tawa-wa__btn:focus-visible {
	background: var(--tawa-wa-face-hover);
	color: #fff;
	transform: scale(1.08);
	box-shadow: 0 10px 26px rgba(18, 140, 67, 0.42), 0 3px 8px rgba(36, 51, 42, 0.2);
}

.tawa-wa__btn:focus {
	outline: none;
}

.tawa-wa__btn:focus-visible {
	outline: 3px solid var(--tawa-primary, #006d31);
	outline-offset: 4px;
}

/* Click feedback (CSS for :active, plus a JS-driven ripple class). */
.tawa-wa__btn:active {
	transform: scale(0.94);
	transition-duration: 90ms;
}

.tawa-wa__btn.is-pressed::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.35);
	animation: tawa-wa-press 450ms ease-out forwards;
	pointer-events: none;
}

.tawa-wa__icon {
	position: relative;
	z-index: 1;
	display: block;
	width: 30px;
	height: 30px;
}

/* Pulse ring. */
.tawa-wa__pulse {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: var(--tawa-wa-green);
	opacity: 0;
	pointer-events: none;
	animation: tawa-wa-pulse 2.8s cubic-bezier(0.2, 0, 0, 1) 1.2s infinite;
}

/* Tooltip label (desktop / pointer devices only). */
.tawa-wa__tip {
	position: absolute;
	left: calc(100% + 12px);
	top: 50%;
	padding: 8px 14px;
	border-radius: var(--tawa-radius-full, 9999px);
	background: #fff;
	color: var(--tawa-on-surface, #24332a);
	font-family: var(--tawa-font-body, system-ui, sans-serif);
	font-size: 14px;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
	box-shadow: var(--tawa-shadow-md, 0 4px 16px rgba(36, 51, 42, 0.08));
	opacity: 0;
	transform: translate(-6px, -50%);
	transition: opacity 150ms ease-out, transform 200ms cubic-bezier(0.2, 0, 0, 1);
	pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
	.tawa-wa__btn:hover + .tawa-wa__tip,
	.tawa-wa__btn:focus-visible + .tawa-wa__tip {
		opacity: 1;
		transform: translate(0, -50%);
	}
}

@keyframes tawa-wa-in {
	from {
		opacity: 0;
		transform: translateY(12px) scale(0.9);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes tawa-wa-float {
	0%,
	100% {
		transform: translateY(0);
	}
	50% {
		transform: translateY(-4px);
	}
}

@keyframes tawa-wa-pulse {
	0% {
		opacity: 0.45;
		transform: scale(1);
	}
	70%,
	100% {
		opacity: 0;
		transform: scale(1.55);
	}
}

@keyframes tawa-wa-press {
	from {
		opacity: 1;
		transform: scale(0.6);
	}
	to {
		opacity: 0;
		transform: scale(1.25);
	}
}

/* Tablet / mobile: a little smaller and closer to the edge, still a ≥48px target. */
@media (max-width: 921px) {
	.tawa-wa {
		--tawa-wa-size: 56px;
		--tawa-wa-offset: 18px;
	}
}

@media (max-width: 544px) {
	.tawa-wa {
		--tawa-wa-size: 52px;
		--tawa-wa-offset: 16px;
	}

	.tawa-wa__icon {
		width: 28px;
		height: 28px;
	}
}

/* Keep clear of the page while printing. */
@media print {
	.tawa-wa {
		display: none !important;
	}
}

/* Reduced motion: keep the hover/focus colour change, drop the movement. */
@media (prefers-reduced-motion: reduce) {
	.tawa-wa,
	.tawa-wa__btn,
	.tawa-wa__pulse,
	.tawa-wa__btn.is-pressed::after {
		animation: none !important;
	}

	.tawa-wa__pulse {
		display: none;
	}

	.tawa-wa__btn,
	.tawa-wa__tip {
		transition: background-color 150ms ease-out, opacity 150ms ease-out;
	}

	.tawa-wa__btn:hover,
	.tawa-wa__btn:focus-visible,
	.tawa-wa__btn:active {
		transform: none;
	}
}
