/**
 * Gestaltung des Wirtschaftlichkeitsrechners.
 *
 * Alle Regeln hängen an der Klasse .ps-rechner. Damit kann kein Theme die
 * Darstellung überschreiben und der Rechner sieht auf jeder Seite gleich aus.
 * Farben kommen aus den Plugin-Einstellungen und stehen als Variablen bereit.
 */

.ps-rechner {
	--ps-primaer: #48661D;
	--ps-akzent: #C1660F;
	--ps-dunkel: #16211B;
	--ps-hell: #EDF3E1;
	--ps-ecken: 18px;
	--ps-flaeche: #FFFFFF;
	--ps-papier: #F7F7F3;
	--ps-linie: #DCDCD2;
	--ps-text: #2E362F;
	--ps-leise: #5F6A62;

	box-sizing: border-box;
	color: var(--ps-text);
	font-size: 16px;
	line-height: 1.6;
	max-width: 100%;
}

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

.ps-rechner p { margin: 0 0 10px; }
.ps-rechner h2,
.ps-rechner h3,
.ps-rechner h4 { margin: 0; color: var(--ps-dunkel); line-height: 1.25; }

/* ---- Kopfbereich ---------------------------------------------------- */

.ps-rechner .ps-kopf { margin-bottom: 22px; }
.ps-rechner .ps-kopf__titel { font-size: 1.7rem; font-weight: 700; margin-bottom: 6px; }
.ps-rechner .ps-kopf__text { color: var(--ps-leise); max-width: 62ch; }

/* ---- Raster --------------------------------------------------------- */

.ps-rechner .ps-raster {
	display: grid;
	grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
	gap: 24px;
	align-items: start;
}

@media (max-width: 900px) {
	.ps-rechner .ps-raster { grid-template-columns: 1fr; }
}

