/* AI & SEO Visibility Score: chat mode. Builds on the tokens and components in form.css. */

/* The chat lives in one fixed-size card: the page does not grow while chatting. */
.avs-wrap.avs-chat {
	max-width: 820px;
}

.avs-wrap .avs-chat__card {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: calc(100vh - 120px);
	height: calc(100dvh - 120px);
	min-height: 480px;
	padding: 0;
	overflow: hidden;
}

@media (min-width: 768px) {
	.avs-wrap .avs-chat__card {
		height: clamp(440px, 62vh, 560px);
		min-height: 0;
	}
}

/* Landing layout: heading and card fill the first screen; the booking card after a result follows below. */
body.avs-landing .site-main > .section:has(.avs-chat) {
	padding-top: 0;
}

body.avs-landing .avs-chat .avs-hero {
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-height: 100vh;
	min-height: 100svh;
	padding: 24px 0;
	box-sizing: border-box;
}

@media (max-width: 767px) {
	body.avs-landing .avs-chat .avs-hero {
		height: 100vh;
		height: 100svh;
		min-height: 520px;
		padding: 12px 0;
	}

	body.admin-bar.avs-landing .avs-chat .avs-hero {
		height: calc(100svh - 46px);
	}

	body.avs-landing .avs-chat .avs-hero .avs-heading {
		flex: none;
		margin-bottom: 14px;
	}

	body.avs-landing .avs-wrap .avs-chat__card {
		flex: 1 1 auto;
		height: auto;
		min-height: 0;
	}

	/* Fill the tall card: the result preview takes whatever height the lead, list and button leave. */
	body.avs-landing .avs-chat .avs-chat__intro-inner {
		display: flex;
		flex: 1 0 auto;
		margin: 0;
	}

	body.avs-landing .avs-chat .avs-intro__grid {
		display: flex;
		flex: 1 1 auto;
		flex-direction: column;
		align-items: stretch;
		gap: 16px;
	}

	body.avs-landing .avs-chat .avs-preview {
		display: flex;
		flex: 1 1 auto;
		align-items: center;
		min-height: 104px;
		padding: 14px 18px;
		container-type: size;
	}

	body.avs-landing .avs-chat .avs-preview__blur {
		width: 100%;
	}

	/* Same order as the grid areas: lead, preview, list, button. */
	body.avs-landing .avs-chat .avs-preview {
		order: 1;
	}

	body.avs-landing .avs-chat .avs-intro__main {
		order: 2;
	}

	body.avs-landing .avs-chat .avs-intro__cta {
		order: 3;
	}
}

/* Landing hero on a phone with room to spare: the preview becomes a full score card that scales with its height. */
@container (min-height: 200px) {
	body.avs-landing .avs-chat .avs-preview__blur {
		flex-direction: column;
		align-items: stretch;
		gap: clamp(14px, 8cqh, 30px);
		max-width: 320px;
		margin: 0 auto;
	}

	body.avs-landing .avs-chat .avs-preview__head {
		flex-direction: row;
		justify-content: center;
		gap: 18px;
	}

	body.avs-landing .avs-chat .avs-preview__ring {
		flex-basis: clamp(72px, 36cqh, 128px);
		width: clamp(72px, 36cqh, 128px);
		height: clamp(72px, 36cqh, 128px);
	}

	body.avs-landing .avs-chat .avs-preview__num {
		font-size: clamp(24px, 12cqh, 42px);
	}

	body.avs-landing .avs-chat .avs-preview__band {
		padding: 5px 14px;
		font-size: 13px;
	}

	body.avs-landing .avs-chat .avs-preview__bars li {
		margin-bottom: clamp(8px, 4cqh, 14px);
	}

	body.avs-landing .avs-chat .avs-preview__name {
		height: 8px;
		margin-bottom: 6px;
	}

	body.avs-landing .avs-chat .avs-preview__bar {
		height: 10px;
	}

	body.avs-landing .avs-chat .avs-preview__lock {
		padding: 8px 16px;
		font-size: 14px;
	}
}

/* Intro, vertically centred in the card */
.avs-wrap .avs-chat__intro {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-height: 0;
	padding: 20px 16px;
	overflow-y: auto;
	transition: opacity .16s ease;
}

