/**
 * 3D Welcome Bot — front-end widget styles.
 *
 * Every selector is anchored on #tdwb-widget. That gives an ID's specificity
 * (1,1,0) so a theme's own `button { color: … }` or `a { color: pink }` can
 * never bleed into the widget — which is exactly what went wrong when the
 * controls inherited a theme's link colour. Properties a theme might inherit
 * into the widget are also reset explicitly.
 *
 * Colour, size, offset and z-index arrive as custom properties set inline by
 * PHP, so this file stays static and fully cacheable.
 */

#tdwb-widget {
	--tdwb-accent: #00e5ff;
	--tdwb-glow: #7c4dff;
	--tdwb-size: 100px;
	--tdwb-min-size: 56px;
	--tdwb-z: 99990;
	--tdwb-offset-x: 24px;
	--tdwb-offset-y: 24px;

	--tdwb-surface: #ffffff;
	--tdwb-ink: #14172a;
	--tdwb-muted: #5b6076;
	--tdwb-border: rgba(20, 23, 42, 0.1);
	--tdwb-shadow: 0 20px 48px -14px rgba(12, 16, 40, 0.42);

	position: fixed;
	bottom: var(--tdwb-offset-y);
	z-index: var(--tdwb-z);
	display: flex;
	flex-direction: column;
	gap: 10px;
	width: auto;
	max-width: none;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 14px;
	font-weight: 400;
	font-style: normal;
	line-height: 1.5;
	letter-spacing: normal;
	text-transform: none;
	text-align: left;
	color: var(--tdwb-ink);
	pointer-events: none;
}

#tdwb-widget *,
#tdwb-widget *::before,
#tdwb-widget *::after {
	box-sizing: border-box;
}

#tdwb-widget.tdwb--bottom-right {
	right: var(--tdwb-offset-x);
	align-items: flex-end;
}

#tdwb-widget.tdwb--bottom-left {
	left: var(--tdwb-offset-x);
	align-items: flex-start;
}

/* Boot state: invisible until the script decides the widget may appear. */
#tdwb-widget.tdwb--boot {
	opacity: 0;
	visibility: hidden;
}

#tdwb-widget.tdwb--gone {
	display: none;
}

/* ---------------------------------------------------------------------------
 * Entrance animations — the bot has to be noticed
 * ------------------------------------------------------------------------ */

#tdwb-widget.tdwb--ready {
	visibility: visible;
	opacity: 1;
}

#tdwb-widget.tdwb--enter-warp .tdwb__stage {
	animation: tdwb-warp 900ms cubic-bezier(0.16, 1.1, 0.3, 1) both;
}

#tdwb-widget.tdwb--enter-rise .tdwb__stage {
	animation: tdwb-rise 820ms cubic-bezier(0.22, 1.15, 0.36, 1) both;
}

#tdwb-widget.tdwb--enter-blink .tdwb__stage {
	animation: tdwb-materialise 900ms steps(1, end) both;
}

@keyframes tdwb-warp {
	0% {
		opacity: 0;
		transform: translate3d(120px, 60px, 0) scale(0.2) rotate(22deg);
		filter: blur(6px);
	}
	55% {
		opacity: 1;
		transform: translate3d(-10px, -8px, 0) scale(1.14) rotate(-4deg);
		filter: blur(0);
	}
	100% {
		opacity: 1;
		transform: none;
		filter: blur(0);
	}
}

@keyframes tdwb-rise {
	0% {
		opacity: 0;
		transform: translate3d(0, 46px, 0) scale(0.72);
	}
	100% {
		opacity: 1;
		transform: none;
	}
}

@keyframes tdwb-materialise {
	0%, 18%, 34% { opacity: 0; }
	10%, 26%, 44% { opacity: 0.55; }
	60% { opacity: 0.3; }
	100% { opacity: 1; }
}

/* The shockwave ring that fires once on arrival. */
#tdwb-widget .tdwb__pulse {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 100%;
	height: 100%;
	margin: -50% 0 0 -50%;
	border-radius: 50%;
	border: 2px solid var(--tdwb-accent);
	opacity: 0;
	pointer-events: none;
}

