/**
 * Full screen product search opened by the [heimdal_buscador] shortcode.
 *
 * The overlay is appended to <body>, so it is never clipped by a theme header with
 * overflow hidden. Its z-index sits above the usual sticky headers.
 */

/* Magnifier button printed by the shortcode. */

/*
 * Themes style every <button> in the page — background, border, radius, padding,
 * min-height — so the trigger states its own reset rather than inheriting whatever
 * the theme's button rules happen to be. It has to read as a bare icon.
 */
.heimdal-search-toggle {
	display: inline-flex !important;
	align-items: center;
	gap: .4em;
	width: auto !important;
	min-width: 0 !important;
	height: auto !important;
	min-height: 0 !important;
	padding: 0 !important;
	margin: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	background: none !important;
	background-color: transparent !important;
	background-image: none !important;
	box-shadow: none !important;
	text-decoration: none !important;
	text-transform: none !important;
	color: var( --heimdal-search-icon-color, currentColor ) !important;
	cursor: pointer;
	line-height: 1;
	vertical-align: middle;
}

.heimdal-search-toggle:hover,
.heimdal-search-toggle:focus,
.heimdal-search-toggle:focus-visible {
	background: none !important;
	background-color: transparent !important;
	border: 0 !important;
	box-shadow: none !important;
	color: var( --heimdal-search-icon-color, currentColor ) !important;
	opacity: .75;
}

.heimdal-search-toggle__icon {
	display: block;
	width: var( --heimdal-search-icon-size, 24px );
	height: var( --heimdal-search-icon-size, 24px );
}

.heimdal-search-toggle__text {
	font: inherit;
}

/* Overlay. */

.heimdal-search-overlay {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	justify-content: center;
	align-items: flex-start;
	padding: 8vh 1rem 2rem;
	background: rgba( 0, 0, 0, .82 );
	opacity: 0;
	transition: opacity .2s ease;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.heimdal-search-overlay.is-visible {
	opacity: 1;
}

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

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

.heimdal-search-panel {
	position: relative;
	width: 100%;
	max-width: 720px;
	color: #fff;
}

.heimdal-search-close {
	position: absolute;
	top: -3rem;
	right: 0;
	display: inline-flex;
	padding: .5rem;
	border: 0;
	background: none !important;
	color: #fff !important;
	cursor: pointer;
	line-height: 0;
}

.heimdal-search-close:hover,
.heimdal-search-close:focus-visible {
	opacity: .7;
}

/* Search field. */

.heimdal-search-field {
	display: flex;
	align-items: center;
	gap: .75rem;
	padding: .35rem 1rem;
	background: #fff;
	border-radius: 8px;
}

.heimdal-search-field__icon {
	flex: 0 0 auto;
	color: #666;
}

.heimdal-search-input {
	flex: 1 1 auto;
	width: 100%;
	padding: .85rem 0;
	border: 0 !important;
	outline: none;
	background: transparent;
	box-shadow: none !important;
	color: #111 !important;
	font-size: 1.15rem;
	line-height: 1.3;
}

.heimdal-search-input::-webkit-search-cancel-button {
	cursor: pointer;
}

/*
 * Belt and braces against other search plugins. They look for search inputs in the
 * DOM and graft their own autocomplete, clear button and results panel onto them —
 * which inside this overlay reads as a second search stacked on the first. The
 * markup already avoids their hooks (no type="search", no name="s"); should one
 * still latch on, whatever it injects here is hidden rather than layered on top.
 */
.heimdal-search-field .yith-ajaxsearchform-container,
.heimdal-search-field .autocomplete-suggestions,
.heimdal-search-field .yith-s-results,
.heimdal-search-field .yith-ajaxsearchform-container .clear,
.heimdal-search-results .autocomplete-suggestions {
	display: none !important;
}

/* Results. */

.heimdal-search-results {
	margin-top: 1rem;
}

.heimdal-search-list {
	background: #fff;
	border-radius: 8px;
	overflow: hidden;
}

.heimdal-search-result {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: .75rem 1rem;
	color: #111;
	text-decoration: none;
	border-bottom: 1px solid #eee;
}

.heimdal-search-result:last-child {
	border-bottom: 0;
}

.heimdal-search-result:hover,
.heimdal-search-result:focus-visible {
	background: #f5f5f5;
	color: #111;
}

.heimdal-search-result__image {
	flex: 0 0 auto;
	width: 56px;
	height: 56px;
	object-fit: cover;
	border-radius: 4px;
	background: #f0f0f0;
}

.heimdal-search-result__image--empty {
	display: block;
}

.heimdal-search-result__body {
	display: flex;
	flex-direction: column;
	gap: .15rem;
	min-width: 0;
}

.heimdal-search-result__name {
	font-weight: 600;
	line-height: 1.3;
}

.heimdal-search-result__price {
	font-size: .9em;
	color: #555;
}

.heimdal-search-result__price del {
	opacity: .6;
	margin-right: .35em;
}

.heimdal-search-message {
	margin: 0;
	padding: 1rem .25rem;
	color: rgba( 255, 255, 255, .85 );
	text-align: center;
}

@media ( max-width: 600px ) {

	.heimdal-search-overlay {
		padding: 4.5rem 1rem 2rem;
	}

	.heimdal-search-close {
		top: -3.25rem;
	}

	.heimdal-search-result__image {
		width: 46px;
		height: 46px;
	}

}

@media ( prefers-reduced-motion: reduce ) {

	.heimdal-search-overlay {
		transition: none;
	}

}
