/**
 * London Lantern — floating WhatsApp button + greeting card
 *
 * Colours / size / offsets come in as CSS variables on #ll-wa (Settings →
 * WhatsApp Button). Side is a class: .ll-wa--right / .ll-wa--left.
 * Fonts are inherited, so Arabic pages keep Tajawal / IBM Plex Sans Arabic.
 */

.ll-wa {
	--ll-wa-bg: #25D366;
	--ll-wa-icon: #fff;
	--ll-wa-head: #890C25;
	--ll-wa-size: 60px;
	--ll-wa-bottom: 24px;
	--ll-wa-side: 24px;
	--ll-wa-ease: cubic-bezier(.2, .9, .3, 1.2);

	/* The corner is physical; text direction lives on the card / teaser. */
	direction: ltr;
	position: fixed;
	bottom: calc(var(--ll-wa-bottom) + env(safe-area-inset-bottom, 0px));
	z-index: 99990;
	display: flex;
	flex-direction: column;
	gap: 14px;
	font-family: inherit;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
}

.ll-wa--right { right: var(--ll-wa-side); align-items: flex-end; }
.ll-wa--left  { left:  var(--ll-wa-side); align-items: flex-start; }

.ll-wa *,
.ll-wa *::before,
.ll-wa *::after { box-sizing: border-box; }

.ll-wa svg { display: block; width: 100%; height: 100%; }


/* ---------------------------------------------------------------------------
 * The round button
 * ------------------------------------------------------------------------ */

.ll-wa__btn {
	position: relative;
	width: var(--ll-wa-size);
	height: var(--ll-wa-size);
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: var(--ll-wa-bg);
	color: var(--ll-wa-icon);
	cursor: pointer;
	display: grid;
	place-items: center;
	box-shadow: 0 10px 24px -6px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .12);
	transition: transform .25s var(--ll-wa-ease), box-shadow .25s ease;
	text-decoration: none;
	-webkit-tap-highlight-color: transparent;
}

.ll-wa__btn:hover,
.ll-wa__btn:focus-visible {
	transform: translateY(-3px) scale(1.04);
	box-shadow: 0 16px 30px -8px rgba(0, 0, 0, .4), 0 3px 8px rgba(0, 0, 0, .14);
	color: var(--ll-wa-icon);
}

.ll-wa__btn:focus-visible { outline: 3px solid var(--ll-wa-bg); outline-offset: 4px; }

/* Icon swap: WhatsApp ↔ close */
.ll-wa__ico {
	grid-area: 1 / 1;
	width: 52%;
	height: 52%;
	transition: transform .3s var(--ll-wa-ease), opacity .2s ease;
}

.ll-wa__ico--x { width: 40%; height: 40%; opacity: 0; transform: rotate(-90deg) scale(.6); }

.ll-wa.is-open .ll-wa__ico--wa { opacity: 0; transform: rotate(90deg) scale(.6); }
.ll-wa.is-open .ll-wa__ico--x  { opacity: 1; transform: none; }

/* Pulse ring */
.ll-wa--pulse .ll-wa__btn::before,
.ll-wa--pulse .ll-wa__btn::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: var(--ll-wa-bg);
	z-index: -1;
	animation: ll-wa-pulse 2.6s ease-out infinite;
}

.ll-wa--pulse .ll-wa__btn::after { animation-delay: 1.3s; }
.ll-wa.is-open .ll-wa__btn::before,
.ll-wa.is-open .ll-wa__btn::after { animation: none; opacity: 0; }

@keyframes ll-wa-pulse {
	0%   { transform: scale(1);   opacity: .45; }
	100% { transform: scale(1.7); opacity: 0; }
}

/* Unread badge */
.ll-wa__badge {
	position: absolute;
	top: -2px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border-radius: 10px;
	background: #ff3b30;
	color: #fff;
	font: 700 11px/20px system-ui, -apple-system, "Segoe UI", sans-serif;
	text-align: center;
	box-shadow: 0 0 0 2px #fff;
	opacity: 0;
	transform: scale(0);
	transition: transform .35s var(--ll-wa-ease), opacity .2s ease;
}

.ll-wa--right .ll-wa__badge { right: -2px; }
.ll-wa--left  .ll-wa__badge { left:  -2px; }

.ll-wa.has-badge .ll-wa__badge { opacity: 1; transform: scale(1); }
.ll-wa.is-open .ll-wa__badge   { opacity: 0; transform: scale(0); }


