/* WhatsApp chat widget. Markup: layout/whatsapp-widget.php. Behaviour: assets/js/whatsapp-widget.js. */
.mld-whatsapp-widget {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 1042;
	font-family: inherit;
}

.mld-whatsapp-widget,
.mld-whatsapp-widget * {
	box-sizing: border-box;
}

.mld-whatsapp-widget .visually-hidden {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

.mld-whatsapp-widget__toggle {
	position: relative;
	display: inline-flex;
	align-items: center;
	min-height: 52px;
	padding: 0.81rem 1.305rem;
	border: 1px solid #fff;
	border-radius: 999px;
	background: #139644;
	color: #fff;
	box-shadow: 0 16px 34px rgba(0, 0, 0, 0.2);
	font-size: clamp(0.98rem, 1vw, 1.08rem);
	font-weight: 700;
	letter-spacing: 0.01em;
	cursor: pointer;
	transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.mld-whatsapp-widget__toggle:hover,
.mld-whatsapp-widget__toggle:focus-visible {
	background: #16a94d;
	box-shadow: 0 20px 42px rgba(0, 0, 0, 0.26);
	transform: translateY(-3px) scale(1.02);
}

.mld-whatsapp-widget__toggle:active {
	background: #10863c;
	box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
	transform: translateY(1px) scale(0.98);
}

.mld-whatsapp-widget__toggle-icon {
	display: inline-grid;
	width: 108px;
	height: 25px;
	place-items: center;
}

.mld-whatsapp-widget__toggle-icon img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.mld-whatsapp-widget__close svg {
	width: 100%;
	height: 100%;
}

.mld-whatsapp-widget__panel {
	position: absolute;
	right: 0;
	bottom: calc(100% + 9px);
	display: flex;
	flex-direction: column;
	width: min(360px, calc(100vw - 32px));
	/* Room for the button below the panel (desktop) or the bottom bar (phones). */
	max-height: calc(100vh - 110px);
	max-height: calc(100dvh - 110px);
	overflow: hidden;
	border-radius: 22px;
	background: #fff;
	box-shadow: 0 28px 70px rgba(0, 0, 0, 0.25);
	opacity: 0;
	pointer-events: none;
	transform: translateY(18px) scale(0.98);
	transform-origin: right bottom;
	transition: opacity 220ms ease, transform 220ms ease, visibility 220ms ease;
	visibility: hidden;
}

.mld-whatsapp-widget.is-open .mld-whatsapp-widget__panel {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0) scale(1);
	visibility: visible;
}

.mld-whatsapp-widget__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	flex: 0 0 auto;
	gap: 1rem;
	padding: 1.25rem 1.1rem 1.15rem;
	background: #00896f;
	color: #fff;
}

.mld-whatsapp-widget__brand {
	display: flex;
	align-items: center;
	gap: 0.9rem;
	min-width: 0;
}

.mld-whatsapp-widget__avatar {
	position: relative;
	display: inline-grid;
	width: 66px;
	height: 66px;
	flex: 0 0 66px;
	place-items: center;
	border: 2px solid #d8b55f;
	border-radius: 50%;
	background: #063d2d;
}

.mld-whatsapp-widget__avatar img {
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	padding: 18%; /* keeps the mark clear of the gold ring and of the online dot */
	object-fit: contain;
	/* No border-radius here: on an image with padding, the browser rounds the drawing
	   area itself, which cut the monogram's square corners into a smaller circle. The
	   round frame comes from the avatar circle around it, and the mark fits inside. */
	border-radius: 0;
}

/* Sits on the gold ring at its bottom-right point (45deg), like a messaging app's status
   dot. It used to sit further in and covered the monogram's bottom-right corner.
   14.6% from each edge is where a 45deg line from the centre meets the circle. */
.mld-whatsapp-widget__online-dot {
	position: absolute;
	box-sizing: border-box;
	right: calc(14.6% - 7px);
	bottom: calc(14.6% - 7px);
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #64d800;
	border: 2px solid #00896f;
}

.mld-whatsapp-widget__brand strong,
.mld-whatsapp-widget__brand small {
	display: block;
	line-height: 1.2;
}

.mld-whatsapp-widget__brand strong {
	font-size: 1.3rem;
	font-weight: 800;
}

.mld-whatsapp-widget__brand small {
	margin-top: 0.35rem;
	font-size: 1rem;
	font-weight: 500;
}

