/*
 * Suche im Kopf (core/search, nur Button, Feld aufklappbar).
 * Der Lupen-Button ist ein runder Glas-Button wie Telefon und Menü (48 px Tippfläche).
 * Das Feld klappt unter der Kopfleiste auf, rechtsbündig, damit Logo und Menü nicht
 * verrutschen. Öffnen, Escape und Fokusverlust steuert Core (Interactivity API).
 * Die Algolia-Vorschläge (Plugin „WP Search with Algolia“) hängen sich an input[name="s"].
 */

.himml-header__bar:has(.himml-header-search) {
	position: relative;
}

.himml-header .himml-header-search {
	flex: none;
	margin: 0;
}

/* Core gibt dem Wrapper im Button-Modus feste Breiten; das Feld liegt hier absolut. */
.himml-header .himml-header-search .wp-block-search__inside-wrapper {
	width: auto !important;
	padding: 0;
	border: 0;
	background: none;
}

.himml-header .himml-header-search .wp-block-search__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 48px;
	height: 48px;
	margin: 0;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, .28);
	border-radius: var(--wp--preset--border-radius--pill);
	background: rgba(255, 255, 255, .1);
	color: #fff;
	box-shadow: none;
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	cursor: pointer;
	transition: background-color .2s, border-color .2s;
}

.himml-header .himml-header-search .wp-block-search__button:hover,
.himml-header .himml-header-search:not(.wp-block-search__searchfield-hidden) .wp-block-search__button {
	border-color: rgba(255, 255, 255, .45);
	background: rgba(255, 255, 255, .16);
}

.himml-header .himml-header-search .wp-block-search__button svg {
	width: 24px;
	height: 24px;
	min-width: 24px;
	fill: currentColor;
}

/* Aufgeklappt: Feld unter der Leiste. Core setzt im zugeklappten Zustand Breite 0 mit !important. */
.himml-header .himml-header-search .wp-block-search__input {
	position: absolute;
	top: calc(100% - 12px);
	right: 0;
	z-index: 60;
	box-sizing: border-box;
	width: min(440px, 100%);
	height: 56px;
	padding: 0 24px;
	border: 1px solid rgba(255, 255, 255, .28);
	border-radius: var(--wp--preset--border-radius--pill);
	background: var(--wp--preset--color--night);
	color: #fff;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--medium);
	box-shadow: var(--wp--preset--shadow--card, 0 18px 40px -18px rgba(0, 0, 0, .6));
	opacity: 1;
	transition: opacity .2s var(--himml-ease, ease), transform .2s var(--himml-ease, ease);
}

.himml-header .himml-header-search .wp-block-search__input::placeholder {
	color: rgba(255, 255, 255, .6);
	opacity: 1;
}

.himml-header .himml-header-search .wp-block-search__input:focus {
	outline: 2px solid var(--wp--preset--color--sky);
	outline-offset: 3px;
}

.himml-header .himml-header-search.wp-block-search__searchfield-hidden .wp-block-search__input {
	opacity: 0;
	transform: translateY(-6px);
	pointer-events: none;
}

/* Browser-eigenes Löschkreuz im Suchfeld ist auf Nachtblau kaum sichtbar. */
.himml-header .himml-header-search .wp-block-search__input::-webkit-search-cancel-button {
	filter: invert(1);
}

/* Platz im Kopf: Der Lupen-Button kostet 60 px. Damit „Jetzt erreichbar“ einzeilig bleibt
 * und die Leiste (max. 1168 px) nicht überläuft, rücken Kontaktgruppe, Telefon und
 * Menüpunkte etwas enger. Greift nur, wenn die Suche im Kopf steht. */
.himml-header .himml-header__contact:has(.himml-header-search) {
	gap: 8px;
}

.himml-header .himml-header__contact:has(.himml-header-search) .is-style-status {
	white-space: nowrap;
}

@media (min-width: 1040px) {
	.himml-header .himml-header__contact:has(.himml-header-search) .wp-block-button__link {
		padding-inline: 22px;
	}
}

@media (min-width: 1040px) and (max-width: 1199px) {
	.himml-header__bar:has(.himml-header-search) .wp-block-navigation.is-style-pill .wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content {
		padding-inline: 9px;
	}
}

@media (min-width: 1200px) {
	.himml-header__bar:has(.himml-header-search) .wp-block-navigation.is-style-pill .wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content {
		padding-inline: 14px;
	}
}

/* „Jetzt erreichbar“ passt mit Suche erst ab 1300 px (ohne Suche ab 1181 px). */
@media (max-width: 1299px) {
	.himml-header .himml-header__contact:has(.himml-header-search) .is-style-status {
		display: none !important;
	}
}

/* Handy: Logo, Suche, Telefon und Menü passen unter 400 px nur, wenn das Logo etwas schrumpft
 * (theme.css macht das ohne Suche erst unter 360 px). */
@media (max-width: 399px) {
	.himml-header__bar:has(.himml-header-search) .himml-logo {
		flex: 0 1 auto;
		min-width: 0;
	}

	.himml-header__bar:has(.himml-header-search) .himml-logo img {
		max-width: 100%;
		object-fit: contain;
		object-position: left center;
	}
}

@media (max-width: 760px) {
	.himml-header .himml-header-search .wp-block-search__input {
		top: calc(100% - 8px);
		width: 100%;
		/* 16 px und mehr: iOS zoomt sonst beim Antippen ins Feld. */
		font-size: 17px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.himml-header .himml-header-search .wp-block-search__input {
		transition: none;
	}
}
