/* torque.news AI chat, the visitor-facing window, in the site's own look:
 * a flat amber launcher with dark text, a near-black header carrying the
 * Torque News wordmark and the word Chat, a paper-coloured body with white
 * and amber bubbles, Rajdhani for titles and Barlow for everything else.
 * Everything lives under #tqc-chat-root so the theme's styles stay out. */

#tqc-chat-root {
	--tqc-amber: #f49731;
	--tqc-amber-dark: #d16e02;
	--tqc-ink: #111111;
	--tqc-ink-2: #1b1b1b;
	--tqc-ink-rule: #333333;
	--tqc-paper: #f2f0ea;
	--tqc-panel: #ffffff;
	--tqc-text: #26282c;
	--tqc-muted: #6b7280;
	--tqc-dim: #a9aeb6;
	--tqc-rule: #e2dfd6;
	--tqc-line: #d6d2c8;
	--tqc-radius: 6px;
	--tqc-font-title: 'Rajdhani', 'Arial Narrow', Arial, sans-serif;
	--tqc-font-body: 'Barlow', Arial, Helvetica, sans-serif;
	font-family: var(--tqc-font-body);
	font-size: 14px;
	line-height: 1.5;
	color: var(--tqc-text);
	box-sizing: border-box;
}
#tqc-chat-root *, #tqc-chat-root *::before, #tqc-chat-root *::after { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
	#tqc-chat-root, #tqc-chat-root * {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}
}

/* ---------- Launcher ---------- */
#tqc-chat-root .tqc-launcher {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 90;
	height: 40px;
	padding: 0 16px 0 14px;
	border: 0;
	border-radius: var(--tqc-radius);
	background: var(--tqc-amber);
	color: var(--tqc-ink);
	display: inline-flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	box-shadow: none;
	font-family: var(--tqc-font-title);
	font-weight: 700;
	font-size: 13px;
	line-height: 1;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	transition: background 0.15s ease;
}
#tqc-chat-root .tqc-launcher:hover { background: var(--tqc-amber-dark); }
#tqc-chat-root .tqc-launcher:focus-visible { outline: 2px solid var(--tqc-ink); outline-offset: 2px; }
#tqc-chat-root .tqc-launcher svg { width: 18px; height: 18px; flex-shrink: 0; }
#tqc-chat-root .tqc-launcher__label { white-space: nowrap; padding-top: 1px; }
@media (max-width: 480px) {
	#tqc-chat-root .tqc-launcher { padding: 0; width: 44px; height: 44px; justify-content: center; right: 16px; bottom: 16px; }
	#tqc-chat-root .tqc-launcher__label { display: none; }
	#tqc-chat-root .tqc-launcher svg { width: 22px; height: 22px; }
}

/* ---------- Panel ---------- */
#tqc-chat-root .tqc-panel {
	position: fixed;
	right: 24px;
	bottom: 76px;
	z-index: 90;
	width: 380px;
	max-width: calc(100vw - 24px);
	height: min(600px, calc(100vh - 100px));
	background: var(--tqc-panel);
	color: var(--tqc-text);
	border-radius: 8px;
	border: 1px solid var(--tqc-rule);
	box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.28);
	display: none;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(10px);
	transition: opacity 0.18s ease, transform 0.18s ease;
	transform-origin: bottom right;
}
#tqc-chat-root .tqc-panel.is-open { display: flex; opacity: 1; transform: translateY(0); }
@media (max-width: 480px) {
	#tqc-chat-root .tqc-panel { right: 12px; left: 12px; bottom: 72px; width: auto; max-width: none; height: min(600px, calc(100vh - 90px)); }
}

/* ---------- Header ---------- */
#tqc-chat-root .tqc-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 14px 14px 18px;
	background: var(--tqc-ink);
	border-top: 3px solid var(--tqc-amber);
	border-bottom: 1px solid var(--tqc-ink-rule);
	color: #fff;
}
#tqc-chat-root .tqc-header__meta { flex: 1; min-width: 0; }
#tqc-chat-root .tqc-header__brand { display: flex; align-items: center; gap: 10px; }
#tqc-chat-root .tqc-header__logo { display: block; height: 20px; width: auto; max-width: 150px; }
#tqc-chat-root .tqc-header__name, #tqc-chat-root .tqc-header__word {
	font-family: var(--tqc-font-title);
	font-weight: 700;
	font-size: 20px;
	line-height: 1;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #fff;
}
#tqc-chat-root .tqc-header__word { color: var(--tqc-amber); padding-top: 2px; }
#tqc-chat-root .tqc-header__sub { font-size: 12px; color: var(--tqc-dim); margin-top: 5px; line-height: 1.3; }
#tqc-chat-root .tqc-header__close {
	width: 32px; height: 32px; flex-shrink: 0;
	background: transparent; color: #fff;
	border: 1px solid var(--tqc-ink-rule); border-radius: var(--tqc-radius);
	display: flex; align-items: center; justify-content: center; cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease;
}
#tqc-chat-root .tqc-header__close:hover { border-color: #fff; background: var(--tqc-ink-2); }
#tqc-chat-root .tqc-header__close:focus-visible { outline: 2px solid var(--tqc-amber); outline-offset: 1px; }
#tqc-chat-root .tqc-header__close svg { width: 16px; height: 16px; }

