/* ==========================================================================
   SHK-Info.de – Rechenwerkzeuge
   ========================================================================== */

.rechner {
  display: grid; gap: var(--raum-8);
  align-items: start;
}
@media (min-width: 62rem) {
  .rechner { grid-template-columns: 21rem 1fr; gap: var(--raum-12); }
}

/* --- Eingaben ------------------------------------------------------------- */
.eingaben { display: grid; gap: var(--raum-8); }

.feldgruppe {
  padding: var(--raum-6);
  border: 1px solid var(--farbe-linie);
  border-radius: var(--radius-lg);
  background: #fff;
}
.feldgruppe > h2 {
  font-size: var(--text-xs); font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--farbe-text-leise);
  margin-bottom: var(--raum-5);
}

.feld { display: grid; gap: var(--raum-2); }
.feld + .feld { margin-top: var(--raum-5); }
.feld__name { font-size: var(--text-sm); font-weight: 600; }
.feld__hinweis { font-size: var(--text-xs); color: var(--farbe-text-leise); }

.feld input[type="number"] {
  width: 100%;
  padding: var(--raum-3) var(--raum-4);
  border: 1px solid var(--grau-300);
  border-radius: var(--radius);
  font-variant-numeric: tabular-nums;
}
/* --- Auswahlfelder --------------------------------------------------------
   Ein <select> zeichnet sonst das Betriebssystem, und das passt neben
   unseren Eingabefeldern nie ganz. appearance: none schaltet das ab, den
   Pfeil legen wir als eigenes SVG dahinter. Die aufgeklappte Liste bleibt
   Sache des Systems - an die kommt CSS nicht heran.                        */
.feld select,
.schichten select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: var(--raum-3) var(--raum-4);
  padding-right: calc(var(--raum-4) + 1.1rem);
  border: 1px solid var(--grau-300);
  border-radius: var(--radius);
  background-color: var(--farbe-flaeche);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2364748b' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--raum-3) center;
  background-size: .7rem auto;
  cursor: pointer;
  /* Lange Bezeichnungen enden mit Auslassungspunkten statt mitten im Wort */
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

.feld select:hover,
.schichten select:hover { border-color: var(--blau-300); }

/* Fuer Auswahl- und Zahlenfelder derselbe Fokusring */
.feld select:focus-visible,
.schichten select:focus-visible,
.feld input[type="number"]:focus-visible,
.schichten input:focus-visible {
  outline: none;
  border-color: var(--farbe-fokus);
  box-shadow: 0 0 0 3px var(--blau-100);
}

