/**
 * Theme Search — single form: shell → toggle + inner → search (form + results).
 * Bar vs icon per breakpoint via root modifiers + media queries (px only).
 */

.bolt-theme-search.bolt-simple-search,
.bolt-simple-search[data-bolt-simple-search] {
	--bolt-ts-accent: var(--wp--preset--color--primary, #0056b3);
	--bolt-ts-border: var(--wp--preset--color--contrast-faded, #8693a3);
	--bolt-ts-surface: var(--wp--preset--color--base, #fff);
	--bolt-ts-text: var(--wp--preset--color--contrast, #1f2937);
	--bolt-ts-input-border: #ccd4df;
	--bolt-ts-form-border: #d9e0ea;
	--bolt-ts-muted: #4b5563;
	--bolt-ts-placeholder: #8693a3;

	position: relative;
	z-index: 1;
	isolation: isolate;
}

.bolt-theme-search {
	--bolt-ts-bar-width: 560px;

	display: block;
	width: min(100%, var(--bolt-ts-bar-width));
	max-width: 100%;
}

.bolt-theme-search__shell {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
	position: relative;
	width: 100%;
	min-width: 0;
}

.bolt-theme-search__toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	flex-shrink: 0;
	border: 1px solid color-mix(in srgb, var(--bolt-ts-border, #8693a3) 35%, transparent);
	border-radius: 50%;
	background: var(--bolt-ts-surface, #fff);
	color: var(--bolt-ts-accent, #0056b3);
	cursor: pointer;
	transition: background 0.2s ease, border-color 0.2s ease;
}

.bolt-theme-search__toggle:hover {
	border-color: var(--bolt-ts-accent, #0056b3);
}

.bolt-theme-search__toggle[aria-expanded="true"] {
	background: color-mix(in srgb, var(--bolt-ts-accent, #0056b3) 12%, var(--bolt-ts-surface, #fff));
}

.bolt-theme-search__inner {
	min-width: 0;
	flex: 1;
}

.bolt-theme-search__inner:not(.is-open):not(.bolt-theme-search__inner--static) {
	display: none;
}

.bolt-theme-search__inner.is-open,
.bolt-theme-search__inner--static {
	display: block;
}

.bolt-theme-search__inner--static {
	display: block !important;
}

.bolt-theme-search__search {
	position: relative;
	width: 100%;
	min-width: 0;
}

.bolt-theme-search__svg {
	display: block;
}

.bolt-simple-search {
	position: relative;
}

.bolt-simple-search__form {
	display: flex;
	gap: 8px;
	margin: 0;
	padding: 6px;
	background: var(--bolt-ts-surface);
	border: 1px solid var(--bolt-ts-form-border);
	border-radius: 12px;
	box-shadow: 0 8px 20px rgba(17, 24, 39, 0.08);
	align-items: stretch;
}

.bolt-simple-search__input {
	flex: 1;
	min-width: 0;
	height: 44px;
	padding: 0 14px;
	font-size: 15px;
	border: 1px solid var(--bolt-ts-input-border);
	border-radius: 9px;
	background: var(--bolt-ts-surface);
	color: var(--bolt-ts-text);
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.bolt-simple-search__input::placeholder {
	color: var(--bolt-ts-placeholder);
}

.bolt-simple-search__input:focus {
	outline: none;
	border-color: var(--bolt-ts-accent);
}

.bolt-simple-search__button,
.bolt-theme-search__submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 44px;
	padding: 0 16px;
	border: none;
	border-radius: 9px;
	background: var(--bolt-ts-accent);
	color: var(--bolt-ts-surface);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.12s ease, filter 0.2s ease;
}

.bolt-simple-search__button:hover,
.bolt-theme-search__submit:hover {
	filter: brightness(0.92);
}

.bolt-simple-search__button:active,
.bolt-theme-search__submit:active {
	transform: translateY(1px);
}

.bolt-simple-search__button:focus-visible,
.bolt-theme-search__submit:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--bolt-ts-accent) 35%, transparent);
}

.bolt-simple-search .bolt-theme-search__submit:has(.bolt-theme-search__svg) {
	width: 44px;
	min-width: 44px;
	padding: 0;
	font-size: 0;
	line-height: 0;
}

.bolt-simple-search .bolt-theme-search__submit:has(.bolt-theme-search__svg):hover {
	filter: brightness(0.92);
}

@media (max-width: 640px) {
	.bolt-simple-search__form {
		flex-direction: column;
	}

	.bolt-simple-search__button {
		width: 100%;
	}

	.bolt-simple-search .bolt-theme-search__submit:has(.bolt-theme-search__svg) {
		width: 100%;
		min-width: 0;
		height: 44px;
	}
}

.bolt-simple-search__loading {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	font-size: 13px;
	color: var(--bolt-ts-muted);
}

.bolt-simple-search__loading-spinner {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	border-radius: 50%;
	border: 2px solid #d7deea;
	border-top-color: var(--bolt-ts-accent);
	animation: bolt-simple-search-spin 0.8s linear infinite;
}

.bolt-simple-search__results-grid {
	display: flex;
	flex-direction: column;
	padding: 0;
}

.bolt-simple-search__result-card {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 14px 16px;
	border-bottom: 1px solid #f0f2f5;
	transition: background 0.15s ease;
}

.bolt-simple-search__result-card:hover {
	background: #f7f9fc;
}

.bolt-simple-search__result-card:last-child {
	border-bottom: none;
}

.bolt-simple-search__result-card-image-link {
	display: block;
	width: 64px;
	height: 64px;
	border-radius: 8px;
	overflow: hidden;
	flex-shrink: 0;
	background: #f3f4f6;
	line-height: 0;
}

.bolt-simple-search__result-card-image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.bolt-simple-search__result-card-content {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.bolt-simple-search__result-card-title {
	font-size: 14px;
	line-height: 18px;
	margin: 0 0 4px;
	font-weight: 600;
}

.bolt-simple-search__result-card-title a {
	color: var(--bolt-ts-accent);
	text-decoration: none;
}

.bolt-simple-search__result-card-title a:hover {
	text-decoration: underline;
}

.bolt-simple-search__result-card-excerpt {
	font-size: 13px;
	line-height: 18px;
	color: #555;
	display: -webkit-box;
	line-clamp: 2;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.bolt-simple-search__result-card-score {
	margin-top: 6px;
	font-size: 12px;
	line-height: 16px;
	font-family: ui-monospace, monospace;
	color: #6b7280;
}

.bolt-simple-search__empty {
	padding: 14px 16px;
	font-size: 13px;
	line-height: 22px;
	color: var(--bolt-ts-muted);
	background: linear-gradient(180deg, #fbfcfe 0%, #f7f9fc 100%);
	border-radius: 0 0 12px 12px;
}

.bolt-theme-search__search .bolt-simple-search__results,
.bolt-theme-search__search .bolt-theme-search__results {
	position: absolute;
	top: calc(100% + 2px);
	left: 0;
	width: 100%;
	background: var(--bolt-ts-surface);
	border: 1px solid #e3e7ed;
	border-radius: 0 0 12px 12px;
	box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
	max-height: min(420px, 70vh);
	overflow-y: auto;
	z-index: 999;
	margin: 0;
	padding: 0;
	list-style: none;
	display: none;
}

.bolt-theme-search__search .bolt-simple-search__results.is-active,
.bolt-theme-search__search .bolt-theme-search__results.is-active {
	display: block;
}

@media (min-width: 778px) {
	.bolt-theme-search--desktop-bar .bolt-theme-search__toggle {
		display: none !important;
	}

	.bolt-theme-search--desktop-bar .bolt-theme-search__inner {
		display: block !important;
		flex: 1;
	}

	.bolt-theme-search--desktop-icon .bolt-theme-search__toggle {
		display: inline-flex !important;
	}

	.bolt-theme-search--desktop-icon .bolt-theme-search__shell {
		justify-content: flex-end;
	}

	.bolt-theme-search--desktop-icon .bolt-theme-search__inner:not(.is-open) {
		display: none !important;
	}

	.bolt-theme-search--desktop-icon .bolt-theme-search__inner.is-open {
		display: block !important;
		position: absolute;
		top: calc(100% + 8px);
		right: 0;
		z-index: 50;
		flex: none;
		width: 420px;
		padding: 0;
		border-radius: 12px;
		border: 1px solid color-mix(in srgb, var(--bolt-ts-border, #8693a3) 30%, transparent);
		background: var(--bolt-ts-surface, #fff);
		box-shadow: 0 8px 24px rgba(17, 24, 39, 0.12);
	}

	.bolt-theme-search--desktop-icon .bolt-theme-search__inner.is-open .bolt-simple-search__form {
		box-shadow: none;
	}
}

@media (max-width: 777px) {
	.bolt-theme-search {
		width: 100%;
		max-width: 100%;
	}

	.bolt-theme-search--mobile-bar .bolt-theme-search__toggle {
		display: none !important;
	}

	.bolt-theme-search--mobile-bar .bolt-theme-search__inner {
		display: block !important;
		flex: 1;
	}

	.bolt-theme-search--mobile-icon .bolt-theme-search__toggle {
		display: inline-flex !important;
	}

	.bolt-theme-search--mobile-icon .bolt-theme-search__shell {
		justify-content: flex-end;
	}

	.bolt-theme-search--mobile-icon .bolt-theme-search__inner:not(.is-open) {
		display: none !important;
	}

	.bolt-theme-search--mobile-icon .bolt-theme-search__inner.is-open {
		display: block !important;
		position: absolute;
		top: calc(100% + 8px);
		right: 0;
		left: auto;
		z-index: 50;
		flex: none;
		width: min(320px, calc(100vw - 24px));
		padding: 12px;
		border-radius: 12px;
		border: 1px solid color-mix(in srgb, var(--bolt-ts-border, #8693a3) 30%, transparent);
		background: var(--bolt-ts-surface, #fff);
		box-shadow: 0 8px 24px rgba(17, 24, 39, 0.12);
	}

	.bolt-theme-search--mobile-icon .bolt-theme-search__inner.is-open .bolt-simple-search__form {
		flex-direction: row;
		box-shadow: none;
	}

	.bolt-theme-search--mobile-icon .bolt-theme-search__inner.is-open .bolt-simple-search__button,
	.bolt-theme-search--mobile-icon .bolt-theme-search__inner.is-open .bolt-theme-search__submit {
		width: auto;
	}

	.bolt-theme-search--mobile-icon .bolt-theme-search__inner.is-open .bolt-theme-search__submit:has(.bolt-theme-search__svg) {
		width: 44px;
		min-width: 44px;
	}
}

.bolt-simple-search[data-bolt-simple-search]:not(.bolt-theme-search) {
	width: min(100%, 560px);
	max-width: 100%;
}

.bolt-simple-search[data-bolt-simple-search]:not(.bolt-theme-search) .bolt-theme-search__toggle {
	display: none !important;
}

.bolt-simple-search[data-bolt-simple-search]:not(.bolt-theme-search) .bolt-theme-search__shell {
	justify-content: stretch;
}

.bolt-simple-search[data-bolt-simple-search]:not(.bolt-theme-search) .bolt-theme-search__inner {
	flex: 1;
}

.bolt-theme-search__results li {
	margin: 0;
}

.bolt-theme-search__results a {
	display: block;
	padding: 8px 12px;
	color: var(--bolt-ts-text, #1f2937);
	text-decoration: none;
	font-size: 15px;
	line-height: 22px;
	border-radius: 6px;
	transition: background 0.15s ease;
}


.bolt-theme-search__results .bolt-theme-search__meta {
	display: block;
	margin-top: 2px;
	font-size: 12px;
	color: color-mix(in srgb, var(--bolt-ts-text, #1f2937) 55%, transparent);
	text-transform: uppercase;
	letter-spacing: 1px;
}

@keyframes bolt-simple-search-spin {
	from {
		transform: rotate(0deg);
	}

	to {
		transform: rotate(360deg);
	}
}