.mld-whatsapp-widget__close {
	display: inline-grid;
	width: 32px;
	height: 32px;
	place-items: center;
	padding: 0;
	border: 0;
	background: transparent;
	color: rgba(255, 255, 255, 0.72);
	cursor: pointer;
	transition: color 180ms ease, transform 180ms ease;
}

.mld-whatsapp-widget__close:hover,
.mld-whatsapp-widget__close:focus-visible {
	color: #fff;
	transform: rotate(6deg);
}

.mld-whatsapp-widget__close path {
	fill: none;
	stroke: currentColor;
	stroke-linecap: round;
	stroke-width: 2.4;
}

.mld-whatsapp-widget__body {
	position: relative;
	flex: 1 1 auto;
	min-height: 170px;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 1.55rem 1.15rem 1.45rem;
	background-color: #f7f7f5;
	background-position: center;
	background-size: 320px auto;
}

.mld-whatsapp-widget__body::after {
	display: table;
	clear: both;
	content: "";
}

.mld-whatsapp-widget__time {
	display: block;
	margin-bottom: 1rem;
	color: rgba(15, 35, 28, 0.36);
	font-size: 0.82rem;
	font-weight: 500;
	text-align: center;
}

.mld-whatsapp-widget__back {
	display: inline-flex;
	align-items: center;
	gap: 0.18rem;
	min-height: 30px;
	margin: -0.25rem 0 0.75rem;
	padding: 0.28rem 0.68rem 0.28rem 0.48rem;
	border: 1px solid rgba(0, 137, 111, 0.16);
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.92);
	color: #075f4e;
	box-shadow: 0 8px 18px rgba(0, 0, 0, 0.06);
	font: inherit;
	font-size: 0.78rem;
	font-weight: 800;
	line-height: 1;
	cursor: pointer;
	transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.mld-whatsapp-widget__back[hidden] {
	display: none;
}

.mld-whatsapp-widget__back:hover,
.mld-whatsapp-widget__back:focus-visible {
	border-color: #00896f;
	background: #00896f;
	color: #fff;
	transform: translateY(-1px);
}

.mld-whatsapp-widget__back svg {
	width: 17px;
	height: 17px;
}

.mld-whatsapp-widget__back path {
	fill: none;
	stroke: currentColor;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 2.4;
}

.mld-whatsapp-widget__bubble {
	position: relative;
	width: fit-content;
	max-width: 82%;
	padding: 1rem 1.25rem 0.9rem;
	border-radius: 0 18px 18px 18px;
	border: 1px solid rgba(216, 181, 95, 0.34);
	background: #fff9ea;
	color: #151515;
	box-shadow: 0 12px 28px rgba(32, 24, 8, 0.08);
}

.mld-whatsapp-widget__bubble.is-entering {
	animation: mldWhatsappMessageIn 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.mld-whatsapp-widget__bubble::before {
	position: absolute;
	top: 0;
	left: -11px;
	width: 16px;
	height: 16px;
	background: #fff9ea;
	clip-path: polygon(100% 0, 0 0, 100% 100%);
	content: "";
}

.mld-whatsapp-widget__bubble p {
	margin: 0;
	color: inherit;
	font-size: 1rem;
	line-height: 1.45;
}

.mld-whatsapp-widget__bubble p + p {
	margin-top: 0.85rem;
}

.mld-whatsapp-widget__typing {
	display: inline-flex;
	align-items: center;
	gap: 0.32rem;
	min-width: 46px;
	min-height: 20px;
}

.mld-whatsapp-widget__typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: rgba(7, 95, 78, 0.46);
	animation: mldWhatsappTypingDot 900ms ease-in-out infinite;
}

.mld-whatsapp-widget__typing span:nth-child(2) {
	animation-delay: 140ms;
}

.mld-whatsapp-widget__typing span:nth-child(3) {
	animation-delay: 280ms;
}

.mld-whatsapp-widget__choices {
	display: flex;
	flex-wrap: wrap;
	gap: 0.62rem;
	margin-top: 1rem;
}

