/* ==========================================================================
   Astoria27 — "Plan your AV" chat bubble (inc/chat.php, assets/js/chat.js)
   ========================================================================== */

.a27-chat {
	position: fixed;
	right: clamp(.75rem, 2.5vw, 1.5rem);
	bottom: clamp(.75rem, 2.5vw, 1.5rem);
	z-index: 200;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: .75rem;
	font-family: var(--wp--preset--font-family--body);
}
.a27-chat[hidden],
.a27-chat [hidden] { display: none !important; }

/* Launcher */
.a27-chat__launcher {
	display: inline-flex;
	align-items: center;
	gap: .6rem;
	padding: .85rem 1.3rem;
	border: 0;
	border-radius: 0;
	background: var(--a27-yellow);
	color: #000;
	font-family: var(--wp--preset--font-family--display);
	font-size: .8rem;
	font-weight: 800;
	letter-spacing: .14em;
	text-transform: uppercase;
	cursor: pointer;
	box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
	transition: background .2s, color .2s, transform .2s var(--a27-ease);
}
.a27-chat__launcher:hover,
.a27-chat__launcher:focus-visible { background: #000; color: #fff; transform: translateY(-2px); }
.a27-chat.is-open .a27-chat__launcher { display: none; }

/* Panel */
.a27-chat__panel {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(380px, calc(100vw - 1.5rem));
	height: min(600px, calc(100vh - 6rem));
	height: min(600px, calc(100dvh - 6rem));
	background: var(--a27-ink);
	border: 1px solid var(--a27-line);
	border-top: var(--a27-rule) solid var(--a27-yellow);
	box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
	animation: a27-chat-in .28s var(--a27-ease);
}
@keyframes a27-chat-in { from { opacity: 0; transform: translateY(12px); } }
@media (prefers-reduced-motion: reduce) { .a27-chat__panel, .a27-chat__msg { animation: none !important; } }

.a27-chat__head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 1.1rem .9rem;
	border-bottom: 1px solid var(--a27-line);
}
.a27-chat__head p { margin: 0; }
.a27-chat__title {
	font-family: var(--wp--preset--font-family--display);
	font-weight: 800;
	font-size: 1rem;
	color: #fff;
}
.a27-chat__sub { font-size: .82rem; color: var(--a27-muted); margin-top: .2rem !important; }
.a27-chat__close {
	flex: none;
	display: grid;
	place-items: center;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--a27-muted);
	cursor: pointer;
}
.a27-chat__close:hover,
.a27-chat__close:focus-visible { color: #fff; }

/* Conversation */
.a27-chat__log {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: var(--a27-line) transparent;
	padding: 1rem 1.1rem;
	display: flex;
	flex-direction: column;
	gap: .6rem;
}
.a27-chat__msg {
	max-width: 85%;
	margin: 0;
	padding: .65rem .85rem;
	font-size: .92rem;
	line-height: 1.45;
	white-space: pre-line;
	overflow-wrap: anywhere;
	animation: a27-chat-in .22s var(--a27-ease);
}
.a27-chat__msg--bot { align-self: flex-start; background: var(--a27-graphite); color: #e6e8ec; border-left: 3px solid var(--a27-yellow); }
.a27-chat__msg--user { align-self: flex-end; background: var(--a27-yellow); color: #000; font-weight: 600; }
.a27-chat__msg--error { border-left-color: #e5534b; }
.a27-chat__msg a { color: var(--a27-yellow); }
.a27-chat__typing { display: inline-flex; gap: .3rem; }
.a27-chat__typing i { width: .4rem; height: .4rem; background: var(--a27-muted); transform: rotate(45deg); animation: a27-chat-dot 1s infinite; }
.a27-chat__typing i:nth-child(2) { animation-delay: .15s; }
.a27-chat__typing i:nth-child(3) { animation-delay: .3s; }
@keyframes a27-chat-dot { 50% { opacity: .25; } }

/* Answer area */
.a27-chat__input {
	padding: .85rem 1.1rem 1rem;
	border-top: 1px solid var(--a27-line);
	background: var(--a27-base);
}
.a27-chat__input:empty { display: none; }
.a27-chat__chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.a27-chat__chip {
	padding: .45rem .75rem;
	border: 1px solid var(--a27-line);
	border-radius: 0;
	background: var(--a27-graphite);
	color: #e6e8ec;
	font: inherit;
	font-size: .85rem;
	cursor: pointer;
	transition: border-color .15s, background .15s, color .15s;
}
.a27-chat__chip:hover,
.a27-chat__chip:focus-visible { border-color: var(--a27-yellow); }
.a27-chat__chip[aria-pressed="true"] { background: var(--a27-yellow); border-color: var(--a27-yellow); color: #000; font-weight: 600; }

.a27-chat__form { display: grid; gap: .55rem; margin: 0; }
.a27-chat__form + .a27-chat__chips,
.a27-chat__chips + .a27-chat__form { margin-top: .6rem; }
.a27-chat__fields { display: grid; gap: .55rem; }
.a27-chat__fields--split { grid-template-columns: 1fr 1fr; }
.a27-chat__field { display: grid; gap: .25rem; min-width: 0; }
.a27-chat__field label { font-size: .75rem; font-weight: 600; color: var(--a27-muted); }
.a27-chat__form input,
.a27-chat__form select,
.a27-chat__form textarea {
	width: 100%;
	box-sizing: border-box;
	padding: .6rem .7rem;
	border: 1px solid var(--a27-line);
	border-radius: 0;
	background: var(--a27-graphite);
	color: #fff;
	font: inherit;
	font-size: 1rem; /* 16px keeps iOS from zooming on focus */
	color-scheme: dark;
}
.a27-chat__form textarea { resize: none; min-height: 4.5rem; }
.a27-chat__form input:focus,
.a27-chat__form select:focus,
.a27-chat__form textarea:focus { border-color: var(--a27-yellow); outline: 0; box-shadow: 0 0 0 3px rgba(226, 205, 0, .3); }
.a27-chat__form input[aria-invalid="true"] { border-color: #e5534b; }
.a27-chat__hint { margin: 0; font-size: .78rem; color: #f0a59f; }
.a27-chat__hint:empty { display: none; }
.a27-chat__actions { display: flex; gap: .5rem; justify-content: flex-end; }
.a27-chat__send {
	padding: .6rem 1.2rem;
	border: 0;
	border-radius: 0;
	background: var(--a27-yellow);
	color: #000;
	font-family: var(--wp--preset--font-family--display);
	font-size: .75rem;
	font-weight: 800;
	letter-spacing: .12em;
	text-transform: uppercase;
	cursor: pointer;
}
.a27-chat__send:hover,
.a27-chat__send:focus-visible { background: #fff; }
.a27-chat__send:disabled { opacity: .5; cursor: not-allowed; }
.a27-chat__skip {
	padding: .6rem .4rem;
	border: 0;
	background: transparent;
	color: var(--a27-muted);
	font: inherit;
	font-size: .85rem;
	text-decoration: underline;
	cursor: pointer;
}
.a27-chat__skip:hover { color: #fff; }

.a27-chat__hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Phones: panel fills the screen above the keyboard */
@media (max-width: 480px) {
	.a27-chat.is-open { inset: 0; gap: 0; }
	.a27-chat__panel { width: 100%; height: 100%; border: 0; border-top: var(--a27-rule) solid var(--a27-yellow); }
	.a27-chat__launcher span { display: none; }
	.a27-chat__launcher { padding: .9rem; }
}
