/*
 * FCG Assistant.
 *
 * Mobile first: the panel is a full-height sheet on a phone and only becomes
 * a floating card once there is room for one. Sizing uses dvh rather than vh
 * so the panel does not sit under a mobile browser's collapsing toolbar, and
 * the composer carries the safe-area inset so it clears the home indicator.
 */

.fcga {
	--fcga-gold: #b6912c;
	--fcga-gold-bright: #d9b654;
	--fcga-ink: #0a0a0c;

	/* Glass, in the same language as the site header: a dark translucent
	   panel with a blurred backdrop, a hairline edge and an inset highlight
	   along the top so it reads as curved glass rather than a tinted box.
	   Dark rather than light on purpose - white text on a dark pane stays
	   legible whatever photograph happens to be behind it, which a light
	   glass panel cannot promise over this site's hero images. */
	--fcga-surface: rgba(22, 24, 31, 0.72);
	--fcga-edge: rgba(255, 255, 255, 0.2);
	--fcga-line: rgba(255, 255, 255, 0.16);
	--fcga-body: #f7f8fa;
	/* 0.85, not the 0.55 this started at. The faintest text is the first
	   thing to lose contrast as the pane gets more transparent: measured
	   over a white page behind the glass, 0.55 fell to 3.0:1 and 0.62 to
	   3.7:1, both under the 4.5:1 normal-size text needs. 0.85 holds
	   4.75:1 at the current 0.72 pane - which is why 0.72 is the floor.
	   Any more transparency and this line fails before the body text does. */
	--fcga-muted: rgba(255, 255, 255, 0.85);
	--fcga-bot: rgba(255, 255, 255, 0.13);
	/* More blur, not less, now that more of the page shows through - it is
	   the blur that stops busy photography competing with the text. */
	--fcga-blur: blur(32px) saturate(175%);

	/* Bottom-left: on the right it sat over the hero copy and the closing
	   lines of most sections, and that corner belongs to the webchat. */
	position: fixed;
	left: max(16px, env(safe-area-inset-left));
	bottom: max(16px, env(safe-area-inset-bottom));
	z-index: 99998;
	font-family: inherit;
}

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

/* ------------------------------------------------------------- Launcher */

.fcga .fcga-launcher {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 52px;
	padding: 0 20px;
	border: 1px solid rgba(217, 182, 84, 0.9);
	border-radius: 999px;
	background: linear-gradient(180deg, var(--fcga-gold-bright) 0%, var(--fcga-gold) 100%);
	box-shadow: 0 2px 10px rgba(10, 10, 12, 0.25), 0 12px 26px -12px rgba(182, 145, 44, 0.8);
	color: #14100a;
	font: inherit;
	font-size: 15px;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
	transition: box-shadow 0.3s cubic-bezier(0.22, 1, 0.36, 1), transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.fcga .fcga-launcher:hover,
.fcga .fcga-launcher:focus-visible {
	transform: translateY(-2px);
	box-shadow: 0 4px 14px rgba(10, 10, 12, 0.3), 0 18px 32px -12px rgba(182, 145, 44, 0.9);
}

.fcga .fcga-launcher:active {
	transform: translateY(0);
	box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.3);
}

.fcga-launcher__icon {
	display: inline-flex;
	flex: none;
	width: 20px;
	height: 20px;
}

.fcga-launcher__icon svg {
	width: 100%;
	height: 100%;
}

.fcga.is-open .fcga-launcher {
	display: none;
}

/* ---------------------------------------------------------------- Panel */

/* Phone: a bottom sheet, not a takeover. Leaving the top of the page
   visible means the visitor can always see where they were, and tapping it
   is the fastest way back - the same gesture a native sheet uses. */
.fcga-panel {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	top: auto;
	display: flex;
	flex-direction: column;
	height: 86dvh;
	max-height: 86dvh;
	background: linear-gradient(180deg, rgba(38, 41, 52, 0.72) 0%, rgba(18, 19, 25, 0.78) 100%);
	-webkit-backdrop-filter: var(--fcga-blur);
	backdrop-filter: var(--fcga-blur);
	color: var(--fcga-body);
	border-top: 1px solid var(--fcga-edge);
	border-radius: 18px 18px 0 0;
	box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.16);
	/* Native form controls (the scrollbar, the caret) follow this. */
	color-scheme: dark;
	overflow: hidden;
}

