/* Listing Manager — header search (icon in the primary menu + overlay) */

/* Menu icon: an <a> like the other items, so the theme's padding/colour/hover apply.
   Icon only on desktop; the "Search" label shows in the stacked mobile menu. */
.lm-search-item .lm-search-label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
}

.lm-search-item svg {
	vertical-align: -2px;
}

@media ( max-width: 768px ) {
	.lm-search-item .lm-search-label {
		position: static;
		width: auto;
		height: auto;
		overflow: visible;
		clip: auto;
		margin-left: 6px;
	}
}

/* Colours: light by default, remapped under html.dark-theme. */
.lm-search {
	--lms-bg: #fff;
	--lms-text: #1d1d1f;
	--lms-muted: #5f6368;
	--lms-border: #dfe3e8;
	--lms-hover: #f1f4f8;
	--lms-accent: #046ed0;
	--lms-shadow: 0 12px 32px rgba( 0, 0, 0, 0.18 );
}

.dark-theme .lm-search {
	--lms-bg: var( --lm-surface, #1f2229 );
	--lms-text: var( --lm-text, #e8e8ec );
	--lms-muted: var( --lm-text-muted, #a0a4ad );
	--lms-border: var( --lm-border, #2c2f37 );
	--lms-hover: #2a2e36;
	--lms-accent: #4d9fff;
	--lms-shadow: 0 12px 32px rgba( 0, 0, 0, 0.6 );
}

.lm-search[hidden] {
	display: none;
}

.lm-search {
	position: fixed;
	inset: 0;
	z-index: 100000;
	color: var( --lms-text );
}

.lm-search-backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 0, 0, 0, 0.45 );
}

/* Desktop: a panel under the icon (--lms-top / --lms-right are set by search.js). */
.lm-search-panel {
	position: absolute;
	top: var( --lms-top, 70px );
	right: var( --lms-right, 15px );
	width: min( 440px, calc( 100vw - 30px ) );
	max-height: calc( 100vh - var( --lms-top, 70px ) - 16px );
	overflow-y: auto;
	padding: 10px;
	background: var( --lms-bg );
	border: 1px solid var( --lms-border );
	border-radius: 12px;
	box-shadow: var( --lms-shadow );
}

/* Phone: full-width, full-height overlay. */
@media ( max-width: 768px ) {
	.lm-search-backdrop {
		display: none;
	}
	.lm-search-panel {
		top: 0;
		right: 0;
		left: 0;
		bottom: 0;
		width: 100%;
		max-height: none;
		padding: 12px 15px;
		border: 0;
		border-radius: 0;
		box-shadow: none;
	}
	html.lm-search-open {
		overflow: hidden;
	}
}

.lm-search-form {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var( --lms-muted );
}

.lm-search-form > svg {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
}

/* 16px stops iOS zooming the page when the field gets focus. */
.lm-search .lm-search-input {
	flex: 1;
	min-width: 0;
	height: 44px;
	padding: 0 12px;
	font-size: 16px;
	color: var( --lms-text );
	background: var( --lms-bg );
	border: 1px solid var( --lms-border );
	border-radius: 8px;
	-webkit-appearance: none;
	appearance: none;
}

.lm-search .lm-search-input::placeholder {
	color: var( --lms-muted );
	opacity: 1;
}

.lm-search .lm-search-input::-webkit-search-cancel-button {
	-webkit-appearance: none;
}

.lm-search .lm-search-close {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	color: var( --lms-muted );
	background: transparent;
	border: 0;
	border-radius: 8px;
	cursor: pointer;
}

.lm-search .lm-search-close:hover {
	color: var( --lms-text );
	background: var( --lms-hover );
}

.lm-search :focus-visible {
	outline: 2px solid var( --lms-accent );
	outline-offset: 2px;
}

.lm-search-results {
	list-style: none;
	margin: 8px 0 0;
	padding: 0;
}

.lm-search-results:empty {
	display: none;
}

.lm-search-results li {
	margin: 0;
}

.lm-search .lm-search-results a {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px;
	color: var( --lms-text );
	text-decoration: none;
	border-radius: 8px;
}

.lm-search .lm-search-results a:hover,
.lm-search .lm-search-results a:focus-visible {
	background: var( --lms-hover );
}

.lm-search-result-icon {
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	object-fit: cover;
	background: var( --lms-border );
	border-radius: 10px;
}

.lm-search-result-title {
	min-width: 0;
	font-size: 15px;
	font-weight: 600;
	overflow-wrap: anywhere;
}

.lm-search-status {
	margin: 8px 4px 0;
	font-size: 13px;
	color: var( --lms-muted );
}

.lm-search-status:empty {
	display: none;
}

/* Results page extras */
.lm-search-empty {
	color: inherit;
}
