/* Chat widget. Ink launcher, paper panel, ink for the visitor. */

.adbull-chat {
	--chat-radius: 12px;
	--chat-bubble: 10px;
	--chat-edge: 24px;
}

.adbull-chat__launch {
	visibility: visible;
	position: fixed;
	z-index: 160;
	right: var(--chat-edge);
	bottom: calc(var(--chat-edge) + env(safe-area-inset-bottom) + var(--adbull-chat-lift, 0px));
	display: inline-flex;
	align-items: center;
	gap: 0.55em;
	min-height: 44px;
	padding: 0 16px 0 14px;
	border: 1px solid rgba(255, 255, 255, 0.22);
	border-radius: 999px;
	background: var(--ink);
	color: #fff;
	font-family: var(--font);
	font-size: 15px;
	font-weight: 650;
	line-height: 1;
	cursor: pointer;
	box-shadow: var(--shadow-lg);
	transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.adbull-chat__launch:hover {
	background: var(--ink-2);
	transform: translateY(-2px);
}

/* Ink launcher with a lime bubble: present without competing with the lime calls to action.
   The faint light edge keeps it visible over the dark sections too. */
.adbull-chat__bubble {
	flex: none;
	color: var(--lime);
}

.adbull-chat__launch-label {
	display: grid;
	justify-items: start;
}

.adbull-chat__launch-open,
.adbull-chat__launch-close {
	grid-area: 1 / 1;
}

.adbull-chat__launch-close {
	visibility: hidden;
}

.adbull-chat.is-open .adbull-chat__launch-open {
	visibility: hidden;
}

.adbull-chat.is-open .adbull-chat__launch-close {
	visibility: visible;
}

.adbull-chat__panel {
	position: fixed;
	z-index: 170;
	right: var(--chat-edge);
	bottom: calc(var(--chat-edge) + 60px + env(safe-area-inset-bottom) + var(--adbull-chat-lift, 0px));
	display: flex;
	flex-direction: column;
	width: min(400px, calc(100vw - 48px));
	height: min(760px, calc(100dvh - 100px));
	overflow: hidden;
	background: var(--paper);
	color: var(--ink);
	border: 1px solid var(--line);
	border-radius: var(--chat-radius);
	box-shadow: 0 22px 50px -28px rgba(25, 28, 25, 0.55);
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

.adbull-chat__panel.is-open {
	opacity: 1;
	transform: none;
}

.adbull-chat__panel[hidden] {
	display: none;
}

.adbull-chat__head {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: none;
	padding: 16px 8px 14px 18px;
	border-bottom: 1px solid var(--line);
	background: var(--surface-2);
}

.adbull-chat__id {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	min-width: 0;
	flex: 1;
	gap: 5px;
}

.adbull-chat__brand {
	margin: 0;
	color: var(--ink);
	font-size: 22px;
	line-height: 1;
}

.adbull-chat__brand:focus {
	outline: none;
}

.adbull-chat__mark {
	display: flex;
}

.adbull-chat__wordmark {
	display: block;
	width: auto;
	height: 0.84em;
	overflow: visible;
}

.adbull-chat__sub {
	margin: 0;
	color: var(--text-muted);
	font-size: 13px;
	line-height: 1.3;
}

.adbull-chat__clear,
.adbull-chat__close,
.adbull-chat__send,
.adbull-chat__chips button,
.adbull-chat__jump,
.adbull-chat__error button,
.adbull-chat__error a {
	font-family: var(--font);
}

.adbull-chat__clear {
	flex: none;
	min-height: 44px;
	padding: 0 8px;
	border: 0;
	background: transparent;
	color: var(--text-muted);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.adbull-chat__clear:hover {
	color: var(--ink);
}

.adbull-chat__close,
.adbull-chat__send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 48px;
	height: 48px;
	border-radius: var(--radius-sm);
	cursor: pointer;
}

.adbull-chat__close {
	border: 0;
	background: transparent;
	color: var(--ink);
}

.adbull-chat__close:hover {
	background: var(--surface);
}

.adbull-chat__log {
	position: relative;
	flex: 1;
	min-height: 0;
	overflow: auto;
	padding: 16px 20px 8px;
}

.adbull-chat__thread {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.adbull-chat__msg {
	max-width: 92%;
	padding: 12px 14px;
	border-radius: var(--chat-bubble);
	font-size: 16px;
	line-height: 1.5;
	overflow-wrap: anywhere;
}

.adbull-chat__msg p {
	margin: 0;
}

.adbull-chat__msg p + p {
	margin-top: 0.7em;
}

.adbull-chat__msg a {
	color: inherit;
	font-weight: 650;
	text-underline-offset: 3px;
}

.adbull-chat__msg--bot {
	align-self: flex-start;
	background: var(--surface);
	color: var(--ink);
}

.adbull-chat__msg--user {
	align-self: flex-end;
	background: var(--ink);
	color: var(--paper);
}

.adbull-chat__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 12px;
}

.adbull-chat__chips[hidden],
.adbull-chat__jump[hidden] {
	display: none;
}

.adbull-chat__chips button {
	min-height: 44px;
	padding: 8px 12px;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	color: var(--ink);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	text-align: left;
	cursor: pointer;
}

.adbull-chat__chips button:hover {
	border-color: var(--ink);
	background: var(--lime);
}

.adbull-chat__chips--follow {
	margin-top: 10px;
}

.adbull-chat__msg--lead {
	max-width: 100%;
}

.adbull-chat__lead {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 12px;
}

.adbull-chat__lead label {
	display: flex;
	flex-direction: column;
	gap: 4px;
	color: var(--ink);
	font-size: 13px;
	font-weight: 650;
}

.adbull-chat__lead input:not(.adbull-chat__hp) {
	width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 8px 10px;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	color: var(--ink);
	font-family: var(--font);
	font-size: 16px;
	font-weight: 450;
	line-height: 1.4;
}

.adbull-chat__lead input:not(.adbull-chat__hp)::placeholder {
	color: #4e5348;
	opacity: 1;
}

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

.adbull-chat__lead-error,
.adbull-chat__sent {
	margin: 8px 0 0;
	font-size: 14px;
	line-height: 1.45;
}

.adbull-chat__lead-error {
	color: var(--danger);
}

.adbull-chat__lead-error[hidden] {
	display: none;
}

.adbull-chat__sent {
	color: var(--success-ink);
}

.adbull-chat__cta {
	display: flex;
	width: 100%;
	margin-top: 12px;
	white-space: normal;
	text-align: center;
}

.adbull-chat__pending {
	position: relative;
	align-self: flex-start;
	display: flex;
	align-items: center;
	min-height: 44px;
	margin: 0;
	padding: 12px 16px;
	border-radius: var(--chat-bubble);
	background: var(--surface);
	color: var(--text-muted);
	font-size: 15px;
	line-height: 1.2;
	animation: adbull-wait-in 180ms ease-out;
}

.adbull-chat__status {
	position: relative;
}

.adbull-chat__pending:not(.is-typing) .adbull-chat__status::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: -4px;
	width: 100%;
	height: 2px;
	border-radius: 2px;
	background: var(--lime);
	transform-origin: left center;
	animation: adbull-read 1.05s ease-out infinite;
}

.adbull-chat__dots {
	display: none;
	align-items: center;
	gap: 5px;
	height: 10px;
}

.adbull-chat__pending.is-typing .adbull-chat__status {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.adbull-chat__pending.is-typing .adbull-chat__dots {
	display: flex;
}

.adbull-chat__dots span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--ink);
	opacity: 0.28;
	animation: adbull-type 1s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

.adbull-chat__dots span:nth-child(2) {
	animation-delay: 0.14s;
}

.adbull-chat__dots span:nth-child(3) {
	animation-delay: 0.28s;
}

@keyframes adbull-wait-in {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes adbull-read {
	0% {
		transform: scaleX(0.15);
		opacity: 0.4;
	}
	55% {
		transform: scaleX(1);
		opacity: 1;
	}
	100% {
		transform: scaleX(1);
		opacity: 0;
	}
}

@keyframes adbull-type {
	0%,
	60%,
	100% {
		transform: translateY(0);
		opacity: 0.28;
	}
	30% {
		transform: translateY(-3px);
		opacity: 1;
	}
}

.adbull-chat__error {
	align-self: stretch;
	padding: 12px 14px;
	border: 1px solid var(--danger-line);
	border-radius: var(--chat-bubble);
	background: var(--danger-bg);
	color: var(--ink);
	font-size: 15px;
	line-height: 1.45;
}

.adbull-chat__error p {
	margin: 0 0 10px;
}

.adbull-chat__error .adbull-chat__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.adbull-chat__error button,
.adbull-chat__error a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 12px;
	border: 1px solid var(--ink);
	border-radius: var(--radius-sm);
	background: var(--paper);
	color: var(--ink);
	font-size: 14px;
	font-weight: 650;
	text-decoration: none;
	cursor: pointer;
}

.adbull-chat__error button {
	background: var(--ink);
	color: var(--paper);
}

.adbull-chat__jump {
	align-self: center;
	margin: 0 0 8px;
	min-height: 44px;
	padding: 0 14px;
	border: 1px solid var(--ink);
	border-radius: var(--radius-sm);
	background: var(--lime);
	color: var(--ink);
	font-size: 14px;
	font-weight: 650;
	cursor: pointer;
}

.adbull-chat__form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	flex: none;
	padding: 8px 12px 8px 16px;
	border-top: 1px solid var(--line);
	background: var(--surface-2);
}