.avs-wrap .avs-chat__intro-inner {
	width: 100%;
	margin: auto;
}

.avs-wrap .avs-chat__intro.is-leaving {
	opacity: 0;
}

/* Pane: header, messages, composer */
.avs-wrap .avs-chat__pane {
	flex: 1 1 auto;
	display: grid;
	grid-template-columns: minmax(0, 1fr); /* Sideways-scrolling chips must not widen the card. */
	grid-template-rows: auto minmax(0, 1fr) auto;
	min-height: 0;
	animation: avs-fade-in .16s ease-out both;
}

.avs-wrap .avs-chat__pane[hidden] {
	display: none;
}

@keyframes avs-fade-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

/* Header */
.avs-wrap .avs-chat__head {
	position: relative;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 16px;
	border-bottom: 1px solid var(--avs-border);
}

.avs-wrap .avs-chat__avatar {
	flex: 0 0 32px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--avs-accent);
	color: #fff;
	font-family: var(--avs-font-display);
	font-size: 16px;
	font-weight: 600;
	line-height: 1;
}

.avs-wrap .avs-chat__name {
	font-size: 15px;
	font-weight: 600;
	color: var(--avs-text);
}

.avs-wrap .avs-chat__progress {
	margin-left: auto;
	font-size: 13px;
	font-weight: 600;
	color: var(--avs-muted);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.avs-wrap .avs-chat__bar {
	position: absolute;
	left: 0;
	right: 0;
	bottom: -1px;
	height: 3px;
	pointer-events: none;
}

.avs-wrap .avs-chat__bar span {
	display: block;
	width: 0;
	height: 100%;
	background: var(--avs-accent);
	transition: width .25s ease;
}

/* Scrolling panes: messages and result */
.avs-wrap .avs-chat__body {
	position: relative;
	min-height: 0;
}

.avs-wrap .avs-chat__scroll {
	height: 100%;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	/* Messages dissolve at the top and bottom edges. */
	-webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
	mask-image: linear-gradient(to bottom, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
	scrollbar-width: thin;
	scrollbar-color: color-mix(in srgb, var(--avs-muted) 45%, transparent) transparent;
}

.avs-wrap .avs-chat__scroll:focus {
	outline: none;
}

.avs-wrap .avs-chat__scroll:focus-visible {
	box-shadow: inset 0 0 0 3px var(--avs-accent-soft);
}

.avs-wrap .avs-chat__scroll::-webkit-scrollbar {
	width: 6px;
}

.avs-wrap .avs-chat__scroll::-webkit-scrollbar-track {
	background: transparent;
}

.avs-wrap .avs-chat__scroll::-webkit-scrollbar-thumb {
	background: color-mix(in srgb, var(--avs-muted) 45%, transparent);
	border-radius: 3px;
}

/* Desktop: the scrollbar only shows while hovering the pane. */
@media (hover: hover) and (pointer: fine) {
	.avs-wrap .avs-chat__scroll {
		scrollbar-color: transparent transparent;
	}

	.avs-wrap .avs-chat__scroll:hover {
		scrollbar-color: color-mix(in srgb, var(--avs-muted) 45%, transparent) transparent;
	}

	.avs-wrap .avs-chat__scroll::-webkit-scrollbar-thumb {
		background: transparent;
	}

	.avs-wrap .avs-chat__scroll:hover::-webkit-scrollbar-thumb {
		background: color-mix(in srgb, var(--avs-muted) 45%, transparent);
	}
}

.avs-wrap .avs-chat__log {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 18px 16px;
}

.avs-wrap .avs-chat__log[hidden],
.avs-wrap .avs-chat__result[hidden] {
	display: none;
}

.avs-wrap .avs-chat__scroll.is-entering {
	animation: avs-fade-in .16s ease-out both;
}

/* "New message" pill */
.avs-wrap .avs-chat__pill {
	position: absolute;
	left: 50%;
	bottom: 12px;
	z-index: 2;
	margin: 0;
	padding: 6px 14px;
	background: var(--avs-text);
	border: 0;
	border-radius: 999px;
	box-shadow: 0 6px 18px rgba(20, 20, 15, .18);
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.3;
	color: #fff;
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
	transform: translateX(-50%);
	animation: avs-pill-in .16s ease-out both;
}

.avs-wrap .avs-chat__pill:hover,
.avs-wrap .avs-chat__pill:focus {
	background: var(--avs-accent);
	color: #fff;
}

.avs-wrap .avs-chat__pill:focus-visible {
	outline: 3px solid var(--avs-accent-soft);
	outline-offset: 2px;
}

@keyframes avs-pill-in {
	from {
		opacity: 0;
		transform: translate(-50%, 6px);
	}
	to {
		opacity: 1;
		transform: translate(-50%, 0);
	}
}

/* Messages */
.avs-wrap .avs-msg {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	min-width: 0;
	animation: avs-msg-in .16s ease-out both;
}

@keyframes avs-msg-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.avs-wrap .avs-msg--user {
	align-items: flex-end;
}

.avs-wrap .avs-bubble {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 16px;
	line-height: 1.45;
	overflow-wrap: anywhere;
}

.avs-wrap .avs-msg--ai .avs-bubble {
	background: var(--avs-surface);
	border: 1px solid var(--avs-border);
	border-bottom-left-radius: 4px;
	color: var(--avs-text);
}

.avs-wrap .avs-msg--user .avs-bubble {
	background: var(--avs-accent);
	border-bottom-right-radius: 4px;
	color: #fff;
}

.avs-wrap .avs-msg--warn .avs-bubble {
	background: var(--avs-error-soft);
	border-color: transparent;
	color: #7a1a14;
}

/* Typing indicator */
.avs-wrap .avs-dots {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	height: 20px;
}

.avs-wrap .avs-dots span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--avs-muted);
	opacity: .35;
	animation: avs-dot 1s infinite ease-in-out;
}

