/* ==========================================================================
   AI Chat — site-wide
   ========================================================================== */

.er-chat {
	position: fixed;
	inset: 0;
	z-index: 520;
	display: grid;
	place-items: end end;
	padding: max(1rem, env(safe-area-inset-top, 0px))
		max(1rem, env(safe-area-inset-right, 0px))
		max(1rem, env(safe-area-inset-bottom, 0px))
		max(1rem, env(safe-area-inset-left, 0px));
	pointer-events: none;
	box-sizing: border-box;
}

.er-chat[hidden] {
	display: none;
}

.er-chat__panel {
	width: min(22rem, 100%);
	max-width: 100%;
	max-height: min(32rem, calc(100dvh - 2rem));
	display: flex;
	flex-direction: column;
	min-width: 0;
	background: rgba(22, 25, 24, 0.96);
	border: 1px solid var(--er-color-border);
	border-radius: var(--er-radius-lg);
	box-shadow: var(--er-shadow);
	backdrop-filter: blur(16px);
	pointer-events: auto;
	overflow: hidden;
	box-sizing: border-box;
}

.er-chat__head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 1rem 1rem 0.5rem;
	border-bottom: 1px solid var(--er-color-border);
	min-width: 0;
	box-sizing: border-box;
}

.er-chat__head > div {
	min-width: 0;
	flex: 1 1 auto;
}

.er-chat__eyebrow {
	margin: 0;
	font-size: 0.625rem;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--er-gold);
}

.er-chat__title {
	margin: 0.15rem 0 0;
	font-family: var(--er-font-display);
	font-size: clamp(1.05rem, 4.5vw, 1.25rem);
	line-height: 1.25;
	color: #fff;
	overflow-wrap: break-word;
}

.er-chat__close {
	flex-shrink: 0;
	border: 0;
	background: transparent;
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
	color: var(--er-color-text-muted);
}

.er-chat__messages {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.65rem;
	min-width: 0;
	box-sizing: border-box;
}

.er-chat__msg {
	max-width: min(92%, 100%);
	padding: 0.65rem 0.8rem;
	border-radius: 12px;
	font-size: 0.875rem;
	line-height: 1.5;
	box-sizing: border-box;
	overflow-wrap: anywhere;
	word-wrap: break-word;
}

.er-chat__msg p {
	margin: 0;
}

.er-chat__msg--bot {
	align-self: flex-start;
	background: var(--er-color-surface);
	color: #fff;
}

.er-chat__msg--user {
	align-self: flex-end;
	background: var(--er-gold);
	color: var(--er-ink);
}

.er-chat__gate {
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
	min-width: 0;
	box-sizing: border-box;
}

.er-chat__gate[hidden],
.er-chat__body[hidden] {
	display: none !important;
}

.er-chat__gate-text {
	margin: 0;
	font-size: 0.9rem;
	line-height: 1.5;
	color: #fff;
	overflow-wrap: break-word;
	word-wrap: break-word;
	max-width: 100%;
}