.adbull-chat__input {
	flex: 1;
	min-width: 0;
	max-height: calc(1.5em * 4 + 18px);
	margin: 0;
	padding: 12px 0;
	border: 0;
	resize: none;
	overflow: auto;
	background: transparent;
	color: var(--ink);
	font-family: var(--font);
	font-size: 16px;
	line-height: 1.5;
}

.adbull-chat__input::placeholder {
	color: #4e5348;
	opacity: 1;
}

.adbull-chat__input:focus,
.adbull-chat__input:focus-visible {
	outline: none;
	box-shadow: none;
}

.adbull-chat__form:focus-within {
	box-shadow: none;
}

.adbull-chat__send:focus-visible {
	outline: 2px solid var(--ink);
	outline-offset: 2px;
}

.adbull-chat__send {
	border: 1px solid var(--ink);
	background: var(--lime);
	color: var(--ink);
}

.adbull-chat__send:hover {
	background: #c8ef3f;
}

.adbull-chat__send:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.adbull-chat__privacy {
	flex: none;
	margin: 0;
	padding: 0 16px 12px;
	background: var(--surface-2);
	font-size: 13px;
}

.adbull-chat__privacy a {
	color: var(--text-muted);
	font-weight: 650;
	text-underline-offset: 3px;
}

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