#tdwb-widget.tdwb--announce .tdwb__pulse {
	animation: tdwb-shock 1400ms ease-out 2;
}

@keyframes tdwb-shock {
	0% { opacity: 0.85; transform: scale(0.55); }
	100% { opacity: 0; transform: scale(2.1); }
}

/* ---------------------------------------------------------------------------
 * Speech bubble
 * ------------------------------------------------------------------------ */

#tdwb-widget .tdwb__bubble {
	position: relative;
	order: 1;
	width: max-content;
	max-width: min(330px, calc(100vw - 40px));
	min-width: 190px;
	margin: 0;
	padding: 14px 16px 12px;
	border: 1px solid var(--tdwb-border);
	border-radius: 16px;
	background: var(--tdwb-surface);
	box-shadow: var(--tdwb-shadow);
	opacity: 0;
	transform: translateY(10px) scale(0.96);
	transform-origin: bottom right;
	transition: opacity 240ms ease, transform 240ms cubic-bezier(0.22, 1.2, 0.36, 1);
	pointer-events: none;
}

#tdwb-widget.tdwb--bottom-left .tdwb__bubble {
	transform-origin: bottom left;
}

#tdwb-widget.tdwb--open .tdwb__bubble {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* Minimised: the bubble is gone entirely, only the small bot remains. */
#tdwb-widget.tdwb--min .tdwb__bubble,
#tdwb-widget.tdwb--min .tdwb__prompt,
#tdwb-widget.tdwb--min .tdwb__lead {
	display: none;
}

#tdwb-widget .tdwb__text {
	display: block;
	max-height: 40vh;
	overflow-y: auto;
	margin: 0 20px 0 0;
	padding: 0;
	border: 0;
	background: none;
	font-family: inherit;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.55;
	color: var(--tdwb-ink);
	text-align: left;
	overflow-wrap: break-word;
	overscroll-behavior: contain;
}

#tdwb-widget .tdwb__text mark {
	padding: 0 1px;
	border-radius: 3px;
	background: rgba(0, 229, 255, 0.24);
	color: inherit;
}

/* During long narration the caption is split per audio clip, and the group
   currently being spoken is brought forward. */
#tdwb-widget .tdwb__chunk {
	opacity: 0.45;
	transition: opacity 260ms ease;
}

#tdwb-widget .tdwb__chunk.is-active {
	opacity: 1;
	font-weight: 500;
}

/* Thin progress line showing how far through a long narration we are. */
#tdwb-widget .tdwb__progress {
	position: relative;
	height: 3px;
	margin: 10px 0 0;
	border-radius: 999px;
	background: rgba(20, 23, 42, 0.1);
	overflow: hidden;
}

#tdwb-widget .tdwb__progress span {
	position: absolute;
	inset: 0 auto 0 0;
	display: block;
	width: 0;
	border-radius: 999px;
	background: linear-gradient(90deg, var(--tdwb-accent), var(--tdwb-glow));
	transition: width 240ms linear;
}

#tdwb-widget:not(.tdwb--talking) .tdwb__progress {
	opacity: 0.45;
}

#tdwb-widget .tdwb__actions {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 10px 0 0;
	padding: 0;
}

/* Full reset on every control: themes love to restyle buttons and links. */
#tdwb-widget .tdwb__btn,
#tdwb-widget .tdwb__close,
#tdwb-widget .tdwb__prompt,
#tdwb-widget .tdwb__hit,
#tdwb-widget .tdwb__cta {
	appearance: none;
	-webkit-appearance: none;
	box-shadow: none;
	text-decoration: none;
	text-transform: none;
	letter-spacing: normal;
	font-family: inherit;
	line-height: 1.2;
	cursor: pointer;
	outline: none;
}

#tdwb-widget .tdwb__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background-color: rgba(0, 229, 255, 0.14);
	background-image: none;
	color: var(--tdwb-ink);
	font-size: 0;
	transition: background-color 160ms ease, transform 160ms ease;
}

