/* ==========================================================================
   Gertrudes — Messenger chat launcher (2026-08-22)
   --------------------------------------------------------------------------
   Four-state progressive disclosure, replacing the permanent orange
   "Chat with us" pill (which was a hand-pasted snippet in the analytics
   admin field): quiet launcher → hover lift → one-time greeting bubble →
   presentation panel that hands off to Messenger (m.me). Markup + behavior:
   common/footer.twig + javascript/plaza/gtr-chat/gtr-chat.js.

   The root keeps the legacy `messenger-float` class ON PURPOSE: every
   existing "widget yields while a drawer/panel is open" rule targets it
   (gtr-header.css, header-mobile.css, gtr-annbar.css) and visibility
   inherits, so the whole widget still bows out correctly.

   Visual hierarchy per the approved spec: the Messenger mark keeps its
   natural gradient (recognition); Gertrudes shows up around it — the peach
   welcome tint, orange chip borders, the shop logo avatar.
   ========================================================================== */

:root {
	--gc-orange: #c73e12;
	--gc-orange-soft: #fdeee6;
	--gc-peach: #fff4ee;
	--gc-ink: #2f2a26;
	--gc-muted: #6f6862;
	--gc-line: #e7ded6;
	--gc-line-soft: #f1ebe4;
	--gc-green: #31a24c;
}

.gtr-chat {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 9999;
	font-family: inherit;
}

/* --------------------------------------------------------------------------
   1. Launcher — white circle, natural Messenger mark
   -------------------------------------------------------------------------- */
.gtr-chat__launcher {
	position: relative;   /* anchors the notification badge */
	display: flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 58px;
	padding: 0;
	border: 1px solid var(--gc-line);
	border-radius: 50%;
	background: #fff;
	cursor: pointer;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.10);
	transition: transform 180ms ease, box-shadow 180ms ease;
}

.gtr-chat__launcher:hover,
.gtr-chat__launcher:focus-visible {
	background: #fff;
	transform: translateY(-2px) scale(1.04);
	/* Lift + a subtle warm Gertrudes halo. No bouncing, no pulsing. */
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14), 0 0 0 7px rgba(199, 62, 18, 0.08);
}

.gtr-chat__launcher:active {
	background: #fff;
	transform: translateY(-1px) scale(1.01);
}

.gtr-chat__icon {
	display: block;
	width: 32px;
	height: 32px;
}

/* Open state: the launcher becomes the collapse control (spec option B). */
.gtr-chat__icon--close {
	display: none;
	width: 26px;
	height: 26px;
	color: var(--gc-ink);
}

.gtr-chat.is-open .gtr-chat__icon--brand { display: none; }
.gtr-chat.is-open .gtr-chat__icon--close { display: block; }

/* Notification badge — Messenger-red unread count on the launcher's top
   right corner. gtr-chat.js drives the states: .is-in pops it in with a
   small spring, .is-bump re-fires when the count increments, .is-out
   shrinks it away when the chat is opened ("read"). */
.gtr-chat__badge {
	position: absolute;
	top: -5px;
	right: -5px;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border: 2px solid #fff;
	border-radius: 999px;
	background: #fa383e;
	color: #fff;
	font-size: 12.5px;
	font-weight: 700;
	line-height: 1;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.20);
	transform: scale(0);
	pointer-events: none;
}

.gtr-chat__badge[hidden] { display: none; }

.gtr-chat__badge.is-in {
	animation: gc-badge-pop 380ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.gtr-chat__badge.is-bump {
	/* forwards keeps scale(1) after the bump settles */
	animation: gc-badge-bump 320ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.gtr-chat__badge.is-out {
	animation: gc-badge-out 200ms ease forwards;
}

@keyframes gc-badge-pop {
	0%   { transform: scale(0.2); opacity: 0; }
	60%  { transform: scale(1.15); opacity: 1; }
	100% { transform: scale(1); opacity: 1; }
}

@keyframes gc-badge-bump {
	0%   { transform: scale(1); }
	45%  { transform: scale(1.3); }
	100% { transform: scale(1); }
}

@keyframes gc-badge-out {
	from { transform: scale(1); opacity: 1; }
	to   { transform: scale(0); opacity: 0; }
}

/* --------------------------------------------------------------------------
   2. Greeting bubble — a real message bubble, not a browser tooltip
   -------------------------------------------------------------------------- */
.gtr-chat__greeting {
	position: absolute;
	right: 4px;
	bottom: calc(100% + 14px);
	width: 250px;
	max-width: calc(100vw - 32px);
	padding: 14px 36px 14px 16px;
	border-radius: 14px;
	background: #fff;
	color: #333;
	font-size: 14px;
	line-height: 1.5;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
	cursor: pointer;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 220ms ease, transform 220ms ease;
}

.gtr-chat__greeting[hidden] { display: none; }

.gtr-chat__greeting.is-in {
	opacity: 1;
	transform: translateY(0);
}

.gtr-chat__greeting p {
	margin: 0;
}

/* Speech tail pointing at the launcher. */
.gtr-chat__greeting::after {
	content: "";
	position: absolute;
	right: 22px;
	bottom: -6px;
	width: 12px;
	height: 12px;
	background: #fff;
	transform: rotate(45deg);
	box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.06);
}

.gtr-chat__greeting-x {
	position: absolute;
	top: 4px;
	right: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #9b938b;
	cursor: pointer;
}

.gtr-chat__greeting-x:hover,
.gtr-chat__greeting-x:active {
	background: var(--gc-orange-soft);
	color: var(--gc-ink);
}

.gtr-chat__greeting-x svg {
	width: 14px;
	height: 14px;
}

/* --------------------------------------------------------------------------
   3. Panel — white header / peach welcome / chips / composer hand-off
   -------------------------------------------------------------------------- */
.gtr-chat__panel {
	position: fixed;
	right: 24px;
	bottom: 96px;
	display: flex;
	flex-direction: column;
	width: 372px;
	max-width: calc(100vw - 32px);
	max-height: min(520px, calc(100vh - 130px));
	overflow: hidden;
	border: 1px solid var(--gc-line-soft);
	border-radius: 18px;
	background: #fff;
	box-shadow: 0 18px 50px rgba(35, 27, 25, 0.22);
	opacity: 0;
	transform: translateY(10px);
	transition: opacity 220ms ease, transform 220ms ease;
}

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

.gtr-chat__panel.is-in {
	opacity: 1;
	transform: translateY(0);
}

/* Header: white, identity left, close right. */
.gtr-chat__head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 12px 12px 14px;
	border-bottom: 1px solid var(--gc-line-soft);
}

