/* Noqta – Talking Site Assistant */
#noqta-root {
	--nq-a: #12a8e0;
	position: fixed;
	bottom: 20px;
	z-index: 99999;
	display: flex;
	align-items: flex-end;
	gap: 10px;
	direction: ltr;
	font-family: inherit;
	line-height: 1.5;
}
#noqta-root.nq-left { left: 20px; flex-direction: row; }
#noqta-root.nq-right { right: 20px; flex-direction: row-reverse; }
#noqta-root.nq-hidden { display: none; }
#noqta-root *, #noqta-root *::before, #noqta-root *::after { box-sizing: border-box; }
#noqta-root button { text-transform: none; letter-spacing: normal; box-shadow: none; font-family: inherit; }

/* character */
#noqta-root .nq-drop {
	width: 96px; height: 96px; flex: none; padding: 0; margin: 0;
	border: 0; background: none; border-radius: 50%; cursor: pointer;
	filter: drop-shadow(0 10px 18px rgba(6, 60, 100, .28));
	animation: nq-bob 3.4s ease-in-out infinite;
}
#noqta-root .nq-drop:focus-visible { outline: 3px solid var(--nq-a); outline-offset: 4px; }
#noqta-root .nq-drop svg { width: 100%; height: 100%; display: block; overflow: visible; }
#noqta-root .nq-g0 { stop-color: #fff; stop-opacity: .6; }
#noqta-root .nq-g1 { stop-color: #e6f6ff; stop-opacity: .2; }
#noqta-root .nq-g2 { stop-color: var(--nq-a); stop-opacity: .3; }

#noqta-root .nq-w { fill: var(--nq-a); }
#noqta-root .nq-w2 { opacity: .45; animation: nq-wave 4.6s linear infinite reverse; }
#noqta-root .nq-w1 { opacity: .9; animation: nq-wave 3s linear infinite; }
#noqta-root .nq-level { transition: transform .6s ease; }
#noqta-root .nq-bub { fill: #fff; opacity: 0; animation: nq-rise 3.6s ease-in infinite; }

#noqta-root .nq-eyes { transform-box: fill-box; transform-origin: center; animation: nq-blink 5s infinite; }
#noqta-root .nq-pupils { animation: nq-glance 9s ease-in-out infinite; }
#noqta-root .nq-mouth { transform-box: fill-box; transform-origin: center; opacity: 0; }
#noqta-root .nq-smile { transition: opacity .15s; }

/* reading: eyes scan left and right */
#noqta-root.nq-reading .nq-pupils { animation: nq-scan 1s ease-in-out infinite; }
#noqta-root.nq-reading .nq-w1 { animation-duration: 2s; }

/* talking: mouth moves, water sloshes */
#noqta-root.nq-talking .nq-smile { opacity: 0; }
#noqta-root.nq-talking .nq-mouth { opacity: 1; animation: nq-talk .7s infinite; }
#noqta-root.nq-talking .nq-level { transform: translateY(-3px); }
#noqta-root.nq-talking .nq-w1 { animation-duration: 1.3s; }
#noqta-root.nq-talking .nq-w2 { animation-duration: 2s; }
#noqta-root.nq-talking .nq-drop { animation: nq-wobble .5s ease-in-out infinite; }

/* real lip-sync from the audio: JS sets the mouth size */
#noqta-root.nq-lipsync.nq-talking .nq-mouth { animation: none; transition: transform .06s linear; }