#tdwb-widget .tdwb__btn svg {
	display: block;
	width: 16px;
	height: 16px;
	/* The icons are currentColor, so this is what stops a theme's link colour
	   turning the controls pink. */
	color: var(--tdwb-ink);
	fill: none;
}

#tdwb-widget .tdwb__btn svg path {
	fill: currentColor;
}

#tdwb-widget .tdwb__btn:hover,
#tdwb-widget .tdwb__btn:focus-visible {
	background-color: rgba(0, 229, 255, 0.26);
	transform: translateY(-1px);
	color: var(--tdwb-ink);
}

#tdwb-widget .tdwb__btn:focus-visible {
	outline: 2px solid var(--tdwb-accent);
	outline-offset: 2px;
}

/* The mute button swaps which of its two icons is visible. */
#tdwb-widget .tdwb__icon-off {
	display: none;
}

#tdwb-widget.tdwb--muted .tdwb__icon-on {
	display: none;
}

#tdwb-widget.tdwb--muted .tdwb__icon-off {
	display: block;
}

#tdwb-widget .tdwb__cta {
	display: inline-flex;
	align-items: center;
	margin: 0 0 0 auto;
	padding: 7px 13px;
	border: 0;
	border-radius: 999px;
	background-color: var(--tdwb-accent);
	background-image: none;
	color: #04121a;
	font-size: 12.5px;
	font-weight: 700;
	white-space: nowrap;
	transition: filter 160ms ease, transform 160ms ease;
}

#tdwb-widget .tdwb__cta:hover,
#tdwb-widget .tdwb__cta:focus-visible {
	filter: brightness(1.1);
	transform: translateY(-1px);
	color: #04121a;
	text-decoration: none;
}

#tdwb-widget .tdwb__close {
	position: absolute;
	top: 6px;
	right: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--tdwb-muted);
	font-size: 17px;
	opacity: 0.7;
	transition: opacity 160ms ease, background-color 160ms ease;
}

#tdwb-widget .tdwb__close:hover,
#tdwb-widget .tdwb__close:focus-visible {
	opacity: 1;
	background-color: rgba(20, 23, 42, 0.07);
	color: var(--tdwb-muted);
}

#tdwb-widget .tdwb__tail {
	position: absolute;
	bottom: -7px;
	right: 30px;
	width: 14px;
	height: 14px;
	border-right: 1px solid var(--tdwb-border);
	border-bottom: 1px solid var(--tdwb-border);
	background: var(--tdwb-surface);
	transform: rotate(45deg);
}

#tdwb-widget.tdwb--bottom-left .tdwb__tail {
	right: auto;
	left: 30px;
}

/* ---------------------------------------------------------------------------
 * "How may I help you?" button
 * ------------------------------------------------------------------------ */

#tdwb-widget .tdwb__ask {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	margin: 10px 0 0;
	padding: 10px 14px;
	border: 1px solid transparent;
	border-radius: 12px;
	background-color: #0e1225;
	background-image:
		linear-gradient(#0e1225, #0e1225),
		linear-gradient(120deg, var(--tdwb-accent), var(--tdwb-glow), var(--tdwb-accent));
	background-origin: border-box;
	background-clip: padding-box, border-box;
	color: #ffffff;
	font-size: 13px;
	font-weight: 700;
	text-align: left;
	overflow: hidden;
	transition: transform 160ms ease, box-shadow 160ms ease;
}

#tdwb-widget .tdwb__ask:hover,
#tdwb-widget .tdwb__ask:focus-visible {
	transform: translateY(-1px);
	box-shadow: 0 8px 22px -8px var(--tdwb-accent);
	color: #ffffff;
}

#tdwb-widget .tdwb__ask:focus-visible {
	outline: 2px solid var(--tdwb-accent);
	outline-offset: 2px;
}

/* Sweeping light that runs across the button to draw the eye. */
#tdwb-widget .tdwb__ask-glow {
	position: absolute;
	top: 0;
	left: -60%;
	width: 45%;
	height: 100%;
	background: linear-gradient(100deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.22) 50%, rgba(255, 255, 255, 0) 100%);
	animation: tdwb-sweep 3.6s ease-in-out infinite;
	pointer-events: none;
}