/* ---------------------------------------------------------------------------
 * Teaser bubble
 * ------------------------------------------------------------------------ */

.ll-wa__teaser {
	position: relative;
	display: flex;
	align-items: center;
	gap: 10px;
	max-width: min(280px, calc(100vw - 2 * var(--ll-wa-side)));
	padding: 11px 14px;
	background: #fff;
	color: #1f2c34;
	border-radius: 14px;
	font-size: 14px;
	font-weight: 600;
	box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .3), 0 2px 6px rgba(0, 0, 0, .08);
	cursor: pointer;
	animation: ll-wa-pop .45s var(--ll-wa-ease) both;
}

.ll-wa__teaser[hidden] { display: none; }

/* Tail pointing to the button */
.ll-wa__teaser::after {
	content: "";
	position: absolute;
	bottom: -6px;
	width: 14px;
	height: 14px;
	background: #fff;
	transform: rotate(45deg);
	border-radius: 2px;
}

.ll-wa--right .ll-wa__teaser::after { right: calc(var(--ll-wa-size) / 2 - 7px); }
.ll-wa--left  .ll-wa__teaser::after { left:  calc(var(--ll-wa-size) / 2 - 7px); }

.ll-wa__teaser-x {
	flex: none;
	width: 22px;
	height: 22px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: #f0f2f5;
	color: #54656f;
	font-size: 16px;
	line-height: 22px;
	cursor: pointer;
}

.ll-wa__teaser-x:hover { background: #e2e5e9; }

.ll-wa.is-open .ll-wa__teaser { display: none; }


/* ---------------------------------------------------------------------------
 * Greeting card
 * ------------------------------------------------------------------------ */

.ll-wa__card {
	width: 340px;
	max-width: calc(100vw - 2 * var(--ll-wa-side));
	border-radius: 18px;
	overflow: hidden;
	background: #fff;
	box-shadow: 0 24px 60px -16px rgba(9, 18, 35, .45), 0 4px 14px rgba(9, 18, 35, .08);
	transform-origin: bottom right;
	animation: ll-wa-pop .4s var(--ll-wa-ease) both;
}

.ll-wa--left .ll-wa__card { transform-origin: bottom left; }
.ll-wa__card[hidden] { display: none; }

@keyframes ll-wa-pop {
	from { opacity: 0; transform: translateY(14px) scale(.92); }
	to   { opacity: 1; transform: none; }
}

/* Header */
.ll-wa__head {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 16px 18px;
	background: var(--ll-wa-head);
	background-image:
		radial-gradient(120% 140% at 100% 0%, rgba(255, 255, 255, .18), transparent 55%),
		linear-gradient(135deg, rgba(255, 255, 255, .06), rgba(0, 0, 0, .12));
	color: #fff;
}

.ll-wa__avatar {
	position: relative;
	flex: none;
	width: 46px;
	height: 46px;
	border-radius: 50%;
	background: #fff;
	color: var(--ll-wa-bg);
	box-shadow: 0 0 0 2px rgba(255, 255, 255, .35);
	padding: 0;
}

.ll-wa__avatar img {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	object-fit: cover;
	display: block;
}

.ll-wa__avatar > svg { padding: 10px; }

.ll-wa__online {
	position: absolute;
	bottom: 1px;
	right: 1px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #25D366;
	box-shadow: 0 0 0 2px var(--ll-wa-head);
}

[dir="rtl"] .ll-wa__online { right: auto; left: 1px; }

.ll-wa__who {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
}

.ll-wa__who strong {
	font-size: 15.5px;
	font-weight: 700;
	color: #fff;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ll-wa__status {
	font-size: 12.5px;
	opacity: .85;
}

.ll-wa__close {
	flex: none;
	align-self: flex-start;
	width: 30px;
	height: 30px;
	padding: 7px;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .14);
	color: #fff;
	cursor: pointer;
	transition: background .2s ease;
}

.ll-wa__close:hover { background: rgba(255, 255, 255, .26); }

/* Chat body — WhatsApp wallpaper feel */
.ll-wa__body {
	position: relative;
	min-height: 128px;
	padding: 20px 16px 22px;
	background-color: #efeae2;
	background-image:
		radial-gradient(rgba(0, 0, 0, .045) 1px, transparent 1.5px),
		radial-gradient(rgba(0, 0, 0, .03) 1px, transparent 1.5px);
	background-size: 18px 18px, 18px 18px;
	background-position: 0 0, 9px 9px;
}

