/* The chat bubble */

.adi-chat {
	--ch-ink: #111010;
	--ch-muted: #5f5a56;
	--ch-line: rgba(17, 16, 16, .14);
	--ch-card: #ffffff;
	--ch-paper: #f6f4f1;
	--ch-accent: #e03127;
	--ch-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

	position: fixed;
	right: clamp(14px, 3vw, 28px);
	bottom: clamp(14px, 3vw, 28px);
	z-index: 99991;
	font-family: var(--ch-sans);
	color: var(--ch-ink);

	/* Clear of the iOS home indicator. */
	margin-bottom: env(safe-area-inset-bottom, 0px);
}

.adi-chat *, .adi-chat *::before, .adi-chat *::after { box-sizing: border-box; }

.adi-chat__sr {
	position: absolute;
	width: 1px; height: 1px;
	margin: -1px; padding: 0;
	overflow: hidden; clip: rect(0 0 0 0);
	white-space: nowrap; border: 0;
}

/* ---------- the bubble ---------- */

.adi-chat__bubble {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 54px;
	padding: 14px 20px;
	margin-left: auto;
	border: 0;
	border-radius: 999px;
	background: var(--ch-ink);
	color: #fff;
	font: inherit;
	font-size: 15px;
	cursor: pointer;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
	transition: transform .18s ease, background-color .18s ease;
}
.adi-chat__bubble:hover { transform: translateY(-2px); background: var(--ch-accent); }
.adi-chat.is-open .adi-chat__bubble { background: var(--ch-accent); }

.adi-chat__icon { display: block; width: 22px; flex: none; }
.adi-chat__icon svg { width: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- the panel ---------- */

.adi-chat__panel {
	position: absolute;
	right: 0;
	bottom: calc(100% + 12px);
	width: min(380px, calc(100vw - 28px));
	max-height: min(72vh, 620px);
	display: flex;
	flex-direction: column;
	padding: 20px;
	background: var(--ch-card);
	border: 1px solid var(--ch-line);
	border-radius: 10px;
	box-shadow: 0 24px 60px rgba(0, 0, 0, .24);
}
.adi-chat__panel[hidden] { display: none; }

.adi-chat__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }

.adi-chat__title {
	margin: 0;
	font-size: 18px;
	line-height: 1.3;
	letter-spacing: -.01em;
	font-weight: 600;
	color: inherit;
}

.adi-chat__close {
	display: grid;
	place-items: center;
	width: 36px; height: 36px;
	flex: none;
	margin: -6px -6px 0 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--ch-muted);
	cursor: pointer;
}
.adi-chat__close:hover { background: var(--ch-paper); color: var(--ch-ink); }
.adi-chat__close svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.adi-chat__intro { margin: 8px 0 14px; font-size: 13px; line-height: 1.6; color: var(--ch-muted); }

/* ---------- the conversation ---------- */

.adi-chat__log {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	display: grid;
	gap: 10px;
	align-content: start;
	margin-bottom: 12px;
	overscroll-behavior: contain;
}
.adi-chat__log:empty { display: none; }

