/**
 * Toyad Homes — website assistant.
 *
 * Uses the theme's tokens so the panel belongs to the site rather than looking
 * like a third-party widget bolted on. Fallbacks keep it presentable if it is
 * ever rendered under another theme.
 */

.toyad-ai {
	--ai-ink:   var(--tw-ink, #12312a);
	--ai-brass: var(--tw-brass, #c2a15a);
	--ai-paper: var(--tw-paper, #fbf9f4);
	--ai-bone:  var(--tw-bone, #f4f0e6);
	--ai-line:  var(--tw-line, #ddd5c6);
	--ai-muted: var(--tw-muted, #6d7b74);
	--ai-sans:  var(--tw-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
	--ai-serif: var(--tw-display, Georgia, serif);

	position: fixed;
	right: clamp(.9rem, 2vw, 1.6rem);
	bottom: clamp(.9rem, 2vw, 1.6rem);
	z-index: 9990;
	font-family: var(--ai-sans);
}

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

.toyad-ai__launch {
	display: inline-flex;
	align-items: center;
	gap: .6rem;
	padding: .85rem 1.35rem .85rem 1.05rem;
	border: 0;
	border-radius: 999px;
	background: var(--ai-ink);
	color: var(--ai-bone);
	font-family: inherit;
	font-size: .9rem;
	font-weight: 700;
	letter-spacing: .01em;
	cursor: pointer;
	box-shadow: 0 6px 18px rgba(11, 33, 28, .18), 0 22px 48px rgba(11, 33, 28, .18);
	transition: transform .2s cubic-bezier(.22, .68, .3, 1), background-color .2s ease;
}

.toyad-ai__launch:hover { transform: translateY(-2px); background: #0b211c; }
.toyad-ai__launch:focus-visible { outline: 3px solid var(--ai-brass); outline-offset: 3px; }

.toyad-ai__launchicon {
	display: grid;
	place-items: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--ai-brass);
	color: var(--ai-ink);
	flex: none;
}

.toyad-ai.is-open .toyad-ai__launch { display: none; }

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

.toyad-ai__panel {
	display: flex;
	flex-direction: column;
	width: min(400px, calc(100vw - 1.8rem));
	height: min(620px, calc(100vh - 3rem));
	background: #fff;
	border: 1px solid var(--ai-line);
	border-radius: 14px;
	overflow: hidden;
	box-shadow: 0 10px 28px rgba(11, 33, 28, .14), 0 40px 90px rgba(11, 33, 28, .22);
	animation: toyad-ai-in .26s cubic-bezier(.22, .68, .3, 1) both;
}

@keyframes toyad-ai-in {
	from { opacity: 0; transform: translateY(14px) scale(.985); }
	to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
	.toyad-ai__panel { animation: none; }
	.toyad-ai__launch { transition: none; }
}

.toyad-ai__head {
	display: flex;
	align-items: center;
	gap: .7rem;
	padding: .85rem 1rem;
	background: var(--ai-ink);
	color: var(--ai-bone);
	flex: none;
}

.toyad-ai__mark {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	flex: none;
	border-radius: 50%;
	background: var(--ai-brass);
	color: var(--ai-ink);
	font-family: var(--ai-serif);
	font-size: .82rem;
	font-weight: 700;
	letter-spacing: .04em;
}

.toyad-ai__headtext { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.toyad-ai__headtext strong { font-size: .95rem; font-weight: 700; }
.toyad-ai__headtext small { font-size: .7rem; color: rgba(244, 240, 230, .62); }

.toyad-ai__x {
	margin-left: auto;
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	flex: none;
	border: 0;
	border-radius: 50%;
	background: rgba(244, 240, 230, .12);
	color: var(--ai-bone);
	cursor: pointer;
	transition: background-color .18s ease;
}

.toyad-ai__x:hover { background: rgba(244, 240, 230, .24); }

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

.toyad-ai__log {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 1rem;
	background: var(--ai-paper);
	display: flex;
	flex-direction: column;
	gap: .7rem;
	scrollbar-width: thin;
}

.toyad-ai__row { display: flex; }
.toyad-ai__row--me { justify-content: flex-end; }

.toyad-ai__bubble {
	max-width: 86%;
	padding: .7rem .9rem;
	border-radius: 14px;
	font-size: .875rem;
	line-height: 1.55;
	background: #fff;
	border: 1px solid var(--ai-line);
	color: var(--tw-body, #3f4a45);
	border-bottom-left-radius: 5px;
}

.toyad-ai__bubble p { margin: 0 0 .6rem; }
.toyad-ai__bubble p:last-child { margin-bottom: 0; }

.toyad-ai__row--me .toyad-ai__bubble {
	background: var(--ai-ink);
	border-color: var(--ai-ink);
	color: var(--ai-bone);
	border-radius: 14px;
	border-bottom-right-radius: 5px;
	border-bottom-left-radius: 14px;
}

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

.toyad-ai__dots { display: inline-flex; gap: 4px; align-items: center; padding: .85rem .9rem; }

.toyad-ai__dots i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--ai-brass);
	animation: toyad-ai-blink 1.1s infinite ease-in-out;
}

.toyad-ai__dots i:nth-child(2) { animation-delay: .16s; }
.toyad-ai__dots i:nth-child(3) { animation-delay: .32s; }

@keyframes toyad-ai-blink {
	0%, 80%, 100% { opacity: .25; transform: translateY(0); }
	40%           { opacity: 1;   transform: translateY(-3px); }
}

/* ---------- Listing cards ---------- */

.toyad-ai__cards {
	list-style: none;
	margin: .55rem 0 0;
	padding: 0;
	display: grid;
	gap: .5rem;
	width: 100%;
}

.toyad-ai__row--bot { flex-direction: column; align-items: flex-start; }
.toyad-ai__row--bot > .toyad-ai__bubble { max-width: 100%; }

.toyad-ai__card {
	display: flex;
	gap: .7rem;
	padding: .5rem;
	background: #fff;
	border: 1px solid var(--ai-line);
	border-radius: 10px;
	text-decoration: none;
	color: inherit;
	transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.toyad-ai__card:hover {
	border-color: var(--ai-brass);
	transform: translateY(-1px);
	box-shadow: 0 4px 14px rgba(11, 33, 28, .08);
}

.toyad-ai__card img,
.toyad-ai__cardnoimg {
	width: 78px;
	height: 60px;
	flex: none;
	border-radius: 6px;
	object-fit: cover;
	background: var(--ai-bone);
}

.toyad-ai__cardbody { display: flex; flex-direction: column; gap: .12rem; min-width: 0; justify-content: center; }

.toyad-ai__cardbody strong {
	font-size: .82rem;
	font-weight: 700;
	color: var(--ai-ink);
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.toyad-ai__cardprice { font-size: .8rem; font-weight: 800; color: var(--tw-brass-d, #a8873f); }
.toyad-ai__cardmeta { font-size: .7rem; color: var(--ai-muted); }

.toyad-ai__more {
	display: inline-block;
	margin-top: .5rem;
	padding: .5rem .9rem;
	border: 1px solid var(--ai-line);
	border-radius: 999px;
	background: #fff;
	font-size: .76rem;
	font-weight: 700;
	color: var(--ai-ink);
	text-decoration: none;
	transition: border-color .18s ease, background-color .18s ease;
}

.toyad-ai__more:hover { border-color: var(--ai-brass); background: var(--ai-bone); }

/* ---------- Chips and actions ---------- */

.toyad-ai__chips,
.toyad-ai__acts { display: flex; flex-wrap: wrap; gap: .4rem; }

.toyad-ai__chip,
.toyad-ai__act {
	padding: .48rem .85rem;
	border: 1px solid var(--ai-line);
	border-radius: 999px;
	background: #fff;
	font-family: inherit;
	font-size: .76rem;
	font-weight: 600;
	color: var(--ai-ink);
	text-decoration: none;
	cursor: pointer;
	transition: border-color .18s ease, background-color .18s ease, color .18s ease;
}

.toyad-ai__chip:hover,
.toyad-ai__act:hover { border-color: var(--ai-brass); background: var(--ai-brass); color: var(--ai-ink); }

.toyad-ai__act { background: var(--ai-ink); border-color: var(--ai-ink); color: var(--ai-bone); font-weight: 700; }
.toyad-ai__act--wa:hover { background: #25d366; border-color: #25d366; color: #06301a; }

/* ---------- Callback form ---------- */

.toyad-ai__lead {
	display: flex;
	flex-direction: column;
	gap: .55rem;
	padding: .9rem;
	background: #fff;
	border: 1px solid var(--ai-brass);
	border-radius: 12px;
}

.toyad-ai__lead > strong { font-family: var(--ai-serif); font-size: 1rem; font-weight: 400; color: var(--ai-ink); }

.toyad-ai__f { display: flex; flex-direction: column; gap: .2rem; }

.toyad-ai__f > span {
	font-size: .68rem;
	font-weight: 700;
	letter-spacing: .07em;
	text-transform: uppercase;
	color: var(--ai-muted);
}

.toyad-ai__f input,
.toyad-ai__f textarea {
	width: 100%;
	padding: .55rem .65rem;
	border: 1px solid var(--ai-line);
	border-radius: 6px;
	background: var(--ai-paper);
	font-family: inherit;
	font-size: .85rem;
	color: var(--ai-ink);
	resize: vertical;
}

.toyad-ai__f input:focus,
.toyad-ai__f textarea:focus { outline: 2px solid var(--ai-brass); outline-offset: 1px; border-color: var(--ai-brass); }

.toyad-ai__trap { position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important; }

.toyad-ai__consent {
	display: flex;
	align-items: flex-start;
	gap: .45rem;
	font-size: .72rem;
	line-height: 1.45;
	color: var(--ai-muted);
}

.toyad-ai__consent input { margin-top: .18rem; flex: none; }
.toyad-ai__consent a { color: var(--tw-brass-d, #a8873f); }

.toyad-ai__leaderr {
	margin: 0;
	padding: .5rem .65rem;
	border-radius: 6px;
	background: #fbeceb;
	color: #8a1f11;
	font-size: .76rem;
}

.toyad-ai__leadgo {
	padding: .7rem 1rem;
	border: 0;
	border-radius: 6px;
	background: var(--ai-ink);
	color: var(--ai-bone);
	font-family: inherit;
	font-size: .84rem;
	font-weight: 800;
	cursor: pointer;
	transition: background-color .18s ease;
}

.toyad-ai__leadgo:hover { background: var(--ai-brass); color: var(--ai-ink); }
.toyad-ai__leadgo:disabled { opacity: .6; cursor: default; }

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

.toyad-ai__ask {
	display: flex;
	align-items: flex-end;
	gap: .5rem;
	padding: .7rem;
	background: #fff;
	border-top: 1px solid var(--ai-line);
	flex: none;
}

.toyad-ai__ask textarea {
	flex: 1 1 auto;
	min-height: 42px;
	max-height: 120px;
	padding: .65rem .8rem;
	border: 1px solid var(--ai-line);
	border-radius: 10px;
	background: var(--ai-paper);
	font-family: inherit;
	font-size: .875rem;
	line-height: 1.45;
	color: var(--ai-ink);
	resize: none;
}

.toyad-ai__ask textarea:focus { outline: 2px solid var(--ai-brass); outline-offset: 1px; border-color: var(--ai-brass); }

.toyad-ai__send {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	flex: none;
	border: 0;
	border-radius: 10px;
	background: var(--ai-ink);
	color: var(--ai-bone);
	cursor: pointer;
	transition: background-color .18s ease;
}

.toyad-ai__send:hover { background: var(--ai-brass); color: var(--ai-ink); }

.toyad-ai__foot {
	margin: 0;
	padding: .5rem .9rem .7rem;
	background: #fff;
	font-size: .66rem;
	line-height: 1.4;
	color: var(--ai-muted);
	text-align: center;
	flex: none;
}

/* ---------- Phone ---------- */

/* ---------- Phones ----------
 *
 * The launcher used to span the full width of the screen, which put a large
 * dark bar permanently across the bottom of every page — it covered the very
 * links people were scrolling towards. On a phone it becomes a round button
 * in the corner, the shape everyone already reads as "chat", and it sits
 * above the home indicator rather than under it.
 */

@media (max-width: 560px) {
	.toyad-ai {
		right: max(0.85rem, env(safe-area-inset-right));
		bottom: max(0.85rem, env(safe-area-inset-bottom));
		left: auto;
	}

	.toyad-ai__launch {
		width: 58px;
		height: 58px;
		padding: 0;
		justify-content: center;
		border-radius: 50%;
	}

	.toyad-ai__launchtext {
		/* Kept for screen readers; the icon carries it visually. */
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.toyad-ai__launchicon { width: 30px; height: 30px; background: none; color: var(--ai-brass); }

	/* Open, it takes the whole screen — a 400px panel inside a 390px phone is
	   a window within a window. */
	.toyad-ai.is-open { inset: 0; }

	.toyad-ai__panel {
		width: 100%;
		height: 100dvh;
		border-radius: 0;
		border: 0;
	}

	.toyad-ai__head {
		padding-top: max(0.85rem, calc(env(safe-area-inset-top) + 0.5rem));
	}

	/* The close control is the one thing a person must be able to hit first
	   time, so it gets a full target. */
	.toyad-ai__x { width: 42px; height: 42px; }

	.toyad-ai__log { padding: 0.85rem; gap: .8rem; }
	.toyad-ai__bubble { max-width: 92%; font-size: 0.92rem; }

	/* 16px or iOS zooms the page the moment the keyboard opens. */
	.toyad-ai__ask textarea,
	.toyad-ai__f input,
	.toyad-ai__f textarea { font-size: 16px; }

	.toyad-ai__ask {
		padding: 0.7rem;
		padding-bottom: max(0.7rem, env(safe-area-inset-bottom));
	}

	.toyad-ai__ask textarea { min-height: 48px; }
	.toyad-ai__send { width: 48px; height: 48px; }

	.toyad-ai__chip,
	.toyad-ai__act { min-height: 42px; display: inline-flex; align-items: center; font-size: 0.8rem; }

	.toyad-ai__card { padding: 0.6rem; }
	.toyad-ai__card img,
	.toyad-ai__cardnoimg { width: 88px; height: 66px; }
	.toyad-ai__cardbody strong { font-size: 0.86rem; }

	.toyad-ai__leadgo { min-height: 50px; }
	.toyad-ai__f input,
	.toyad-ai__f textarea { padding: 0.7rem 0.8rem; }

	/* The footnote is the least important thing on a small screen. */
	.toyad-ai__foot { font-size: 0.62rem; padding: 0.4rem 0.8rem 0.55rem; }
}

/* A phone held sideways has almost no height; the panel should not try to
   keep its full furniture. */
@media (max-height: 460px) and (orientation: landscape) and (pointer: coarse) {
	.toyad-ai__panel { height: 100dvh; }
	.toyad-ai__foot { display: none; }
	.toyad-ai__head { padding-block: 0.5rem; }
}

/* The admin bar must not sit on top of the launcher. */
.admin-bar .toyad-ai.is-open .toyad-ai__panel { padding-top: env(safe-area-inset-top); }

/* ---------- Action card ---------- */

.toyad-ai__do {
	display: flex;
	flex-direction: column;
	gap: .5rem;
	width: 100%;
	margin-top: .55rem;
	padding: .95rem;
	background: #fff;
	border: 1px solid var(--ai-brass);
	border-left-width: 4px;
	border-radius: 11px;
	box-shadow: 0 3px 12px rgba(11, 33, 28, .07);
}

.toyad-ai__do > strong {
	font-family: var(--ai-serif);
	font-size: 1.02rem;
	font-weight: 400;
	color: var(--ai-ink);
}

.toyad-ai__do > p { margin: 0; font-size: .8rem; line-height: 1.5; color: var(--ai-muted); }

.toyad-ai__quick { display: grid; gap: .4rem; margin-top: .15rem; }

.toyad-ai__quick input {
	width: 100%;
	padding: .55rem .65rem;
	border: 1px solid var(--ai-line);
	border-radius: 6px;
	background: var(--ai-paper);
	font-family: inherit;
	font-size: .82rem;
	color: var(--ai-ink);
}

.toyad-ai__quick input:focus { outline: 2px solid var(--ai-brass); outline-offset: 1px; border-color: var(--ai-brass); }

.toyad-ai__hint { font-size: .68rem; line-height: 1.4; color: var(--ai-muted); }

.toyad-ai__doGo {
	display: inline-block;
	margin-top: .2rem;
	padding: .72rem 1.1rem;
	border-radius: 7px;
	background: var(--ai-ink);
	color: var(--ai-bone);
	font-size: .84rem;
	font-weight: 800;
	text-align: center;
	text-decoration: none;
	transition: background-color .18s ease, color .18s ease;
}

.toyad-ai__doGo:hover { background: var(--ai-brass); color: var(--ai-ink); }

/* A link inside a reply. Underlined rather than colour-only, so it is
   recognisable as a link without relying on colour vision. */
.toyad-ai__link {
	color: var(--tw-brass-d, #a8873f);
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 2px;
	text-decoration-thickness: 1px;
	overflow-wrap: anywhere;
}

.toyad-ai__link:hover { color: var(--ai-ink); text-decoration-thickness: 2px; }
