/* =========================================================================
   Emmering Glass – Frontend
   Alle Farb-/Größenwerte kommen aus CSS-Custom-Properties (per Admin gesetzt).
   Fallbacks sind eingebaut, damit das Plugin auch ohne Inline-Vars läuft.
   ========================================================================= */

.egs-glass {
	position: relative;
	isolation: isolate;
	border-radius: var(--egs-radius, 11px);
	overflow: hidden;
	padding: clamp(16px, 4vw, 22px);
	box-shadow:
		0 12px 34px rgba(20, 20, 40, var(--egs-shadow, 0.28)),
		0 1px 2px rgba(20, 20, 40, calc(var(--egs-shadow, 0.28) * 0.4));
	font-family: var(--egs-font, inherit);
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

/* Frost- und Refraktionsschicht (das eigentliche „Glas“) – exakt wie im alten
   Block: Backdrop-Blur + Sättigung, dazu der SVG-Filter als separates `filter`.
   Wichtig: KEIN halbtransparenter Hintergrund auf .egs-glass, sonst würde der
   Backdrop das Foto vor dem Blur überdecken und es wirkt flach. */
.egs-glass__backdrop {
	position: absolute;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	border-radius: inherit;
	-webkit-backdrop-filter: blur(var(--egs-blur, 16px)) saturate(var(--egs-saturation, 160%));
	backdrop-filter: blur(var(--egs-blur, 16px)) saturate(var(--egs-saturation, 160%));
	filter: url(#egs-glass-distortion);
}

/* Tönung – regelt Kontrast/Lesbarkeit über der Frost-Schicht */
.egs-glass__tint {
	position: absolute;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	border-radius: inherit;
	background: var(--egs-tint, #ffffff);
	opacity: var(--egs-tint-opacity, 0.62);
}

/* Kantenlicht – der spekulare Glasrand, macht die Kante „scharf“ statt verwaschen */
.egs-glass__edge {
	position: absolute;
	inset: 0;
	z-index: 1;
	pointer-events: none;
	border-radius: inherit;
	box-shadow:
		inset 0 1px 1px rgba(255, 255, 255, calc(var(--egs-highlight, 0.55) * 0.9)),
		inset 0 0 0 1px rgba(255, 255, 255, calc(var(--egs-highlight, 0.55) * 0.5)),
		inset 0 -14px 24px rgba(255, 255, 255, calc(var(--egs-highlight, 0.55) * 0.14));
}

.egs-glass__content {
	position: relative;
	z-index: 2;
}

/* --- Typografie --- */
.egs-eyebrow {
	margin: 0 0 4px;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--egs-muted, #5a6270);
}

.egs-heading {
	margin: 0 0 14px;
	font-size: var(--egs-heading-size, 21px);
	line-height: 1.25;
	font-weight: var(--egs-heading-weight, 800);
	letter-spacing: -0.01em;
	color: var(--egs-heading-color, #1f2430);
}

/* --- Suche --- */
.egs-search {
	display: flex;
	align-items: center;
	gap: 12px;
	background: var(--egs-sf-bg, #ffffff);
	border: var(--egs-sf-bw, 0) solid var(--egs-sf-bc, transparent);
	border-radius: var(--egs-sf-radius, var(--egs-radius, 11px));
	padding: var(--egs-sf-pad, 14px 18px);
	box-shadow: var(--egs-sf-shadow, 0 1px 3px rgba(20, 20, 40, 0.08), 0 8px 24px rgba(20, 20, 40, 0.06));
}

.egs-search:focus-within {
	box-shadow: 0 0 0 3px rgba(63, 94, 251, 0.15), 0 8px 24px rgba(20, 20, 40, 0.08);
}

.egs-search__icon {
	flex: 0 0 auto;
	display: inline-flex;
	color: var(--egs-sf-icon, #1f2430);
}

.egs-glass .egs-search__input,
.egs-search input.egs-search__input {
	flex: 1 1 auto;
	min-width: 0;
	border: 0 !important;
	outline: none !important;
	box-shadow: none !important;
	border-radius: 0 !important;
	-webkit-appearance: none;
	appearance: none;
	background: transparent !important;
	font-size: var(--egs-body-size, 16px); /* nie < 16px – verhindert iOS-Auto-Zoom */
	line-height: 1.3;
	color: var(--egs-sf-txt, #1f2430);
	font-family: inherit;
	padding: 0;
	margin: 0;
	height: auto;
}

/* WebKit: Such-Dekorationen (Rahmen/„x“) entfernen */
.egs-search__input::-webkit-search-decoration,
.egs-search__input::-webkit-search-cancel-button,
.egs-search__input::-webkit-search-results-button,
.egs-search__input::-webkit-search-results-decoration {
	-webkit-appearance: none;
	appearance: none;
}

.egs-search__input::placeholder {
	color: var(--egs-sf-ph, #9aa1ac);
}

/* --- Chips: eine Zeile, kein Umbruch, horizontal scrollbar mit Fade-Kante --- */
.egs-chips {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 12px;
	min-width: 0;
}

.egs-chips__label {
	flex: 0 0 auto;
	font-size: 12px;
	font-weight: 600;
	color: var(--egs-muted, #5a6270);
	white-space: nowrap;
}

.egs-chips__list {
	display: flex;
	flex-wrap: nowrap;
	gap: 8px;
	overflow-x: auto;
	padding: 2px 0;
	scrollbar-width: none;
	-ms-overflow-style: none;
	scroll-snap-type: x proximity;
	-webkit-overflow-scrolling: touch;
}

/* Fade-Kante nur, wenn die Zeile wirklich scrollt (per JS gesetzt) –
   so wird auf dem Desktop kein Chip abgeschnitten, wenn Platz da ist. */
.egs-chips__list.is-scroll {
	-webkit-mask-image: linear-gradient(90deg, #000 90%, transparent 100%);
	mask-image: linear-gradient(90deg, #000 90%, transparent 100%);
}

.egs-chips__list::-webkit-scrollbar { display: none; }

.egs-chip {
	flex: 0 0 auto;
	white-space: nowrap;
	scroll-snap-align: start;
	background: var(--egs-chip-bg, rgba(255, 255, 255, 0.85));
	border: var(--egs-chip-bw, 1px) solid var(--egs-chip-bc, rgba(20, 20, 40, 0.1));
	border-radius: var(--egs-chip-radius, var(--egs-radius, 11px));
	padding: var(--egs-chip-pad, 7px 13px);
	font-size: var(--egs-chip-size, 13.5px);
	font-weight: 600;
	color: var(--egs-chip-txt, #1f2430);
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
	font-family: inherit;
}

.egs-chip:hover {
	background: var(--egs-chip-bg-h, #ffd505);
	border-color: var(--egs-chip-bc-h, var(--egs-chip-bg-h, #ffd505));
	color: var(--egs-chip-txt-h, #222);
}

/* --- Trenner zwischen Suche und Frag Emmi --- */
.egs-divider {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 16px 0 12px;
}

.egs-divider::before,
.egs-divider::after {
	content: "";
	flex: 1;
	height: 1px;
	background: var(--egs-div-line, rgba(20, 20, 40, 0.1));
}

.egs-divider span {
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--egs-div-txt, #b0b5be);
}

/* --- Frag Emmi Button (bewusst eigene Farbwelt) --- */
.egs-emmi { display: flex; }

.egs-emmi__btn {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: var(--egs-emmi-pad, 12px 22px);
	border: var(--egs-emmi-bw, 1px) solid var(--egs-emmi-bc, rgba(63, 94, 251, 0.18));
	border-radius: var(--egs-emmi-radius, var(--egs-radius, 11px));
	background: var(--egs-emmi-bg, #ffffff);
	box-shadow: 0 2px 12px rgba(63, 94, 251, 0.1);
	cursor: pointer;
	font-size: 16px;
	font-weight: 600;
	font-family: inherit;
	transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
	box-sizing: border-box;
}

.egs-emmi__btn:hover {
	background: #f6f8ff;
	box-shadow: 0 6px 22px rgba(63, 94, 251, 0.16);
	transform: translateY(-1px);
}

.egs-emmi__btn:active { transform: translateY(0); }

.egs-emmi__icon {
	width: 20px;
	height: 20px;
	flex: 0 0 auto;
	background: linear-gradient(100deg, var(--egs-emmi-from, #3f5efb) 0%, var(--egs-emmi-to, #fc466b) 100%);
	-webkit-mask: var(--egs-emmi-mask, none) center / contain no-repeat;
	mask: var(--egs-emmi-mask, none) center / contain no-repeat;
}

.egs-emmi__icon--fallback {
	background: none;
	color: var(--egs-emmi-from, #3f5efb);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	-webkit-mask: none;
	mask: none;
}

.egs-emmi__label {
	background: linear-gradient(100deg, var(--egs-emmi-from, #3f5efb) 0%, var(--egs-emmi-to, #fc466b) 100%);
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	font-weight: 600;
}

.egs-emmi__label--short { display: none; }

/* --- Aktuelle Meldungen --- */
.egs-news {
	margin-top: 16px;
	padding-top: 14px;
	border-top: 1px solid rgba(20, 20, 40, 0.1);
}

.egs-news__heading {
	margin: 0 0 8px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--egs-muted, #5a6270);
}

.egs-news__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.egs-news__item a {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	text-decoration: none;
	padding: 6px 8px;
	border-radius: calc(var(--egs-radius, 11px) - 3px);
	transition: background 0.15s ease;
}

.egs-news__item a:hover { background: rgba(255, 255, 255, 0.6); }

.egs-news__title {
	font-size: 14px;
	font-weight: 600;
	color: #1f2430;
	line-height: 1.3;
}

.egs-news__date {
	flex: 0 0 auto;
	font-size: 12px;
	color: var(--egs-muted, #5a6270);
	white-space: nowrap;
}

/* =========================================================================
   Eingebautes Chatfenster (nur bei emmi_mode = builtin)
   ========================================================================= */
.egs-chat {
	position: fixed;
	inset: auto 24px 24px auto;
	width: 400px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 48px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 12px 48px rgba(0, 0, 0, 0.22);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	z-index: 100000;
	opacity: 0;
	transform: translateY(16px) scale(0.98);
	pointer-events: none;
	transition: opacity 0.25s ease, transform 0.25s ease;
}

.egs-chat.is-open {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

.egs-chat__header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px;
	border-bottom: 1px solid #eaeaea;
	flex-shrink: 0;
}

.egs-chat__avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	flex: 0 0 auto;
	background: linear-gradient(100deg, var(--egs-emmi-from, #3f5efb) 0%, var(--egs-emmi-to, #fc466b) 100%);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-weight: 700;
}

.egs-chat__title { flex: 1 1 auto; min-width: 0; }
.egs-chat__title strong { display: block; font-size: 15px; color: #1f2430; }
.egs-chat__title span { display: block; font-size: 12px; color: #7a8290; }

.egs-chat__close {
	flex: 0 0 auto;
	width: 34px;
	height: 34px;
	border: none;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.05);
	color: #555;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.2s ease;
}

.egs-chat__close:hover { background: rgba(0, 0, 0, 0.1); }

.egs-chat__body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px;
	background: #f5f6f8;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.egs-msg {
	max-width: 85%;
	padding: 10px 13px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.35;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
	white-space: pre-wrap;
	word-wrap: break-word;
}

.egs-msg--bot {
	align-self: flex-start;
	background: #fff;
	color: #1f2430;
	border-bottom-left-radius: 4px;
}

.egs-msg--user {
	align-self: flex-end;
	background: #1f2430;
	color: #fff;
	border-bottom-right-radius: 4px;
}

.egs-msg--privacy {
	align-self: stretch;
	max-width: 100%;
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.12);
	color: #5a6270;
	font-size: 12.5px;
}

.egs-msg--typing { color: #7a8290; font-style: italic; }

.egs-chat__footer {
	flex-shrink: 0;
	padding: 12px;
	border-top: 1px solid #eaeaea;
	background: #fff;
}

.egs-chat__inputrow {
	display: flex;
	gap: 8px;
	align-items: center;
}

.egs-chat__input {
	flex: 1 1 auto;
	min-width: 0;
	padding: 10px 14px;
	border: 1px solid #ddd;
	border-radius: 22px;
	font-size: 16px; /* iOS-Zoom vermeiden */
	font-family: inherit;
	outline: none;
}

.egs-chat__input:focus { border-color: var(--egs-emmi-from, #3f5efb); }

.egs-chat__send {
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	border: none;
	border-radius: 50%;
	background: linear-gradient(100deg, var(--egs-emmi-from, #3f5efb) 0%, var(--egs-emmi-to, #fc466b) 100%);
	color: #fff;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease, opacity 0.2s ease;
}

.egs-chat__send:hover { transform: scale(1.06); }
.egs-chat__send:disabled { opacity: 0.4; cursor: not-allowed; }

.egs-chat__disclaimer {
	margin: 8px 0 0;
	font-size: 11px;
	color: #9aa1ac;
	text-align: center;
}

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 480px) {
	.egs-emmi__btn { padding: 12px 16px; gap: 8px; }
	.egs-emmi__label--long { display: none; }
	.egs-emmi__label--short { display: inline; }
	.egs-emmi__icon { width: 16px; height: 16px; }
}

@media (max-width: 600px) {
	.egs-chat {
		inset: 8px 8px 8px 8px;
		width: auto;
		height: auto;
		max-width: none;
		max-height: none;
		border-radius: 14px;
	}
}

/* =========================================================================
   Barrierefreiheit
   ========================================================================= */
.egs-chip:focus-visible,
.egs-emmi__btn:focus-visible,
.egs-chat__send:focus-visible,
.egs-chat__close:focus-visible {
	outline: 2px solid var(--egs-emmi-from, #3f5efb);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.egs-glass *,
	.egs-chat,
	.egs-emmi__btn { transition: none !important; }
}

/* Nutzer mit reduzierter Transparenz: solideres Panel, kein Refraktions-Flimmern */
@media (prefers-reduced-transparency: reduce) {
	.egs-glass__backdrop { filter: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
	.egs-glass__tint { opacity: 0.96; }
}