@keyframes tdwb-sweep {
	0%, 62% { left: -60%; }
	100% { left: 130%; }
}

#tdwb-widget .tdwb__ask-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--tdwb-accent);
	color: #04121a;
}

#tdwb-widget .tdwb__ask-icon svg path {
	fill: currentColor;
}

#tdwb-widget .tdwb__ask-label {
	flex: 1 1 auto;
	line-height: 1.3;
}

#tdwb-widget.tdwb--lead-open .tdwb__bubble {
	display: none;
}

/* ---------------------------------------------------------------------------
 * Lead capture console
 * ------------------------------------------------------------------------ */

#tdwb-widget .tdwb__lead {
	position: relative;
	order: 1;
	width: max-content;
	max-width: min(340px, calc(100vw - 40px));
	min-width: 280px;
	margin: 0;
	padding: 0 0 14px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 16px;
	background:
		radial-gradient(120% 90% at 0% 0%, rgba(0, 229, 255, 0.16), rgba(0, 0, 0, 0) 60%),
		radial-gradient(120% 90% at 100% 100%, rgba(124, 77, 255, 0.18), rgba(0, 0, 0, 0) 60%),
		#0b0f1e;
	box-shadow: 0 24px 54px -18px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(0, 229, 255, 0.12);
	color: #eaf1ff;
	overflow: hidden;
	pointer-events: auto;
}

#tdwb-widget .tdwb__lead[hidden] {
	display: none;
}

/* Slow scanline, the cheapest possible "this is a machine" cue. */
#tdwb-widget .tdwb__lead-scan {
	position: absolute;
	inset: 0;
	background: linear-gradient(rgba(255, 255, 255, 0) 0%, rgba(0, 229, 255, 0.10) 50%, rgba(255, 255, 255, 0) 100%);
	background-size: 100% 220%;
	animation: tdwb-scanline 6s linear infinite;
	pointer-events: none;
}

@keyframes tdwb-scanline {
	0% { background-position: 0 -110%; }
	100% { background-position: 0 210%; }
}

#tdwb-widget .tdwb__lead-head {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 12px 10px 14px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#tdwb-widget .tdwb__lead-pip {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--tdwb-accent);
	box-shadow: 0 0 10px var(--tdwb-accent);
	animation: tdwb-blip 1.8s ease-in-out infinite;
}

@keyframes tdwb-blip {
	0%, 100% { opacity: 1; transform: scale(1); }
	50% { opacity: 0.45; transform: scale(0.75); }
}

#tdwb-widget .tdwb__lead-title {
	flex: 1 1 auto;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.10em;
	text-transform: uppercase;
	color: #cfe6ff;
}

#tdwb-widget .tdwb__lead-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.08);
	color: #cfe6ff;
	font-size: 16px;
	line-height: 1;
}

#tdwb-widget .tdwb__lead-close:hover,
#tdwb-widget .tdwb__lead-close:focus-visible {
	background: rgba(255, 255, 255, 0.18);
	color: #ffffff;
}

/* Step pips */
#tdwb-widget .tdwb__lead-track {
	display: flex;
	gap: 5px;
	padding: 12px 14px 0;
}

#tdwb-widget .tdwb__lead-track i {
	display: block;
	flex: 1 1 auto;
	height: 3px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.14);
	transition: background-color 260ms ease;
}

#tdwb-widget .tdwb__lead-track i.is-done {
	background: var(--tdwb-accent);
}

#tdwb-widget .tdwb__lead-track i.is-active {
	background: linear-gradient(90deg, var(--tdwb-accent), var(--tdwb-glow));
}

/* Conversation log */
#tdwb-widget .tdwb__lead-log {
	max-height: 210px;
	padding: 12px 14px 4px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

#tdwb-widget .tdwb__lead-msg {
	max-width: 88%;
	margin: 0 0 8px;
	padding: 9px 12px;
	border-radius: 12px;
	font-size: 13.5px;
	line-height: 1.5;
	animation: tdwb-msg-in 260ms ease both;
}

