/*!
 * Kirtsy Core: site chat widget.
 * Loaded on every public page, so it is kept small and self-contained.
 * Contrast (WCAG 2.2 AA): text on the panel >= 12:1, secondary text >= 7:1, white on red >= 5:1.
 */

.kc-chat {
	--kc-deep: var(--void, #0a0c0e);
	--kc-bg: var(--steel, #15191d);
	--kc-bg-2: var(--steel-2, #1b2126);
	--kc-line: var(--line, #2b3238);
	--kc-edge: #6b767f;
	--kc-text: var(--billet, #edeff1);
	--kc-dim: #b9bec2;
	--kc-red: var(--redline, #d81f2a);
	--kc-red-2: var(--redline-2, #a5141d);
	--kc-blue-2: var(--boost-2, #8fcbff);
	--kc-err: #ff7d84;
	--kc-display: 'Big Shoulders', 'Big Shoulders Display', 'Arial Narrow', Impact, sans-serif;
	--kc-body: 'IBM Plex Sans', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
	--kc-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

	position: fixed;
	right: max(16px, env(safe-area-inset-right));
	bottom: max(16px, env(safe-area-inset-bottom));
	z-index: 99990;
	box-sizing: border-box;
	color: var(--kc-text);
	font-family: var(--kc-body);
	font-size: 1rem;
	line-height: 1.5;
	color-scheme: dark;
}

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

.kc-chat [hidden],
.kc-chat[hidden] {
	display: none !important;
}

.kc-chat .kc-sr {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	clip-path: inset(50%) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

.kc-chat .kc-hp {
	position: absolute !important;
	left: -9999px !important;
	top: auto !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.kc-chat :focus-visible {
	outline: 3px solid var(--kc-blue-2);
	outline-offset: 2px;
}

/* Launcher button */
.kc-chat-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 58px;
	margin: 0;
	padding: 0;
	border: 2px solid var(--kc-red);
	border-radius: 50%;
	background: var(--kc-red);
	box-shadow: 0 6px 22px rgba(0, 0, 0, 0.55);
	color: #fff;
	cursor: pointer;
	transition: background-color 0.15s ease, transform 0.15s ease;
}

.kc-chat-toggle:hover {
	background: var(--kc-red-2);
	border-color: var(--kc-red-2);
}

.kc-chat-toggle svg {
	display: block;
	flex: 0 0 auto;
}

/* Panel */
.kc-chat-panel {
	position: absolute;
	right: 0;
	bottom: 70px;
	display: flex;
	flex-direction: column;
	width: min(380px, calc(100vw - 32px));
	max-height: min(580px, calc(100vh - 120px));
	max-height: min(580px, calc(100dvh - 120px));
	overflow: hidden;
	border: 1px solid var(--kc-line);
	border-top: 3px solid var(--kc-red);
	border-radius: 6px;
	background: var(--kc-bg);
	box-shadow: 0 14px 44px rgba(0, 0, 0, 0.65);
}

.kc-chat-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 8px 12px 16px;
	border-bottom: 1px solid var(--kc-line);
	background: var(--kc-bg-2);
}

.kc-chat-head > div {
	min-width: 0;
}

.kc-chat-title {
	margin: 0;
	color: var(--kc-text);
	font-family: var(--kc-display);
	font-size: 1.3rem;
	font-weight: 800;
	letter-spacing: 0.02em;
	line-height: 1.15;
	text-transform: uppercase;
}

.kc-chat-status {
	margin: 2px 0 0;
	color: var(--kc-dim);
	font-size: 0.82rem;
	line-height: 1.35;
}

.kc-chat-close {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: var(--radius, 3px);
	background: transparent;
	color: var(--kc-text);
	font-size: 1.9rem;
	line-height: 1;
	cursor: pointer;
}

.kc-chat-close:hover {
	background: rgba(255, 255, 255, 0.1);
}

/* Messages */
.kc-chat-log {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 10px;
	min-height: 150px;
	padding: 14px 16px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.kc-msg {
	max-width: 90%;
	padding: 10px 13px;
	border-radius: 10px;
	font-size: 0.95rem;
	line-height: 1.45;
	overflow-wrap: anywhere;
	white-space: pre-wrap;
}

.kc-msg-bot {
	align-self: flex-start;
	border-top-left-radius: 2px;
	background: #232a30;
	color: var(--kc-text);
}

.kc-msg-user {
	align-self: flex-end;
	border-top-right-radius: 2px;
	background: var(--kc-red-2);
	color: #fff;
}

.kc-msg-who {
	display: block;
	margin: 0 0 3px;
	color: var(--kc-blue-2);
	font-family: var(--kc-mono);
	font-size: 0.68rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

.kc-typing {
	letter-spacing: 0.2em;
	animation: kc-pulse 1.2s ease-in-out infinite;
}

@keyframes kc-pulse {
	0%,
	100% {
		opacity: 0.45;
	}
	50% {
		opacity: 1;
	}
}

/* Quick questions */
.kc-chat-faqs {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 16px 12px;
}

.kc-chat-faq {
	min-height: 40px;
	margin: 0;
	padding: 8px 14px;
	border: 1px solid var(--kc-edge);
	border-radius: 999px;
	background: transparent;
	color: var(--kc-text);
	font: inherit;
	font-size: 0.86rem;
	line-height: 1.25;
	text-align: left;
	cursor: pointer;
}

.kc-chat-faq:hover {
	border-color: var(--kc-text);
	background: rgba(255, 255, 255, 0.06);
}

/* Composer */
.kc-chat-form {
	margin: 0;
	padding: 10px 16px 12px;
	border-top: 1px solid var(--kc-line);
	background: var(--kc-bg);
}

.kc-chat-emailrow {
	margin: 0 0 8px;
}

.kc-chat-form input[type='text'],
.kc-chat-form input[type='email'] {
	display: block;
	width: 100%;
	min-width: 0;
	min-height: 46px;
	margin: 0;
	padding: 10px 12px;
	border: 1px solid var(--kc-edge);
	border-radius: var(--radius, 3px);
	background: var(--kc-deep);
	box-shadow: none;
	color: var(--kc-text);
	font: inherit;
	font-size: 1rem; /* 16px: no zoom on iOS */
	line-height: 1.3;
}

.kc-chat-form input::placeholder {
	color: #98a0a6;
	opacity: 1;
}

.kc-chat-form input:focus {
	border-color: var(--kc-blue-2);
	outline: 3px solid var(--kc-blue-2);
	outline-offset: 1px;
}

.kc-chat-row {
	display: flex;
	gap: 8px;
}

.kc-chat-send {
	flex: 0 0 auto;
	min-width: 76px;
	min-height: 46px;
	margin: 0;
	padding: 10px 16px;
	border: 2px solid var(--kc-red);
	border-radius: var(--radius, 3px);
	background: var(--kc-red);
	color: #fff;
	font-family: var(--kc-display);
	font-size: 1.05rem;
	font-weight: 800;
	letter-spacing: 0.06em;
	line-height: 1;
	text-transform: uppercase;
	cursor: pointer;
}

.kc-chat-send:hover {
	border-color: var(--kc-red-2);
	background: var(--kc-red-2);
}

.kc-chat-send[disabled] {
	opacity: 0.6;
	cursor: wait;
}

.kc-chat-err {
	margin: 0 0 8px;
	color: var(--kc-err);
	font-size: 0.86rem;
	font-weight: 600;
	line-height: 1.4;
}

.kc-chat-note {
	margin: 8px 0 0;
	color: #aab0b5;
	font-size: 0.74rem;
	line-height: 1.4;
}

/* Phones: the panel becomes a sheet along the bottom edge. */
@media (max-width: 520px) {
	.kc-chat-panel {
		position: fixed;
		right: 0;
		bottom: 0;
		left: 0;
		width: auto;
		max-height: 88vh;
		max-height: 88dvh;
		border-right: 0;
		border-bottom: 0;
		border-left: 0;
		border-radius: 12px 12px 0 0;
		padding-bottom: env(safe-area-inset-bottom);
	}

	.kc-chat.is-open .kc-chat-toggle {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.kc-chat-toggle {
		transition: none;
	}

	.kc-typing {
		animation: none;
	}
}

@media (forced-colors: active) {
	.kc-chat-toggle,
	.kc-chat-send {
		border-color: ButtonText;
	}

	.kc-msg {
		border: 1px solid CanvasText;
	}
}

@media print {
	.kc-chat {
		display: none !important;
	}
}
