/*
 * Suche im Footer (C11). Markup: template-parts/suche.php, Verhalten: assets/js/suche.js.
 * Desktop (ab 1024 px): Feld wächst von der Lupe nach links (clip-path statt Breite: bleibt auf der GPU, ruckelt nicht),
 *   Trefferfenster öffnet nach oben. Tablet (701–1023 px): Feld über die ganze Fußbreite, 2 Spalten.
 * Handy (bis 700 px): Suchfläche gleitet von unten hoch (<dialog>, Top-Layer).
 * Ohne JavaScript ist die Suche verborgen. Mindestschrift 12 px; kleiner roter Text auf #141414 mit --rot-text (C10).
 */

.fuss { position: relative; }

.suche { display: none; }
.js .suche { display: block; }

/* ---------- Lupe / Kreuz ---------- */

.suche-knopf {
	position: relative;
	z-index: 3;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	margin: -12px -13px -12px 0; /* Fußhöhe bleibt gleich, Zeichen bündig mit dem Seitenrand */
	padding: 0;
	border: 0;
	background: none;
	color: var(--c-text);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: color var(--uebergang), transform .15s var(--ease-out);
}

.suche-knopf svg {
	grid-area: 1 / 1;
	width: 20px;
	height: 20px;
	transition: opacity .3s var(--ease-out), transform .3s var(--ease-in-out);
}

.suche-kreuz { opacity: 0; transform: rotate(-90deg); }
.suche-aktiv .suche-lupe { opacity: 0; transform: rotate(90deg); }
.suche-aktiv .suche-kreuz { opacity: 1; transform: none; }

.suche-knopf:focus-visible { color: var(--c-rot); }
@media (hover: hover) and (pointer: fine) {
	.suche-knopf:hover { color: var(--c-rot); }
}

/* ---------- Fenster (Desktop/Tablet: unsichtbarer Rahmen, Kinder liegen im Fuß) ---------- */

.suche-fenster {
	display: contents;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
}
.suche-fenster:not([open]) { display: none; }
.suche-blatt { display: contents; }
.suche-griff { display: none; }
.suche-x { display: none; }

.suche-feld {
	position: absolute;
	z-index: 2;
	top: 50%;
	right: calc(var(--rand) - 13px);
	width: 440px;
	height: 44px;
	margin: -22px 0 0;
	display: flex;
	align-items: center;
	background: var(--c-hg);
	clip-path: inset(0 0 0 calc(100% - 44px));
	pointer-events: none;
	transition: clip-path .35s var(--ease-in-out);
}
.suche-fenster.ist-offen .suche-feld {
	clip-path: inset(0);
	pointer-events: auto;
}

.suche-eingabe {
	flex: 1 1 auto;
	min-width: 0;
	height: 100%;
	margin: 0;
	padding: 0 52px 0 2px;
	border: 0;
	border-radius: 0;
	outline: 0;
	background: none;
	color: var(--c-text);
	font: inherit;
	font-size: 16px; /* mindestens 16 px: iOS zoomt sonst beim Antippen */
	-webkit-appearance: none;
	appearance: none;
	opacity: 0;
	transition: opacity .1s;
}
.suche-eingabe:focus-visible { outline: 0; } /* Fokus zeigt die rote Linie */
.suche-eingabe::placeholder { color: var(--c-grau); opacity: 1; }
.suche-eingabe::-webkit-search-cancel-button,
.suche-eingabe::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.suche-fenster.ist-offen .suche-eingabe { opacity: 1; transition: opacity .2s ease .15s; }

.suche-linie {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 2px;
	background: var(--c-rot);
	transform: scaleX(0);
	transform-origin: right;
	transition: transform .35s var(--ease-in-out);
}
.suche-fenster.ist-offen .suche-linie { transform: scaleX(1); }

/* Links im Fuß blenden aus (Deckkraft 0,15 s, 10 px nach links) */
.fuss-liste {
	transition: opacity .15s var(--ease-out), transform .15s var(--ease-out), visibility 0s;
}
.fuss.suche-aktiv .fuss-liste {
	opacity: 0;
	transform: translateX(-10px);
	visibility: hidden;
	transition: opacity .15s var(--ease-out), transform .15s var(--ease-out), visibility 0s .15s;
}

