/* Native content-row combobox. Result bodies use canonical Text/plain and Media. */
.ef-search {
	position: relative;
	min-width: 0;
	width: 100%;
}

.ef-search__surface {
	min-width: 0;
}

/* Search fields can sit flush with the card edge. Carry the actual card radius
   through the body and surface instead of clipping a small-radius input to it. */
.ef-card > .ef-card-body:has(> .ef-search),
.ef-card > .ef-card-body > .ef-search {
	border-radius: inherit;
}

.ef-card > .ef-card-body > .ef-search > .ef-search__surface,
.ef-card > .ef-card-body > .ef-search .ef-search__bar,
.ef-card > .ef-card-body > .ef-search .ef-search__panel {
	border-radius: inherit;
}

.ef-search[data-ef-search-compact="true"]:only-child {
	width: auto;
}

.ef-search__surface[popover] {
	position: fixed;
	inset: auto;
	margin: 0;
	box-sizing: border-box;
	max-width: calc(100vw - 16px);
	padding: var(--ef-space-s);
	border: var(--ef-border-default) solid var(--ef-color-gray_light);
	border-radius: var(--ef-radius-m);
	background: var(--ef-color-white_surface);
	color: var(--ef-color-white_contrast);
	box-shadow: var(--ef-shadow-panel);
	overflow: visible;
}

/* Compact search occupies the same single-button slot as navbar actions,
   including beside the hamburger when the full navigation is hidden. */
.ef-navbar > .ef-navbar-content:has(> .ef-search[data-ef-search-compact="true"]:only-child) {
	display: grid;
	flex: 0 0 auto;
	min-inline-size: 0;
	max-inline-size: none;
}

.ef-navbar:has(> .ef-navbar-content > .ef-search[data-ef-search-compact="true"]:only-child) > .ef-navbar-toggle {
	margin-inline-start: 0;
}

.ef-search__bar {
	position: relative;
	display: flex;
	align-items: center;
	gap: var(--ef-space-s);
	box-sizing: border-box;
	height: var(--_btn-size, var(--ef-size-touch-target));
	padding-inline: calc(var(--ef-space-s) * 2 + var(--_btn-size, var(--ef-size-touch-target))) var(--ef-space-s);
	border: var(--ef-border-default) solid var(--ef-color-gray_light);
	border-radius: var(--ef-radius-s);
	background: var(--ef-color-white_surface);
	color: var(--ef-color-white_contrast);
}

/* Promote the card's own search without activating fields in nested cards.
   Hover paint stays separate from the keyboard focus ring and field geometry. */
@media (hover: hover) and (pointer: fine) {
	.ef-card:hover > .ef-card-body > .ef-search .ef-search__bar {
		border-color: var(--ef-color-primary);
		background: var(--ef-color-primary_light_surface);
		color: var(--ef-color-primary_light_contrast);
	}

	/* A nested wrapper starts a new hover owner, including main wrappers.
	   The page-level main must never promote every search on the page. */
	@scope (.ef-wrapper:not(main, [role="main"], .ef-wrapper-tag--main)) to (.ef-wrapper) {
		:scope:hover .ef-search__bar {
			border-color: var(--ef-color-primary);
			background: var(--ef-color-primary_light_surface);
			color: var(--ef-color-primary_light_contrast);
		}
	}
}

.ef-search__bar:focus-within {
	padding-inline: var(--ef-space-s) calc(var(--ef-space-s) * 2 + var(--_btn-size, var(--ef-size-touch-target)));
	outline: var(--ef-border-strong) solid var(--ef-color-primary);
	outline-offset: 2px;
}

/* The bar owns field chrome. Match focus explicitly so theme input focus
   selectors cannot paint a second border or shadow inside that field. */
.ef-search .ef-search__bar input[type="search"],
.ef-search .ef-search__bar input[type="search"]:focus,
.ef-search .ef-search__bar input[type="search"]:focus-visible {
	flex: 1;
	min-width: 0;
	width: 100%;
	height: 100%;
	min-height: 0;
	padding: 0;
	/* Elementor kit input rules may be !important. This owned inner input
	   must stay chromeless because the enclosing bar supplies visible focus. */
	border: 0 !important;
	border-radius: 0 !important;
	outline: none !important;
	box-shadow: none !important;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: max(16px, 1em);
	appearance: none;
}

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

