/* Moustache · widget en marque blanche. Code couleur :
   accent = messages du visiteur, boutons de réponse, liens ; valider = envoi ; fermer = terminer et réduire.
   Tout est préfixé pour ne pas toucher au thème. */
#moustache-root {
	--h-noir: #000;
	/* Couleurs du client, redéfinies par l'extension (onglet Identité) */
	--m-accent: #691abe; --m-accent-txt: #fff;
	--m-ok: #34d141; --m-ok-txt: #000;
	--m-ko: #e74910; --m-ko-txt: #000;
	--m-entete: #000; --m-entete-txt: #fff;
	--m-fond: #fbfaf7; --m-fond-txt: #000;
	--h-gris: #5c5c5c;
	--h-bord: #e4e1d8;
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99990;
	font-family: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: var(--h-noir);
}
#moustache-root *,
#moustache-root *::before,
#moustache-root *::after { box-sizing: border-box; }

#moustache-root .moustache-sr {
	position: absolute !important;
	width: 1px; height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}
#moustache-root .moustache-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Neutralise les styles de boutons et champs du thème (Hello Elementor, Elementor…). */
#moustache-root button,
#moustache-root textarea {
	text-transform: none;
	letter-spacing: normal;
	box-shadow: none;
	min-height: 0;
	margin: 0;
	line-height: 1.3;
	font-family: inherit;
}

/* Bouton d'ouverture */
#moustache-root .moustache-launcher {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-left: auto;
	padding: 12px 18px;
	border: 2px solid #fff;
	border-radius: 999px;
	background: var(--m-entete);
	color: var(--m-entete-txt);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
	transition: transform .15s ease;
}
#moustache-root .moustache-launcher svg { color: var(--m-entete-txt); }
#moustache-root .moustache-launcher:hover,
#moustache-root .moustache-launcher:focus { transform: translateY(-2px); background: var(--m-entete); color: var(--m-entete-txt); }
#moustache-root.is-open .moustache-launcher-label { display: none; }
#moustache-root.is-open .moustache-launcher { padding: 12px; }

/* Panneau */
#moustache-root .moustache-panel {
	position: absolute;
	right: 0;
	bottom: calc(100% + 12px);
	width: 370px;
	max-width: calc(100vw - 40px);
	height: 560px;
	max-height: calc(100vh - 110px);
	display: flex;
	flex-direction: column;
	background: var(--m-fond);
	border: 2px solid #fff;
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
#moustache-root .moustache-panel[hidden] { display: none; }

#moustache-root .moustache-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
	padding: 14px 16px;
	background: var(--m-entete);
	color: var(--m-entete-txt);
}
#moustache-root .moustache-head p { margin: 0; }
#moustache-root .moustache-id { display: flex; align-items: center; gap: 10px; }
#moustache-root .moustache-avatar { width: 36px; height: 36px; border-radius: 50%; border: 2px solid #fff; object-fit: cover; flex: none; margin: 0; }
#moustache-root .moustache-title:focus { outline: none; }
#moustache-root .moustache-title {
	font-family: "Monument Extended", "Archivo", "Hanken Grotesk", sans-serif;
	font-weight: 800;
	font-size: 15px;
	text-transform: uppercase;
	letter-spacing: .02em;
}
#moustache-root .moustache-sub { font-size: 12px; color: var(--m-entete-txt); opacity: .75; }
#moustache-root .moustache-actions { display: flex; align-items: center; gap: 6px; }
#moustache-root .moustache-end,
#moustache-root .moustache-close {
	border: 1px solid var(--m-ko);
	background: transparent;
	color: var(--m-ko);
	font: inherit;
	font-size: 12px;
	border-radius: 999px;
	cursor: pointer;
	padding: 5px 10px;
}
#moustache-root .moustache-close { font-size: 18px; line-height: 1; padding: 3px 9px; }
#moustache-root .moustache-end:hover,
#moustache-root .moustache-close:hover,
#moustache-root .moustache-end:focus,
#moustache-root .moustache-close:focus { background: var(--m-ko); color: var(--m-ko-txt); }

/* Fil de discussion */
#moustache-root .moustache-log {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
#moustache-root .moustache-msg {
	max-width: 85%;
	padding: 10px 13px;
	border-radius: 14px;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}
#moustache-root .moustache-bot {
	align-self: flex-start;
	background: #fff;
	border: 1px solid var(--h-bord);
	border-bottom-left-radius: 4px;
}
#moustache-root .moustache-user {
	align-self: flex-end;
	background: var(--m-accent);
	color: var(--m-accent-txt);
	border-bottom-right-radius: 4px;
}
#moustache-root .moustache-msg a { color: var(--m-accent); font-weight: 700; text-decoration: underline; }
#moustache-root .moustache-user a { color: var(--m-accent-txt); }

#moustache-root .moustache-typing { display: flex; gap: 4px; padding: 14px; }
#moustache-root .moustache-typing span {
	width: 7px; height: 7px;
	border-radius: 50%;
	background: var(--h-gris);
	animation: moustache-dot 1s infinite ease-in-out;
}
#moustache-root .moustache-typing span:nth-child(2) { animation-delay: .15s; }
#moustache-root .moustache-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes moustache-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Vignettes de projets et d'articles */
#moustache-root .moustache-cards { display: flex; gap: 8px; align-self: flex-start; max-width: 100%; }
#moustache-root .moustache-card {
	display: flex;
	flex-direction: column;
	width: 150px;
	border-radius: 12px;
	overflow: hidden;
	background: #fff;
	border: 1px solid var(--h-bord);
	color: var(--h-noir);
	text-decoration: none;
	font-size: 13px;
	font-weight: 700;
	line-height: 1.3;
}
#moustache-root .moustache-card img { width: 100%; height: 90px; object-fit: cover; display: block; margin: 0; }
#moustache-root .moustache-card span { padding: 8px 10px; }
#moustache-root .moustache-card:hover span,
#moustache-root .moustache-card:focus span { color: var(--m-accent); text-decoration: underline; }