.mld-whatsapp-widget__choice {
	min-height: 40px;
	padding: 0.62rem 0.86rem;
	border: 1px solid rgba(5, 93, 75, 0.9);
	border-radius: 999px;
	background: #075f4e;
	color: #fff;
	box-shadow: 0 10px 22px rgba(0, 89, 72, 0.18);
	font: inherit;
	font-size: 0.88rem;
	font-weight: 700;
	line-height: 1.2;
	text-align: left;
	cursor: pointer;
	transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.mld-whatsapp-widget__choice.is-entering {
	animation: mldWhatsappChoiceIn 280ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.mld-whatsapp-widget__choice:hover,
.mld-whatsapp-widget__choice:focus-visible {
	border-color: #d8b55f;
	background: #0b8068;
	color: #fff9ea;
	transform: translateY(-1px);
}

.mld-whatsapp-widget__choice--wide {
	width: 100%;
	border-radius: 14px;
}

@keyframes mldWhatsappMessageIn {
	from {
		opacity: 0;
		transform: translateY(10px) scale(0.98);
	}

	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

@keyframes mldWhatsappChoiceIn {
	from {
		opacity: 0;
		transform: translateY(8px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes mldWhatsappTypingDot {
	0%,
	80%,
	100% {
		opacity: 0.35;
		transform: translateY(0);
	}

	40% {
		opacity: 1;
		transform: translateY(-4px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.mld-whatsapp-widget__bubble.is-entering,
	.mld-whatsapp-widget__choice.is-entering,
	.mld-whatsapp-widget__typing span {
		animation: none;
	}
}

@media (max-width: 991px) {
	.mld-whatsapp-widget {
		right: 14px;
		bottom: 86px;
	}

	.mld-whatsapp-widget__toggle {
		display: none;
	}

	.mld-whatsapp-widget__panel {
		width: min(348px, calc(100vw - 28px));
		border-radius: 18px;
	}

	.mld-whatsapp-widget__header {
		padding: 1rem 0.95rem;
	}

	.mld-whatsapp-widget__avatar {
		width: 56px;
		height: 56px;
		flex-basis: 56px;
	}

	.mld-whatsapp-widget__brand strong {
		font-size: 1.04rem;
	}

	.mld-whatsapp-widget__brand small {
		font-size: 0.9rem;
	}

	.mld-whatsapp-widget__body {
		min-height: 148px;
		padding: 1.15rem 1rem;
	}

	.mld-whatsapp-widget__bubble {
		max-width: 88%;
	}

	.mld-whatsapp-widget__choices {
		gap: 0.5rem;
	}

	.mld-whatsapp-widget__choice {
		min-height: 38px;
		font-size: 0.82rem;
	}
}

/* 3D treatment: the panel floats, the header is lit from the top, the avatar sits in a
   raised gold ring, the chat wallpaper is lightly tinted, and the choice buttons are raised
   and press in on tap. These rules start with `body` so they win over the mobile rules
   above without reordering them. */
/* ---------- Panel: floats above the page ---------- */
body .mld-whatsapp-widget__panel {
    border: 1px solid rgba(216, 181, 95, 0.35);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.6) inset,
        0 2px 4px rgba(0, 0, 0, 0.08),
        0 12px 24px rgba(0, 0, 0, 0.14),
        0 32px 64px rgba(0, 0, 0, 0.22);
}

/* ---------- Header: lit from the top, a soft edge onto the chat ---------- */
body .mld-whatsapp-widget__header {
    position: relative;
    background: linear-gradient(180deg, #17a98a 0%, #00896f 55%, #00735d 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.28),
        inset 0 -1px 0 rgba(0, 0, 0, 0.18),
        0 6px 14px rgba(0, 60, 48, 0.28);
    z-index: 1;
}

body .mld-whatsapp-widget__brand strong {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

body .mld-whatsapp-widget__brand small {
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

/* Logo sits in a raised gold ring. */
body .mld-whatsapp-widget__avatar {
    border: 0;
    box-shadow:
        0 0 0 2px #e9cc85,
        0 0 0 3px #a9853c,
        0 6px 14px rgba(0, 0, 0, 0.35),
        inset 0 2px 4px rgba(0, 0, 0, 0.35);
}

/* Glossy online dot. */
body .mld-whatsapp-widget__online-dot {
    background: radial-gradient(circle at 35% 30%, #b8ff7a 0%, #64d800 45%, #3f9a00 100%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

/* Close button becomes a small glassy chip. */
body .mld-whatsapp-widget__close {
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 6px rgba(0, 0, 0, 0.18);
    color: rgba(255, 255, 255, 0.9);
}

body .mld-whatsapp-widget__close:active {
    transform: scale(0.94);
}

/* ---------- Chat wallpaper: a little darker ---------- */
/* A light brand-green tint over the doodle wallpaper so the cream bubble and the
   green buttons stand out more. */
body .mld-whatsapp-widget__body {
    background-color: #d3d9d3;
}

/* The wallpaper is only fetched once the panel has been opened (.has-opened is set by
   whatsapp-widget.js), so pages where nobody opens the chat never download it. */
body .mld-whatsapp-widget.has-opened .mld-whatsapp-widget__body {
    background-image:
        linear-gradient(rgba(11, 46, 36, 0.12), rgba(11, 46, 36, 0.12)),
        url("../images/footer/whatsapp-widget-bg.webp");
    background-size: auto, 320px auto;
    background-position: center, center;
}

/* Outside office hours the status dot goes grey. */
body .mld-whatsapp-widget.is-away .mld-whatsapp-widget__online-dot {
    background: #b4b2a9;
}

/* Secondary choices ("Just chat with us", "Ask about another project"): white, not green. */
body .mld-whatsapp-widget__choice.mld-whatsapp-widget__choice--ghost,
body .mld-whatsapp-widget__choice.mld-whatsapp-widget__choice--ghost:hover,
body .mld-whatsapp-widget__choice.mld-whatsapp-widget__choice--ghost:focus-visible,
body .mld-whatsapp-widget__choice.mld-whatsapp-widget__choice--ghost:active {
    border-color: #075f4e;
    background: #fff;
    color: #075f4e;
    text-shadow: none;
    box-shadow: 0 2px 4px rgba(0, 60, 48, 0.12), 0 6px 12px rgba(0, 60, 48, 0.12);
}

body .mld-whatsapp-widget__choice.mld-whatsapp-widget__choice--ghost:hover,
body .mld-whatsapp-widget__choice.mld-whatsapp-widget__choice--ghost:focus-visible {
    background: #e7f6f0;
}

body .mld-whatsapp-widget__time {
    color: rgba(15, 35, 28, 0.55);
}

/* ---------- Message bubble: soft depth ---------- */
body .mld-whatsapp-widget__bubble {
    background: linear-gradient(180deg, #fffdf6 0%, #fff6e2 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        0 1px 2px rgba(60, 44, 10, 0.1),
        0 8px 20px rgba(60, 44, 10, 0.12);
}

body .mld-whatsapp-widget__bubble::before {
    background: #fffdf6;
}

/* ---------- Choice buttons: raised green, press in on tap ---------- */
body .mld-whatsapp-widget__choice {
    border: 1px solid #054a3d;
    background: linear-gradient(180deg, #13866d 0%, #075f4e 55%, #054c3e 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.25),
        inset 0 -2px 0 rgba(0, 0, 0, 0.18),
        0 2px 4px rgba(0, 60, 48, 0.2),
        0 8px 16px rgba(0, 60, 48, 0.2);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

body .mld-whatsapp-widget__choice:hover,
body .mld-whatsapp-widget__choice:focus-visible {
    border-color: #d8b55f;
    background: linear-gradient(180deg, #1a9479 0%, #0b6e59 55%, #075a49 100%);
    transform: translateY(-1px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        inset 0 -2px 0 rgba(0, 0, 0, 0.18),
        0 3px 6px rgba(0, 60, 48, 0.22),
        0 12px 22px rgba(0, 60, 48, 0.24);
}

body .mld-whatsapp-widget__choice:active {
    transform: translateY(1px) scale(0.98);
    background: linear-gradient(180deg, #075f4e 0%, #054c3e 100%);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 1px 2px rgba(0, 60, 48, 0.2);
}

@media (prefers-reduced-motion: reduce) {
    body .mld-whatsapp-widget__choice,
    body .mld-whatsapp-widget__close {
        transition: none;
    }

    body .mld-whatsapp-widget__choice:hover,
    body .mld-whatsapp-widget__choice:focus-visible,
    body .mld-whatsapp-widget__choice:active,
    body .mld-whatsapp-widget__close:active {
        transform: none;
    }
}
/* Keyboard focus: a gold ring on every control. Hover alone never shows it. */
.mld-whatsapp-widget__toggle:focus-visible,
.mld-whatsapp-widget__close:focus-visible,
.mld-whatsapp-widget__back:focus-visible,
.mld-whatsapp-widget__choice:focus-visible {
	outline: 3px solid #d8b55f;
	outline-offset: 2px;
}

.mld-whatsapp-widget__close:focus-visible {
	outline-color: #fff;
}
