/**
 * Espace Health Prämienrechner
 *
 * Gestaltung nach dem HMO-plus-/EHG-Theme: Der Rechner übernimmt die
 * Marken-Tokens des Themes, sofern sie definiert sind, und fällt sonst auf die
 * dokumentierten Markenwerte zurück – dieselbe Schreibweise, die auch die
 * Theme-Komponenten verwenden (var(--primary-color-900, #213272)).
 *
 * Im Theme oder Customizer überschreibbar:
 *
 *   .ehpr {
 *       --ehpr-accent: #213272;
 *       --ehpr-highlight: #7AB1E2;
 *   }
 */

.ehpr {
	/* Marke ------------------------------------------------------------ */
	--ehpr-accent: var(--primary-color-900, #213272);
	--ehpr-accent-contrast: #ffffff;
	--ehpr-highlight: var(--primary-color, #7AB1E2);
	--ehpr-highlight-soft: color-mix(in srgb, var(--primary-color, #7AB1E2) 14%, #ffffff);

	/* Flächen und Linien ----------------------------------------------- */
	--ehpr-bg: #ffffff;
	--ehpr-surface: var(--color-grey-50, #F5F5F5);
	--ehpr-line: var(--color-grey-100, #ECECEC);

	/* Text -------------------------------------------------------------- */
	--ehpr-heading: var(--primary-color-900, #213272);
	--ehpr-fg: #2A3244;
	--ehpr-fg-muted: #5A6478;

	/* Form -------------------------------------------------------------- */
	--ehpr-radius-panel: var(--radius-4xl, 2rem);
	--ehpr-radius: var(--radius-xl, 0.75rem);
	--ehpr-ease: var(--ease-in-out, cubic-bezier(0.4, 0, 0.2, 1));
	--ehpr-shadow: 0 18px 40px rgba(33, 50, 114, 0.14);

	color: var(--ehpr-fg);
	font-size: 1rem;
	line-height: 1.5;
	container-type: inline-size;
}

.ehpr *,
.ehpr *::before,
.ehpr *::after {
	box-sizing: border-box;
}

.ehpr__title {
	margin: 0 0 20px;
	color: var(--ehpr-heading);
	font-size: 1.75rem;
	line-height: 1.2;
	text-wrap: balance;
}

/* Sichtbarer Fokus überall gleich – wie in den Theme-Komponenten. */
.ehpr :focus-visible,
.ehpr__chip input:focus-visible + span,
.ehpr__segment input:focus-visible + span {
	outline: 2px solid var(--ehpr-accent);
	outline-offset: 2px;
}

/* ------------------------------------------------------------- Formular */

.ehpr__form {
	background: var(--ehpr-surface);
	border: 1px solid var(--ehpr-line);
	border-radius: var(--ehpr-radius-panel);
	padding: 24px;
}

.ehpr__fields {
	display: grid;
	gap: 20px;
	grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
	align-items: start;
}

.ehpr__field--loc {
	grid-column: span 2;
	min-width: 0;
}

.ehpr__field label,
.ehpr__label {
	display: block;
	margin-bottom: 8px;
	color: var(--ehpr-heading);
	font-size: 0.875rem;
	font-weight: 700;
}

.ehpr__input {
	width: 100%;
	padding: 12px 14px;
	font: inherit;
	color: var(--ehpr-fg);
	background: var(--ehpr-bg);
	border: 1px solid var(--ehpr-line);
	border-radius: var(--ehpr-radius);
	transition: border-color 150ms var(--ehpr-ease);
}

.ehpr__input:hover {
	border-color: var(--ehpr-highlight);
}

.ehpr__hint {
	margin: 8px 0 0;
	font-size: 0.8125rem;
	line-height: 1.5;
	color: var(--ehpr-fg-muted);
}

/* Ortssuche ---------------------------------------------------------- */

.ehpr__combo {
	position: relative;
}

.ehpr__suggestions {
	position: absolute;
	z-index: 30;
	inset-inline: 0;
	top: calc(100% + 6px);
	margin: 0;
	padding: 6px;
	list-style: none;
	background: var(--ehpr-bg);
	border: 1px solid var(--ehpr-line);
	border-radius: var(--ehpr-radius);
	box-shadow: var(--ehpr-shadow);
	max-height: 17rem;
	overflow-y: auto;
}

.ehpr__suggestion {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 12px;
	border-radius: calc(var(--ehpr-radius) - 2px);
	cursor: pointer;
	font-size: 0.9375rem;
}

.ehpr__suggestion.is-active,
.ehpr__suggestion:hover {
	background: var(--ehpr-surface);
	color: var(--ehpr-heading);
}

.ehpr__suggestion--empty {
	cursor: default;
	color: var(--ehpr-fg-muted);
}

.ehpr__suggestion-meta {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 2px;
	color: var(--ehpr-fg-muted);
	font-size: 0.8125rem;
	text-align: right;
	white-space: nowrap;
}

.ehpr__suggestion-gemeinde {
	color: var(--ehpr-heading);
	font-weight: 700;
}

/* Unfalldeckung: zwei Pillen, wie die Filter im Partnerverzeichnis ----- */

.ehpr__segmented {
	display: inline-flex;
	gap: 8px;
	flex-wrap: wrap;
}

.ehpr__segment input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.ehpr__segment span {
	display: block;
	padding: 8px 20px;
	border: 1px solid var(--ehpr-accent);
	border-radius: 999px;
	background: transparent;
	color: var(--ehpr-accent);
	font-size: 0.95rem;
	font-weight: 700;
	cursor: pointer;
	transition: background-color 150ms var(--ehpr-ease), color 150ms var(--ehpr-ease);
}

.ehpr__segment input:checked + span {
	background: var(--ehpr-accent);
	color: var(--ehpr-accent-contrast);
}

/* Schaltflächen -------------------------------------------------------- */

.ehpr__button {
	display: inline-block;
	padding: 12px 28px;
	font: inherit;
	font-weight: 700;
	color: var(--ehpr-accent-contrast);
	background: var(--ehpr-accent);
	border: 1px solid var(--ehpr-accent);
	border-radius: 999px;
	cursor: pointer;
	transition: filter 150ms var(--ehpr-ease);
}

.ehpr__button:hover {
	filter: brightness(1.15);
}

.ehpr__button--ghost {
	background: transparent;
	color: var(--ehpr-accent);
}

.ehpr__button--ghost:hover {
	background: var(--ehpr-accent);
	color: var(--ehpr-accent-contrast);
	filter: none;
}

/* Die Schaltfläche steht unter den Eingabefeldern über die volle Breite,
   damit sie nicht in einer Spalte allein neben leerem Raum hängt. */
.ehpr__field--submit {
	grid-column: 1 / -1;
}

/* --------------------------------------------------------------- Status */

.ehpr__status {
	margin: 12px 0 0;
	font-size: 0.9375rem;
	min-height: 1.5em;
}

.ehpr__status.is-error {
	color: #A3001C;
	font-weight: 700;
}

.ehpr__status.is-busy {
	color: var(--ehpr-fg-muted);
}

/* ------------------------------------------------------------ Ergebnisse */

.ehpr__results {
	margin-top: 32px;
}

.ehpr__summary-head {
	margin: 0 0 8px;
	color: var(--ehpr-heading);
	font-size: 1.25rem;
	font-weight: 700;
	line-height: 1.3;
}

.ehpr__facts {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 12px;
	margin: 0 0 24px;
	padding: 0;
	list-style: none;
	font-size: 0.8125rem;
}

.ehpr__facts li {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 4px 12px;
	border-radius: 999px;
	background: var(--ehpr-highlight-soft);
	color: var(--ehpr-heading);
}

.ehpr__fact-key {
	color: var(--ehpr-fg-muted);
}

.ehpr__fact-key::after {
	content: ':';
}

.ehpr__fact-val {
	font-weight: 700;
}

/* Filter --------------------------------------------------------------- */

.ehpr__controls {
	display: grid;
	gap: 20px;
	margin-bottom: 24px;
}

.ehpr__control {
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

.ehpr__control legend {
	padding: 0;
	margin-bottom: 8px;
	color: var(--ehpr-heading);
	font-size: 0.875rem;
	font-weight: 700;
}

.ehpr__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.ehpr__chip input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.ehpr__chip > span {
	display: flex;
	flex-direction: column;
	align-items: center;
	line-height: 1.25;
	padding: 8px 20px;
	border: 1px solid var(--ehpr-accent);
	border-radius: 999px;
	background: transparent;
	color: var(--ehpr-accent);
	cursor: pointer;
	font-size: 0.95rem;
	font-weight: 700;
	white-space: nowrap;
	transition: background-color 150ms var(--ehpr-ease), color 150ms var(--ehpr-ease);
}

.ehpr__chip > span small {
	font-size: 0.75rem;
	font-weight: 400;
	color: var(--ehpr-fg-muted);
	font-variant-numeric: tabular-nums;
}

.ehpr__chip input:checked + span {
	background: var(--ehpr-accent);
	color: var(--ehpr-accent-contrast);
}

.ehpr__chip input:checked + span small {
	color: inherit;
	opacity: 0.85;
}

/* Vergleich mit dem aktuellen Modell ----------------------------------- */

.ehpr__compare {
	margin-bottom: 24px;
	padding: 20px;
	background: var(--ehpr-surface);
	border: 1px solid var(--ehpr-line);
	border-radius: var(--ehpr-radius-panel);
}

.ehpr__compare-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 8px;
	margin-bottom: 12px;
}

.ehpr__compare-title {
	color: var(--ehpr-heading);
	font-size: 0.9375rem;
	font-weight: 700;
}

.ehpr__compare-optional {
	padding: 2px 10px;
	border-radius: 999px;
	background: var(--ehpr-bg);
	border: 1px solid var(--ehpr-line);
	font-size: 0.75rem;
	color: var(--ehpr-fg-muted);
}

.ehpr__compare-fields {
	display: grid;
	gap: 12px;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.ehpr__compare-fields .ehpr__field label {
	font-size: 0.8125rem;
}

.ehpr__compare-hint {
	margin: 12px 0 0;
	font-size: 0.8125rem;
	color: var(--ehpr-fg-muted);
}

.ehpr__compare-current {
	margin-top: 16px;
	padding-top: 16px;
	border-top: 1px solid var(--ehpr-line);
}

.ehpr__compare-row {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
}

.ehpr__compare-who {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
	color: var(--ehpr-heading);
}

.ehpr__compare-label {
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--ehpr-fg-muted);
}

.ehpr__compare-warning {
	margin: 0;
	font-size: 0.875rem;
	color: #A3001C;
}

.ehpr__compare-reset {
	margin-top: 12px;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	font-size: 0.8125rem;
	font-weight: 700;
	color: var(--ehpr-heading);
	text-decoration: underline;
	cursor: pointer;
}

/* Differenz zum aktuellen Modell.
   Ersparnis und Mehrkosten sind semantische Farben und bewusst nicht die
   Markenfarbe – sonst wäre die Richtung der Abweichung nicht ablesbar. */

.ehpr__delta {
	display: flex;
	flex-direction: column;
	align-items: inherit;
	margin-top: 6px;
	font-variant-numeric: tabular-nums;
}

.ehpr__delta-main {
	font-size: 0.9375rem;
	font-weight: 700;
}

.ehpr__delta-year {
	font-size: 0.6875rem;
}

.ehpr__delta.is-save { color: #0F7A55; }
.ehpr__delta.is-more { color: #A3001C; }
.ehpr__delta.is-same { color: var(--ehpr-fg-muted); }

/* Trefferliste --------------------------------------------------------- */

.ehpr__list {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: 12px;
}

.ehpr__offer {
	display: grid;
	grid-template-columns: 2rem 1fr auto;
	gap: 8px 20px;
	align-items: center;
	padding: 16px 20px;
	background: var(--ehpr-bg);
	border: 1px solid var(--ehpr-line);
	border-radius: var(--ehpr-radius);
	transition: transform 150ms var(--ehpr-ease), box-shadow 150ms var(--ehpr-ease);
}

.ehpr__offer:hover {
	transform: translateY(-2px);
	box-shadow: var(--ehpr-shadow);
}

.ehpr__offer--highlight {
	border-color: var(--ehpr-highlight);
	background: var(--ehpr-highlight-soft);
	box-shadow: inset 4px 0 0 var(--ehpr-highlight);
}

.ehpr__offer--highlight:hover {
	box-shadow: inset 4px 0 0 var(--ehpr-highlight), var(--ehpr-shadow);
}

.ehpr__rank {
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	font-size: 0.875rem;
	color: var(--ehpr-fg-muted);
	text-align: right;
}

.ehpr__offer-main {
	min-width: 0;
}

.ehpr__offer-name {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	color: var(--ehpr-heading);
	font-weight: 700;
}

.ehpr__badge {
	display: inline-block;
	padding: 4px 10px;
	font-size: 0.8125rem;
	font-weight: 700;
	color: var(--ehpr-accent-contrast);
	background: var(--ehpr-accent);
	border-radius: 999px;
}

/* Das eigene Modell ist Bezugspunkt, keine Empfehlung – deshalb als Umriss
   und nicht gefüllt wie die Partnermodelle.
   Beide Regeln stehen bewusst NACH .ehpr__offer und .ehpr__badge: gleiche
   Spezifität, es gewinnt die spätere. */
.ehpr__offer--current {
	border-color: var(--ehpr-accent);
	border-style: dashed;
}

.ehpr__badge--current {
	background: transparent;
	border: 1px solid var(--ehpr-accent);
	color: var(--ehpr-accent);
}

.ehpr__offer-model {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 8px;
	margin-top: 4px;
	font-size: 0.875rem;
	color: var(--ehpr-fg-muted);
}

.ehpr__model-name {
	font-weight: 700;
	color: var(--ehpr-fg);
}

.ehpr__model-type::before {
	content: '· ';
}

.ehpr__offer-note {
	margin: 8px 0 0;
	font-size: 0.8125rem;
	color: var(--ehpr-fg-muted);
}

/* Modell mit begrenztem Einzugsgebiet – sichtbar, aber ohne Alarmfarbe. */
.ehpr__offer-note--area {
	display: flex;
	align-items: baseline;
	gap: 6px;
}

.ehpr__offer-note--area::before {
	content: "";
	flex: 0 0 auto;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--ehpr-highlight);
	transform: translateY(-1px);
}

.ehpr__price {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	text-align: right;
	white-space: nowrap;
}

.ehpr__price-value {
	color: var(--ehpr-heading);
	font-size: 1.375rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	line-height: 1.2;
}

.ehpr__price-unit,
.ehpr__price-year {
	font-size: 0.75rem;
	color: var(--ehpr-fg-muted);
	font-variant-numeric: tabular-nums;
}

/* Herleitung des angezeigten Betrags: BAG-Prämie minus Rückvergütung. */
.ehpr__rebate {
	margin-top: 4px;
	font-size: 0.6875rem;
	line-height: 1.4;
	color: var(--ehpr-fg-muted);
	font-variant-numeric: tabular-nums;
	white-space: normal;
}

.ehpr__offer-link {
	grid-column: 2 / -1;
	justify-self: start;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 0.875rem;
	font-weight: 700;
	color: var(--ehpr-heading);
	text-decoration: none;
}

.ehpr__offer-link:hover {
	text-decoration: underline;
}

.ehpr__empty,
.ehpr__more {
	padding: 24px 16px;
	text-align: center;
	color: var(--ehpr-fg-muted);
}

.ehpr__disclaimer {
	margin: 24px 0 0;
	font-size: 0.75rem;
	line-height: 1.6;
	color: var(--ehpr-fg-muted);
}

/* ---------------------------------------------------------- Schmale Sicht */

@container (max-width: 640px) {
	.ehpr__field--loc { grid-column: span 1; }
	.ehpr__button { width: 100%; }
	.ehpr__offer { grid-template-columns: 1.75rem 1fr; }

	.ehpr__price {
		grid-column: 2;
		flex-direction: row;
		flex-wrap: wrap;
		align-items: baseline;
		text-align: left;
		gap: 4px 8px;
	}
}

/* Rückfallebene für Browser ohne Container Queries */
@media (max-width: 640px) {
	.ehpr__form { padding: 20px; }
	.ehpr__field--loc { grid-column: span 1; }
	.ehpr__button { width: 100%; }
	.ehpr__offer { grid-template-columns: 1.75rem 1fr; padding: 16px; }

	.ehpr__price {
		grid-column: 2;
		flex-direction: row;
		flex-wrap: wrap;
		align-items: baseline;
		text-align: left;
		gap: 4px 8px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ehpr *,
	.ehpr *::before,
	.ehpr *::after {
		transition: none !important;
		animation: none !important;
	}

	.ehpr__offer:hover { transform: none; }
}