/* ---------- Body ---------- */
#tqc-chat-root .tqc-body {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--tqc-paper);
	scrollbar-width: thin;
	scrollbar-color: var(--tqc-line) transparent;
}
#tqc-chat-root .tqc-body::-webkit-scrollbar { width: 8px; }
#tqc-chat-root .tqc-body::-webkit-scrollbar-thumb { background: var(--tqc-line); border-radius: 8px; }

#tqc-chat-root .tqc-msg-row { display: flex; max-width: 100%; }
#tqc-chat-root .tqc-msg-row.is-user { justify-content: flex-end; }
#tqc-chat-root .tqc-bubble {
	max-width: 86%;
	padding: 10px 14px;
	border-radius: var(--tqc-radius);
	font-size: 14px;
	line-height: 1.5;
	white-space: pre-wrap;
	word-break: break-word;
}
#tqc-chat-root .tqc-msg-row.is-user .tqc-bubble { background: var(--tqc-amber); color: var(--tqc-ink); border-bottom-right-radius: 2px; }
#tqc-chat-root .tqc-msg-row.is-assistant .tqc-bubble { background: var(--tqc-panel); color: var(--tqc-text); border: 1px solid var(--tqc-rule); border-bottom-left-radius: 2px; }
#tqc-chat-root .tqc-msg-row.is-system .tqc-bubble { background: transparent; color: var(--tqc-muted); border: 1px dashed var(--tqc-line); font-size: 12.5px; }
#tqc-chat-root .tqc-bubble a:not(.tqc-cta) { color: var(--tqc-ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--tqc-amber); text-decoration-thickness: 2px; text-underline-offset: 2px; }
#tqc-chat-root .tqc-bubble a:not(.tqc-cta):hover { text-decoration-color: var(--tqc-ink); }
#tqc-chat-root .tqc-bubble code { background: rgba(0, 0, 0, 0.06); padding: 1px 6px; border-radius: 3px; font-size: 12.5px; }
#tqc-chat-root .tqc-bubble strong { font-weight: 700; color: var(--tqc-ink); }
#tqc-chat-root .tqc-bubble em { font-style: italic; }

#tqc-chat-root .tqc-typing { display: inline-flex; gap: 5px; align-items: center; padding: 2px 0; }
#tqc-chat-root .tqc-typing span { width: 7px; height: 7px; background: var(--tqc-amber); border-radius: 999px; opacity: 0.45; animation: tqc-bounce 1.2s infinite ease-in-out; }
#tqc-chat-root .tqc-typing span:nth-child(2) { animation-delay: 0.15s; }
#tqc-chat-root .tqc-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tqc-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.45; } 40% { transform: translateY(-4px); opacity: 1; } }

/* ---------- Lead form ---------- */
#tqc-chat-root .tqc-form { padding: 16px 18px 18px; border-top: 1px solid var(--tqc-rule); background: var(--tqc-panel); display: flex; flex-direction: column; gap: 12px; position: relative; }
#tqc-chat-root .tqc-form label { font-family: var(--tqc-font-title); font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--tqc-muted); display: block; margin-bottom: 4px; }
#tqc-chat-root .tqc-form input[type="text"], #tqc-chat-root .tqc-form input[type="email"], #tqc-chat-root .tqc-form textarea {
	width: 100%; padding: 10px 12px; border: 1px solid var(--tqc-line); border-radius: var(--tqc-radius);
	font-size: 14px; font-family: inherit; background: #fff; color: var(--tqc-text);
}
#tqc-chat-root .tqc-form input::placeholder, #tqc-chat-root .tqc-message-team__form textarea::placeholder { color: var(--tqc-dim); }
#tqc-chat-root .tqc-form input:focus, #tqc-chat-root .tqc-form textarea:focus, #tqc-chat-root .tqc-message-team__form textarea:focus {
	outline: none; border-color: var(--tqc-amber); box-shadow: 0 0 0 3px rgba(244, 151, 49, 0.25);
}
#tqc-chat-root .tqc-form .tqc-hp { position: absolute; left: -9999px; top: -9999px; opacity: 0; }