#tdwb-widget .tdwb__lead-msg--bot {
	margin-right: auto;
	border-bottom-left-radius: 4px;
	background: rgba(255, 255, 255, 0.07);
	color: #eaf1ff;
}

#tdwb-widget .tdwb__lead-msg--user {
	margin-left: auto;
	border-bottom-right-radius: 4px;
	background: linear-gradient(120deg, var(--tdwb-accent), var(--tdwb-glow));
	color: #05101c;
	font-weight: 600;
	word-break: break-word;
}

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

/* Form */
#tdwb-widget .tdwb__lead-form {
	margin: 0;
	padding: 6px 14px 0;
}

/* Honeypot: off-screen rather than display:none, which some bots detect. */
#tdwb-widget .tdwb__lead-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px !important;
	height: 1px !important;
	overflow: hidden !important;
}

#tdwb-widget .tdwb__lead-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

#tdwb-widget .tdwb__lead-field {
	flex: 1 1 auto;
	min-width: 0;
}

#tdwb-widget .tdwb__lead-input {
	display: block;
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	min-height: 40px;
	margin: 0;
	padding: 10px 12px;
	border: 1px solid rgba(255, 255, 255, 0.16);
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.06);
	box-shadow: none;
	color: #ffffff;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.4;
	outline: none;
	resize: none;
	transition: border-color 160ms ease, box-shadow 160ms ease;
}

#tdwb-widget textarea.tdwb__lead-input {
	min-height: 64px;
}

#tdwb-widget .tdwb__lead-input::placeholder {
	color: rgba(234, 241, 255, 0.45);
}

#tdwb-widget .tdwb__lead-input:focus {
	border-color: var(--tdwb-accent);
	box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.18);
}

#tdwb-widget .tdwb__lead-send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: linear-gradient(120deg, var(--tdwb-accent), var(--tdwb-glow));
	color: #04121a;
	transition: transform 160ms ease, filter 160ms ease;
}

#tdwb-widget .tdwb__lead-send svg path {
	fill: currentColor;
}

#tdwb-widget .tdwb__lead-send:hover,
#tdwb-widget .tdwb__lead-send:focus-visible {
	transform: translateY(-1px);
	filter: brightness(1.12);
	color: #04121a;
}

#tdwb-widget .tdwb__lead-send[disabled] {
	opacity: 0.5;
	cursor: default;
	transform: none;
}

#tdwb-widget .tdwb__lead-consent {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin: 0 0 10px;
	font-size: 12px;
	line-height: 1.5;
	color: #b9cbe6;
}

#tdwb-widget .tdwb__lead-consent[hidden] {
	display: none;
}

#tdwb-widget .tdwb__lead-consent input {
	margin: 2px 0 0;
	accent-color: var(--tdwb-accent);
}

#tdwb-widget .tdwb__lead-error {
	margin: 0 0 8px;
	padding: 0;
	color: #ff9db1;
	font-size: 12.5px;
	line-height: 1.45;
}

#tdwb-widget .tdwb__lead-error:empty {
	display: none;
}

/* Success panel */
#tdwb-widget .tdwb__lead-done {
	padding: 20px 18px 6px;
	text-align: center;
}

#tdwb-widget .tdwb__lead-done[hidden] {
	display: none;
}

#tdwb-widget .tdwb__lead-tick {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	margin-bottom: 12px;
	border-radius: 50%;
	background: rgba(0, 229, 255, 0.14);
	color: var(--tdwb-accent);
	animation: tdwb-tick 520ms cubic-bezier(0.22, 1.2, 0.36, 1) both;
}

#tdwb-widget .tdwb__lead-tick svg path {
	fill: currentColor;
}

@keyframes tdwb-tick {
	from { opacity: 0; transform: scale(0.4); }
	to { opacity: 1; transform: scale(1); }
}

#tdwb-widget .tdwb__lead-done p {
	margin: 0;
	padding: 0;
	color: #eaf1ff;
	font-size: 14px;
	line-height: 1.55;
}