/* Réponses rapides */
#moustache-root .moustache-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
#moustache-root .moustache-quick:empty { display: none; }
#moustache-root .moustache-quick button {
	border: 2px solid transparent;
	background: var(--m-accent);
	color: var(--m-accent-txt);
	font: inherit;
	font-size: 13px;
	font-weight: 700;
	border-radius: 999px;
	padding: 6px 12px;
	cursor: pointer;
}
#moustache-root .moustache-quick .moustache-other {
	background: transparent;
	color: var(--m-accent);
	border: 2px solid var(--m-accent);
}
@media (hover: hover) {
	#moustache-root .moustache-quick button:hover { background: var(--m-entete); color: var(--m-entete-txt); }
}
#moustache-root .moustache-quick button:focus-visible { background: var(--m-entete); color: var(--m-entete-txt); }

/* Saisie */
#moustache-root .moustache-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid var(--h-bord);
	background: #fff;
}
#moustache-root .moustache-form textarea {
	flex: 1;
	resize: none;
	border: 1px solid var(--h-bord);
	border-radius: 12px;
	padding: 9px 12px;
	font: inherit;
	color: var(--h-noir);
	background: var(--m-fond);
	max-height: 120px;
	min-height: 40px;
	height: 40px;
	/* 16 px minimum : en dessous, iOS zoome la page à la saisie et le panneau déborde de l'écran. */
	font-size: 16px;
	line-height: 1.4;
	overflow-y: hidden;
	box-sizing: border-box;
}
#moustache-root .moustache-send {
	flex: none;
	width: 40px; height: 40px;
	border: 0;
	border-radius: 50%;
	background: var(--m-ok);
	color: var(--m-ok-txt);
	cursor: pointer;
	display: grid;
	place-items: center;
	padding: 0;
}
#moustache-root .moustache-send:hover,
#moustache-root .moustache-send:focus { background: var(--m-entete); color: var(--m-ok); border: 0; }
#moustache-root .moustache-send:disabled,
#moustache-root .moustache-form textarea:disabled { opacity: .5; cursor: not-allowed; }
#moustache-root .moustache-note {
	margin: 0;
	padding: 6px 12px 9px;
	font-size: 11px;
	color: var(--h-gris);
	background: #fff;
	text-align: center;
}

/* Focus visible (RGAA) */
#moustache-root button:focus-visible,
#moustache-root textarea:focus-visible,
#moustache-root a:focus-visible {
	outline: 3px solid var(--h-noir);
	outline-offset: 2px;
}
/* Sur fond noir (en-tête, bouton d'ouverture) : contour vert, contraste suffisant. */
#moustache-root .moustache-head button:focus-visible { outline-color: #fff; }
/* Bouton d'ouverture : anneau blanc sur fond sombre, anneau noir sur fond clair. */
#moustache-root .moustache-launcher:focus-visible { outline-color: #fff; outline-offset: 3px; box-shadow: 0 0 0 8px var(--h-noir); }

/* Mobile : plein écran */
@media (max-width: 480px) {
	#moustache-root { right: 12px; bottom: 12px; }
	#moustache-root.is-open .moustache-launcher { display: none; }
	#moustache-root .moustache-panel {
		position: fixed;
		inset: 0;
		width: 100%;
		max-width: none;
		height: 100%;
		height: 100dvh;
		max-height: none;
		border-radius: 0;
		border: 0;
	}
}

/* Mobile et tablette (palier mobile d'Elementor, ou écran tactile) : assistant fermé = bulle ronde seule.
   Le libellé reste lu par les lecteurs d'écran. */
@media (max-width: 767px), (hover: none) and (pointer: coarse) {
	#moustache-root .moustache-launcher-label { display: none !important; }
	#moustache-root .moustache-launcher,
	#moustache-root.is-open .moustache-launcher {
		width: 56px !important;
		height: 56px !important;
		min-width: 0 !important;
		padding: 0 !important;
		justify-content: center !important;
	}
	#moustache-root .moustache-launcher svg { width: 26px; height: 26px; }
}
/* Même règle posée par le script (classe moustache-compact), au cas où une feuille du site neutralise la requête média. */
#moustache-root.moustache-compact .moustache-launcher-label { display: none !important; }
#moustache-root.moustache-compact .moustache-launcher {
	width: 56px !important;
	height: 56px !important;
	min-width: 0 !important;
	padding: 0 !important;
	justify-content: center !important;
}

@media (prefers-reduced-motion: reduce) {
	#moustache-root .moustache-launcher { transition: none; }
	#moustache-root .moustache-typing span { animation: none; opacity: .6; }
}

/* Bac à sable de l'administration : panneau intégré dans la page, sans pastille */
#moustache-root.moustache-inline { position: relative; right: auto; bottom: auto; left: auto; z-index: 1; }
#moustache-root.moustache-inline .moustache-launcher { display: none !important; }
#moustache-root.moustache-inline .moustache-panel { position: relative; bottom: auto; right: auto; left: auto; width: 100%; max-width: 420px; height: 600px; max-height: none; }
#moustache-root.moustache-inline .moustache-close { display: none; }