.ps-rechner .ps-eingaben { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---- Eingabeblöcke -------------------------------------------------- */

.ps-rechner .ps-block {
	background: var(--ps-flaeche);
	border: 1px solid var(--ps-linie);
	border-radius: var(--ps-ecken);
	padding: 20px 22px;
}

.ps-rechner .ps-block__kopf { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }

.ps-rechner .ps-block__nummer {
	flex: none;
	width: 30px; height: 30px;
	border-radius: 50%;
	background: var(--ps-hell);
	color: var(--ps-primaer);
	font-weight: 700; font-size: 0.9rem;
	display: flex; align-items: center; justify-content: center;
}

.ps-rechner .ps-block__titel { font-size: 1.08rem; font-weight: 700; }
.ps-rechner .ps-block__text { font-size: 0.9rem; color: var(--ps-leise); margin: 2px 0 0; }

/* ---- Felder --------------------------------------------------------- */

.ps-rechner .ps-feld { margin-bottom: 16px; }
.ps-rechner .ps-feld:last-child { margin-bottom: 0; }

.ps-rechner .ps-feld__label {
	display: block;
	font-size: 0.9rem; font-weight: 600;
	margin-bottom: 7px; color: var(--ps-dunkel);
}

.ps-rechner .ps-feld__zeile { display: flex; align-items: center; gap: 14px; }

/* Schieber und Spannenbeschriftung bilden eine Einheit. */
.ps-rechner .ps-feld__spur { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.ps-rechner .ps-feld__zeile--schmal { max-width: 420px; }

.ps-rechner .ps-schieber {
	flex: 1 1 auto; min-width: 0;
	-webkit-appearance: none; appearance: none;
	height: 26px;
	background: transparent;
	outline: none; margin: 0;
	cursor: pointer;
}

/*
 * Die Spur wird ausdrücklich gezeichnet – ein Hintergrund am Feld selbst
 * reicht nicht, weil Browser die Spur als eigenes Element behandeln.
 * Der zurückgelegte Teil wird eingefärbt, damit die Stellung sofort ablesbar ist.
 */
.ps-rechner .ps-schieber::-webkit-slider-runnable-track {
	height: 10px;
	border-radius: 999px;
	border: 1px solid #C6CDBF;
	background: linear-gradient(
		to right,
		var(--ps-primaer) 0,
		var(--ps-primaer) var(--ps-anteil, 50%),
		#E2E6DC var(--ps-anteil, 50%),
		#E2E6DC 100%
	);
}

.ps-rechner .ps-schieber::-webkit-slider-thumb {
	-webkit-appearance: none; appearance: none;
	width: 24px; height: 24px; border-radius: 50%;
	background: var(--ps-primaer);
	border: 4px solid #fff;
	box-shadow: 0 1px 5px rgba(22, 33, 27, .35);
	cursor: grab;
	margin-top: -8px;
}

.ps-rechner .ps-schieber:active::-webkit-slider-thumb { cursor: grabbing; }

.ps-rechner .ps-schieber::-moz-range-track {
	height: 10px; border-radius: 999px;
	border: 1px solid #C6CDBF;
	background: #E2E6DC;
}

.ps-rechner .ps-schieber::-moz-range-progress {
	height: 10px; border-radius: 999px;
	background: var(--ps-primaer);
}

.ps-rechner .ps-schieber::-moz-range-thumb {
	width: 20px; height: 20px; border-radius: 50%;
	background: var(--ps-primaer); border: 4px solid #fff;
	box-shadow: 0 1px 5px rgba(22, 33, 27, .35); cursor: grab;
}

.ps-rechner .ps-schieber:focus-visible::-webkit-slider-thumb,
.ps-rechner .ps-schieber:focus-visible::-moz-range-thumb {
	outline: 3px solid var(--ps-akzent);
	outline-offset: 2px;
}

/* Kleine Beschriftung unter der Spur: kleinster und größter Wert. */
.ps-rechner .ps-spanne {
	display: flex; justify-content: space-between;
	font-size: 0.74rem; color: var(--ps-leise);
	margin-top: -2px; padding: 0 2px;
	font-variant-numeric: tabular-nums;
}

.ps-rechner .ps-feld__eingabe { display: flex; align-items: center; gap: 6px; flex: none; }

.ps-rechner .ps-zahl,
.ps-rechner .ps-text {
	width: 120px;
	padding: 9px 11px;
	border: 1px solid var(--ps-linie);
	border-radius: 10px;
	background: #fff;
	font-size: 0.95rem;
	font-variant-numeric: tabular-nums;
	color: var(--ps-text);
	text-align: right;
}

.ps-rechner .ps-text { width: 130px; text-align: left; }

.ps-rechner .ps-zahl:focus,
.ps-rechner .ps-text:focus {
	outline: 2px solid var(--ps-primaer);
	outline-offset: 1px;
	border-color: var(--ps-primaer);
}

.ps-rechner .ps-einheit { font-size: 0.85rem; color: var(--ps-leise); white-space: nowrap; }
.ps-rechner .ps-region { font-size: 0.85rem; color: var(--ps-primaer); font-weight: 600; }

.ps-rechner .ps-hilfe {
	display: inline-flex; align-items: center; justify-content: center;
	width: 16px; height: 16px; margin-left: 5px;
	border-radius: 50%; background: var(--ps-hell); color: var(--ps-primaer);
	font-size: 11px; font-weight: 700; cursor: help; vertical-align: 1px;
}

/* ---- Kachelauswahl -------------------------------------------------- */

.ps-rechner .ps-kacheln { display: flex; flex-wrap: wrap; gap: 8px; }

.ps-rechner .ps-kachel {
	appearance: none;
	background: var(--ps-papier);
	border: 1px solid var(--ps-linie);
	border-radius: 999px;
	padding: 9px 16px;
	font-size: 0.88rem; font-weight: 600;
	color: var(--ps-text);
	cursor: pointer;
	transition: background .15s, border-color .15s, color .15s;
	line-height: 1.3;
}

.ps-rechner .ps-kachel:hover { background: var(--ps-hell); border-color: var(--ps-primaer); }

.ps-rechner .ps-kachel.ist-aktiv {
	background: var(--ps-primaer);
	border-color: var(--ps-primaer);
	color: #fff;
}

/* ---- Schalter ------------------------------------------------------- */

.ps-rechner .ps-schalter { display: flex; align-items: center; gap: 11px; cursor: pointer; }
.ps-rechner .ps-schalter input { position: absolute; opacity: 0; width: 0; height: 0; }

.ps-rechner .ps-schalter__spur {
	width: 46px; height: 26px; border-radius: 999px;
	background: #C9CFC7; flex: none; position: relative;
	transition: background .18s;
}

.ps-rechner .ps-schalter__knopf {
	position: absolute; top: 3px; left: 3px;
	width: 20px; height: 20px; border-radius: 50%;
	background: #fff; transition: transform .18s;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

.ps-rechner .ps-schalter input:checked + .ps-schalter__spur { background: var(--ps-primaer); }
.ps-rechner .ps-schalter input:checked + .ps-schalter__spur .ps-schalter__knopf { transform: translateX(20px); }
.ps-rechner .ps-schalter input:focus-visible + .ps-schalter__spur { outline: 2px solid var(--ps-primaer); outline-offset: 2px; }
.ps-rechner .ps-schalter__text { font-size: 0.92rem; font-weight: 600; }

/* ---- Aufklappbereich ------------------------------------------------ */

.ps-rechner .ps-block--klapp { padding: 0; overflow: hidden; }

.ps-rechner .ps-klapp {
	width: 100%; display: flex; justify-content: space-between; align-items: center;
	background: var(--ps-papier); border: 0; padding: 15px 22px;
	font-size: 0.95rem; font-weight: 600; color: var(--ps-dunkel);
	cursor: pointer; text-align: left;
}

.ps-rechner .ps-klapp:hover { background: var(--ps-hell); }
.ps-rechner .ps-klapp__zeichen { font-size: 1.2rem; color: var(--ps-primaer); font-weight: 700; }
.ps-rechner .ps-klapp__inhalt { padding: 18px 22px 20px; }
.ps-rechner .ps-hinweis { font-size: 0.85rem; color: var(--ps-leise); margin: 12px 0 0; }

/* ---- Ergebnisspalte ------------------------------------------------- */

/*
 * Die Ergebnisspalte bleibt beim Blättern stehen. Der Abstand nach oben kommt
 * aus --ps-oben: ps-sticky.js misst dafür die Höhe einer feststehenden
 * Kopfzeile, damit die Spalte nicht darunter verschwindet. Die Höhe ist auf
 * den sichtbaren Bereich begrenzt, damit auch bei langen Ergebnissen jede
 * Zeile erreichbar bleibt.
 */
.ps-rechner .ps-ergebnis {
	position: sticky;
	top: var(--ps-oben, 20px);
	min-width: 0;
	max-height: calc(100vh - var(--ps-oben, 20px) - 24px);
	overflow-y: auto;
	/* Kein overscroll-behavior: contain – sonst blättert die Seite nicht
	   weiter, sobald der Zeiger über der Ergebnisspalte steht. */
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, .35) transparent;
}

.ps-rechner .ps-ergebnis::-webkit-scrollbar { width: 8px; }
.ps-rechner .ps-ergebnis::-webkit-scrollbar-track { background: transparent; }

.ps-rechner .ps-ergebnis::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, .28);
	border-radius: 999px;
}

