/* LRob - Chatbot: chat window, floating or inline.
   No color is written here. chat.js sets the three variables below from the colors the page
   really shows (background and text around the window, the theme's accent), checked for
   contrast, and again at each change of light or dark mode. Without script: the browser's
   Canvas and CanvasText, which follow the page's color scheme. Tints are made from one base,
   currentColor, for their background and their text alike. */
.lrob-chatbot {
	/* The theme's accent when it names one ("accent", "primary"); never a guess from the first
	   color of its palette: else the text color. */
	--lrob-chatbot-accent: var(--wp--preset--color--accent, var(--wp--preset--color--primary, var(--lrob-chatbot-text)));
	--lrob-chatbot-surface: Canvas;
	--lrob-chatbot-text: CanvasText;
	--lrob-chatbot-btn: 60px;
	--lrob-chatbot-w: 380px;
	--lrob-chatbot-h: 600px;
	--lrob-chatbot-speed: 250ms;
	--lrob-chatbot-scale: 0.9;
	--lrob-chatbot-slide: 0px;
	--lrob-chatbot-pos: none;
	/* The size of the site's text, or the one chosen in the settings; every other size of the
	   window is relative to it (em), so the proportions hold. */
	font-size: var(--lrob-chatbot-font-size, inherit);
	line-height: 1.5;
}
.lrob-chatbot *,
.lrob-chatbot *::before,
.lrob-chatbot *::after {
	box-sizing: border-box;
}

/* At rest, the window is in the colors of the text: neutral washes and borders. The accent is
   kept for what acts: the send button, the main buttons, the launcher's icon, links and focus. */
.lrob-chatbot-launcher,
.lrob-chatbot-send,
.lrob-chatbot-retry,
.lrob-chatbot-confirm-yes {
	color: var(--lrob-chatbot-accent);
}
.lrob-chatbot-send,
.lrob-chatbot-retry,
.lrob-chatbot-confirm-yes {
	background: color-mix(in srgb, currentColor 14%, transparent);
}
.lrob-chatbot-header {
	background: color-mix(in srgb, var(--lrob-chatbot-text) 6%, transparent);
}
.is-visitor .lrob-chatbot-text {
	background: color-mix(in srgb, var(--lrob-chatbot-text) 14%, transparent);
}

/* ===== Launcher ===== */
.lrob-chatbot-launcher {
	align-items: center;
	background: var(--lrob-chatbot-surface);
	border: 1px solid color-mix(in srgb, var(--lrob-chatbot-text) 18%, transparent);
	border-radius: 50%;
	/* A shadow is a translucent black in both modes: derived from the text, it became a light
	   glow on a dark page. */
	box-shadow: 0 4px 14px rgb(0 0 0 / 0.3);
	cursor: pointer;
	/* Centred whatever the theme gives buttons (padding, line height, letter spacing…). */
	display: grid;
	font-size: calc(var(--lrob-chatbot-btn) * 0.45);
	height: var(--lrob-chatbot-btn);
	letter-spacing: normal;
	line-height: 1;
	margin: 0;
	min-height: 0;
	min-width: 0;
	padding: 0;
	place-items: center;
	position: fixed;
	text-transform: none;
	transition: opacity var(--lrob-chatbot-speed) ease, transform var(--lrob-chatbot-speed) ease;
	width: var(--lrob-chatbot-btn);
	z-index: 99998;
}
/* The icon in a square of its own size, centred; an emoji's drawing varies with the system's
   font: a fine shift can be set in the settings. */
.lrob-chatbot-launcher > span {
	display: block;
	height: 1em;
	line-height: 1;
	margin: 0;
	text-align: center;
	transform: translate(var(--lrob-chatbot-icon-x, 0px), var(--lrob-chatbot-icon-y, 0px));
	vertical-align: top;
	width: 1em;
}
.lrob-chatbot.is-open .lrob-chatbot-launcher {
	opacity: 0;
	pointer-events: none;
	transform: var(--lrob-chatbot-pos) scale(0.8);
}