/* ---------- Consent switch ---------- */
#tqc-chat-root .tqc-form label.tqc-switch { display: flex; gap: 12px; align-items: flex-start; font-family: var(--tqc-font-body); font-size: 12px; color: var(--tqc-muted); line-height: 1.5; cursor: pointer; font-weight: 400; letter-spacing: 0; text-transform: none; margin: 2px 0 0; }
#tqc-chat-root .tqc-switch__input { position: absolute; opacity: 0; width: 1px; height: 1px; overflow: hidden; }
#tqc-chat-root .tqc-switch__track { display: inline-block; position: relative; width: 40px; height: 22px; flex: 0 0 40px; background: var(--tqc-line); border: 1px solid var(--tqc-line); border-radius: 999px; transition: background 0.2s ease, border-color 0.2s ease; }
#tqc-chat-root .tqc-switch__knob { display: block; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 999px; transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease; }
#tqc-chat-root .tqc-switch__input:focus-visible + .tqc-switch__track { box-shadow: 0 0 0 3px rgba(244, 151, 49, 0.3); border-color: var(--tqc-amber); }
#tqc-chat-root .tqc-switch__input:checked + .tqc-switch__track { background: var(--tqc-amber); border-color: var(--tqc-amber); }
#tqc-chat-root .tqc-switch__input:checked + .tqc-switch__track .tqc-switch__knob { background: var(--tqc-ink); transform: translateX(18px); }
#tqc-chat-root .tqc-switch__copy { padding-top: 2px; font-size: 12px; font-weight: 400; color: var(--tqc-muted); line-height: 1.5; }
#tqc-chat-root .tqc-switch__copy a { color: var(--tqc-ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--tqc-amber); text-decoration-thickness: 2px; }

#tqc-chat-root .tqc-form__cta {
	width: 100%; background: var(--tqc-amber); color: var(--tqc-ink);
	border: 0; padding: 12px 18px; border-radius: var(--tqc-radius);
	font-family: var(--tqc-font-title); font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
	cursor: pointer; transition: background 0.15s ease;
}
#tqc-chat-root .tqc-form__cta:hover { background: var(--tqc-amber-dark); }
#tqc-chat-root .tqc-form__cta:disabled { opacity: 0.55; cursor: not-allowed; }
#tqc-chat-root .tqc-form__cta:focus-visible { outline: 2px solid var(--tqc-ink); outline-offset: 2px; }
#tqc-chat-root .tqc-form__error, #tqc-chat-root .tqc-message-team__error { color: #b32d2e; font-size: 12.5px; }
#tqc-chat-root .tqc-form__error:empty, #tqc-chat-root .tqc-message-team__error:empty { display: none; }

/* ---------- Composer ---------- */
#tqc-chat-root .tqc-composer { border-top: 1px solid var(--tqc-rule); padding: 12px; display: flex; gap: 8px; background: var(--tqc-panel); align-items: flex-end; }
#tqc-chat-root .tqc-composer textarea {
	flex: 1; resize: none; max-height: 110px; min-height: 40px; padding: 10px 12px; border: 1px solid var(--tqc-line);
	border-radius: var(--tqc-radius); font-size: 14px; font-family: inherit; background: #fff; color: var(--tqc-text); line-height: 1.4;
}
#tqc-chat-root .tqc-composer textarea::placeholder { color: var(--tqc-dim); }
#tqc-chat-root .tqc-composer textarea:focus { outline: none; border-color: var(--tqc-amber); box-shadow: 0 0 0 3px rgba(244, 151, 49, 0.25); }
#tqc-chat-root .tqc-composer__send {
	background: var(--tqc-amber); color: var(--tqc-ink); border: 0;
	width: 40px; height: 40px; border-radius: var(--tqc-radius); cursor: pointer; display: flex; align-items: center; justify-content: center;
	flex-shrink: 0; transition: background 0.15s ease;
}
#tqc-chat-root .tqc-composer__send:hover { background: var(--tqc-amber-dark); }
#tqc-chat-root .tqc-composer__send:disabled { opacity: 0.4; cursor: not-allowed; }
#tqc-chat-root .tqc-composer__send:focus-visible { outline: 2px solid var(--tqc-ink); outline-offset: 2px; }
#tqc-chat-root .tqc-composer__send svg { width: 18px; height: 18px; }

/* ---------- Footer ---------- */
#tqc-chat-root .tqc-footer { padding: 8px 16px 12px; background: var(--tqc-panel); border-top: 1px solid var(--tqc-rule); font-size: 11px; color: var(--tqc-muted); display: flex; justify-content: space-between; gap: 12px; }
#tqc-chat-root .tqc-footer button { background: none; border: none; color: var(--tqc-muted); cursor: pointer; padding: 0; font-size: 11px; font-family: var(--tqc-font-title); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
#tqc-chat-root .tqc-footer button:hover { color: var(--tqc-ink); }
#tqc-chat-root .tqc-footer button:focus-visible { outline: 2px solid var(--tqc-amber); outline-offset: 2px; }