/* bubble */
#noqta-root .nq-bubble {
	position: relative;
	max-width: min(320px, calc(100vw - 140px));
	margin-bottom: 20px;
	padding: 12px 14px 10px;
	background: #fff; color: #0b2540;
	border: 2px solid var(--nq-a);
	border-radius: 18px 18px 18px 4px;
	box-shadow: 0 14px 34px rgba(0, 0, 0, .16);
	font-size: 15px;
	transform-origin: bottom left;
	transition: opacity .25s, transform .25s, visibility 0s;
}
#noqta-root.nq-right .nq-bubble { border-radius: 18px 18px 4px 18px; transform-origin: bottom right; }
#noqta-root .nq-bubble.nq-off {
	opacity: 0; visibility: hidden; pointer-events: none;
	transform: scale(.92) translateY(6px);
	transition: opacity .25s, transform .25s, visibility 0s .25s;
}
#noqta-root .nq-name { display: block; margin-bottom: 2px; font-size: 13px; font-weight: 700; color: var(--nq-a); }
#noqta-root .nq-text { margin: 0; min-height: 1.5em; font-size: 15px; color: #0b2540; }
#noqta-root .nq-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#noqta-root .nq-tools button {
	min-height: 34px; padding: 0 12px; margin: 0;
	border: 1px solid #d5e9f3; border-radius: 999px;
	background: #f1f9fd; color: #0b2540;
	font-size: 13px; line-height: 1; cursor: pointer;
}
#noqta-root .nq-tools button[aria-pressed="true"] { background: var(--nq-a); border-color: var(--nq-a); color: #fff; }
#noqta-root .nq-tools button:focus-visible { outline: 2px solid var(--nq-a); outline-offset: 2px; }

/* small reopen button */
#noqta-reopen {
	--nq-a: #12a8e0;
	position: fixed; bottom: 20px; z-index: 99999;
	display: none; width: 54px; height: 54px; padding: 0;
	border: 2px solid #fff; border-radius: 50%; cursor: pointer;
	background: linear-gradient(to top, var(--nq-a) 50%, rgba(220, 240, 255, .75) 50%);
	box-shadow: 0 8px 20px rgba(6, 60, 100, .3);
}
#noqta-reopen.nq-left { left: 20px; }
#noqta-reopen.nq-right { right: 20px; }

/* shown only to admins while voice files are prepared */
.nq-admin-pill {
	position: fixed; top: 46px; left: 50%; z-index: 100000;
	transform: translateX(-50%);
	padding: 8px 16px; border-radius: 999px;
	background: #0b2540; color: #fff; font: 14px/1.4 system-ui, sans-serif;
	box-shadow: 0 8px 20px rgba(0, 0, 0, .25);
}

@media (max-width: 600px) {
	#noqta-root { bottom: 14px; }
	#noqta-root.nq-left, #noqta-reopen.nq-left { left: 12px; }
	#noqta-root.nq-right, #noqta-reopen.nq-right { right: 12px; }
	#noqta-root .nq-drop { width: 72px; height: 72px; }
	#noqta-root .nq-bubble { max-width: calc(100vw - 110px); font-size: 14px; }
	#noqta-root .nq-text { font-size: 14px; }
}

@keyframes nq-bob { 50% { transform: translateY(-6px); } }
@keyframes nq-wobble { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.04, .97); } }
@keyframes nq-wave { from { transform: translateX(0); } to { transform: translateX(-60px); } }
@keyframes nq-rise { 0% { opacity: 0; transform: translateY(0); } 15% { opacity: .8; } 100% { opacity: 0; transform: translateY(-36px); } }
@keyframes nq-blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes nq-glance { 0%, 40%, 62%, 100% { transform: translateX(0); } 46%, 54% { transform: translateX(-3px); } 80%, 88% { transform: translateX(3px); } }
@keyframes nq-scan { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4.5px); } 75% { transform: translateX(4.5px); } }
@keyframes nq-talk {
	0% { transform: scaleY(.3); } 18% { transform: scaleY(1); } 34% { transform: scaleY(.5); }
	52% { transform: scaleY(.9); } 70% { transform: scaleY(.35); } 86% { transform: scaleY(.8); } 100% { transform: scaleY(.3); }
}

@media (prefers-reduced-motion: reduce) {
	#noqta-root .nq-drop, #noqta-root.nq-talking .nq-drop,
	#noqta-root .nq-w, #noqta-root .nq-bub, #noqta-root .nq-eyes,
	#noqta-root .nq-pupils, #noqta-root.nq-talking .nq-mouth { animation: none; }
	#noqta-root.nq-talking .nq-mouth { transform: scaleY(.7); }
}
