/**
 * EkoBox Konfigurationsfragebogen – Schwebender Button & Popup-Modal.
 *
 * Eigenständig (kein Theme-Konflikt), passend zum kantigen Premium-Design
 * des Fragebogens. Farben über CSS-Custom-Properties anpassbar.
 */

/* --- Schwebender Button (FAB) + Aktionsmenü --- */
.ekobox-kf-fab-wrap {
	--ekobox-fab-bg: #4c2f6e;
	--ekobox-fab-bg-hover: #3a2358;

	position: fixed;
	bottom: 24px;
	z-index: 99998;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-width: calc(100vw - 32px);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	animation: ekobox-kf-rise 0.5s ease-out both;
}

@keyframes ekobox-kf-rise {
	from {
		opacity: 0;
		transform: translateY(14px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.ekobox-kf-fab-wrap--right {
	right: 24px;
	align-items: flex-end;
}

.ekobox-kf-fab-wrap--left {
	left: 24px;
	align-items: flex-start;
}

.ekobox-kf-fab {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	padding: 14px 22px;
	border: none;
	border-radius: 0;
	background: var(--ekobox-fab-bg);
	color: #ffffff;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.01em;
	text-transform: none;
	cursor: pointer;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
	transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
	-webkit-font-smoothing: antialiased;
}

/* Dezenter „Puls“-Ring, der alle paar Sekunden Aufmerksamkeit weckt. */
.ekobox-kf-fab::after {
	content: "";
	position: absolute;
	inset: 0;
	border: 2px solid var(--ekobox-fab-bg);
	opacity: 0;
	pointer-events: none;
	animation: ekobox-kf-pulse 5s ease-out infinite;
	animation-delay: 1.5s;
}

@keyframes ekobox-kf-pulse {
	0%,
	72% {
		opacity: 0;
		transform: scale(1);
	}
	76% {
		opacity: 0.5;
		transform: scale(1);
	}
	100% {
		opacity: 0;
		transform: scale(1.25, 1.55);
	}
}

.ekobox-kf-fab-icon {
	transition: transform 0.25s ease;
}

.ekobox-kf-fab:hover .ekobox-kf-fab-icon {
	transform: rotate(-8deg) scale(1.15);
}

/* --- Aktionsmenü (Anrufen + Konfigurator) --- */
.ekobox-kf-fab-menu {
	display: flex;
	flex-direction: column;
	gap: 10px;
	align-items: inherit;
}

.ekobox-kf-fab-menu[hidden] {
	display: none !important;
}

.ekobox-kf-fab-item {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	padding: 12px 18px;
	border: 1px solid #ddd6e6;
	border-radius: 0;
	background: #ffffff;
	color: var(--ekobox-fab-bg);
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.01em;
	text-transform: none;
	text-decoration: none;
	cursor: pointer;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
	transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
	animation: ekobox-kf-rise 0.22s ease-out both;
}

/* Menüeinträge erscheinen leicht versetzt nacheinander. */
.ekobox-kf-fab-menu .ekobox-kf-fab-item:first-child {
	animation-delay: 0.06s;
}

.ekobox-kf-fab-item:hover,
.ekobox-kf-fab-item:focus-visible {
	background: var(--ekobox-fab-bg);
	border-color: var(--ekobox-fab-bg);
	color: #ffffff;
	text-decoration: none;
	transform: translateY(-2px);
}

.ekobox-kf-fab-item:focus-visible {
	outline: 2px solid #f0a500;
	outline-offset: 2px;
}

.ekobox-kf-fab:hover,
.ekobox-kf-fab:focus-visible {
	background: var(--ekobox-fab-bg-hover);
	color: #ffffff;
	transform: translateY(-2px);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

.ekobox-kf-fab:focus-visible {
	outline: 2px solid #f0a500;
	outline-offset: 2px;
}

.ekobox-kf-fab-icon {
	flex: 0 0 auto;
}

@media (max-width: 480px) {
	.ekobox-kf-fab-wrap {
		bottom: 16px;
	}

	.ekobox-kf-fab-wrap--right {
		right: 16px;
	}

	.ekobox-kf-fab-wrap--left {
		left: 16px;
	}

	.ekobox-kf-fab {
		padding: 12px 18px;
		font-size: 14px;
	}
}

/* --- Modal --- */
.ekobox-kf-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.ekobox-kf-modal[hidden] {
	display: none !important;
}

.ekobox-kf-modal-overlay {
	position: absolute;
	inset: 0;
	background: rgba(22, 32, 27, 0.62);
}

.ekobox-kf-modal-dialog {
	position: relative;
	width: 100%;
	max-width: 560px;
	max-height: calc(100vh - 48px);
	max-height: calc(100dvh - 48px);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	background: #ffffff;
	border-top: 3px solid #1b5e20;
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

.ekobox-kf-modal-head {
	position: sticky;
	top: 0;
	z-index: 2;
	display: flex;
	justify-content: flex-end;
	padding: 8px;
	pointer-events: none;
}

.ekobox-kf-modal-close {
	pointer-events: auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 1px solid #e4ebe6;
	border-radius: 0;
	background: #ffffff;
	color: #2c3a32;
	line-height: 1;
	cursor: pointer;
	transition: border-color 0.2s ease, color 0.2s ease;
}

.ekobox-kf-modal-close-icon {
	display: block;
	transition: transform 0.3s ease;
}

/* Hover: keine Füllung – das X dreht sich stattdessen. */
.ekobox-kf-modal-close:hover,
.ekobox-kf-modal-close:focus-visible {
	background: #ffffff;
	border-color: #16201b;
	color: #16201b;
}

.ekobox-kf-modal-close:hover .ekobox-kf-modal-close-icon,
.ekobox-kf-modal-close:focus-visible .ekobox-kf-modal-close-icon {
	transform: rotate(90deg);
}

.ekobox-kf-modal-close:focus-visible {
	outline: 2px solid #f0a500;
	outline-offset: 2px;
}

.ekobox-kf-modal-body {
	padding: 0 20px 24px;
}

/* Formular im Modal: Rahmen entfernen, volle Breite nutzen. */
.ekobox-kf-modal .ekobox-kf {
	max-width: none;
	margin: 0;
	border: none;
	border-top: none;
	padding-top: 0;
}

/* Kompakteres Layout für die schnelle Anfrage. */
.ekobox-kf-modal .ekobox-kf--quick {
	padding: 0 clamp(8px, 2vw, 20px) 8px;
}

/* Ruhigere Typografie im Popup – weniger fett als der große Fragebogen.
   Titel in Versalien, etwas größer. */
.ekobox-kf-modal .ekobox-kf--quick .ekobox-kf-title {
	font-size: 1.9rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.ekobox-kf-modal .ekobox-kf--quick .ekobox-kf-label {
	font-weight: 500;
}

.ekobox-kf-modal .ekobox-kf--quick .ekobox-kf-header {
	margin-bottom: 18px;
}

.ekobox-kf-modal .ekobox-kf--quick .ekobox-kf-actions {
	justify-content: flex-end;
}

/* Hintergrund-Scrollen sperren, solange das Modal offen ist. */
body.ekobox-kf-modal-open {
	overflow: hidden;
}

/* Schwebenden Button hinter dem Modal ausblenden, solange es offen ist. */
body.ekobox-kf-modal-open .ekobox-kf-fab-wrap {
	visibility: hidden;
}

@media (max-width: 640px) {
	.ekobox-kf-modal {
		padding: 0;
	}

	.ekobox-kf-modal-dialog {
		max-width: none;
		height: 100%;
		max-height: 100vh;
		max-height: 100dvh;
	}

	.ekobox-kf-modal-body {
		padding: 0 12px 20px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ekobox-kf-fab,
	.ekobox-kf-fab-icon,
	.ekobox-kf-fab-item,
	.ekobox-kf-modal-close {
		transition: none;
	}

	.ekobox-kf-fab-wrap,
	.ekobox-kf-fab-item {
		animation: none;
	}

	.ekobox-kf-fab::after {
		display: none;
	}
}