.avs-wrap .avs-dots span:nth-child(2) {
	animation-delay: .15s;
}

.avs-wrap .avs-dots span:nth-child(3) {
	animation-delay: .3s;
}

@keyframes avs-dot {
	0%, 60%, 100% {
		opacity: .35;
	}
	30% {
		opacity: 1;
	}
}

.avs-wrap .avs-chat__status {
	margin: 6px 0 0 2px;
	font-size: 13px;
	color: var(--avs-muted);
}

/* Composer, pinned to the bottom of the card */
.avs-wrap .avs-chat__composer {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 12px 16px;
	background: var(--avs-bg);
	border-top: 1px solid var(--avs-border);
}

.avs-wrap .avs-composer__main {
	flex: 1 1 auto;
	min-width: 0;
}

.avs-wrap .avs-composer__meta {
	flex: 0 0 auto;
}

.avs-wrap .avs-composer__meta[hidden] {
	display: none;
}

.avs-wrap .avs-change {
	margin: 0;
	padding: 2px 0;
	background: none;
	border: 0;
	box-shadow: none;
	font: inherit;
	font-size: 13px;
	line-height: 1.3;
	color: var(--avs-muted);
	text-decoration: underline;
	text-transform: none;
	letter-spacing: normal;
	white-space: nowrap;
	cursor: pointer;
}

.avs-wrap .avs-change:hover,
.avs-wrap .avs-change:focus {
	background: none;
	color: var(--avs-text);
}

.avs-wrap .avs-change:focus-visible {
	outline: 3px solid var(--avs-accent-soft);
	outline-offset: 2px;
	border-radius: 4px;
}

.avs-wrap .avs-reply {
	display: flex;
	flex-direction: column;
	gap: 8px;
	transition: opacity .12s ease, transform .12s ease;
}

.avs-wrap .avs-reply.is-leaving {
	opacity: 0;
	transform: translateY(6px);
	pointer-events: none;
}

.avs-wrap .avs-reply--idle {
	opacity: .55;
}

/* Answer chips */
.avs-wrap .avs-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.avs-wrap .avs-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	max-width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 6px 16px 6px 7px;
	background: var(--avs-bg);
	border: 2px solid var(--avs-border);
	border-radius: 999px;
	box-shadow: none;
	font: inherit;
	font-size: 15px;
	font-weight: 500;
	line-height: 1.25;
	color: var(--avs-text);
	text-align: left;
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
	transition: border-color .15s ease, background-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.avs-wrap .avs-chip .avs-option__key {
	flex-basis: 26px;
	width: 26px;
	height: 26px;
	font-size: 12px;
}

