/**
 * AI Site Agent — Frontend Stylesheet
 *
 * Loaded on every page when Design Agent templates are active.
 * Covers: search overlay, newsletter toast, sticky nav, TOC.
 *
 * @package AI_Site_Agent
 */

/* ── Accessibility helpers ────────────────────────────────────────────────── */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0,0,0,0);
	white-space: nowrap;
	border: 0;
}

/* ── Sticky nav enhancements ─────────────────────────────────────────────── */
.ain {
	transition: box-shadow .2s, transform .25s;
}
.ain.ain-scrolled {
	box-shadow: 0 2px 12px rgba(0,0,0,.18);
}
.ain.ain-hidden {
	transform: translateY(-100%);
}

/* ── Search button in nav ────────────────────────────────────────────────── */
.ain-search {
	display: flex;
	align-items: center;
	gap: 5px;
	background: transparent;
	border: 1.5px solid rgba(255,255,255,.35);
	color: #fff;
	padding: 6px 14px;
	border-radius: 20px;
	cursor: pointer;
	font-size: 13px;
	font-family: inherit;
	transition: background .18s, border-color .18s;
}
.ain-search:hover,
.ain-search:focus {
	background: rgba(255,255,255,.12);
	border-color: rgba(255,255,255,.6);
	outline: none;
}

/* ── Search Overlay ──────────────────────────────────────────────────────── */
#ai-search-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(10,10,20,.72);
	z-index: 99999;
	align-items: flex-start;
	justify-content: center;
	padding-top: 80px;
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	animation: ai-overlay-in .18s ease;
}
#ai-search-overlay.open {
	display: flex;
}
@keyframes ai-overlay-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

.ai-search-box {
	background: #fff;
	border-radius: 12px;
	width: 100%;
	max-width: 640px;
	box-shadow: 0 24px 64px rgba(0,0,0,.35);
	overflow: hidden;
	animation: ai-box-in .2s ease;
}
@keyframes ai-box-in {
	from { transform: translateY(-20px) scale(.97); opacity: 0; }
	to   { transform: translateY(0) scale(1); opacity: 1; }
}

.ai-search-input-row {
	display: flex;
	align-items: center;
	padding: 14px 18px;
	border-bottom: 1px solid #f0f0f0;
	gap: 10px;
}
.ai-search-icon {
	font-size: 18px;
	flex-shrink: 0;
	color: #999;
}
.ai-search-input {
	flex: 1;
	border: none;
	outline: none;
	font-size: 17px;
	font-family: inherit;
	color: #1d2327;
	background: transparent;
}
.ai-search-input::placeholder {
	color: #bbb;
}
#ai-search-close {
	background: #f5f5f5;
	border: none;
	border-radius: 50%;
	width: 30px;
	height: 30px;
	cursor: pointer;
	font-size: 14px;
	color: #555;
	flex-shrink: 0;
	transition: background .15s;
}
#ai-search-close:hover {
	background: #e5e5e5;
}

/* Search results list */
#ai-search-results {
	max-height: 420px;
	overflow-y: auto;
}
.ai-sr-list {
	list-style: none;
	margin: 0;
	padding: 8px 0;
}
.ai-sr-item {
	margin: 0;
}
.ai-sr-link {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 12px 18px;
	text-decoration: none;
	color: #1d2327;
	transition: background .13s;
}
.ai-sr-link:hover {
	background: #f7f7fb;
}
.ai-sr-thumb {
	width: 60px;
	height: 60px;
	border-radius: 6px;
	object-fit: cover;
	flex-shrink: 0;
	background: #eee;
}
.ai-sr-thumb-placeholder {
	opacity: .3;
}
.ai-sr-text {
	flex: 1;
	min-width: 0;
}
.ai-sr-cat {
	display: inline-block;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: .5px;
	text-transform: uppercase;
	color: #fff;
	padding: 2px 7px;
	border-radius: 3px;
	margin-bottom: 4px;
}
.ai-sr-title {
	display: block;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	margin-bottom: 3px;
	color: #1d2327;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.ai-sr-title mark {
	background: #fff3cd;
	color: inherit;
	border-radius: 2px;
}
.ai-sr-excerpt {
	display: block;
	font-size: 12px;
	color: #777;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.ai-sr-date {
	display: block;
	font-size: 11px;
	color: #aaa;
	margin-top: 2px;
}
.ai-sr-loading,
.ai-sr-none {
	padding: 20px 24px;
	color: #888;
	font-size: 14px;
	text-align: center;
}

/* Body scroll lock when overlay open */
body.ai-search-open {
	overflow: hidden;
}

/* ── Table of Contents ───────────────────────────────────────────────────── */
.ai-toc {
	background: #f8f9fa;
	border-left: 3px solid var(--ai-primary, #e63946);
	border-radius: 0 6px 6px 0;
	padding: 16px 20px;
	margin: 24px 0 28px;
	max-width: 520px;
}
.ai-toc-title {
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .5px;
	color: #555;
	margin: 0 0 10px;
}
.ai-toc-list {
	margin: 0;
	padding: 0 0 0 18px;
}
.ai-toc-item {
	margin: 5px 0;
}
.ai-toc-h3 {
	padding-left: 14px;
	font-size: 13px;
}
.ai-toc-item a {
	color: #1d2327;
	font-size: 13.5px;
	text-decoration: none;
	line-height: 1.5;
}
.ai-toc-item a:hover {
	color: var(--ai-primary, #e63946);
	text-decoration: underline;
}

/* ── Toast notifications ─────────────────────────────────────────────────── */
.ai-toast {
	font-family: -apple-system, 'Segoe UI', Arial, sans-serif;
	pointer-events: none;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
	#ai-search-overlay {
		padding-top: 0;
		align-items: flex-end;
	}
	.ai-search-box {
		border-radius: 12px 12px 0 0;
		max-width: 100%;
		animation: ai-box-in-mobile .2s ease;
	}
	@keyframes ai-box-in-mobile {
		from { transform: translateY(30px); opacity: 0; }
		to   { transform: translateY(0);    opacity: 1; }
	}
	#ai-search-results {
		max-height: 55vh;
	}
}