.ll-wa__typing,
.ll-wa__msg {
	position: relative;
	max-width: 88%;
	background: #fff;
	border-radius: 0 12px 12px 12px;
	box-shadow: 0 1px .5px rgba(11, 20, 26, .13);
}

[dir="rtl"] .ll-wa__typing,
[dir="rtl"] .ll-wa__msg { border-radius: 12px 0 12px 12px; }

/* Bubble tail */
.ll-wa__typing::before,
.ll-wa__msg::before {
	content: "";
	position: absolute;
	top: 0;
	left: -8px;
	border: 8px solid transparent;
	border-top-color: #fff;
	border-right-color: #fff;
	border-width: 0 8px 10px 0;
}

[dir="rtl"] .ll-wa__typing::before,
[dir="rtl"] .ll-wa__msg::before {
	left: auto;
	right: -8px;
	border-right-color: transparent;
	border-left-color: #fff;
	border-width: 0 0 10px 8px;
}

.ll-wa__typing {
	display: none;
	width: 64px;
	padding: 14px 16px;
	gap: 5px;
}

.ll-wa__typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #8696a0;
	animation: ll-wa-dot 1.2s infinite ease-in-out;
}

.ll-wa__typing span:nth-child(2) { animation-delay: .15s; }
.ll-wa__typing span:nth-child(3) { animation-delay: .3s; }

@keyframes ll-wa-dot {
	0%, 60%, 100% { transform: translateY(0);   opacity: .5; }
	30%           { transform: translateY(-4px); opacity: 1; }
}

.ll-wa__msg {
	padding: 8px 12px 6px;
	color: #111b21;
	animation: ll-wa-msg .35s ease both;
}

@keyframes ll-wa-msg {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: none; }
}

/* JS adds .is-typing for ~1s when the card opens */
.ll-wa.is-typing .ll-wa__typing { display: flex; }
.ll-wa.is-typing .ll-wa__msg    { display: none; }

.ll-wa__msg-name {
	display: block;
	font-size: 12.5px;
	font-weight: 700;
	color: var(--ll-wa-head);
	margin-bottom: 2px;
}

.ll-wa__msg p {
	margin: 0;
	font-size: 14.5px;
	line-height: 1.55;
	color: #111b21;
}

.ll-wa__time {
	display: block;
	margin-top: 2px;
	font-size: 11px;
	color: #667781;
	text-align: end;
	direction: ltr;
}

[dir="rtl"] .ll-wa__time { text-align: left; }

/* Footer CTA */
.ll-wa__foot {
	padding: 14px 16px 16px;
	background: #fff;
}

.ll-wa__cta {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	min-height: 48px;
	padding: 12px 18px;
	border-radius: 999px;
	background: #25D366;
	color: #fff !important;
	font-size: 15px;
	font-weight: 700;
	text-decoration: none !important;
	box-shadow: 0 8px 18px -8px rgba(37, 211, 102, .8);
	transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.ll-wa__cta:hover,
.ll-wa__cta:focus-visible {
	background: #1ebe5b;
	transform: translateY(-1px);
	box-shadow: 0 12px 22px -8px rgba(37, 211, 102, .9);
}

.ll-wa__cta svg { width: 20px; height: 20px; flex: none; }


/* ---------------------------------------------------------------------------
 * Devices
 * ------------------------------------------------------------------------ */

@media (max-width: 767px) {

	.ll-wa--no-mobile { display: none !important; }

	/* Phones: side gap never more than 16px (bottom stays as set). */
	.ll-wa--right { right: min(var(--ll-wa-side), 16px); }
	.ll-wa--left  { left:  min(var(--ll-wa-side), 16px); }

	.ll-wa__btn { width: min(var(--ll-wa-size), 56px); height: min(var(--ll-wa-size), 56px); }
	.ll-wa__card { width: calc(100vw - 32px); max-width: 360px; }
	.ll-wa__teaser { font-size: 13.5px; }
}

@media (min-width: 768px) {
	.ll-wa--no-desktop { display: none !important; }
}

/* Never print */
@media print { .ll-wa { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
	.ll-wa *,
	.ll-wa *::before,
	.ll-wa *::after { animation: none !important; transition: none !important; }
}