/* ---------------------------------------------------------------------------
 * "Tap to hear us" pill — shown only when the browser refuses autoplay
 * ------------------------------------------------------------------------ */

#tdwb-widget .tdwb__prompt {
	order: 2;
	display: inline-flex;
	align-items: center;
	gap: 7px;
	width: auto;
	margin: 0;
	padding: 8px 14px;
	border: 0;
	border-radius: 999px;
	background-color: var(--tdwb-accent);
	background-image: none;
	color: #04121a;
	font-size: 13px;
	font-weight: 700;
	box-shadow: var(--tdwb-shadow);
	pointer-events: auto;
	animation: tdwb-attention 2.2s ease-in-out infinite;
}

#tdwb-widget .tdwb__prompt[hidden] {
	display: none;
}

@keyframes tdwb-attention {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.06); }
}

/* ---------------------------------------------------------------------------
 * The bot stage
 * ------------------------------------------------------------------------ */

#tdwb-widget .tdwb__stage {
	position: relative;
	order: 3;
	width: var(--tdwb-size);
	height: var(--tdwb-size);
	margin: 0;
	padding: 0;
	transition: width 320ms cubic-bezier(0.22, 1.2, 0.36, 1), height 320ms cubic-bezier(0.22, 1.2, 0.36, 1);
	pointer-events: auto;
}

#tdwb-widget.tdwb--min .tdwb__stage {
	width: var(--tdwb-min-size);
	height: var(--tdwb-min-size);
}

#tdwb-widget .tdwb__hit {
	position: absolute;
	inset: 0;
	z-index: 3;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
}

#tdwb-widget .tdwb__hit:focus-visible {
	outline: 2px solid var(--tdwb-accent);
	outline-offset: 3px;
}

#tdwb-widget .tdwb__canvas {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: none;
	width: 100%;
	height: 100%;
	background: none;
	border: 0;
}

#tdwb-widget.tdwb--3d .tdwb__canvas {
	display: block;
}

/* Soft ground glow under the bot, in the brand colour. */
#tdwb-widget .tdwb__halo {
	position: absolute;
	left: 50%;
	bottom: 2%;
	z-index: 1;
	width: 68%;
	height: 16%;
	margin-left: -34%;
	border-radius: 50%;
	background: radial-gradient(ellipse at center, var(--tdwb-accent) 0%, rgba(0, 0, 0, 0) 70%);
	opacity: 0.4;
	filter: blur(5px);
	pointer-events: none;
}

#tdwb-widget.tdwb--talking .tdwb__halo {
	animation: tdwb-halo 0.9s ease-in-out infinite;
}

@keyframes tdwb-halo {
	0%, 100% { opacity: 0.32; transform: scaleX(0.9); }
	50% { opacity: 0.6; transform: scaleX(1.08); }
}

/* ---------------------------------------------------------------------------
 * CSS-only 2D avatar — mobile fallback, and what shows while the model loads
 * or when WebGL is unavailable
 * ------------------------------------------------------------------------ */

#tdwb-widget .tdwb__avatar {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	animation: tdwb-float 3.4s ease-in-out infinite;
}

#tdwb-widget.tdwb--3d .tdwb__avatar {
	display: none;
}

#tdwb-widget .tdwb__core {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 72%;
	height: 72%;
	border-radius: 28% 28% 34% 34% / 32% 32% 38% 38%;
	background:
		linear-gradient(155deg, #ffffff 0%, #dfe5f2 52%, #b9c2d8 100%);
	box-shadow:
		inset 0 -6px 14px rgba(16, 22, 48, 0.2),
		0 12px 26px -12px rgba(12, 16, 40, 0.6);
}

#tdwb-widget .tdwb__visor {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 72%;
	height: 30%;
	border-radius: 6px;
	background: linear-gradient(150deg, #1b2138 0%, #080b18 100%);
	box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.22);
}

#tdwb-widget .tdwb__scan {
	display: block;
	width: 80%;
	height: 38%;
	border-radius: 3px;
	background: var(--tdwb-glow);
	box-shadow: 0 0 10px var(--tdwb-glow);
	animation: tdwb-scan 3.2s ease-in-out infinite;
}