/* ---------- Quick-reply chips ---------- */
#tqc-chat-root .tqc-msg-row--chips { display: block; }
#tqc-chat-root .tqc-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0; }
#tqc-chat-root .tqc-chip {
	display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
	background: var(--tqc-panel); color: var(--tqc-ink); border: 1px solid var(--tqc-line);
	font-size: 12.5px; font-weight: 600; font-family: inherit; cursor: pointer; text-decoration: none; transition: border-color 0.15s ease, background 0.15s ease;
}
#tqc-chat-root .tqc-chip:hover { border-color: var(--tqc-amber); background: #fff0df; }
#tqc-chat-root .tqc-chip:focus-visible { outline: 2px solid var(--tqc-amber); outline-offset: 2px; }
#tqc-chat-root .tqc-icon { display: inline-flex; align-items: center; }
#tqc-chat-root .tqc-icon svg { width: 13px; height: 13px; opacity: 0.85; }

/* ---------- The call to action the AI offers, inside its bubble ---------- */
#tqc-chat-root .tqc-ctas { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--tqc-rule); display: flex; flex-wrap: wrap; gap: 8px; }
#tqc-chat-root .tqc-cta {
	display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: var(--tqc-radius);
	font-family: var(--tqc-font-title); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
	cursor: pointer; text-decoration: none; background: var(--tqc-ink); color: #fff; border: 0;
	transition: background 0.15s ease, color 0.15s ease;
}
#tqc-chat-root .tqc-cta:hover { background: var(--tqc-amber); color: var(--tqc-ink); }
#tqc-chat-root .tqc-cta:focus-visible { outline: 2px solid var(--tqc-amber); outline-offset: 2px; }
#tqc-chat-root .tqc-cta .tqc-icon svg { width: 14px; height: 14px; }

/* ---------- Message the team overlay ---------- */
#tqc-chat-root .tqc-message-team {
	position: absolute; inset: 0; background: var(--tqc-paper); display: flex; flex-direction: column; z-index: 5;
	opacity: 0; transform: translateY(8px); transition: opacity 0.2s ease, transform 0.2s ease; pointer-events: none;
}
#tqc-chat-root .tqc-message-team.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
#tqc-chat-root .tqc-message-team__header { padding: 16px 18px; background: var(--tqc-ink); border-top: 3px solid var(--tqc-amber); border-bottom: 1px solid var(--tqc-ink-rule); }
#tqc-chat-root .tqc-message-team__title { font-family: var(--tqc-font-title); font-size: 18px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #fff; line-height: 1; }
#tqc-chat-root .tqc-message-team__sub { font-size: 12px; color: var(--tqc-dim); margin-top: 6px; line-height: 1.5; }
#tqc-chat-root .tqc-message-team__body { flex: 1; overflow-y: auto; padding: 16px 18px; }
#tqc-chat-root .tqc-message-team__form textarea {
	width: 100%; padding: 10px 12px; border: 1px solid var(--tqc-line); border-radius: var(--tqc-radius);
	font-size: 14px; font-family: inherit; background: #fff; color: var(--tqc-text); resize: vertical;
}
#tqc-chat-root .tqc-message-team__actions { display: flex; gap: 8px; align-items: center; padding-top: 10px; }
#tqc-chat-root .tqc-message-team__actions .tqc-form__cta { flex: 1; width: auto; }
#tqc-chat-root .tqc-message-team__cancel {
	background: transparent; color: var(--tqc-ink); border: 1px solid var(--tqc-line); padding: 10px 14px; border-radius: var(--tqc-radius);
	font-family: var(--tqc-font-title); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
}
#tqc-chat-root .tqc-message-team__cancel:hover { border-color: var(--tqc-ink); }
#tqc-chat-root .tqc-message-team__cancel:focus-visible { outline: 2px solid var(--tqc-amber); outline-offset: 2px; }

/* ---------- Staging only: lifted above the Bugpot notes button ---------- */
#tqc-chat-root.tqc--lift .tqc-launcher { bottom: 92px; }
#tqc-chat-root.tqc--lift .tqc-panel { bottom: 144px; height: min(600px, calc(100vh - 168px)); }
@media (max-width: 480px) {
	#tqc-chat-root.tqc--lift .tqc-launcher { bottom: 84px; }
	#tqc-chat-root.tqc--lift .tqc-panel { bottom: 140px; height: min(600px, calc(100vh - 160px)); }
}
