/**
 * Blog search — hero field, typeahead dropdown, header trigger + overlay.
 */

/* Accessible visually-hidden label (in case the theme lacks it). */
.screen-reader-text {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0);
	white-space: nowrap; border: 0;
}

/* ---------- Shared field ---------- */
.ha-search-field {
	position: relative;
	display: flex;
	align-items: center;
}

.ha-search-field__input {
	width: 100%;
	font-family: var(--ha-font-body, 'BrutalType', sans-serif);
	font-size: 1rem;
	line-height: 1.4;
	color: var(--ha-gray-800, rgb(38, 45, 53));
	background: var(--ha-white, #fff);
	border: 1px solid var(--ha-gray-200, rgb(230, 232, 235));
	border-radius: 9999px;
	padding: 0.7rem 2.75rem 0.7rem 1.1rem;
	outline: none;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.ha-search-field__input::placeholder { color: var(--ha-gray-600, rgb(125, 129, 134)); }

.ha-search-field__input:focus {
	border-color: var(--ha-blue-500, rgb(0, 167, 225));
	box-shadow: 0 0 0 3px #e5f6fc;
}

.ha-search-field__submit {
	position: absolute;
	right: 0.35rem;
	top: 50%;
	transform: translateY(-50%);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	border: 0;
	border-radius: 9999px;
	background: transparent;
	color: var(--ha-blue-500, rgb(0, 167, 225));
	cursor: pointer;
}
.ha-search-field__submit:hover { color: var(--ha-blue-600, rgb(46, 124, 192)); }

/* ---------- Hero search ---------- */
.ha-blog-search {
	max-width: 460px;
	margin: 1.5rem auto 0;
}

/* ---------- Typeahead dropdown ---------- */
/* display:flex below would otherwise override the UA [hidden]{display:none}
   (author beats UA at equal specificity), leaving an empty bordered box
   visible under the field. Keep [hidden] authoritative. */
.ha-search-suggest[hidden] { display: none; }

.ha-search-suggest {
	position: absolute;
	top: calc(100% + 0.5rem);
	left: 0;
	right: 0;
	z-index: 50;
	display: flex;
	flex-direction: column;
	background: var(--ha-white, #fff);
	border: 1px solid var(--ha-gray-200, rgb(230, 232, 235));
	border-radius: 1rem;
	box-shadow: 0 18px 50px rgba(38, 45, 53, 0.12);
	overflow: hidden;
	max-height: min(70vh, 520px);
	text-align: left;
}

/* The result list scrolls; the "all results" footer sits outside it (a flex
   sibling) so the scrollbar stops above the footer and the footer keeps both
   rounded bottom corners — no scrollbar gutter clipping one side. */
.ha-search-suggest__list {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
}

.ha-search-suggest__item {
	display: flex;
	gap: 0.85rem;
	align-items: center;
	padding: 0.75rem 1rem;
	text-decoration: none;
	color: var(--ha-gray-800, rgb(38, 45, 53));
	border-bottom: 1px solid #f1f2f4;
}
.ha-search-suggest__item:last-of-type { border-bottom: 0; }
.ha-search-suggest__item.is-active,
.ha-search-suggest__item:hover { background: #f5fbfe; }

.ha-search-suggest__thumb {
	flex: 0 0 auto;
	width: 56px;
	height: 42px;
	border-radius: 0.5rem;
	background-size: cover;
	background-position: center;
	background-color: var(--ha-blue-100, rgb(204, 237, 249));
}
.ha-search-suggest__thumb--empty { background-color: #e6e8eb; }

.ha-search-suggest__text { min-width: 0; }

.ha-search-suggest__cat {
	display: block;
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--ha-blue-600, rgb(46, 124, 192));
	font-weight: 600;
}
.ha-search-suggest__title {
	display: block;
	font-family: var(--ha-font-heading, 'Nexa', sans-serif);
	font-weight: 700;
	font-size: 0.95rem;
	line-height: 1.25;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.ha-search-suggest__excerpt {
	display: block;
	font-size: 0.8125rem;
	color: var(--ha-gray-600, rgb(125, 129, 134));
	line-height: 1.4;
	margin-top: 0.15rem;
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.ha-search-suggest mark {
	background: #fff4c8;
	color: inherit;
	padding: 0 1px;
	border-radius: 2px;
}

.ha-search-suggest__more {
	display: block;
	/* Non-scrolling footer: a flex sibling of the result list, always visible. */
	flex: 0 0 auto;
	text-align: center;
	padding: 0.8rem 1rem;
	font-weight: 600;
	font-size: 0.9rem;
	color: var(--ha-white, #fff);
	background: var(--ha-blue-500, rgb(0, 167, 225));
	text-decoration: none;
}
.ha-search-suggest__more:hover { background: var(--ha-blue-600, rgb(46, 124, 192)); }

.ha-search-suggest__empty {
	padding: 1rem;
	color: var(--ha-gray-600, rgb(125, 129, 134));
	font-size: 0.9rem;
}

/* Empty-state suggestions (frequent searches + topic tags) */
.ha-search-suggest__section { padding: 0.85rem 1rem; border-bottom: 1px solid #f1f2f4; }
.ha-search-suggest__section:last-child { border-bottom: 0; }
.ha-search-suggest__section-title {
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-weight: 700;
	color: var(--ha-gray-600, rgb(125, 129, 134));
	margin-bottom: 0.55rem;
}
.ha-search-suggest__chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ha-search-suggest__chip {
	border: 1px solid var(--ha-gray-200, rgb(230, 232, 235));
	background: #f5fbfe;
	color: var(--ha-blue-600, rgb(46, 124, 192));
	font-size: 0.85rem;
	font-weight: 600;
	padding: 0.35rem 0.8rem;
	border-radius: 9999px;
	cursor: pointer;
	transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.ha-search-suggest__chip:hover {
	background: var(--ha-blue-500, rgb(0, 167, 225));
	color: #fff;
	border-color: var(--ha-blue-500, rgb(0, 167, 225));
}

/* ---------- Header trigger ---------- */
.ha-search-trigger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 9999px;
	background: transparent;
	color: var(--ha-gray-800, rgb(38, 45, 53));
	cursor: pointer;
	transition: background-color 0.15s, color 0.15s;
}
.ha-search-trigger:hover {
	background: var(--ha-blue-100, rgb(204, 237, 249));
	color: var(--ha-blue-600, rgb(46, 124, 192));
}

/* ---------- Overlay ---------- */
/* The class rule below sets display:flex, which would otherwise override the
   [hidden] attribute (equal specificity) and leave the invisible overlay
   covering the viewport — blocking all clicks. Keep [hidden] authoritative. */
.ha-search-overlay[hidden] { display: none; }

.ha-search-overlay {
	position: fixed;
	inset: 0;
	z-index: 1000;
	background: rgba(38, 45, 53, 0.45);
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: clamp(4rem, 12vh, 9rem) 1rem 2rem;
	opacity: 0;
	transition: opacity 0.2s ease;
}
.ha-search-overlay.is-open { opacity: 1; }

.ha-search-overlay__panel {
	position: relative;
	width: 100%;
	max-width: 620px;
	transform: translateY(-8px);
	transition: transform 0.2s ease;
}
.ha-search-overlay.is-open .ha-search-overlay__panel { transform: translateY(0); }

.ha-search-overlay .ha-search-field__input {
	font-size: 1.15rem;
	padding: 1rem 3rem 1rem 1.25rem;
	box-shadow: 0 18px 50px rgba(38, 45, 53, 0.18);
}

.ha-search-overlay__close {
	position: absolute;
	top: -3.25rem;
	right: 0;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	background: var(--ha-white, #fff);
	border: 0;
	color: var(--ha-gray-800, rgb(38, 45, 53));
	font-size: 0.85rem;
	font-weight: 600;
	padding: 0.45rem 0.9rem;
	border-radius: 9999px;
	box-shadow: 0 4px 16px rgba(38, 45, 53, 0.28);
	cursor: pointer;
	transition: background-color 0.15s, color 0.15s;
}
.ha-search-overlay__close:hover {
	background: var(--ha-blue-100, rgb(204, 237, 249));
	color: var(--ha-blue-600, rgb(46, 124, 192));
}

@media (max-width: 600px) {
	/* Keep the close pill clear of the header on small screens. */
	.ha-search-overlay { padding-top: 5.5rem; }
	.ha-search-overlay__close { top: -3rem; }
}

body.ha-search-open { overflow: hidden; }

/* ---------- Search results page ---------- */
.ha-search-results__count {
	font-family: var(--ha-font-body, 'BrutalType', sans-serif);
	color: var(--ha-gray-600, rgb(125, 129, 134));
	margin: 0 0 1.5rem;
}
/* Relevanssi highlights matched terms with <strong> — show it like the
   typeahead's <mark> for a consistent look. */
.ha-search-results .ha-card__excerpt strong {
	background: #fff4c8;
	font-weight: 700;
	padding: 0 1px;
	border-radius: 2px;
}
.ha-search-empty { text-align: center; padding: 2rem 0 3rem; }
.ha-search-empty__lead {
	font-family: var(--ha-font-heading, 'Nexa', sans-serif);
	font-size: 1.4rem;
	font-weight: 700;
	color: var(--ha-gray-800, rgb(38, 45, 53));
}
.ha-search-empty__hint { color: var(--ha-gray-600, rgb(125, 129, 134)); margin: 0.5rem 0 1.5rem; }
.ha-search-empty__cats {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
	justify-content: center;
}
.ha-search-empty__cat {
	display: inline-block;
	padding: 0.45rem 1rem;
	border-radius: 9999px;
	background: var(--ha-blue-100, rgb(204, 237, 249));
	color: var(--ha-blue-600, rgb(46, 124, 192));
	text-decoration: none;
	font-weight: 600;
	font-size: 0.9rem;
}
.ha-search-empty__cat:hover { background: var(--ha-blue-500, rgb(0, 167, 225)); color: #fff; }

@media (max-width: 600px) {
	.ha-search-trigger { width: 36px; height: 36px; }
	.ha-search-suggest__excerpt { display: none; }
}