@media (max-width: 767px) {
	/* Hide chat while the mobile offcanvas nav is open. */
	html.is-nav-open .adbull-chat {
		visibility: hidden;
		pointer-events: none;
	}

	.adbull-chat__launch {
		right: 16px;
		bottom: calc(16px + env(safe-area-inset-bottom) + var(--adbull-chat-lift, 0px));
		justify-content: center;
		width: 48px;
		height: 48px;
		padding: 0;
		gap: 0;
	}

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

	.adbull-chat.is-open .adbull-chat__launch {
		display: none;
	}

	.adbull-chat__panel {
		inset: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		height: 100%;
		max-height: none;
		border: 0;
		border-radius: 0;
	}

	.adbull-chat__head {
		padding-top: max(16px, env(safe-area-inset-top));
	}

	.adbull-chat__log {
		padding: 16px 16px 8px;
	}

	.adbull-chat__privacy {
		padding: 0 16px 8px;
	}

	.adbull-chat__form {
		padding-bottom: max(8px, env(safe-area-inset-bottom));
	}

	/* Keyboard open: dock input to the keyboard, free vertical space. */
	.adbull-chat.is-keyboard .adbull-chat__privacy,
	.adbull-chat.is-keyboard .adbull-chat__chips {
		display: none;
	}

	.adbull-chat.is-keyboard .adbull-chat__head {
		padding-top: max(10px, env(safe-area-inset-top));
		padding-bottom: 10px;
	}

	.adbull-chat.is-keyboard .adbull-chat__form {
		padding-bottom: 8px;
		border-top-color: var(--line);
	}

	.adbull-chat.is-keyboard .adbull-chat__log {
		padding-top: 12px;
	}

	html.is-chat-open,
	html.is-chat-open body {
		overflow: hidden;
		height: 100%;
		overscroll-behavior: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.adbull-chat__launch,
	.adbull-chat__panel,
	.adbull-chat__pending,
	.adbull-chat__pending:not(.is-typing) .adbull-chat__status::after,
	.adbull-chat__dots span {
		transition: none;
		animation: none;
	}

	.adbull-chat__launch:hover {
		transform: none;
	}

	.adbull-chat__pending.is-typing .adbull-chat__status {
		position: static;
		width: auto;
		height: auto;
		margin: 0;
		overflow: visible;
		clip: auto;
		white-space: normal;
	}

	.adbull-chat__pending.is-typing .adbull-chat__dots {
		display: none;
	}
}