.avs-wrap .avs-chip:focus {
	background: var(--avs-bg);
	border-color: var(--avs-accent);
	color: var(--avs-text);
}

/* Hover only where it is real, so it does not stick after a tap on touch screens. */
@media (hover: hover) {
	.avs-wrap .avs-chip:hover {
		background: var(--avs-bg);
		border-color: var(--avs-accent);
		color: var(--avs-text);
		transform: translateY(-1px);
		box-shadow: 0 4px 10px rgba(20, 20, 15, .08);
	}
}

.avs-wrap .avs-chip:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px var(--avs-accent-soft);
}

.avs-wrap .avs-chip.is-pressed,
.avs-wrap .avs-chip.is-selected {
	border-color: var(--avs-accent);
	background: var(--avs-accent-soft);
}

.avs-wrap .avs-chip.is-pressed {
	transform: scale(.97);
	box-shadow: none;
}

.avs-wrap .avs-chip.is-pressed .avs-option__key,
.avs-wrap .avs-chip.is-selected .avs-option__key {
	border-color: var(--avs-accent);
	background: var(--avs-accent);
	color: #fff;
}

.avs-wrap .avs-chip__text {
	min-width: 0;
	overflow-wrap: anywhere;
}

/* Phones: more than two rows of chips scroll sideways in two rows. */
.avs-wrap .avs-chips.is-scroll {
	display: grid;
	grid-auto-flow: column;
	grid-template-rows: repeat(2, auto);
	grid-auto-columns: max-content;
	margin: 0 -16px;
	padding: 2px 16px 6px;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.avs-wrap .avs-chips.is-scroll::-webkit-scrollbar {
	display: none;
}

.avs-wrap .avs-chips.is-scroll .avs-chip {
	max-width: 78vw;
}

/* Text input + round send button */
.avs-wrap .avs-reply__form {
	margin: 0;
}

.avs-wrap .avs-reply__row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.avs-wrap .avs-reply__row .avs-input {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 46px;
	border-radius: 999px;
	padding-left: 18px;
	padding-right: 18px;
}

.avs-wrap .avs-send {
	flex: 0 0 46px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 46px;
	height: 46px;
	margin: 0;
	padding: 0;
	background: var(--avs-accent);
	border: 0;
	border-radius: 50%;
	box-shadow: none;
	color: #fff;
	cursor: pointer;
	transition: background-color .15s ease, transform .15s ease;
}

.avs-wrap .avs-send svg {
	display: block;
	width: 20px;
	height: 20px;
}

.avs-wrap .avs-send:hover,
.avs-wrap .avs-send:focus {
	background: var(--avs-accent-hover);
	color: #fff;
}

.avs-wrap .avs-send:active {
	transform: scale(.94);
}

.avs-wrap .avs-send:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px var(--avs-accent-soft);
}

.avs-wrap .avs-send:disabled {
	background: var(--avs-border);
	cursor: default;
	transform: none;
}

.avs-wrap .avs-reply__form .avs-field__error:empty {
	display: none;
}

.avs-wrap .avs-reply__form.has-error .avs-input {
	border-color: var(--avs-error);
}

.avs-wrap .avs-chat__composer .avs-field__error {
	margin: 6px 0 0 18px;
}

/* Result view, inside the same card */
.avs-wrap .avs-chat__result {
	padding: 18px 16px;
}

.avs-wrap .avs-result__hello {
	margin: 0 0 12px;
	font-size: 14px;
	font-weight: 600;
	color: var(--avs-muted);
}

.avs-wrap .avs-result__hello:focus {
	outline: none;
}

