/**
 * AI Pop-Up Builder — Public Popup Styles
 *
 * Premium, restrained popup with a soft aurora gradient mesh in the
 * background and sharp indigo accents. Mobile-first.
 *
 * @package AI_Popup_Builder
 * @since   0.9.0
 */

/* ==========================================================================
   Tokens (scoped to .apb-popup so they never leak into the host theme)
   ========================================================================== */

.apb-popup {
	--apb-accent:             var(--accent, #6366F1);
	--apb-accent-2:           var(--accent-2, #A855F7);
	--apb-pop-primary:        var(--apb-accent, #6366F1);
	--apb-pop-primary-hover:  #4F46E5;
	--apb-pop-primary-soft:   #EEF2FF;
	--apb-pop-primary-ring:   rgba(99, 102, 241, .28);
	--apb-pop-violet:         var(--apb-accent-2, #A855F7);
	--apb-pop-cyan:           #22D3EE;
	--apb-pop-ink:            #0F172A;
	--apb-pop-ink-2:          #1E293B;
	--apb-pop-text:           #0F172A;
	--apb-pop-text-soft:      #475569;
	--apb-pop-text-muted:     #94A3B8;
	--apb-pop-border:         rgba(15, 23, 42, .08);
	--apb-pop-border-strong:  rgba(15, 23, 42, .14);
	--apb-pop-card:           #FFFFFF;
	--apb-pop-overlay:        rgba(7, 11, 28, .58);
	--apb-pop-radius:         18px;
	--apb-pop-radius-sm:      12px;
	--apb-pop-radius-xs:      8px;
	--apb-pop-shadow:         0 24px 60px -20px rgba(15, 23, 42, .35), 0 8px 24px -8px rgba(99, 102, 241, .25);
	--apb-pop-font:           "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--apb-pop-font-display:   "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ==========================================================================
   Container
   ========================================================================== */

.apb-popup,
.apb-popup * {
	box-sizing: border-box;
}

.apb-popup {
	position: fixed;
	inset: 0;
	z-index: 2147483600;
	font-family: var(--apb-pop-font);
	color: var(--apb-pop-text);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	opacity: 0;
	pointer-events: none;
	transition: opacity .22s ease;
}

.apb-popup[hidden] {
	display: none !important;
}

.apb-popup.is-open {
	opacity: 1;
	pointer-events: auto;
}

.apb-popup__overlay {
	position: absolute;
	inset: 0;
	background: var(--apb-pop-overlay);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
}

html.apb-popup-open,
html.apb-popup-open body {
	overflow: hidden;
}

/* ==========================================================================
   Dialog
   ========================================================================== */

.apb-popup__dialog {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -45%);
	width: min(100% - 32px, 480px);
	max-height: calc(100vh - 32px);
	overflow: hidden;
	background: var(--apb-pop-card);
	border: 1px solid var(--apb-pop-border);
	border-radius: var(--apb-pop-radius);
	box-shadow: var(--apb-pop-shadow);
	transition: transform .32s cubic-bezier(.2, .8, .2, 1), opacity .22s ease;
	opacity: 0;
	display: flex;
	flex-direction: column;
	isolation: isolate;
}

.apb-popup.is-open .apb-popup__dialog {
	opacity: 1;
	transform: translate(-50%, -50%);
}

/* Aurora gradient mesh — the one signature visual move. */
.apb-popup__aurora {
	position: absolute;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
	z-index: 0;
}

.apb-popup__aurora-blob {
	position: absolute;
	border-radius: 50%;
	filter: blur(60px);
	opacity: .55;
	will-change: transform;
}

.apb-popup__aurora-blob--a {
	top: -90px;
	left: -60px;
	width: 280px;
	height: 280px;
	background: radial-gradient(circle at 30% 30%, var(--apb-pop-violet) 0%, transparent 70%);
}

.apb-popup__aurora-blob--b {
	top: -40px;
	right: -80px;
	width: 320px;
	height: 320px;
	background: radial-gradient(circle at 70% 30%, var(--apb-pop-cyan) 0%, transparent 70%);
	opacity: .35;
}

.apb-popup__aurora-blob--c {
	bottom: -120px;
	left: 30%;
	width: 360px;
	height: 360px;
	background: radial-gradient(circle at 50% 50%, var(--apb-pop-primary) 0%, transparent 70%);
	opacity: .28;
}

.apb-popup__close {
	position: absolute;
	top: 14px;
	right: 14px;
	width: 34px;
	height: 34px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--apb-pop-border);
	border-radius: 999px;
	background: rgba(255, 255, 255, .85);
	color: var(--apb-pop-ink);
	cursor: pointer;
	z-index: 5;
	transition: background .2s ease, color .2s ease, transform .2s ease;
	padding: 0;
}

.apb-popup__close:hover {
	background: var(--apb-pop-ink);
	color: #fff;
	transform: scale(1.04);
}

.apb-popup__body {
	position: relative;
	z-index: 1;
	padding: 36px 30px 30px;
	overflow-y: auto;
}

/* Scrollbar polish */
.apb-popup__body::-webkit-scrollbar {
	width: 6px;
}

.apb-popup__body::-webkit-scrollbar-thumb {
	background: var(--apb-pop-border-strong);
	border-radius: 999px;
}

/* ==========================================================================
   Screen wrapper + transitions
   ========================================================================== */

.apb-screen {
	display: flex;
	flex-direction: column;
	gap: 18px;
	animation: apbScreenIn .28s ease both;
}

@keyframes apbScreenIn {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Header / typography
   ========================================================================== */

.apb-screen__header {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.apb-screen__header--hero {
	gap: 8px;
	margin-bottom: 4px;
}

.apb-screen__title {
	margin: 0;
	font-family: var(--apb-pop-font-display);
	font-size: 24px;
	line-height: 1.18;
	font-weight: 700;
	letter-spacing: -.012em;
	color: var(--apb-pop-ink);
	text-wrap: balance;
	text-align: center;
	text-transform: uppercase;
}

/* ==========================================================================
   Choice (screen 1)
   ========================================================================== */

.apb-choice {
	display: grid;
	gap: 14px;
	grid-template-columns: 1fr 1fr;
}

.apb-choice-card {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	padding: 20px 18px 18px;
	background: linear-gradient(160deg, #fff 0%, #f8fafc 100%);
	border: 1px solid var(--apb-pop-border);
	border-radius: var(--apb-pop-radius-sm);
	font-family: var(--apb-pop-font);
	font-size: 14px;
	color: var(--apb-pop-ink);
	cursor: pointer;
	overflow: hidden;
	text-align: left;
	transition: transform .25s cubic-bezier(.2, .8, .2, 1),
		border-color .25s ease,
		box-shadow .25s ease,
		background .25s ease;
}

.apb-choice-card::before {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(180deg, transparent 60%, rgba(99, 102, 241, .06) 100%);
	opacity: 0;
	transition: opacity .25s ease;
	pointer-events: none;
}

.apb-choice-card:hover,
.apb-choice-card:focus-visible {
	transform: translateY(-3px);
	border-color: rgba(99, 102, 241, .35);
	box-shadow: 0 18px 30px -18px rgba(99, 102, 241, .55), 0 2px 4px rgba(15, 23, 42, .04);
	outline: none;
}

.apb-choice-card:hover::before,
.apb-choice-card:focus-visible::before {
	opacity: 1;
}

.apb-choice-card__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	border-radius: 14px;
	background: var(--apb-pop-primary-soft);
	color: var(--apb-pop-primary-hover);
	margin-bottom: 8px;
	transition: background .25s ease, color .25s ease;
}

.apb-choice-card--sell .apb-choice-card__icon {
	background: rgba(34, 211, 238, .14);
	color: #0E7490;
}

.apb-choice-card:hover .apb-choice-card__icon,
.apb-choice-card:focus-visible .apb-choice-card__icon {
	background: var(--apb-pop-primary);
	color: #fff;
}

.apb-choice-card__label {
	font-size: 16px;
	font-weight: 700;
	color: var(--apb-pop-ink);
	letter-spacing: -.005em;
}

.apb-choice-card__hint {
	font-size: 12.5px;
	color: var(--apb-pop-text-soft);
	line-height: 1.45;
}

.apb-choice-card__arrow {
	position: absolute;
	right: 14px;
	bottom: 14px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: rgba(15, 23, 42, .04);
	color: var(--apb-pop-ink);
	transition: transform .25s cubic-bezier(.2, .8, .2, 1), background .25s ease, color .25s ease;
}

.apb-choice-card:hover .apb-choice-card__arrow,
.apb-choice-card:focus-visible .apb-choice-card__arrow {
	background: var(--apb-pop-primary);
	color: #fff;
	transform: translateX(3px);
}

/* ==========================================================================
   Forms
   ========================================================================== */

.apb-form {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.apb-field {
	display: flex;
	align-items: center;
	background: #F8FAFC;
	border: 1px solid var(--apb-pop-border);
	border-radius: var(--apb-pop-radius-sm);
	padding: 4px 6px 4px 14px;
	transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}

.apb-field:focus-within {
	border-color: var(--apb-pop-primary);
	background: #fff;
	box-shadow: 0 0 0 4px var(--apb-pop-primary-ring);
}

.apb-field__icon {
	display: inline-flex;
	color: var(--apb-pop-text-muted);
	margin-right: 10px;
	flex-shrink: 0;
}

.apb-field:focus-within .apb-field__icon {
	color: var(--apb-pop-primary);
}

.apb-field__input {
	flex: 1;
	min-width: 0;
	padding: 12px 0;
	border: none;
	background: transparent;
	font-size: 15px;
	font-family: inherit;
	color: var(--apb-pop-ink);
	outline: none;
	letter-spacing: -.005em;
}

.apb-field__input::placeholder {
	color: var(--apb-pop-text-muted);
}

.apb-form__error {
	margin: 0;
	font-size: 13px;
	color: #B91C1C;
	background: #FEF2F2;
	border: 1px solid #FECACA;
	padding: 10px 12px;
	border-radius: var(--apb-pop-radius-xs);
}

/* AIHV form drop-in fits inside our card without competing for attention. */
.apb-selling-form .aihv-search-form {
	display: flex;
	flex-direction: column;
	gap: 12px;
	width: 100%;
}

.apb-selling-form .aihv-search-form__btn {
	width: 100%;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.apb-btn-primary {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 14px 22px;
	border-radius: var(--apb-pop-radius-sm);
	border: none;
	background: var(--apb-accent);
	color: #fff !important;
	font-family: var(--apb-pop-font);
	font-size: 15px;
	font-weight: 600;
	letter-spacing: -.005em;
	cursor: pointer;
	text-decoration: none !important;
	box-shadow: 0 6px 16px -4px rgba(99, 102, 241, .55), inset 0 1px 0 rgba(255, 255, 255, .25);
	transition: background .2s ease, transform .2s ease, box-shadow .25s ease;
}

.apb-btn-primary:hover,
.apb-btn-primary:focus-visible {
	background: var(--apb-accent-2);
	transform: translateY(-1px);
	box-shadow: 0 10px 22px -6px rgba(99, 102, 241, .65), inset 0 1px 0 rgba(255, 255, 255, .25);
	outline: none;
	color: #fff !important;
}

.apb-btn-primary--block {
	width: 100%;
}

.apb-btn-primary svg {
	transition: transform .2s ease;
}

.apb-btn-primary:hover svg {
	transform: translateX(2px);
}

.apb-back {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px 6px 8px;
	margin: -4px 0 4px;
	border: none;
	background: transparent;
	color: var(--apb-pop-text-soft);
	font-family: var(--apb-pop-font);
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	border-radius: 999px;
	width: fit-content;
	transition: background .2s ease, color .2s ease;
}

.apb-back:hover,
.apb-back:focus-visible {
	background: var(--apb-pop-primary-soft);
	color: var(--apb-pop-primary-hover);
	outline: none;
}

/* ==========================================================================
   Loading
   ========================================================================== */

.apb-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
}

.apb-loading--full {
	flex-direction: column;
	gap: 18px;
	padding: 28px 0;
}

.apb-loading--inline {
	padding: 24px 0;
}

.apb-loading__ring {
	width: 44px;
	height: 44px;
	border: 3px solid var(--apb-pop-primary-soft);
	border-top-color: var(--apb-pop-primary);
	border-radius: 50%;
	animation: apbSpin 1s linear infinite;
}

.apb-loading__text {
	margin: 0;
	font-size: 13.5px;
	color: var(--apb-pop-text-soft);
	letter-spacing: -.005em;
}

.apb-loading__dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--apb-pop-primary);
	opacity: .35;
	animation: apbDot 1.2s ease-in-out infinite both;
}

.apb-loading__dot:nth-child(2) { animation-delay: .15s; }
.apb-loading__dot:nth-child(3) { animation-delay: .3s; }

@keyframes apbSpin {
	to { transform: rotate(360deg); }
}

@keyframes apbDot {
	0%, 80%, 100% { opacity: .25; transform: scale(.8); }
	40%           { opacity: 1;   transform: scale(1.1); }
}

/* ==========================================================================
   Results
   ========================================================================== */

.apb-results {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.apb-results__one-liner {
	margin: 0;
	font-size: 16px;
	line-height: 1.45;
	color: var(--apb-pop-ink);
	letter-spacing: -.008em;
	text-wrap: pretty;
	font-weight: 500;
}

.apb-results__list {
	margin: 0;
	padding: 0;
	list-style: none;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.apb-results__item {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 14px 16px;
	background: #F8FAFC;
	border: 1px solid var(--apb-pop-border);
	border-radius: var(--apb-pop-radius-sm);
	transition: background .2s ease, border-color .2s ease, transform .2s ease;
}

.apb-results__item:hover {
	background: #fff;
	border-color: rgba(99, 102, 241, .35);
	transform: translateY(-1px);
}

.apb-results__item-info {
	flex: 1;
	min-width: 0;
}

.apb-results__item-name {
	margin: 0 0 2px;
	font-size: 15px;
	font-weight: 600;
	color: var(--apb-pop-ink);
	letter-spacing: -.005em;
	overflow: hidden;
	text-overflow: ellipsis;
}

.apb-results__item-loc {
	margin: 0;
	font-size: 12.5px;
	color: var(--apb-pop-text-soft);
	letter-spacing: .005em;
}

.apb-results__item-link {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 13px;
	font-weight: 600;
	color: var(--apb-pop-primary-hover) !important;
	text-decoration: none !important;
	white-space: nowrap;
	transition: color .2s ease, transform .2s ease;
}

.apb-results__item-link svg {
	transition: transform .2s ease;
}

.apb-results__item-link:hover svg {
	transform: translateX(2px);
}

/* No-results / fallback */

.apb-results--empty {
	align-items: center;
	text-align: center;
	padding: 8px 0 0;
}

.apb-results__icon-wrap {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 64px;
	border-radius: 18px;
	background: var(--apb-pop-primary-soft);
	color: var(--apb-pop-primary-hover);
	margin-bottom: 4px;
}

.apb-results__empty-title {
	margin: 0;
	font-size: 17px;
	font-weight: 700;
	color: var(--apb-pop-ink);
	letter-spacing: -.008em;
}

.apb-results__empty-body {
	margin: 0;
	font-size: 14px;
	color: var(--apb-pop-text-soft);
	line-height: 1.5;
	max-width: 36ch;
}

/* ==========================================================================
   Mobile
   ========================================================================== */

@media (max-width: 600px) {
	.apb-popup__dialog {
		width: 100%;
		max-width: 100%;
		max-height: 100vh;
		left: 0;
		top: 0;
		transform: translate(0, 12%);
		border-radius: var(--apb-pop-radius) var(--apb-pop-radius) 0 0;
		bottom: 0;
		height: auto;
	}

	.apb-popup.is-open .apb-popup__dialog {
		transform: translate(0, 0);
		min-height: 100%;
	}

	.apb-popup__body {
		padding: 56px 22px 28px;
	}

	.apb-popup__close {
		top: 12px;
		right: 12px;
	}

	.apb-screen__title {
		font-size: 22px;
	}

	.apb-choice {
		grid-template-columns: 1fr;
	}

	.apb-choice-card {
		flex-direction: row;
		align-items: center;
		padding: 16px 16px;
	}

	.apb-choice-card__icon {
		margin-bottom: 0;
		margin-right: 4px;
	}

	.apb-choice-card__arrow {
		position: static;
		margin-left: auto;
	}
}

/* Reduced motion — strip the fancy transitions */

@media (prefers-reduced-motion: reduce) {
	.apb-popup,
	.apb-popup__dialog,
	.apb-screen,
	.apb-choice-card,
	.apb-btn-primary,
	.apb-results__item,
	.apb-loading__ring,
	.apb-loading__dot {
		animation: none !important;
		transition: none !important;
	}
}

/* ==========================================================================
   AIHV [aihv_popup_search] form — overrides when embedded in our popup
   ========================================================================== */

/* The AIHV search input wrap renders against a dark hero by default —
   rgba(255,255,255,.10) background + white icon. Reset to a light surface
   so it reads correctly inside our white popup card. */
.apb-popup .apb-selling-form .aihv-search-form__input-wrap {
	background: #F8FAFC;
	border: 1px solid var(--apb-pop-border);
	backdrop-filter: none;
	-webkit-backdrop-filter: none;
	border-radius: var(--apb-pop-radius-sm);
}

.apb-popup .apb-selling-form .aihv-search-form__input-wrap:focus-within {
	background: #fff;
	border-color: var(--apb-pop-primary);
	box-shadow: 0 0 0 4px var(--apb-pop-primary-ring);
}

/* Map-marker icon — was rgba(255,255,255,.5) (invisible on white). */
.apb-popup .apb-selling-form .aihv-search-form__icon {
	color: var(--apb-pop-text-muted);
}

.apb-popup .apb-selling-form .aihv-search-form__input-wrap:focus-within .aihv-search-form__icon {
	color: var(--apb-pop-primary);
}

.apb-popup .apb-selling-form .aihv-search-form__input {
	color: var(--apb-pop-ink);
}

.apb-popup .apb-selling-form .aihv-search-form__input::placeholder {
	color: var(--apb-pop-text-muted);
}

/* Submit CTA — pick up the popup's accent so the agent's theme color
   carries through to the "Get My Home Value" button. */
.apb-popup .apb-selling-form .aihv-search-form__btn {
	background: var(--apb-accent);
	color: #fff;
}

.apb-popup .apb-selling-form .aihv-search-form__btn:hover {
	background: var(--apb-accent-2);
}

/* ==========================================================================
   Google Places autocomplete dropdown — sits above the popup overlay
   ========================================================================== */

/* The popup overlay sits at z-index 2147483600. Google's autocomplete
   dropdown (.pac-container) is attached to <body> with its own much
   lower stacking value, so the suggestions would otherwise render
   behind our overlay and become unclickable. Force it above. */
.pac-container {
	z-index: 2147483647 !important;
}

/* ==========================================================================
   Aurora blobs — hidden but rules retained
   ========================================================================== */

/* All four blob selectors are forced display:none so the gradient mesh
   is fully invisible. The original sizing / radial-gradient / opacity
   declarations are kept intact above; only the rendering is suppressed. */
.apb-popup__aurora-blob,
.apb-popup__aurora-blob--a,
.apb-popup__aurora-blob--b,
.apb-popup__aurora-blob--c {
	display: none !important;
}

/* ==========================================================================
   Floating bubble — manual entry point on every front-end page
   ========================================================================== */

.apb-bubble {
	--apb-accent:    var(--accent, #6366F1);
	--apb-accent-2:  var(--accent-2, #A855F7);
	position: fixed;
	bottom: 20px;
	z-index: 2147483599;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 18px;
	border: none;
	border-radius: 999px;
	background: var(--apb-accent);
	color: #fff;
	font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 14px;
	font-weight: 600;
	letter-spacing: -.005em;
	cursor: pointer;
	box-shadow: 0 12px 28px -8px rgba(99, 102, 241, .55), 0 4px 10px rgba(15, 23, 42, .14);
	transition: background .2s ease, transform .2s ease, box-shadow .25s ease, opacity .2s ease;
}

.apb-bubble[hidden] {
	display: none !important;
}

.apb-bubble--bottom-right {
	right: 20px;
}

.apb-bubble--bottom-left {
	left: 20px;
}

.apb-bubble:hover,
.apb-bubble:focus-visible {
	background: var(--apb-accent-2);
	transform: translateY(-2px);
	box-shadow: 0 16px 34px -8px rgba(168, 85, 247, .60), 0 6px 12px rgba(15, 23, 42, .18);
	outline: none;
}

.apb-bubble__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 18px;
	line-height: 1;
	/* Emoji rendering: lean on the system emoji font where available so
	   the 🏠 glyph stays a glyph and doesn't pick up the surrounding
	   text-decoration / weight. */
	font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
}

.apb-bubble__label {
	white-space: nowrap;
}

/* Drop the bubble out of view while the popup is open so they never
   visually compete. .apb-popup-open is added to <html> by the popup
   engine on open. */
html.apb-popup-open .apb-bubble {
	opacity: 0;
	pointer-events: none;
}

/* Mobile — collapse to an icon-only circle to reclaim screen space. */
@media (max-width: 600px) {
	.apb-bubble {
		bottom: 16px;
		padding: 14px;
		border-radius: 50%;
	}
	.apb-bubble--bottom-right {
		right: 16px;
	}
	.apb-bubble--bottom-left {
		left: 16px;
	}
	.apb-bubble__icon {
		font-size: 22px;
	}
	.apb-bubble__label {
		display: none;
	}
}