.adi-chat__msg {
	max-width: 92%;
	padding: 11px 14px;
	border-radius: 10px;
	font-size: 14px;
	line-height: 1.6;
}
.adi-chat__msg--me { justify-self: end; background: var(--ch-ink); color: #fff; border-bottom-right-radius: 3px; }
.adi-chat__msg--bot { background: var(--ch-paper); color: var(--ch-ink); border-bottom-left-radius: 3px; }
.adi-chat__msg--bot p { margin: 0 0 8px; }
.adi-chat__msg--bot p:last-child { margin: 0; }
.adi-chat__msg--bot a { color: var(--ch-accent); }

.adi-chat__also { display: grid; gap: 6px; font-size: 12px; color: var(--ch-muted); }
.adi-chat__also-btn {
	text-align: left;
	padding: 9px 12px;
	min-height: 40px;
	border: 1px solid var(--ch-line);
	border-radius: 8px;
	background: none;
	color: inherit;
	font: inherit;
	font-size: 13px;
	cursor: pointer;
}
.adi-chat__also-btn:hover { border-color: var(--ch-ink); }

/* ---------- asking ---------- */

.adi-chat__ask { display: flex; gap: 8px; align-items: center; }

.adi-chat__ask input {
	flex: 1;
	min-width: 0;
	min-height: 46px;
	padding: 12px 14px;
	border: 1px solid var(--ch-line);
	border-radius: 8px;
	background: var(--ch-card);
	color: inherit;
	font: inherit;
	font-size: 16px;  /* stops iOS zooming on focus */
}
.adi-chat__ask input:focus { border-color: var(--ch-ink); }

.adi-chat__send {
	display: grid;
	place-items: center;
	width: 46px; height: 46px;
	flex: none;
	border: 0;
	border-radius: 8px;
	background: var(--ch-ink);
	color: #fff;
	cursor: pointer;
}
.adi-chat__send:hover { background: var(--ch-accent); }
.adi-chat__send svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- leaving a message ---------- */

.adi-chat__lead[hidden] { display: none; }
.adi-chat__lead-note { margin: 0 0 12px; font-size: 13px; line-height: 1.6; color: var(--ch-muted); }

.adi-chat__field { margin: 0 0 10px; }
.adi-chat__field label { display: block; margin-bottom: 5px; font-size: 12px; font-weight: 500; }
.adi-chat__field input,
.adi-chat__field textarea {
	width: 100%;
	min-height: 44px;
	padding: 11px 13px;
	border: 1px solid var(--ch-line);
	border-radius: 8px;
	background: var(--ch-card);
	color: inherit;
	font: inherit;
	font-size: 16px;
}
.adi-chat__field textarea { min-height: 84px; resize: vertical; }

.adi-chat__submit {
	width: 100%;
	min-height: 48px;
	margin-top: 4px;
	border: 0;
	border-radius: 8px;
	background: var(--ch-ink);
	color: #fff;
	font: inherit;
	font-size: 15px;
	cursor: pointer;
}
.adi-chat__submit:hover:not([disabled]) { background: var(--ch-accent); }
.adi-chat__submit[disabled] { opacity: .6; cursor: progress; }

/* Off screen rather than display:none, which some bots detect. */
.adi-chat__hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.adi-chat__thanks {
	margin: 0;
	padding: 16px 0 4px;
	font-size: 14px;
	line-height: 1.6;
	color: #136c3a;
}
.adi-chat__thanks[hidden] { display: none; }

/* ---------- focus ---------- */

.adi-chat button:focus-visible,
.adi-chat input:focus-visible,
.adi-chat textarea:focus-visible {
	outline: 3px solid var(--ch-accent);
	outline-offset: 2px;
}

/* ---------- phones ---------- */

@media (max-width: 480px) {
	.adi-chat__bubble-text { display: none; }
	.adi-chat__bubble { width: 54px; justify-content: center; padding: 0; }
	.adi-chat__panel { width: calc(100vw - 24px); max-height: 78vh; }
}

@media (prefers-reduced-motion: reduce) {
	.adi-chat__bubble { transition: none; }
	.adi-chat__bubble:hover { transform: none; }
}

/* ---------- dark ---------- */

@media (prefers-color-scheme: dark) {
	:root:not([data-adi-theme="light"]) .adi-chat {
		--ch-ink: #f3f1ee;
		--ch-muted: #b4aea7;
		--ch-line: rgba(255, 255, 255, .16);
		--ch-card: #1c1a19;
		--ch-paper: #262322;
		--ch-accent: #ff6b5e;
	}
	:root:not([data-adi-theme="light"]) .adi-chat__bubble,
	:root:not([data-adi-theme="light"]) .adi-chat__send,
	:root:not([data-adi-theme="light"]) .adi-chat__submit,
	:root:not([data-adi-theme="light"]) .adi-chat__msg--me { color: #141312; }
	:root:not([data-adi-theme="light"]) .adi-chat__thanks { color: #5bd48c; }
}

[data-adi-theme="dark"] .adi-chat {
	--ch-ink: #f3f1ee;
	--ch-muted: #b4aea7;
	--ch-line: rgba(255, 255, 255, .16);
	--ch-card: #1c1a19;
	--ch-paper: #262322;
	--ch-accent: #ff6b5e;
}
[data-adi-theme="dark"] .adi-chat__bubble,
[data-adi-theme="dark"] .adi-chat__send,
[data-adi-theme="dark"] .adi-chat__submit,
[data-adi-theme="dark"] .adi-chat__msg--me { color: #141312; }

@media (prefers-contrast: more) {
	.adi-chat { --ch-muted: var(--ch-ink); --ch-line: currentColor; }
}

/* Did that help? */

.adi-chat__resolve {
	padding: 12px;
	border: 1px solid var(--ch-line);
	border-radius: 10px;
	background: none;
}
.adi-chat__resolve-q { margin: 0 0 10px; font-size: 13px; color: var(--ch-muted); }
.adi-chat__resolve-row { display: flex; gap: 8px; }

.adi-chat__resolve-btn {
	flex: 1;
	min-height: 40px;
	padding: 9px 14px;
	border: 1px solid var(--ch-line);
	border-radius: 8px;
	background: none;
	color: inherit;
	font: inherit;
	font-size: 13px;
	cursor: pointer;
}
.adi-chat__resolve-btn:hover { border-color: var(--ch-ink); }
.adi-chat__resolve-btn--no:hover { border-color: var(--ch-accent); color: var(--ch-accent); }

/* The answer inside a chat bubble gets the same treatment as the
   accordion: themes colour these elements too. */
.adi-chat__msg--bot,
.adi-chat__msg--bot p,
.adi-chat__msg--bot li,
.adi-chat__msg--bot span,
.adi-chat__msg--bot em { color: var(--ch-ink); background: none; }
.adi-chat__msg--bot strong { color: var(--ch-ink); font-weight: 600; }
.adi-chat__msg--bot ul { margin: 6px 0; padding-left: 18px; }
.adi-chat__msg--bot li { margin: 0 0 5px; }
.adi-chat__msg--bot p:empty { display: none; }
