/* ==========================================================================
   Live-search box (ahan_search_box) — printed once by the component.
   ========================================================================== */

/* The form does not clip (no overflow:hidden): the results card hangs
   outside it. Corner rounding therefore lives on the input and the button. */
.ahan-search {
	position: relative;
	display: flex;
	flex-direction: row-reverse;
	align-items: center;
	background: var(--c-bg);
	border-radius: var(--radius-sm);
}

.ahan-search__input {
	flex: 1;
	min-width: 0;
	font: inherit;
	font-size: var(--fs-sm);
	padding: 12px 16px;
	border: 1px solid var(--c-border);
	border-radius: var(--radius-sm);
	background: var(--c-surface);
	color: var(--c-text);
}

/* The form is row-reverse: the button sits at the start (right) edge and meets the input there,
   so that side has no border and no rounding; the outer (end/left) side keeps both. */
.ahan-search__input {
	min-height: 0; /* the base field style (v2 pages) sets 52px */
	border-inline-start: 0;
	border-start-start-radius: 0;
	border-end-start-radius: 0;
}

.ahan-search__input:focus {
	outline: 2px solid var(--c-primary);
	outline-offset: -2px;
}

/* Clear (×): visible only while the input has a value (search.js / header.js). */
.ahan-search__clear {
	display: none;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	flex-shrink: 0;
	border: 0;
	background: none;
	color: var(--c-text-muted);
	cursor: pointer;
}

.ahan-search__clear svg {
	width: 16px;
	height: 16px;
}

.ahan-search.has-value .ahan-search__clear {
	display: inline-flex;
}

.ahan-search__submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 40px;
	flex-shrink: 0;
	border: 0;
	border-radius: var(--radius-sm);
	border-start-end-radius: 0;
	border-end-end-radius: 0;
	background: var(--c-primary);
	color: var(--c-primary-contrast);
	cursor: pointer;
}

.ahan-search__submit svg {
	width: 20px;
	height: 20px;
}

/* ---------- Results card (floating under the input) ---------- */

/* Shown through :not(:empty), so the entrance runs each time results first
   appear (not on every re-render while it is open). */
.ahan-search__results {
	display: none;
	position: absolute;
	inset-inline: 0;
	top: 100%;
	margin-top: 6px;
	z-index: 40;
	max-height: 60vh;
	overflow-y: auto;
	background: var(--c-surface);
	border: 1px solid var(--c-border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow);
	animation: ahan-search-in .18s ease both;
}

.ahan-search__results:not(:empty) {
	display: block;
}

.ahan-search__result {
	display: block;
	padding: 10px 16px;
	color: var(--c-text);
	text-decoration: none;
	font-size: var(--fs-sm);
	border-bottom: 1px solid var(--c-border);
	transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.ahan-search__result:last-child {
	border-bottom: 0;
}

.ahan-search__result:hover {
	color: var(--c-primary);
	background: var(--c-bg);
}

.ahan-search__empty {
	margin: 0;
	padding: 12px 16px;
	font-size: var(--fs-sm);
	color: var(--c-text-muted);
	text-align: center;
}

/* ---------- Loading dots ---------- */

.ahan-search__loader {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 16px;
}

.ahan-search__loader span {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--c-text-muted);
	animation: ahan-search-bounce .6s infinite alternate;
}

.ahan-search__loader span:nth-child(2) {
	animation-delay: .2s;
}

.ahan-search__loader span:nth-child(3) {
	animation-delay: .4s;
}

@keyframes ahan-search-bounce {
	from {
		opacity: .3;
		transform: translateY(0);
	}
	to {
		opacity: 1;
		transform: translateY(-5px);
	}
}

@keyframes ahan-search-in {
	from {
		opacity: 0;
		transform: translateY(-6px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ahan-search__results,
	.ahan-search__loader span {
		animation: none;
	}

	.ahan-search__result {
		transition-duration: .01ms;
	}
}

/* The box has its own clear (×) button: hide the browser's native one (it printed a second ×). */
.ahan-search__input::-webkit-search-cancel-button {
	appearance: none;
	display: none;
}

/* hover-states */
.ahan-search__clear {
	transition: color var(--dur-fast) var(--ease);
}

.ahan-search__submit {
	transition: filter var(--dur-fast) var(--ease);
}

@media (hover: hover) {
	.ahan-search__clear:hover {
		color: var(--c-text);
	}

	.ahan-search__submit:hover {
		filter: brightness(1.15);
	}
}

@media (prefers-reduced-motion: reduce) {
	.ahan-search__clear,
	.ahan-search__submit {
		transition-duration: 0.01ms;
	}
}
/* ---------- Large variant (ahan_search_box size 'lg': the hero of search/archive pages) ---------- */

.ahan-search--lg {
	background: transparent;
	filter: drop-shadow(0 4px 12px rgba(94, 5, 32, 0.12));
}

.ahan-search--lg .ahan-search__input {
	min-height: 56px;
	padding-inline: 20px;
	font-size: var(--fs-base);
}

.ahan-search--lg .ahan-search__submit {
	width: 64px;
	height: 56px;
}

.ahan-search--lg .ahan-search__submit svg {
	width: 24px;
	height: 24px;
}

.ahan-search--lg .ahan-search__clear {
	width: 36px;
	height: 56px;
	background: var(--c-surface);
}
