/*
 * Modernize Agency — Contact Widget 1.0.0
 * Colours of interactive elements use !important on purpose: some themes style every
 * <button> with high-specificity selectors (e.g. button:not(:hover):not(:active)...).
 * The floating button is the mascot itself. All selectors are prefixed (.macw)
 * and set their own key properties to resist theme styles.
 *
 * Palette: #101114 noir profond · #FF6500 orange · #FFFFFF · #F0F1F3 gris clair
 *          #252830 graphite · #FF9A00 orange secondaire
 * Typography: LAO MN only (see includes/class-modernize-contact-widget-fonts.php).
 */

.macw {
	--macw-size: 72px;
	--macw-gap: 20px;
	--macw-black: #101114;
	--macw-orange: #ff6500;
	--macw-orange-2: #ff9a00;
	--macw-white: #fff;
	--macw-grey: #f0f1f3;
	--macw-graphite: #252830;
	--macw-muted: #5b5f68;
	position: fixed;
	z-index: 99990;
	bottom: calc(var(--macw-gap) + env(safe-area-inset-bottom, 0px));
	font-family: "Modernize Lao MN", "Lao MN", sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: var(--macw-black);
	text-align: left;
	-webkit-font-smoothing: antialiased;
}
.macw--right { right: calc(var(--macw-gap) + env(safe-area-inset-right, 0px)); }
.macw--left  { left: calc(var(--macw-gap) + env(safe-area-inset-left, 0px)); }
.macw[hidden], .macw [hidden] { display: none !important; }
.macw *, .macw *::before, .macw *::after { box-sizing: border-box; }