#tdwb-widget .tdwb__ring {
	position: absolute;
	left: 50%;
	bottom: 4%;
	width: 86%;
	height: 18%;
	margin-left: -43%;
	border: 2px solid var(--tdwb-accent);
	border-radius: 50%;
	box-shadow: 0 0 12px var(--tdwb-accent);
	opacity: 0.85;
	animation: tdwb-spin 4.5s linear infinite;
}

#tdwb-widget .tdwb__crest {
	position: absolute;
	left: 50%;
	top: -6%;
	width: 14%;
	height: 16%;
	margin-left: -7%;
	border-radius: 3px;
	background: var(--tdwb-accent);
	box-shadow: 0 0 10px var(--tdwb-accent);
}

#tdwb-widget.tdwb--talking .tdwb__avatar {
	animation-duration: 1.3s;
}

#tdwb-widget.tdwb--talking .tdwb__scan {
	animation-duration: 0.5s;
}

@keyframes tdwb-float {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-6px); }
}

@keyframes tdwb-scan {
	0%, 100% { opacity: 1; transform: scaleX(1); }
	50% { opacity: 0.55; transform: scaleX(0.72); }
}

@keyframes tdwb-spin {
	0% { transform: rotateX(68deg) rotateZ(0deg); }
	100% { transform: rotateX(68deg) rotateZ(360deg); }
}

/* ---------------------------------------------------------------------------
 * Responsive + preference-aware behaviour
 * ------------------------------------------------------------------------ */

@media (max-width: 782px) {
	#tdwb-widget {
		--tdwb-offset-x: 14px;
		--tdwb-offset-y: 14px;
	}

	#tdwb-widget .tdwb__bubble {
		max-width: min(268px, calc(100vw - 28px));
		padding: 12px 14px 10px;
	}

	#tdwb-widget .tdwb__text {
		max-height: 34vh;
		font-size: 13.5px;
	}

	#tdwb-widget .tdwb__lead {
		max-width: calc(100vw - 28px);
		min-width: 0;
		width: calc(100vw - 28px);
	}

	#tdwb-widget .tdwb__lead-log {
		max-height: 34vh;
	}
}

/* Landscape phones: the widget would swallow the viewport. */
@media (max-height: 420px) {
	#tdwb-widget .tdwb__bubble {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	#tdwb-widget .tdwb__stage,
	#tdwb-widget .tdwb__avatar,
	#tdwb-widget .tdwb__scan,
	#tdwb-widget .tdwb__ring,
	#tdwb-widget .tdwb__halo,
	#tdwb-widget .tdwb__prompt,
	#tdwb-widget .tdwb__pulse,
	#tdwb-widget .tdwb__ask-glow,
	#tdwb-widget .tdwb__lead-scan,
	#tdwb-widget .tdwb__lead-pip,
	#tdwb-widget .tdwb__lead-msg,
	#tdwb-widget .tdwb__lead-tick {
		animation: none;
	}

	#tdwb-widget .tdwb__bubble {
		transform: none;
		transition: opacity 120ms linear;
	}

	#tdwb-widget.tdwb--open .tdwb__bubble {
		transform: none;
	}
}

@media (prefers-color-scheme: dark) {
	#tdwb-widget {
		--tdwb-surface: #171b2c;
		--tdwb-ink: #eef1fa;
		--tdwb-muted: #a2a9c2;
		--tdwb-border: rgba(255, 255, 255, 0.13);
		--tdwb-shadow: 0 20px 48px -14px rgba(0, 0, 0, 0.7);
	}

	#tdwb-widget .tdwb__progress {
		background: rgba(255, 255, 255, 0.14);
	}

	#tdwb-widget .tdwb__close:hover,
	#tdwb-widget .tdwb__close:focus-visible {
		background-color: rgba(255, 255, 255, 0.1);
	}

	#tdwb-widget .tdwb__btn {
		background-color: rgba(0, 229, 255, 0.18);
	}
}