/* Safari before 18 and Firefox with backdrop-filter disabled get a solid
   panel instead of unreadable text over a photograph. */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
	.fcga-panel {
		background: linear-gradient(180deg, #2b2e3a 0%, #15161d 100%);
	}
}

.fcga-panel[hidden] {
	display: none;
}

.fcga-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(10, 10, 12, 0.5);
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
}

.fcga-backdrop[hidden] {
	display: none;
}

/* The bar a thumb reaches for first. It is a real button, so it also works
   for a keyboard and a screen reader rather than being decoration. */
.fcga .fcga-grab {
	display: block;
	flex: none;
	width: 100%;
	padding: 10px 0 6px;
	background: transparent;
	border: 0;
	border-radius: 18px 18px 0 0;
	cursor: pointer;
}

.fcga .fcga-grab::before {
	content: "";
	display: block;
	width: 42px;
	height: 4px;
	margin: 0 auto;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.4);
}

.fcga .fcga-grab:hover::before,
.fcga .fcga-grab:focus-visible::before {
	background: var(--fcga-gold-bright);
}

.fcga-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex: none;
	padding: 4px 16px 14px;
	border-bottom: 1px solid rgba(217, 182, 84, 0.18);
	color: #fff;
}

.fcga-head__id {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.fcga-head__dot {
	width: 9px;
	height: 9px;
	flex: none;
	border-radius: 50%;
	background: var(--fcga-gold-bright);
	box-shadow: 0 0 0 3px rgba(217, 182, 84, 0.25);
}

.fcga-head__name {
	display: block;
	font-size: 15px;
	line-height: 1.2;
}

.fcga-head__sub {
	display: block;
	color: #b9bcc4;
	font-size: 12px;
	line-height: 1.3;
}

.fcga .fcga-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	/* 44px: the smallest thing a thumb should have to hit. */
	width: 44px;
	height: 44px;
	margin-right: -8px;
	padding: 0;
	background: none;
	border: 0;
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.fcga .fcga-close:hover,
.fcga .fcga-close:focus-visible {
	background: rgba(255, 255, 255, 0.12);
}

.fcga .fcga-close svg {
	width: 20px;
	height: 20px;
}

/* ------------------------------------------------------------------ Log */

.fcga-log {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.fcga-msg {
	max-width: 85%;
	padding: 11px 14px;
	border-radius: 14px;
	font-size: 15px;
	line-height: 1.5;
	overflow-wrap: anywhere;
}

.fcga-msg p {
	margin: 0;
}

.fcga-msg p + p {
	margin-top: 8px;
}

.fcga-msg--bot {
	align-self: flex-start;
	background: var(--fcga-bot);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-bottom-left-radius: 4px;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
	color: var(--fcga-body);
}

/* The visitor's own words carry the brand colour, so the two speakers are
   never in doubt even at a glance. */
.fcga-msg--user {
	align-self: flex-end;
	background: linear-gradient(180deg, rgba(217, 182, 84, 0.95), rgba(182, 145, 44, 0.95));
	border: 1px solid rgba(230, 201, 107, 0.7);
	border-bottom-right-radius: 4px;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
	color: #14100a;
}

.fcga-msg--error {
	align-self: flex-start;
	background: rgba(180, 35, 24, 0.22);
	border: 1px solid rgba(255, 138, 128, 0.35);
	color: #ffc9c4;
}

/* Contact chips and source links share a row that wraps on narrow screens. */
.fcga-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-self: flex-start;
	max-width: 100%;
	margin-top: -2px;
}

.fcga .fcga-chip,
.fcga .fcga-chip:link,
.fcga .fcga-chip:visited {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	min-height: 40px;
	padding: 0 14px;
	border: 1px solid rgba(217, 182, 84, 0.55);
	border-radius: 999px;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05));
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
	color: var(--fcga-gold-bright);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.fcga .fcga-chip:hover,