.gtr-chat__avatar {
	display: block;
	width: 40px;
	height: 40px;
	padding: 3px;
	border: 1px solid var(--gc-line);
	border-radius: 50%;
	background: #fff;
	object-fit: contain;
	flex: 0 0 auto;
}

.gtr-chat__id {
	flex: 1 1 auto;
	min-width: 0;
}

.gtr-chat__name {
	display: block;
	color: var(--gc-ink);
	font-size: 14.5px;
	font-weight: 700;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.gtr-chat__status {
	display: flex;
	align-items: center;
	gap: 5px;
	color: var(--gc-muted);
	font-size: 12px;
	line-height: 1.3;
}

.gtr-chat__dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--gc-green);
	flex: 0 0 auto;
}

.gtr-chat__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--gc-muted);
	cursor: pointer;
	flex: 0 0 auto;
}

.gtr-chat__close:hover,
.gtr-chat__close:active {
	background: var(--gc-orange-soft);
	color: var(--gc-ink);
}

.gtr-chat__close svg {
	width: 18px;
	height: 18px;
}

/* Body: welcome message + quick actions. */
.gtr-chat__body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px 14px;
}

.gtr-chat__msg {
	max-width: 92%;
	padding: 12px 14px;
	border-radius: 4px 16px 16px 16px;
	background: var(--gc-peach);
	color: #3b332e;
	font-size: 14px;
	line-height: 1.55;
}

.gtr-chat__msg p {
	margin: 0;
}

.gtr-chat__msg p + p {
	margin-top: 4px;
}

.gtr-chat__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 14px;
}

/* Outlined pills — deliberately not filled orange. */
.gtr-chat__chip {
	display: inline-flex;
	align-items: center;
	padding: 8px 14px;
	border: 1px solid rgba(199, 62, 18, 0.35);
	border-radius: 999px;
	background: #fff;
	color: var(--gc-ink);
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	transition: background 160ms ease, border-color 160ms ease;
}

.gtr-chat__chip:hover,
.gtr-chat__chip:focus {
	background: var(--gc-orange-soft);
	border-color: rgba(199, 62, 18, 0.6);
	color: var(--gc-ink);
	text-decoration: none;
}

/* Composer: input-styled hand-off — tapping it continues in Messenger. */
.gtr-chat__composer {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 46px;
	margin: 12px 14px 14px;
	padding: 0 16px;
	border: 1px solid var(--gc-line);
	border-radius: 999px;
	background: #fff;
	color: #8a8178;
	font-size: 14px;
	text-decoration: none;
	transition: border-color 160ms ease, background 160ms ease;
}

.gtr-chat__composer:hover,
.gtr-chat__composer:focus {
	border-color: rgba(199, 62, 18, 0.45);
	background: #fffdfb;
	color: #8a8178;
	text-decoration: none;
}

.gtr-chat__composer-text {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.gtr-chat__composer-icons {
	flex: 0 0 auto;
	font-size: 16px;
	letter-spacing: 6px;
	opacity: 0.85;
}

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

/* --------------------------------------------------------------------------
   4. Phones — near-full-screen panel; the header X is the close control
   -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
	.gtr-chat {
		right: 16px;
		bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	}

	.gtr-chat__launcher {
		width: 52px;
		height: 52px;
	}

	.gtr-chat__icon {
		width: 29px;
		height: 29px;
	}

	/* The panel covers the corner, so the launcher yields while open —
	   one close control (the header X), not two. */
	.gtr-chat.is-open .gtr-chat__launcher {
		opacity: 0;
		pointer-events: none;
	}

	.gtr-chat__panel {
		top: 72px;
		right: 12px;
		bottom: calc(12px + env(safe-area-inset-bottom, 0px));
		left: 12px;
		width: auto;
		max-width: none;
		max-height: none;
	}

	.gtr-chat__composer {
		margin-bottom: 12px;
	}
}

/* --------------------------------------------------------------------------
   5. Focus + reduced motion
   -------------------------------------------------------------------------- */
/* !important answers stylesheet.css:7's global *:focus{outline:none !important}. */
.gtr-chat button:focus-visible,
.gtr-chat a:focus-visible {
	outline: 2px solid var(--gc-orange) !important;
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.gtr-chat__launcher,
	.gtr-chat__greeting,
	.gtr-chat__panel,
	.gtr-chat__chip,
	.gtr-chat__composer {
		transition: none;
	}

	.gtr-chat__launcher:hover,
	.gtr-chat__launcher:focus-visible {
		transform: none;
	}

	/* Badge states become instant: visible at rest, gone when read. */
	.gtr-chat__badge.is-in,
	.gtr-chat__badge.is-bump {
		animation: none;
		transform: scale(1);
	}

	.gtr-chat__badge.is-out {
		animation: none;
		transform: scale(0);
	}
}