/* Der Pfeil faerbt sich mit, solange das Feld dran ist */
.feld select:focus-visible,
.schichten select:focus-visible { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%231d71b8' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }

/* Schalterreihe, z. B. für die Raumtemperatur */
.schalterreihe { display: flex; flex-wrap: wrap; gap: var(--raum-1); }
.schalter {
  padding: var(--raum-2) var(--raum-3);
  border: 1px solid var(--grau-300);
  border-radius: var(--radius);
  background: #fff; cursor: pointer;
  font-size: var(--text-sm); font-variant-numeric: tabular-nums;
}
.schalter:hover { border-color: var(--blau-300); }
.schalter[aria-pressed="true"] {
  background: var(--blau-600); border-color: var(--blau-600); color: #fff; font-weight: 600;
}

/* --- Schieberegler -------------------------------------------------------- */
.regler { width: 100%; accent-color: var(--shk-blau); }
.regler__zeile {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: var(--text-sm);
}
.regler__wert { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Zeigt an, dass die Spreizung von Hand gesetzt wurde */
.handbetrieb {
  display: inline-block;
  margin-left: var(--raum-2);
  padding: 0 var(--raum-2);
  border-radius: var(--radius-sm);
  background: var(--gelb-200);
  font-size: var(--text-xs); font-weight: 600;
}
.handbetrieb[hidden] { display: none; }

/* --- Ergebnis ------------------------------------------------------------- */
.ergebnis {
  border: 2px solid var(--farbe-linie);
  border-radius: var(--radius-lg);
  padding: var(--raum-6);
  background: #fff;
  transition: border-color .2s;
}
.ergebnis[data-zustand="passt"]  { border-color: #2f9e6b; }
.ergebnis[data-zustand="knapp"]  { border-color: var(--gelb-500); }
.ergebnis[data-zustand="daneben"]{ border-color: var(--shk-rot); }

.bewertung {
  display: flex; align-items: flex-start; gap: var(--raum-3);
  padding: var(--raum-4);
  border-radius: var(--radius);
  font-size: var(--text-sm); font-weight: 500;
  margin-bottom: var(--raum-6);
}
.bewertung[data-zustand="passt"]   { background: #eaf7f0; color: #1c6344; }
.bewertung[data-zustand="knapp"]   { background: var(--gelb-100); color: #7a5c00; }
.bewertung[data-zustand="daneben"] { background: var(--rot-50); color: var(--rot-800); }

.kennwerte {
  display: grid; gap: var(--raum-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
  margin-top: var(--raum-6);
}
.kennwert {
  padding: var(--raum-4);
  background: var(--grau-50);
  border-radius: var(--radius);
}
.kennwert__wert {
  display: block;
  font-size: var(--text-2xl); font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--blau-700);
}
.kennwert__name {
  display: block; margin-top: var(--raum-1);
  font-size: var(--text-xs); color: var(--farbe-text-leise);
}

/* --- Heizkörperdarstellung ------------------------------------------------ */
.heizkoerper { margin-bottom: var(--raum-2); }
.heizkoerper svg { width: 100%; height: auto; }
.heizkoerper text { font-family: var(--schrift-text); fill: var(--farbe-text); }

/* --- Formelhinweis -------------------------------------------------------- */
.formel {
  margin-top: var(--raum-8);
  padding-top: var(--raum-6);
  border-top: 1px solid var(--farbe-linie);
  font-size: var(--text-sm);
  color: var(--farbe-text-leise);
}
.formel h3 { font-size: var(--text-sm); color: var(--farbe-text); margin-bottom: var(--raum-2); }
.formel code {
  display: inline-block; margin-block: var(--raum-1);
  padding: .15em .4em; background: var(--grau-100);
  border-radius: var(--radius-sm); font-size: .95em;
}

/* --- Schichtentabelle (U-Wert-Rechner) ------------------------------------ */
.schichten__huelle { overflow-x: auto; margin-inline: calc(var(--raum-6) * -1); padding-inline: var(--raum-6); }

.schichten { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.schichten th {
  text-align: left; font-weight: 600; font-size: var(--text-xs);
  letter-spacing: .04em; text-transform: uppercase; color: var(--farbe-text-leise);
  padding: var(--raum-2) var(--raum-2) var(--raum-3);
  border-bottom: 1px solid var(--farbe-linie);
  white-space: nowrap;
}
.schichten td { padding: var(--raum-2); border-bottom: 1px solid var(--grau-100); vertical-align: middle; }
.schichten select, .schichten input {
  width: 100%; min-width: 5rem;
  padding: var(--raum-2);
  border: 1px solid var(--grau-300); border-radius: var(--radius-sm);
  background-color: var(--farbe-flaeche);
}
.schichten select {
  min-width: 11rem;
  padding-right: calc(var(--raum-2) + 1.1rem);
  background-position: right var(--raum-2) center;
}
.schichten .zahlenspalte {
  text-align: right; font-variant-numeric: tabular-nums;
  color: var(--farbe-text-leise); white-space: nowrap;
}

.schicht__weg {
  width: 1.75rem; height: 1.75rem;
  display: grid; place-items: center;
  border: 1px solid var(--grau-300); border-radius: var(--radius-sm);
  background: #fff; cursor: pointer;
  color: var(--farbe-text-leise); font-size: 1.1rem; line-height: 1;
}
.schicht__weg:hover:not(:disabled) {
  border-color: var(--rot-300); color: var(--shk-rot); background: var(--rot-50);
}
.schicht__weg:disabled { opacity: .35; cursor: not-allowed; }

/* Rechenweg als Zeilen, nicht als Fließtext */
.rechenweg {
  margin-top: var(--raum-6); padding-top: var(--raum-4);
  border-top: 1px solid var(--farbe-linie);
  font-size: var(--text-sm);
}
.rechenweg__zeile {
  display: flex; justify-content: space-between; gap: var(--raum-4);
  padding: var(--raum-2) 0;
}
.rechenweg__zeile--summe {
  border-top: 1px solid var(--farbe-linie);
  margin-top: var(--raum-2); padding-top: var(--raum-3);
  font-weight: 700;
}
.rechenweg__wert { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Großer Ergebniswert */
.hauptwert {
  display: flex; align-items: baseline; gap: var(--raum-3);
  margin-bottom: var(--raum-4);
}
.hauptwert__zahl {
  font-size: var(--text-4xl); font-weight: 700;
  letter-spacing: -0.03em; line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--blau-700);
}
.hauptwert__einheit { font-size: var(--text-lg); color: var(--farbe-text-leise); }

/* Zweiter Rechenweg als abgesetzter Block */
.nebenrechner {
  margin-top: var(--raum-12);
  padding: var(--raum-6);
  border: 1px solid var(--farbe-linie);
  border-radius: var(--radius-lg);
  background: var(--grau-50);
}
.nebenrechner > h2 { font-size: var(--text-lg); margin-bottom: var(--raum-2); }
.nebenrechner > p { font-size: var(--text-sm); color: var(--farbe-text-leise); margin-bottom: var(--raum-6); }
.nebenrechner__felder {
  display: grid; gap: var(--raum-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
}

/* --- Verlaufsdiagramm (Amortisation) -------------------------------------- */
.diagramm { margin-block: var(--raum-6); }
.diagramm svg { width: 100%; height: auto; font-family: var(--schrift-text); }

.legende {
  display: flex; flex-wrap: wrap; gap: var(--raum-6);
  font-size: var(--text-sm); color: var(--farbe-text-leise);
  margin-top: var(--raum-2);
}
.legende__strich {
  display: inline-block; width: 1.75rem; height: 3px;
  border-radius: 2px; margin-right: var(--raum-2);
  vertical-align: middle;
}

/* Schalter für die Photovoltaik */
.schaltfeld {
  display: flex; align-items: center; gap: var(--raum-3);
  padding: var(--raum-3) 0;
}
.schaltfeld input { width: 1.1rem; height: 1.1rem; accent-color: var(--shk-blau); }
.schaltfeld label { font-size: var(--text-sm); font-weight: 600; }