.fcga .fcga-chip:focus-visible {
	background: linear-gradient(180deg, var(--fcga-gold-bright), var(--fcga-gold));
	box-shadow: 0 4px 12px rgba(182, 145, 44, 0.35);
	color: #14100a;
	text-decoration: none;
}

.fcga-sources {
	align-self: flex-start;
	max-width: 100%;
	color: var(--fcga-muted);
	font-size: 12.5px;
	line-height: 1.5;
}

.fcga-sources a {
	color: var(--fcga-gold-bright);
	text-decoration: underline;
}

/* Three dots, no layout shift when they are swapped for the real answer. */
.fcga-typing {
	display: inline-flex;
	gap: 4px;
	align-items: center;
	height: 20px;
}

.fcga-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.55);
	animation: fcga-bounce 1.2s infinite ease-in-out;
}

.fcga-typing span:nth-child(2) {
	animation-delay: 0.15s;
}

.fcga-typing span:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes fcga-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.55; }
	30%           { transform: translateY(-4px); opacity: 1; }
}

/* ------------------------------------------------------------- Composer */

.fcga-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	flex: none;
	padding: 10px 12px;
	border-top: 1px solid var(--fcga-line);
	background: rgba(255, 255, 255, 0.04);
}

.fcga .fcga-form textarea {
	flex: 1 1 auto;
	min-width: 0;
	max-height: 120px;
	padding: 11px 14px;
	border: 1px solid rgba(255, 255, 255, 0.16);
	border-radius: 20px;
	background: rgba(255, 255, 255, 0.07);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
	color: #fff;
	font: inherit;
	/* 16px exactly: anything smaller and iOS Safari zooms the page on focus. */
	font-size: 16px;
	line-height: 1.4;
	resize: none;
	overflow-y: auto;
}

.fcga .fcga-form textarea::placeholder {
	color: rgba(255, 255, 255, 0.45);
}

.fcga .fcga-form textarea:focus {
	outline: 2px solid var(--fcga-gold);
	outline-offset: 1px;
	border-color: var(--fcga-gold);
	background: rgba(255, 255, 255, 0.12);
}

.fcga .fcga-send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid var(--fcga-gold);
	border-radius: 50%;
	background: linear-gradient(180deg, var(--fcga-gold-bright), var(--fcga-gold));
	color: #14100a;
	cursor: pointer;
	transition: box-shadow 0.2s ease, opacity 0.2s ease;
}

.fcga .fcga-send svg {
	width: 18px;
	height: 18px;
}

.fcga .fcga-send:hover:not(:disabled),
.fcga .fcga-send:focus-visible {
	box-shadow: 0 4px 12px rgba(182, 145, 44, 0.45);
}

.fcga .fcga-send:disabled {
	opacity: 0.45;
	cursor: default;
}

.fcga-foot {
	flex: none;
	margin: 0;
	padding: 0 14px calc(10px + env(safe-area-inset-bottom));
	color: var(--fcga-muted);
	font-size: 11.5px;
	line-height: 1.4;
	text-align: center;
}

.fcga .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* --------------------------------------------------- Tablet and desktop */

@media (min-width: 600px) {
	.fcga-panel {
		inset: auto;
		left: 0;
		bottom: 0;
		right: auto;
		width: 380px;
		/* Never taller than the viewport, never so short it cannot hold a
		   conversation. */
		height: min(620px, calc(100dvh - 40px));
		max-height: none;
		border: 1px solid var(--fcga-edge);
		border-radius: 16px;
		box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.16);
	}

	/* There is no sheet to dismiss on a desktop, and dimming the whole page
	   for a 380px panel would be heavy-handed. */
	.fcga-backdrop,
	.fcga .fcga-grab {
		display: none;
	}

	.fcga-head {
		padding: 14px 16px;
		border-radius: 15px 15px 0 0;
	}

	.fcga.is-open .fcga-launcher {
		display: none;
	}
}