.ps-rechner .ps-ergebnis::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .45); }

@media (max-width: 900px) {
	.ps-rechner .ps-ergebnis {
		position: static;
		max-height: none;
		overflow-y: visible;
	}
}

.ps-rechner .ps-ergebnis__innen {
	background: var(--ps-dunkel);
	border-radius: var(--ps-ecken);
	padding: 22px;
	color: #EDF0EA;
}

.ps-rechner .ps-kennzahlen {
	display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px;
}

.ps-rechner .ps-kennzahl {
	background: rgba(255, 255, 255, .06);
	border-radius: 12px; padding: 12px 14px;
}

.ps-rechner .ps-kennzahl--gross { grid-column: 1 / -1; background: var(--ps-primaer); }

.ps-rechner .ps-kennzahl__wert {
	display: block; font-size: 1.35rem; font-weight: 700; color: #fff;
	font-variant-numeric: tabular-nums; line-height: 1.2;
}

.ps-rechner .ps-kennzahl--gross .ps-kennzahl__wert { font-size: 1.9rem; }
.ps-rechner .ps-kennzahl__label { display: block; font-size: 0.78rem; color: #B7C4B4; margin-top: 3px; }
.ps-rechner .ps-kennzahl--gross .ps-kennzahl__label { color: rgba(255, 255, 255, .85); }

.ps-rechner .ps-zeilen { border-top: 1px solid rgba(255, 255, 255, .12); }

.ps-rechner .ps-zeile {
	display: flex; justify-content: space-between; gap: 14px;
	padding: 9px 0; border-bottom: 1px solid rgba(255, 255, 255, .09);
	font-size: 0.88rem;
}

.ps-rechner .ps-zeile span { color: #B7C4B4; }
.ps-rechner .ps-zeile b { color: #fff; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ps-rechner .ps-zeilen--eng .ps-zeile { padding: 6px 0; font-size: 0.84rem; }

/* ---- Speicherbewertung ---------------------------------------------- */

.ps-rechner .ps-speicher {
	margin-top: 18px; padding: 16px;
	background: rgba(255, 255, 255, .06); border-radius: 12px;
}

.ps-rechner .ps-speicher__titel { font-size: 0.95rem; color: #fff; margin-bottom: 8px; }

.ps-rechner .ps-speicher__urteil {
	display: inline-block; padding: 6px 14px; border-radius: 999px;
	font-size: 0.85rem; font-weight: 700; margin-bottom: 8px;
	background: #C9CFC7; color: var(--ps-dunkel);
}

.ps-rechner .ps-speicher__urteil.ist-ja { background: #A8D06A; color: #16211B; }
.ps-rechner .ps-speicher__urteil.ist-nein { background: #E8A96A; color: #16211B; }
.ps-rechner .ps-speicher__text { font-size: 0.85rem; color: #C0C8BE; margin-bottom: 10px; }

/* ---- Verlauf -------------------------------------------------------- */

.ps-rechner .ps-verlauf { margin-top: 18px; }
.ps-rechner .ps-verlauf__titel { font-size: 0.95rem; color: #fff; margin-bottom: 10px; }

.ps-rechner .ps-verlauf__grafik {
	display: flex; align-items: flex-end; gap: 3px; height: 90px;
	padding: 6px; background: rgba(0, 0, 0, .18); border-radius: 10px;
}

.ps-rechner .ps-balken { flex: 1 1 auto; border-radius: 3px 3px 0 0; min-height: 2px; }
.ps-rechner .ps-balken.ist-negativ { background: #7C6A4A; }
.ps-rechner .ps-balken.ist-positiv { background: #A8D06A; }
.ps-rechner .ps-verlauf__legende { font-size: 0.76rem; color: #8D978C; margin: 8px 0 0; }

/* ---- Anfrage -------------------------------------------------------- */

.ps-rechner .ps-anfrage {
	margin-top: 24px; padding: 24px;
	background: var(--ps-papier);
	border: 1px solid var(--ps-linie);
	border-radius: var(--ps-ecken);
}

.ps-rechner .ps-anfrage__titel { font-size: 1.15rem; font-weight: 700; margin-bottom: 6px; }
.ps-rechner .ps-anfrage__text { color: var(--ps-leise); font-size: 0.92rem; max-width: 62ch; }

.ps-rechner .ps-anfrage__felder {
	display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 12px; margin: 16px 0;
}

.ps-rechner .ps-eingabe { display: flex; flex-direction: column; gap: 5px; }
.ps-rechner .ps-eingabe--breit { grid-column: 1 / -1; }
.ps-rechner .ps-eingabe span { font-size: 0.85rem; font-weight: 600; }
.ps-rechner .ps-eingabe em { color: var(--ps-akzent); font-style: normal; margin-left: 2px; }

.ps-rechner .ps-eingabe input,
.ps-rechner .ps-eingabe textarea {
	padding: 10px 12px; border: 1px solid var(--ps-linie);
	border-radius: 10px; background: #fff; font-size: 0.95rem;
	font-family: inherit; color: var(--ps-text); width: 100%;
}

.ps-rechner .ps-eingabe input:focus,
.ps-rechner .ps-eingabe textarea:focus {
	outline: 2px solid var(--ps-primaer); outline-offset: 1px; border-color: var(--ps-primaer);
}

.ps-rechner .ps-zustimmung { display: flex; gap: 10px; align-items: flex-start; font-size: 0.85rem; color: var(--ps-leise); }
.ps-rechner .ps-zustimmung input { margin-top: 3px; flex: none; }
.ps-rechner .ps-zustimmung a { color: var(--ps-primaer); }

.ps-rechner .ps-anfrage__aktionen { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.ps-rechner .ps-knopf {
	appearance: none; border: 1px solid transparent; border-radius: 999px;
	padding: 13px 26px; font-size: 0.95rem; font-weight: 700;
	cursor: pointer; transition: background .15s, color .15s;
	font-family: inherit; line-height: 1.2;
}

.ps-rechner .ps-knopf--akzent { background: var(--ps-akzent); color: #fff; }
.ps-rechner .ps-knopf--akzent:hover { background: var(--ps-dunkel); color: #fff; }

/* Auch die zweite Schaltfläche hat eine Fläche – nichts bleibt durchsichtig. */
.ps-rechner .ps-knopf--rand { background: #fff; color: var(--ps-dunkel); border-color: var(--ps-linie); }
.ps-rechner .ps-knopf--rand:hover { background: var(--ps-hell); border-color: var(--ps-primaer); color: var(--ps-primaer); }

.ps-rechner .ps-meldung {
	margin-top: 14px; padding: 12px 16px; border-radius: 10px;
	font-size: 0.9rem; font-weight: 600;
}

.ps-rechner .ps-meldung.ist-erfolg { background: var(--ps-hell); color: var(--ps-primaer); }
.ps-rechner .ps-meldung.ist-fehler { background: #FAE8D8; color: #9A4E0A; }
.ps-rechner .ps-meldung.ist-hinweis { background: #EFEFE8; color: var(--ps-leise); }

.ps-rechner .ps-fussnote {
	margin-top: 18px; font-size: 0.78rem; color: var(--ps-leise);
	line-height: 1.6; max-width: 90ch;
}

/* ---- Rücksicht auf Nutzerwünsche ------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.ps-rechner * { transition: none !important; }
}