/* ---------- Trefferfenster ---------- */

.suche-treffer {
	--rot-klein: var(--rot-text);
	position: absolute;
	z-index: 4;
	right: calc(var(--rand) - 13px);
	bottom: calc(100% + 8px);
	width: 520px;
	max-width: calc(100vw - 2 * var(--rand) + 26px);
	max-height: min(580px, calc(100vh - 140px));
	overflow-y: auto;
	overscroll-behavior: contain;
	background: #141414;
	border: 1px solid #262626;
	border-radius: 4px;
	opacity: 0;
	transform: translateY(10px);
	visibility: hidden;
	pointer-events: none;
	transition: opacity .2s ease-out, transform .25s ease-out, visibility 0s .25s;
}
.suche-fenster.ist-offen.ist-bereit .suche-treffer {
	opacity: 1;
	transform: none;
	visibility: visible;
	pointer-events: auto;
	transition: opacity .2s ease-out, transform .25s ease-out, visibility 0s;
}

.suche-kopf {
	margin: 0;
	padding: 14px 16px 6px;
	color: var(--c-grau);
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .12em;
	text-transform: uppercase;
}

.suche-liste { margin: 0; padding: 0 0 6px; list-style: none; }

.suche-hit {
	display: flex;
	align-items: center;
	gap: 16px;
	min-height: 52px;
	padding: 8px 16px;
	color: var(--c-text);
	text-decoration: none;
}
.suche-hit:focus-visible {
	color: var(--c-text);
	background: #1C1C1C;
	outline: 2px solid var(--c-rot);
	outline-offset: -2px;
}
@media (hover: hover) and (pointer: fine) {
	.suche-hit:hover { color: var(--c-text); background: #1C1C1C; }
}

.suche-bild {
	flex: none;
	display: block;
	width: 64px;
	height: 36px;
	border-radius: 2px;
	background: #1C1C1C;
	object-fit: cover;
}
span.suche-bild { box-shadow: inset 0 0 0 1px #262626; }

.suche-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.suche-titel {
	overflow: hidden;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.3;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.suche-art { color: var(--c-grau); font-size: 12px; letter-spacing: .04em; line-height: 1.3; }

.suche-leer { margin: 0; padding: 6px 16px 16px; color: var(--c-grau-hell); font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.suche-leer[hidden] { display: none; }
.suche-leer a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
	.suche-leer a:hover { color: var(--c-text); }
}

.suche-alle {
	display: flex;
	padding: 14px 16px;
	border-top: 1px solid #262626;
}

/* Treffer erscheinen gestaffelt (nur beim Öffnen, nicht bei jedem Tastendruck) */
.suche-liste.ist-neu li {
	animation: suche-hit .3s var(--ease-out) both;
	animation-delay: calc(var(--n, 0) * .05s);
}
@keyframes suche-hit {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: none; }
}

/* ---------- Tablet (701–1023 px) ---------- */

@media (min-width: 701px) and (max-width: 1023px) {
	.suche-knopf { width: 48px; height: 48px; margin: -14px -15px -14px 0; }
	.suche-feld { left: var(--rand); right: calc(var(--rand) - 15px); width: auto; height: 48px; margin-top: -24px; clip-path: inset(0 0 0 calc(100% - 48px)); }
	.suche-fenster.ist-offen .suche-feld { clip-path: inset(0); }
	.suche-eingabe { padding-right: 56px; font-size: 18px; }
	.suche-treffer { left: var(--rand); right: calc(var(--rand) - 15px); width: auto; max-width: none; }
	.suche-liste { display: grid; grid-template-columns: 1fr 1fr; padding: 0 8px 8px; }
	.suche-hit { min-height: 64px; }
	.suche-bild { width: 80px; height: 45px; }
	.fuss-links { transition: opacity .15s var(--ease-out), transform .15s var(--ease-out), visibility 0s; }
	.fuss.suche-aktiv .fuss-links {
		opacity: 0;
		transform: translateX(-10px);
		visibility: hidden;
		transition: opacity .15s var(--ease-out), transform .15s var(--ease-out), visibility 0s .15s;
	}
}

/* ---------- Handy (bis 700 px): Suchfläche von unten ---------- */

@media (max-width: 700px) {
	.suche-knopf { color: var(--c-grau); } /* dezent wie die Profil-Icons */
	.suche-knopf svg { width: 18px; height: 18px; }
	.suche-knopf:active { color: var(--c-rot); transform: scale(.92); }
	.suche-kreuz { display: none; }
	.suche-aktiv .suche-lupe { opacity: 1; transform: none; }
	.fuss.suche-aktiv .fuss-liste { opacity: 1; transform: none; visibility: visible; }

	.suche-fenster {
		display: block;
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		overflow: hidden;
		background: transparent;
		color: var(--c-text);
	}
	.suche-fenster:not([open]) { display: none; }
	.suche-fenster::backdrop {
		background: rgba(0, 0, 0, .65);
		opacity: 0;
		transition: opacity .3s ease-out;
	}
	.suche-fenster.ist-offen::backdrop { opacity: 1; }

	.suche-blatt {
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		display: flex;
		flex-direction: column;
		height: 92vh;
		height: 92dvh;
		padding: 0 20px;
		overflow: hidden;
		border-radius: 16px 16px 0 0;
		background: #121212;
		transform: translateY(100%);
		transition: transform .32s cubic-bezier(.32, .72, 0, 1);
	}
	.suche-fenster.ist-offen .suche-blatt { transform: none; }

	.suche-griff {
		display: block;
		flex: none;
		width: 40px;
		height: 4px;
		margin: 10px auto 6px;
		border-radius: 2px;
		background: var(--c-rahmen);
	}

	.suche-feld {
		position: relative;
		flex: none;
		top: auto;
		right: auto;
		left: auto;
		width: auto;
		height: 64px;
		margin: 4px 0 0;
		gap: 12px;
		background: none;
		clip-path: none;
		pointer-events: auto;
		transition: none;
	}
	.suche-fenster.ist-offen .suche-feld { clip-path: none; }
	.suche-eingabe { padding: 0; font-size: 20px; opacity: 1; transition: none; }
	.suche-fenster.ist-offen .suche-eingabe { transition: none; }
	.suche-linie { transform-origin: left; transition: transform .38s var(--ease-in-out) .12s; }
	.suche-x {
		display: grid;
		flex: none;
		place-items: center;
		width: 44px;
		height: 44px;
		padding: 0;
		border: 0;
		border-radius: 50%;
		background: #1C1C1C;
		color: var(--c-text);
		cursor: pointer;
		-webkit-tap-highlight-color: transparent;
		transition: transform .15s var(--ease-out), color var(--uebergang);
	}
	.suche-x:active { color: var(--c-rot); transform: scale(.92); }

	.suche-treffer {
		position: static;
		flex: 1 1 auto;
		min-height: 0;
		width: auto;
		max-width: none;
		max-height: none;
		margin: 0 -20px;
		padding: 0 20px env(safe-area-inset-bottom, 0px);
		border: 0;
		border-radius: 0;
		background: none;
		opacity: 1;
		transform: none;
		visibility: visible;
		pointer-events: auto;
		transition: none;
	}
	.suche-fenster.ist-offen.ist-bereit .suche-treffer { transition: none; }
	.suche-kopf { padding: 16px 0 8px; }
	.suche-liste { padding: 0; }
	.suche-hit { min-height: 60px; padding: 8px 0; gap: 14px; }
	.suche-bild { width: 80px; height: 45px; }
	.suche-leer { padding: 8px 0 16px; }
	.suche-alle { padding: 18px 0; }
}

/* Seite dahinter scrollt nicht (Scroll-Sperre ohne Layoutsprung: Breite der Bildlaufleiste als Innenabstand) */
html.suche-sperre { overflow: hidden; padding-right: var(--suche-sb, 0px); }

/* Sprungmarken auf der Leistungen-Seite (Treffer „Gaussian Splatting“ usw.) landen unter dem Seitenkopf */
main h2[id],
main section.filmgruppe[id] { scroll-margin-top: calc(var(--kopf-hoehe) + 24px); }