.avs-wrap.avs-chat .avs-teaser--split {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 20px;
	padding: 0;
	background: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

.avs-wrap.avs-chat .avs-teaser--split .avs-result__score {
	flex-direction: row;
	align-items: center;
	gap: 16px;
	margin-bottom: 16px;
	text-align: left;
}

.avs-wrap.avs-chat .avs-teaser--split .avs-ring {
	flex: 0 0 104px;
	width: 104px;
	height: 104px;
}

.avs-wrap.avs-chat .avs-teaser--split .avs-ring__num {
	font-size: 34px;
}

.avs-wrap.avs-chat .avs-teaser--split .avs-ring__max {
	font-size: 12px;
}

.avs-wrap.avs-chat .avs-teaser--split .avs-step__title {
	margin: 0 0 8px;
	font-size: 18px;
	line-height: 1.2;
}

.avs-wrap.avs-chat .avs-teaser--split .avs-gap {
	margin-bottom: 12px;
	padding: 12px 14px;
	font-size: 15px;
}

.avs-wrap.avs-chat .avs-teaser--split .avs-note {
	margin: 0 0 14px;
	font-size: 14px;
}

.avs-wrap.avs-chat .avs-teaser--split .avs-note + .avs-note--spam {
	margin-top: -11px;
	font-size: 12.5px;
}

.avs-wrap.avs-chat .avs-teaser--split .avs-bars {
	margin: 0;
}

.avs-wrap.avs-chat .avs-teaser--split .avs-bars li:last-child {
	margin-bottom: 0;
}

.avs-wrap.avs-chat .avs-teaser--split .avs-btn {
	min-height: 42px;
	padding: 10px 20px;
	font-size: 15px;
}

/* Composer on the result view: text links */
.avs-wrap .avs-composer__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 18px;
}

.avs-wrap .avs-linkbtn {
	margin: 0;
	padding: 4px 0;
	background: none;
	border: 0;
	box-shadow: none;
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.3;
	color: var(--avs-muted);
	text-decoration: underline;
	text-underline-offset: 3px;
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
}

.avs-wrap .avs-linkbtn:hover,
.avs-wrap .avs-linkbtn:focus {
	background: none;
	color: var(--avs-text);
}

.avs-wrap .avs-linkbtn:focus-visible {
	outline: 3px solid var(--avs-accent-soft);
	outline-offset: 2px;
	border-radius: 4px;
}

.avs-wrap .avs-linkbtn--strong {
	font-weight: 700;
	color: var(--avs-accent);
}

/* Dark CTA card, below the chat card once the score is shown */
.avs-wrap .avs-chat__after {
	margin-top: 16px;
	animation: avs-msg-in .16s ease-out both;
}

.avs-wrap .avs-chat__after[hidden] {
	display: none;
}

.avs-wrap.avs-chat .avs-cta {
	margin-top: 0;
}

@media (min-width: 480px) {
	.avs-wrap .avs-msg--ai .avs-bubble {
		max-width: 80%;
	}

	.avs-wrap .avs-msg--user .avs-bubble {
		max-width: 70%;
	}
}

@media (min-width: 560px) {
	.avs-wrap .avs-chat__intro {
		padding: 32px;
	}

	.avs-wrap .avs-chat__head {
		padding: 14px 24px;
	}

	.avs-wrap .avs-chat__log,
	.avs-wrap .avs-chat__result {
		padding: 20px 24px;
	}

	.avs-wrap .avs-chat__composer {
		padding: 12px 24px 14px;
	}
}

@media (min-width: 768px) {
	/* "Change" on the left of the composer, the reply controls beside it. */
	.avs-wrap .avs-chat__composer {
		flex-direction: row;
		align-items: center;
		gap: 16px;
	}

	.avs-wrap .avs-chat__composer.is-result {
		justify-content: flex-start;
	}

	.avs-wrap.avs-chat .avs-teaser--split {
		grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
		gap: 32px;
		align-items: start;
	}

	.avs-wrap.avs-chat .avs-teaser--split .avs-teaser__side {
		padding-top: 4px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.avs-wrap .avs-msg,
	.avs-wrap .avs-chat__pane,
	.avs-wrap .avs-chat__pill,
	.avs-wrap .avs-chat__after,
	.avs-wrap .avs-chat__scroll.is-entering,
	.avs-wrap .avs-dots span {
		animation: none !important;
	}

	.avs-wrap .avs-dots span {
		opacity: .6;
	}

	.avs-wrap .avs-chat__scroll {
		scroll-behavior: auto;
	}

	.avs-wrap .avs-chip:hover,
	.avs-wrap .avs-chip.is-pressed,
	.avs-wrap .avs-send:active {
		transform: none !important;
	}
}