@media (min-width: 600px) and (max-height: 560px) {
	.fcga-panel {
		height: calc(100dvh - 32px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.fcga .fcga-launcher,
	.fcga .fcga-chip,
	.fcga .fcga-send,
	.fcga .fcga-close {
		transition: none;
	}

	.fcga .fcga-launcher:hover,
	.fcga .fcga-launcher:focus-visible,
	.fcga .fcga-launcher:active {
		transform: none;
	}

	.fcga-typing span {
		animation: none;
	}
}

/* ===================================================== Light glass ==== *
 * A frosted white pane with dark text, for anyone who wants the panel to
 * read lighter than the smoked version above.
 *
 * It is not just the dark palette inverted. Dark glass gets *less* legible
 * the more transparent it is over a white page - white text on a pane that
 * is washing out towards white - which is what pins the dark version at
 * 0.72. Light glass has the opposite failure mode and a much kinder one:
 * dark text over a pale pane stays readable whether the page behind is a
 * black hero photograph or a white costs table. Measured at the values
 * below, body text holds 9:1 over a dark backdrop and better over a light
 * one, so this variant can afford to be more transparent than the dark one.
 * ====================================================================== */

.fcga.fcga--light {
	--fcga-surface: rgba(255, 255, 255, 0.72);
	--fcga-edge: rgba(255, 255, 255, 0.75);
	--fcga-line: rgba(16, 18, 24, 0.12);
	--fcga-body: #171a20;
	--fcga-muted: rgba(23, 26, 32, 0.72);
	--fcga-bot: rgba(255, 255, 255, 0.62);
}

.fcga--light .fcga-panel {
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.78) 0%, rgba(243, 244, 248, 0.72) 100%);
	border-top-color: var(--fcga-edge);
	box-shadow: 0 -12px 40px rgba(10, 10, 12, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.9);
	color-scheme: light;
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
	.fcga--light .fcga-panel {
		background: linear-gradient(180deg, #ffffff 0%, #f3f4f8 100%);
	}
}

.fcga--light .fcga-head {
	border-bottom-color: rgba(182, 145, 44, 0.35);
	color: var(--fcga-body);
}

.fcga--light .fcga-head__sub {
	color: var(--fcga-muted);
}

.fcga--light .fcga-close {
	color: var(--fcga-body);
}

.fcga--light .fcga-close:hover,
.fcga--light .fcga-close:focus-visible {
	background: rgba(16, 18, 24, 0.08);
}

.fcga--light .fcga-grab::before {
	background: rgba(16, 18, 24, 0.28);
}

.fcga--light .fcga-msg--bot {
	border-color: rgba(16, 18, 24, 0.08);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
	color: var(--fcga-body);
}

/* The gold bubble already carries dark ink, so it needs nothing here - it
   is the one element that works identically in both tones. */

.fcga--light .fcga-msg--error {
	background: rgba(180, 35, 24, 0.12);
	border-color: rgba(180, 35, 24, 0.3);
	color: #8a2018;
}

.fcga--light .fcga-chip,
.fcga--light .fcga-chip:link,
.fcga--light .fcga-chip:visited {
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.6));
	border-color: rgba(182, 145, 44, 0.75);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
	color: #6b5312;
}

.fcga--light .fcga-sources a {
	color: #6b5312;
}

.fcga--light .fcga-typing span {
	background: rgba(23, 26, 32, 0.45);
}

.fcga--light .fcga-form {
	background: rgba(255, 255, 255, 0.45);
	border-top-color: var(--fcga-line);
}

.fcga--light .fcga-form textarea {
	background: rgba(255, 255, 255, 0.75);
	border-color: rgba(16, 18, 24, 0.14);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
	color: var(--fcga-body);
}

.fcga--light .fcga-form textarea::placeholder {
	color: rgba(23, 26, 32, 0.5);
}

.fcga--light .fcga-form textarea:focus {
	background: rgba(255, 255, 255, 0.95);
}

.fcga--light .fcga-backdrop {
	background: rgba(10, 10, 12, 0.35);
}