.macw__sr {
	position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------- Trigger = the mascot ---------- */
.macw__trigger {
	display: flex; align-items: center; gap: 8px;
	margin: 0; padding: 0; border: 0 !important; border-radius: 0;
	background: none !important; box-shadow: none !important; color: inherit !important;
	font: inherit; text-transform: none; letter-spacing: normal; line-height: inherit;
	cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.macw--right .macw__trigger { flex-direction: row-reverse; }
.macw--character .macw__trigger { align-items: flex-start; }
.macw__trigger:hover, .macw__trigger:focus { background: none !important; color: inherit !important; box-shadow: none !important; }
.macw__trigger:focus { outline: none; }

.macw__figure { position: relative; display: block; flex: 0 0 auto; }
.macw__mascot {
	position: relative; display: block;
	width: var(--macw-w, var(--macw-size)); height: var(--macw-size);
	min-width: 44px; min-height: 44px;
	transition: transform .2s ease;
}
.macw__mascot picture, .macw__mascot img {
	display: block; width: 100%; height: 100%; max-width: none; margin: 0; padding: 0; border: 0;
	-webkit-user-drag: none; user-select: none;
}

/* Poses: extra images stacked over the idle pose, cross-faded by JS state */
.macw__mascot img.macw__pose:not(.macw__pose--idle) {
	position: absolute; inset: 0; opacity: 0; pointer-events: none;
}
.macw__mascot img.macw__pose { transition: opacity .22s ease; }
.macw[data-pose-active="hover"] .macw__mascot img.macw__pose--hover,
.macw[data-pose-active="open"] .macw__mascot img.macw__pose--open,
.macw[data-pose-active="attention"] .macw__mascot img.macw__pose--attention { opacity: 1; }
.macw[data-pose-active="hover"] .macw__mascot img.macw__pose--idle,
.macw[data-pose-active="open"] .macw__mascot img.macw__pose--idle,
.macw[data-pose-active="attention"] .macw__mascot img.macw__pose--idle { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .macw__mascot img.macw__pose { transition: none; } }

/* Round medallion (image with background) */
.macw--round .macw__mascot img {
	border-radius: 50%;
	object-fit: cover; object-position: 50% 45%;
	border: 3px solid var(--macw-orange);
	background: var(--macw-grey);
	box-shadow: 0 8px 24px rgba(16, 17, 20, .28);
}
.macw--round .macw__shadow { display: none; }

/* 3D character (transparent cutout): no frame, ground shadow */
.macw--character .macw__mascot { transform-origin: 50% 100%; }
.macw--character .macw__mascot img {
	object-fit: contain; object-position: 50% 100%;
	filter: drop-shadow(0 6px 10px rgba(16, 17, 20, .25));
}
.macw--character .macw__shadow {
	position: absolute; left: 12%; right: 12%; bottom: -6px; height: 14px;
	border-radius: 50%;
	background: radial-gradient(closest-side, rgba(16, 17, 20, .35), rgba(16, 17, 20, 0));
	pointer-events: none;
}
.macw__trigger:hover .macw__mascot { transform: scale(1.05); }
.macw--character .macw__trigger:hover .macw__mascot { transform: translateY(-4px) scale(1.03); }

/* Label = speech bubble next to the mascot */
.macw__label {
	position: relative; display: block;
	max-width: 220px; padding: 8px 14px;
	border-radius: 14px; background: var(--macw-white); color: var(--macw-black);
	font-weight: 700; font-size: 14px; line-height: 1.3; white-space: nowrap;
	overflow: hidden; text-overflow: ellipsis;
	box-shadow: 0 6px 20px rgba(16, 17, 20, .18);
}
.macw--character .macw__label { margin-top: calc(var(--macw-size) * .3); }
.macw--right.macw--character .macw__label { border-bottom-right-radius: 4px; }
.macw--left.macw--character .macw__label { border-bottom-left-radius: 4px; }
.macw--no-label .macw__label {
	position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; box-shadow: none;
}

/* Focus: dark ring + orange halo (visible on light and dark pages) */
.macw--round .macw__trigger:focus-visible .macw__mascot img,
.macw--character .macw__trigger:focus-visible .macw__figure {
	outline: 3px solid var(--macw-black); outline-offset: 3px;
	box-shadow: 0 0 0 8px var(--macw-orange-2);
}
.macw--character .macw__trigger:focus-visible .macw__figure { border-radius: 14px; }
.macw__trigger:focus-visible .macw__label { outline: 2px solid var(--macw-black); outline-offset: 2px; }
.macw__close:focus-visible, .macw__choice:focus-visible, .macw__back:focus-visible,
.macw__channel:focus-visible, .macw__team:focus-visible {
	outline: 3px solid var(--macw-black); outline-offset: 2px;
	box-shadow: 0 0 0 6px var(--macw-orange-2);
}

/* ---------- Animations (the whole image moves, never redrawn) ---------- */
@media (prefers-reduced-motion: no-preference) {
	.macw--anim-float .macw__mascot { animation: macw-float 3.2s ease-in-out infinite; }
	.macw--anim-float .macw__shadow { animation: macw-shadow-float 3.2s ease-in-out infinite; }

	.macw--anim-hop .macw__mascot { animation: macw-hop 3.6s ease-in-out infinite; }
	.macw--anim-hop .macw__shadow { animation: macw-shadow-hop 3.6s ease-in-out infinite; }

	.macw--anim-sway .macw__mascot { transform-origin: 50% 100%; animation: macw-sway 4s ease-in-out infinite; }

	.macw--anim-pulse.macw--round .macw__mascot::after {
		content: ""; position: absolute; inset: 0; border-radius: 50%;
		border: 3px solid var(--macw-orange); pointer-events: none;
		animation: macw-pulse 2.4s ease-out infinite;
	}
	.macw--anim-pulse.macw--character .macw__shadow {
		background: radial-gradient(closest-side, rgba(255, 101, 0, .55), rgba(255, 101, 0, 0));
		animation: macw-glow 2.4s ease-in-out infinite;
	}

	/* Pause while interacting or when the panel is open */
	.macw__trigger:hover .macw__mascot, .macw__trigger:hover .macw__shadow,
	.macw__trigger:focus-visible .macw__mascot, .macw__trigger:focus-visible .macw__shadow,
	.macw.is-open .macw__mascot, .macw.is-open .macw__shadow,
	.macw__trigger:hover .macw__mascot::after, .macw.is-open .macw__mascot::after { animation-play-state: paused; }
	.macw.is-open .macw__mascot::after { opacity: 0; }

	.macw__panel.is-entering { animation: macw-in .2s ease-out; }
	.macw__label { animation: macw-label-in .35s ease-out .6s both; }
}
@keyframes macw-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes macw-shadow-float { 0%, 100% { transform: scaleX(1); opacity: 1; } 50% { transform: scaleX(.82); opacity: .6; } }
@keyframes macw-hop {
	0%, 62%, 100% { transform: translateY(0) scale(1, 1); }
	66% { transform: translateY(0) scale(1.04, .96); }
	74% { transform: translateY(-16px) scale(.98, 1.02); }
	82% { transform: translateY(0) scale(1.03, .97); }
	88% { transform: translateY(-5px) scale(1, 1); }
	94% { transform: translateY(0); }
}
@keyframes macw-shadow-hop { 0%, 66%, 82%, 100% { transform: scaleX(1); opacity: 1; } 74% { transform: scaleX(.7); opacity: .45; } 88% { transform: scaleX(.9); opacity: .8; } }
@keyframes macw-sway  { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes macw-pulse { 0% { transform: scale(1); opacity: .7; } 80%, 100% { transform: scale(1.45); opacity: 0; } }
@keyframes macw-glow  { 0%, 100% { transform: scaleX(1); opacity: .9; } 50% { transform: scaleX(1.5); opacity: .35; } }
@keyframes macw-in    { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes macw-label-in { from { opacity: 0; transform: translateX(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
	.macw__mascot, .macw__trigger:hover .macw__mascot,
	.macw--character .macw__trigger:hover .macw__mascot { transition: none; transform: none; }
}

/* ---------- Panel ---------- */
.macw__panel {
	position: absolute;
	bottom: calc(var(--macw-size) + 16px);
	width: min(360px, calc(100vw - 2 * var(--macw-gap)));
	max-height: calc(100vh - var(--macw-size) - 3 * var(--macw-gap));
	max-height: calc(100dvh - var(--macw-size) - 3 * var(--macw-gap) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
	overflow: auto; overscroll-behavior: contain;
	padding: 18px 20px 20px;
	border: 1px solid #e3e4e8; border-radius: 18px;
	background: var(--macw-white);
	box-shadow: 0 20px 60px rgba(16, 17, 20, .25);
}
.macw--character .macw__panel { bottom: calc(var(--macw-size) + 20px); }
.macw--right .macw__panel { right: 0; }
.macw--left .macw__panel  { left: 0; }

.macw__head { display: flex; align-items: flex-start; gap: 12px; }
.macw__logo { display: block; width: 96px; max-width: 40%; height: auto; margin: 0 0 10px; }
.macw__title {
	flex: 1 1 auto; margin: 4px 0 0; padding: 0; border: 0;
	font-family: inherit; font-size: 19px; font-weight: 700; line-height: 1.25;
	color: var(--macw-black); text-transform: none; letter-spacing: normal;
}
.macw__close {
	display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
	width: 40px; height: 40px; margin: 0 -6px 0 0; padding: 0; border: 0 !important; border-radius: 50%;
	background: var(--macw-grey) !important; color: var(--macw-black) !important; cursor: pointer; box-shadow: none;
}
.macw__close:hover { background: #e3e4e8 !important; color: var(--macw-black) !important; }

.macw__icon { flex: 0 0 auto; display: block; }

.macw__bubble {
	margin: 14px 0 0; padding: 12px 14px;
	border-radius: 14px 14px 14px 4px; background: var(--macw-grey);
	color: var(--macw-graphite); font-size: 15px;
}
.macw__question { margin: 16px 0 8px; font-weight: 700; font-size: 15px; color: var(--macw-black); }

.macw__choices, .macw__channels { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.macw__choices li, .macw__channels li { margin: 0; padding: 0; list-style: none; }
.macw__channels li::before, .macw__choices li::before { content: none; }

.macw__choice {
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	width: 100%; min-height: 48px; margin: 0; padding: 12px 14px;
	border: 1.5px solid #e3e4e8 !important; border-radius: 12px;
	background: var(--macw-white) !important; color: var(--macw-black) !important;
	font: inherit; text-align: left; text-transform: none; letter-spacing: normal;
	cursor: pointer; box-shadow: none; transition: border-color .15s ease, background-color .15s ease;
}
.macw__choice:hover { border-color: var(--macw-orange) !important; background: #fff8f3 !important; color: var(--macw-black) !important; }
.macw__choice .macw__icon { color: var(--macw-orange); }
.macw__choice-text { display: grid; gap: 2px; }
.macw__choice-text strong { font-weight: 700; font-size: 15px; }
.macw__choice-text span { font-size: 13px; color: var(--macw-muted); }

.macw__back {
	display: inline-flex; align-items: center; gap: 4px;
	margin: 14px 0 0 -6px; padding: 6px 8px; border: 0; border-radius: 8px;
	background: none !important; color: var(--macw-graphite) !important; font: inherit; font-size: 14px;
	cursor: pointer; box-shadow: none; text-transform: none;
}
.macw__back:hover { background: var(--macw-grey) !important; color: var(--macw-black) !important; }

.macw__team {
	margin: 14px 0 8px; padding: 0; border: 0;
	font-family: inherit; font-size: 15px; font-weight: 700; color: var(--macw-black);
	text-transform: none; letter-spacing: normal;
}
.macw__group + .macw__group .macw__team { margin-top: 16px; }
.macw__body > .macw__group:first-of-type .macw__channels:first-child { margin-top: 14px; }

.macw__channel {
	display: flex; align-items: center; gap: 10px;
	min-height: 48px; padding: 12px 14px; border-radius: 12px;
	background: var(--macw-black) !important; color: var(--macw-white) !important;
	font-weight: 700; text-decoration: none; box-shadow: none;
	transition: background-color .15s ease;
}
.macw__channel:hover, .macw__channel:focus { background: var(--macw-graphite) !important; color: var(--macw-white) !important; text-decoration: none; }
.macw__channel:visited { color: var(--macw-white); }
.macw__channel .macw__icon { color: var(--macw-orange-2); }

.macw__foot { margin: 14px 0 0; color: var(--macw-muted); font-size: 13px; }

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
	.macw { --macw-gap: 14px; }
	.macw--character .macw__mascot { height: min(var(--macw-size), 120px); width: calc(min(var(--macw-size), 120px) * var(--macw-ratio, .6)); }
	.macw--character .macw__panel { bottom: calc(min(var(--macw-size), 120px) + 2 * var(--macw-gap) + env(safe-area-inset-bottom, 0px)); }
	/* Visually hidden, still the button's accessible name */
	.macw__label {
		position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
		overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; box-shadow: none; animation: none;
	}
	.macw__panel {
		position: fixed;
		left: calc(12px + env(safe-area-inset-left, 0px));
		right: calc(12px + env(safe-area-inset-right, 0px));
		width: auto;
		bottom: calc(var(--macw-size) + 2 * var(--macw-gap) + env(safe-area-inset-bottom, 0px));
	}
	.macw--right .macw__panel, .macw--left .macw__panel { left: calc(12px + env(safe-area-inset-left, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); }
}

@media print { .macw { display: none !important; } }

@media (forced-colors: active) {
	.macw__channel, .macw__choice, .macw__close, .macw__label { border: 1px solid CanvasText; }
}