.er-chat__gate-form {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 0.5rem;
	align-items: stretch;
	width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

.er-chat__body {
	display: flex;
	flex-direction: column;
	min-height: 0;
	min-width: 0;
	flex: 1;
}

.er-chat__msg--typing {
	padding: 0.75rem 1rem;
	min-width: 3.25rem;
}

.er-chat__dots {
	display: inline-flex;
	align-items: center;
	gap: 0.28rem;
	height: 0.85rem;
}

.er-chat__dots i {
	display: block;
	width: 0.38rem;
	height: 0.38rem;
	border-radius: 50%;
	background: rgba(245, 241, 234, 0.75);
	animation: er-chat-dot 1.15s ease-in-out infinite;
}

.er-chat__dots i:nth-child(2) {
	animation-delay: 0.15s;
}

.er-chat__dots i:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes er-chat-dot {
	0%,
	80%,
	100% {
		opacity: 0.35;
		transform: translateY(0);
	}
	40% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

.er-chat__hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.er-chat__form {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 0.5rem;
	padding: 0.75rem;
	border-top: 1px solid var(--er-color-border);
	min-width: 0;
	box-sizing: border-box;
}

.er-chat__input {
	width: 100%;
	min-width: 0;
	padding: 0.6rem 0.75rem;
	border: 1px solid var(--er-color-border);
	border-radius: var(--er-radius-sm);
	font: inherit;
	background: var(--er-color-bg-soft);
	color: #fff;
	box-sizing: border-box;
}

.er-chat__send {
	cursor: pointer;
	flex-shrink: 0;
	white-space: nowrap;
	max-width: 100%;
}

.er-chat__gate-form .er-chat__send,
.er-chat__form .er-chat__send {
	padding-inline: 0.85rem;
	letter-spacing: 0.1em;
	font-size: 0.625rem;
}

.er-chat__fab {
	position: fixed;
	right: max(1.25rem, var(--er-container-gutter));
	bottom: max(1.25rem, var(--er-container-gutter));
	left: auto;
	z-index: 455;
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5rem;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: #fff;
	cursor: pointer;
	box-shadow: none;
	backdrop-filter: none;
}

.er-chat__fab-label {
	font-family: var(--er-font-booking);
	font-size: 0.8125rem;
	font-weight: var(--er-weight-semibold);
	letter-spacing: 0.06em;
	text-transform: none;
	white-space: nowrap;
	color: #fff;
	text-shadow:
		0 2px 14px rgba(0, 0, 0, 0.65),
		0 0 18px rgba(201, 169, 106, 0.35);
	animation: er-chat-fab-float 2.4s var(--er-ease-luxury) infinite;
	will-change: transform, text-shadow;
}

.er-chat__fab:hover .er-chat__fab-label {
	color: var(--er-gold-light);
	animation-play-state: paused;
	transform: translateY(-2px);
}

@keyframes er-chat-fab-float {
	0%,
	100% {
		transform: translateY(0);
		text-shadow:
			0 2px 14px rgba(0, 0, 0, 0.65),
			0 0 12px rgba(201, 169, 106, 0.2);
		opacity: 0.88;
	}

	40% {
		transform: translateY(-0.45rem);
		text-shadow:
			0 6px 20px rgba(0, 0, 0, 0.55),
			0 0 22px rgba(201, 169, 106, 0.55);
		opacity: 1;
	}

	70% {
		transform: translateY(-0.2rem);
		opacity: 0.96;
	}
}

.er-chat__fab[hidden] {
	display: none;
}

.er-chat__fab-horse {
	display: block;
	width: 5.75rem;
	height: 3.65rem;
	object-fit: contain;
	object-position: center;
	filter: drop-shadow(0 3px 12px rgba(0, 0, 0, 0.45));
	pointer-events: none;
}

.er-chat__fab .er-activity-icon {
	width: 3.5rem;
	height: 3.5rem;
	margin: 0;
	color: #fff;
	filter: drop-shadow(0 3px 12px rgba(0, 0, 0, 0.45));
}

.er-inquiry-open .er-chat,
.er-inquiry-open .er-chat__fab {
	visibility: hidden;
	pointer-events: none;
}

@media (max-width: 48rem) {
	.er-chat {
		place-items: end stretch;
		padding: max(0.75rem, env(safe-area-inset-top, 0px))
			max(0.85rem, env(safe-area-inset-right, 0px))
			max(0.85rem, env(safe-area-inset-bottom, 0px))
			max(0.85rem, env(safe-area-inset-left, 0px));
	}

	.er-chat__panel {
		width: 100%;
		max-width: 100%;
		max-height: min(78svh, 38rem);
		border-radius: 14px;
	}

	.er-chat__gate-form {
		grid-template-columns: 1fr;
	}

	.er-chat__gate-form .er-chat__send {
		width: 100%;
		min-height: 2.75rem;
	}

	.er-chat__form {
		grid-template-columns: minmax(0, 1fr) auto;
	}

	.er-chat__fab {
		right: max(0.85rem, env(safe-area-inset-right, 0px));
		bottom: max(0.85rem, env(safe-area-inset-bottom, 0px));
		z-index: 455;
	}

	.er-chat__fab-label {
		font-size: 0.8125rem;
	}

	.er-chat__fab-horse {
		width: 5.15rem;
		height: 3.25rem;
	}

	.er-chat__fab .er-activity-icon {
		width: 3.15rem;
		height: 3.15rem;
	}
}

/* Homepage hero: keep chat clear of the booking bar */
@media (max-width: 48rem) {
	.er-journey-body .er-chat__fab {
		bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
		right: max(0.65rem, env(safe-area-inset-right, 0px));
		transform: scale(1);
		transform-origin: bottom right;
	}
}

@media (prefers-reduced-motion: reduce) {
	.er-chat__fab-label {
		animation: none;
		opacity: 1;
	}
}