/* ===== Panel ===== */
.lrob-chatbot-panel {
	background: var(--lrob-chatbot-surface);
	border: 1px solid color-mix(in srgb, var(--lrob-chatbot-text) 15%, transparent);
	border-radius: 12px;
	color: var(--lrob-chatbot-text);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
.is-floating .lrob-chatbot-panel {
	box-shadow: 0 8px 28px rgb(0 0 0 / 0.28);
	height: var(--lrob-chatbot-h);
	max-height: calc(100vh - 40px);
	max-width: calc(100vw - 32px);
	position: fixed;
	transform: var(--lrob-chatbot-pos);
	width: var(--lrob-chatbot-w);
	z-index: 99999;
}
.is-floating .lrob-chatbot-panel:not([hidden]) {
	animation: lrob-chatbot-in var(--lrob-chatbot-speed) ease;
}
.is-floating .lrob-chatbot-panel[hidden] {
	display: none;
}
@keyframes lrob-chatbot-in {
	from {
		opacity: var(--lrob-chatbot-fade, 0);
		transform: var(--lrob-chatbot-pos) translateY(var(--lrob-chatbot-slide)) scale(var(--lrob-chatbot-scale));
	}
}
.is-floating .lrob-chatbot-panel.is-expanded {
	height: 90vh;
	width: min(900px, 92vw);
}
.is-inline .lrob-chatbot-panel {
	height: var(--lrob-chatbot-h);
	max-height: 85vh;
}

/* ===== Positions ===== */
.is-pos-bottom-right .lrob-chatbot-launcher,
.is-pos-bottom-right .lrob-chatbot-panel { bottom: 20px; right: 20px; }
.is-pos-bottom-left .lrob-chatbot-launcher,
.is-pos-bottom-left .lrob-chatbot-panel { bottom: 20px; left: 20px; }
.is-pos-bottom-center .lrob-chatbot-launcher,
.is-pos-bottom-center .lrob-chatbot-panel { bottom: 20px; left: 50%; }
.is-pos-bottom-center { --lrob-chatbot-pos: translateX(-50%); }
.is-pos-middle-right .lrob-chatbot-launcher,
.is-pos-middle-right .lrob-chatbot-panel { right: 20px; top: 50%; }
.is-pos-middle-left .lrob-chatbot-launcher,
.is-pos-middle-left .lrob-chatbot-panel { left: 20px; top: 50%; }
.is-pos-middle-right,
.is-pos-middle-left { --lrob-chatbot-pos: translateY(-50%); }
.is-pos-bottom-center .lrob-chatbot-launcher,
.is-pos-middle-right .lrob-chatbot-launcher,
.is-pos-middle-left .lrob-chatbot-launcher { transform: var(--lrob-chatbot-pos); }

/* ===== Header ===== */
.lrob-chatbot-header {
	align-items: center;
	border-bottom: 1px solid color-mix(in srgb, var(--lrob-chatbot-text) 15%, transparent);
	display: flex;
	flex: 0 0 auto;
	gap: 8px;
	padding: 10px 12px;
}
.lrob-chatbot-title {
	flex: 1;
	font-weight: 600;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.lrob-chatbot-controls {
	display: flex;
	gap: 4px;
}
.lrob-chatbot-controls button {
	align-items: center;
	background: transparent;
	border: 0;
	border-radius: 4px;
	color: inherit;
	cursor: pointer;
	display: flex;
	font-size: 1.2em;
	line-height: 1;
	padding: 4px 6px;
}
.lrob-chatbot-controls button:hover,
.lrob-chatbot-controls button:focus-visible {
	background: color-mix(in srgb, currentColor 15%, transparent);
}

/* ===== Reset confirmation ===== */
.lrob-chatbot-confirm {
	align-items: center;
	background: color-mix(in srgb, currentColor 8%, var(--lrob-chatbot-surface));
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
	padding: 8px 12px;
}
.lrob-chatbot-confirm[hidden] {
	display: none;
}

/* ===== The visitor's conversations ===== */
.lrob-chatbot-past {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 8px;
	overflow-y: auto;
	padding: 12px;
}
.lrob-chatbot-past[hidden],
.lrob-chatbot-messages[hidden],
.lrob-chatbot-form[hidden],
.lrob-chatbot-status[hidden] {
	display: none;
}
.lrob-chatbot-past-head {
	font-weight: 600;
}
.lrob-chatbot-past-list {
	display: flex;
	flex-direction: column;
	gap: 6px;
	list-style: none;
	margin: 0;
	padding: 0;
}
.lrob-chatbot-past-list li {
	align-items: stretch;
	display: flex;
	gap: 6px;
}
.lrob-chatbot-past-open {
	background: color-mix(in srgb, currentColor 6%, transparent);
	border: 1px solid color-mix(in srgb, currentColor 15%, transparent);
	border-radius: 8px;
	color: inherit;
	cursor: pointer;
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	font: inherit;
	gap: 2px;
	min-width: 0;
	padding: 8px 10px;
	text-align: left;
}
.lrob-chatbot-past-open[aria-current="true"] {
	border-color: color-mix(in srgb, currentColor 55%, transparent);
	font-weight: 600;
}
.lrob-chatbot-past-title {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.lrob-chatbot-past-date {
	font-size: max(13px, 0.85em);
	opacity: 0.7;
}
.lrob-chatbot-past-delete,
.lrob-chatbot-past-back,
.lrob-chatbot-past-all {
	background: none;
	border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
	border-radius: 8px;
	color: inherit;
	cursor: pointer;
	font: inherit;
	padding: 6px 10px;
}
.lrob-chatbot-past-delete {
	align-items: center;
	display: flex;
	flex: none;
	padding: 0 10px;
}
.lrob-chatbot-past-actions {
	display: flex;
	gap: 8px;
	justify-content: space-between;
	margin-top: auto;
}
.lrob-chatbot-past-all[hidden] {
	display: none;
}
.lrob-chatbot-past-empty {
	opacity: 0.7;
}

/* ===== Messages ===== */
.lrob-chatbot-messages {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 10px;
	overflow-y: auto;
	padding: 14px 12px;
}
.lrob-chatbot-message {
	max-width: 88%;
}
.lrob-chatbot-message.is-visitor {
	align-self: flex-end;
}
.lrob-chatbot-text {
	border-radius: 12px;
	overflow-wrap: anywhere;
	padding: 8px 12px;
}
.is-assistant .lrob-chatbot-text {
	background: color-mix(in srgb, currentColor 7%, transparent);
	border-bottom-left-radius: 4px;
}
.is-visitor .lrob-chatbot-text {
	border-bottom-right-radius: 4px;
	white-space: pre-wrap;
}
.lrob-chatbot-text p,
.lrob-chatbot-text ul,
.lrob-chatbot-text ol {
	margin: 0 0 0.5em;
}
.lrob-chatbot-text > :last-child {
	margin-bottom: 0;
}
.lrob-chatbot-text ul,
.lrob-chatbot-text ol {
	padding-left: 1.3em;
}
.lrob-chatbot-text a,
.lrob-chatbot-sources a {
	color: inherit;
	text-decoration: underline;
}
.lrob-chatbot-text code {
	background: color-mix(in srgb, currentColor 10%, transparent);
	border-radius: 3px;
	font-size: 0.9em;
	padding: 0 3px;
}
/* The answer being written: a soft cursor after the last characters. */
.lrob-chatbot-message[aria-busy="true"] .lrob-chatbot-text::after {
	animation: lrob-chatbot-blink 1.2s ease-in-out infinite;
	content: "▍";
	margin-left: 1px;
	opacity: 0.5;
}
@keyframes lrob-chatbot-blink {
	50% { opacity: 0.15; }
}
.lrob-chatbot-sources {
	font-size: max(13px, 0.87em);
	margin: 4px 0 0;
	opacity: 0.85;
	padding: 0 4px;
}
.lrob-chatbot-notice {
	align-items: center;
	align-self: center;
	display: flex;
	flex-direction: column;
	font-size: max(13px, 0.87em);
	gap: 6px;
	text-align: center;
}

/* The field robots fill and people never see. */
.lrob-chatbot-hp {
	height: 1px;
	left: -9999px;
	opacity: 0;
	position: absolute;
	width: 1px;
}

/* ===== Status, input ===== */
.lrob-chatbot-status {
	font-size: max(13px, 0.87em);
	opacity: 0.75;
	padding: 0 14px;
}
.lrob-chatbot.is-busy .lrob-chatbot-status {
	padding-bottom: 6px;
}
.lrob-chatbot-form {
	align-items: flex-end;
	border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent);
	display: flex;
	flex: 0 0 auto;
	gap: 8px;
	padding: 10px 12px;
}
.lrob-chatbot-input {
	background: transparent;
	border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
	border-radius: 8px;
	color: inherit;
	flex: 1;
	font: inherit;
	max-height: 160px;
	min-height: 40px;
	padding: 8px 10px;
	resize: none;
}
.lrob-chatbot-input:focus {
	border-color: var(--lrob-chatbot-accent);
	outline: 2px solid color-mix(in srgb, var(--lrob-chatbot-accent) 35%, transparent);
	outline-offset: 0;
}
.lrob-chatbot-send,
.lrob-chatbot-retry,
.lrob-chatbot-confirm button {
	border: 1px solid color-mix(in srgb, currentColor 40%, transparent);
	border-radius: 8px;
	cursor: pointer;
	font: inherit;
	padding: 8px 12px;
}
.lrob-chatbot-send {
	height: 40px;
	width: 44px;
}
.lrob-chatbot-confirm .lrob-chatbot-confirm-no {
	background: transparent;
	color: inherit;
}
.lrob-chatbot-send:disabled {
	cursor: wait;
	opacity: 0.6;
}
.lrob-chatbot button:focus-visible,
.lrob-chatbot a:focus-visible {
	outline: 2px solid var(--lrob-chatbot-accent);
	outline-offset: 2px;
}
.lrob-chatbot-footer {
	font-size: max(13px, 0.85em);
	opacity: 0.7;
	padding: 0 12px 8px;
	text-align: center;
}
.lrob-chatbot-footer a {
	color: inherit;
}
.lrob-chatbot-footer a + a {
	margin-left: 12px;
}

@media (prefers-reduced-motion: reduce) {
	.lrob-chatbot *,
	.lrob-chatbot-launcher {
		animation: none !important;
		transition: none !important;
	}
}
@media (max-width: 480px) {
	.is-floating .lrob-chatbot-panel {
		border-radius: 0;
		bottom: 0;
		height: 100%;
		left: 0;
		max-height: none;
		max-width: none;
		right: 0;
		top: 0;
		transform: none;
		width: 100%;
	}
}