.ef-search__icon,
.ef-search__clear svg {
	flex-shrink: 0;
	width: 20px;
	height: 20px;
}

.ef-search__submit,
.ef-search__clear {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	min-width: var(--_btn-size, var(--ef-size-touch-target));
	height: 100%;
	min-height: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.ef-search__bar input[type="search"] {
	order: 1;
}

.ef-search__clear {
	order: 2;
}

/* Keep the submit control in one stable hit target while logical positioning
   interpolates between field edges. Logical insets also reverse naturally in RTL. */
.ef-search__submit {
	position: absolute;
	inset-block: 0;
	inset-inline-start: var(--ef-space-s);
	width: var(--_btn-size, var(--ef-size-touch-target));
	height: auto;
}

.ef-search__bar:focus-within .ef-search__submit {
	inset-inline-start: calc(100% - var(--ef-space-s) - var(--_btn-size, var(--ef-size-touch-target)));
}

@media (prefers-reduced-motion: no-preference) {
	.ef-search__submit {
		transition: inset-inline-start var(--ef-motion-default) var(--ef-ease-out);
	}

	.ef-search__bar {
		transition: padding-inline var(--ef-motion-default) var(--ef-ease-out),
			border-color var(--ef-motion-default) var(--ef-ease-out),
			background-color var(--ef-motion-default) var(--ef-ease-out),
			color var(--ef-motion-default) var(--ef-ease-out);
	}
}

.ef-search__submit:disabled {
	cursor: default;
}

.ef-search__submit:focus-visible,
.ef-search__clear:focus-visible,
.ef-search__all:focus-visible {
	outline: var(--ef-border-strong) solid var(--ef-color-primary);
	outline-offset: 2px;
}

.ef-search__all {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	margin-top: var(--ef-space-s);
	padding: var(--ef-space-s);
	border-top: var(--ef-border-default) solid var(--ef-color-gray_light);
	color: inherit;
	font-size: var(--ef-font-small);
	text-align: center;
}

.ef-search__panel {
	position: absolute;
	inset: auto;
	top: 100%;
	left: 0;
	z-index: 100;
	box-sizing: border-box;
	width: 100%;
	max-width: calc(100vw - 16px);
	max-height: min(70dvh, 32rem);
	margin: 0;
	padding: var(--ef-space-s);
	overflow: auto;
	overscroll-behavior: contain;
	border: var(--ef-border-default) solid var(--ef-color-gray_light);
	border-radius: var(--ef-radius-s);
	background: var(--ef-color-white_surface);
	color: var(--ef-color-white_contrast);
}

.ef-search__panel[popover] {
	position: fixed;
}

.ef-search [hidden] {
	display: none !important;
}

.ef-search__message {
	padding: var(--ef-space-s);
	font-size: var(--ef-font-small);
}


.ef-search__option {
	display: block;
	min-height: 44px;
	padding: var(--ef-space-s);
	border-radius: var(--ef-radius-s);
	color: inherit;
	text-decoration: none;
	overflow-wrap: anywhere;
}

.ef-search__option:hover,
.ef-search__option[aria-selected="true"] {
	background: var(--ef-color-primary_light_surface);
	color: var(--ef-color-primary_light_contrast);
}

.ef-search__option .ef-text-row {
	margin: 0;
}

.ef-search__result {
	display: flex;
	align-items: center;
	gap: var(--ef-space-s);
}

.ef-search__result > .ef-text-row {
	flex: 0 1 auto;
	min-width: 0;
}

.ef-search__result .ef-ih-heading {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ef-search__media {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 1.5rem;
	width: 1.5rem;
	height: 1.5rem;
}

.ef-search__media > :is(.ef-ih-media, .ef-ih-icon) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 100%;
	width: 100%;
	height: 100%;
}

.ef-search__media img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.ef-search__type {
	flex-shrink: 0;
	font-size: var(--ef-font-small);
}

/* Inert type metadata is smaller than interactive pills. Keep native palette. */
.ef-search__type .ef-pill.ef-pill {
	--_pill-pad-block: var(--ef-space-2xs);
	--_pill-pad-inline: var(--ef-space-xs);
	min-height: 0;
	font-size: 0.6875rem;
	line-height: 1;
}

.ef-search__retry {
	min-height: 44px;
	margin: var(--ef-space-s);
}
