/* Edderton Scott — Chat 2.0. Uses the theme's colour and font tokens where present. */

.es-chat {
	--c-ink: var(--ink, #151515);
	--c-ink-2: var(--ink-2, #2b2b2b);
	--c-paper: var(--paper, #ffffff);
	--c-bg: var(--bg, #f6f5f1);
	--c-panel: var(--panel, #edebe5);
	--c-line: var(--line, #dad7ce);
	--c-muted: var(--muted, #5b5a56);
	--c-signal: var(--signal, #d9480f);
	--c-signal-soft: var(--signal-soft, #f6dfd3);
	--c-dark: var(--dark, #131313);
	--c-ok: var(--ok, #2f6b3a);
	--c-err: var(--err, #a12a1c);
	--f-display: var(--font-display, "Syne", "Helvetica Neue", Arial, sans-serif);
	--f-text: var(--font-text, "Urbanist", "Helvetica Neue", Arial, sans-serif);
	--es-chat-lift: 0px;
	font-family: var(--f-text);
	font-size: 15px;
	line-height: 1.5;
	color: var(--c-ink);
	-webkit-font-smoothing: antialiased;
}
.es-chat *, .es-chat *::before, .es-chat *::after { box-sizing: border-box; }
.es-chat [hidden] { display: none !important; }
.es-chat__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Floating button ---------- */

.es-chat--float { position: fixed; right: 20px; bottom: calc(20px + var(--es-chat-lift)); z-index: 905; transition: bottom .25s ease; }
.es-chat__launcher {
	display: inline-flex; align-items: center; gap: 10px;
	min-height: 48px; padding: 0 18px;
	background: var(--c-dark); color: #fff; border: 1.5px solid var(--c-dark);
	font: 700 15px/1 var(--f-text); letter-spacing: .01em; cursor: pointer;
	box-shadow: 5px 5px 0 var(--c-signal);
	transition: transform .15s ease, box-shadow .15s ease;
}
.es-chat__launcher:hover { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--c-signal); }
.es-chat__launcher:focus-visible { outline: 3px solid var(--c-signal); outline-offset: 3px; }
.es-chat.is-open .es-chat__launcher { box-shadow: none; }

.es-chat__nudge {
	position: absolute; right: 0; bottom: calc(100% + 12px); width: max-content; max-width: min(300px, calc(100vw - 40px));
	margin: 0; padding: 12px 14px; background: var(--c-paper); border: 1.5px solid var(--c-ink);
	box-shadow: 4px 4px 0 var(--c-ink); font-size: 14px; cursor: pointer;
	animation: es-chat-in .3s ease;
}

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

.es-chat__panel {
	display: flex; flex-direction: column;
	background: var(--c-paper); border: 1.5px solid var(--c-ink);
}
.es-chat--float .es-chat__panel {
	position: absolute; right: 0; bottom: calc(100% + 14px);
	width: min(400px, calc(100vw - 40px));
	height: min(620px, calc(100vh - 120px - var(--es-chat-lift)));
	box-shadow: 8px 8px 0 var(--c-ink);
	animation: es-chat-in .22s ease;
}
.es-chat--inline { max-width: 760px; margin: 0 auto; }
.es-chat--inline .es-chat__panel { height: min(680px, 80vh); box-shadow: 8px 8px 0 var(--c-ink); }

.es-chat__head {
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	padding: 14px 14px 14px 18px; background: var(--c-dark); color: #fff;
}
.es-chat__title { margin: 0; font: 700 17px/1.2 var(--f-display); color: #fff; letter-spacing: -.01em; }
.es-chat__sub { margin: 2px 0 0; font-size: 12.5px; color: var(--dark-muted, #a6a49d); }
.es-chat__tools { display: flex; gap: 4px; }
.es-chat__icon {
	display: inline-flex; align-items: center; justify-content: center;
	width: 36px; height: 36px; padding: 0; border: 0; background: transparent; color: #fff; cursor: pointer;
}
.es-chat__icon:hover { background: rgba(255,255,255,.1); }
.es-chat__icon:focus-visible { outline: 2px solid var(--c-signal); outline-offset: -2px; }

/* ---------- Messages ---------- */

.es-chat__log { flex: 1; overflow-y: auto; padding: 18px 16px 8px; background: var(--c-bg); overscroll-behavior: contain; }
.es-chat__log:focus { outline: none; }
.es-chat__msg { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; animation: es-chat-in .2s ease; }
.es-chat__msg--user { align-items: flex-end; }
.es-chat__bubble { max-width: 88%; padding: 10px 13px; overflow-wrap: anywhere; }
.es-chat__bubble p { margin: 0 0 .6em; }
.es-chat__bubble p:last-child { margin-bottom: 0; }
.es-chat__msg--assistant .es-chat__bubble { background: var(--c-paper); border: 1px solid var(--c-line); }
.es-chat__msg--user .es-chat__bubble { background: var(--c-ink); color: #fff; }

.es-chat__note { margin: 0 0 14px; padding: 8px 12px; font-size: 13.5px; border-left: 3px solid var(--c-muted); background: var(--c-paper); }
.es-chat__note--err { border-color: var(--c-err); color: var(--c-err); }
.es-chat__note--ok { border-color: var(--c-ok); }

/* ---------- Cards ---------- */

.es-chat__card {
	display: block; max-width: 88%; padding: 12px 14px;
	background: var(--c-paper); border: 1.5px solid var(--c-ink);
	color: var(--c-ink); text-decoration: none;
	transition: transform .12s ease, box-shadow .12s ease;
}
a.es-chat__card:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--c-ink); }
a.es-chat__card:focus-visible { outline: 3px solid var(--c-signal); outline-offset: 2px; }
.es-chat__card-title { display: block; font: 700 15px/1.3 var(--f-display); }
.es-chat__card-text { display: block; margin-top: 3px; font-size: 13.5px; color: var(--c-muted); }
.es-chat__card-cta { display: inline-block; margin-top: 8px; font-weight: 700; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.es-chat__card--call { background: var(--c-signal); border-color: var(--c-signal); color: #fff; }
.es-chat__card--call .es-chat__card-text { color: rgba(255,255,255,.88); }
a.es-chat__card--call:hover { box-shadow: 3px 3px 0 var(--c-ink); }
.es-chat__card--question { max-width: 100%; }

.es-chat__qform { margin-top: 10px; display: grid; gap: 8px; }
.es-chat__field { display: grid; gap: 3px; font-size: 13px; font-weight: 600; }
.es-chat__field input, .es-chat__field textarea {
	width: 100%; min-height: 40px; padding: 8px 10px; border: 1.5px solid var(--c-line-strong, #b9b6ac); background: #fff;
	font: 400 15px/1.4 var(--f-text); color: var(--c-ink); border-radius: 0;
}
.es-chat__field textarea { resize: vertical; }
.es-chat__field input:focus, .es-chat__field textarea:focus { outline: 2px solid var(--c-ink); outline-offset: 0; border-color: var(--c-ink); }
.es-chat__hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.es-chat__ferr { margin: 0; color: var(--c-err); font-size: 13.5px; }
.es-chat__fbtn {
	min-height: 44px; padding: 0 16px; border: 1.5px solid var(--c-signal); background: var(--c-signal); color: #fff;
	font: 700 15px/1 var(--f-text); cursor: pointer;
}
.es-chat__fbtn:disabled { opacity: .6; cursor: default; }
.es-chat__fbtn:focus-visible { outline: 3px solid var(--c-ink); outline-offset: 2px; }
.es-chat__fsmall { margin: 0; font-size: 12px; color: var(--c-muted); }

/* ---------- Typing ---------- */

.es-chat__typing { display: inline-flex; gap: 5px; padding: 12px 14px; margin: 0 0 14px; background: var(--c-paper); border: 1px solid var(--c-line); }
.es-chat__typing span { width: 6px; height: 6px; background: var(--c-muted); animation: es-chat-dot 1.2s infinite ease-in-out; }
.es-chat__typing span:nth-child(2) { animation-delay: .15s; }
.es-chat__typing span:nth-child(3) { animation-delay: .3s; }

/* ---------- Starters, compose, legal ---------- */

.es-chat__starters { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 16px 12px; background: var(--c-bg); }
.es-chat__starter {
	min-height: 36px; padding: 6px 12px; border: 1.5px solid var(--c-ink); background: var(--c-paper);
	font: 600 13.5px/1.2 var(--f-text); color: var(--c-ink); cursor: pointer;
}
.es-chat__starter:hover { background: var(--c-ink); color: #fff; }
.es-chat__starter:focus-visible { outline: 3px solid var(--c-signal); outline-offset: 2px; }

.es-chat__compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 10px 10px 14px; border-top: 1.5px solid var(--c-ink); background: var(--c-paper); }
.es-chat__compose textarea {
	flex: 1; min-height: 40px; max-height: 140px; padding: 9px 2px; border: 0; resize: none; background: transparent;
	font: 400 16px/1.4 var(--f-text); color: var(--c-ink);
}
.es-chat__compose textarea:focus { outline: none; }
.es-chat__compose:focus-within { box-shadow: inset 0 0 0 2px var(--c-ink); }
.es-chat__send {
	display: inline-flex; align-items: center; justify-content: center; flex: none;
	width: 44px; height: 44px; border: 0; background: var(--c-signal); color: #fff; cursor: pointer;
}
.es-chat__send:disabled { background: var(--c-panel); color: var(--c-muted); cursor: default; }
.es-chat__send:focus-visible { outline: 3px solid var(--c-ink); outline-offset: 2px; }
.es-chat__legal { margin: 0; padding: 7px 14px 9px; font-size: 11.5px; line-height: 1.4; color: var(--c-muted); background: var(--c-paper); border-top: 1px solid var(--c-line); }
.es-chat__legal a { color: inherit; text-decoration: underline; }

/* ---------- Phones: full screen ---------- */

@media (max-width: 640px) {
	.es-chat--float { right: 12px; bottom: calc(12px + var(--es-chat-lift)); }
	.es-chat--float.is-open { inset: 0; }
	.es-chat--float.is-open .es-chat__launcher { display: none; }
	.es-chat--float .es-chat__panel {
		position: fixed; inset: 0; width: 100%; height: 100%; height: 100dvh;
		border: 0; box-shadow: none; animation: none;
	}
	.es-chat__nudge { right: 0; }
	html.es-chat-open, html.es-chat-open body { overflow: hidden; }
	.es-chat__bubble, .es-chat__card { max-width: 94%; }
}

@media print { .es-chat--float { display: none; } }

@keyframes es-chat-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes es-chat-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
	.es-chat *, .es-chat { animation: none !important; transition: none !important; }
}
