/* ----------------------- Tokens & Reset ----------------------- */
:root {
  --c-bg: #fafaf7;
  --c-surface: #ffffff;
  --c-text: #1f2329;
  --c-muted: #5b6573;
  --c-line: #d8ddd6;
  --c-accent: #2c5e7a;
  --c-accent-soft: #e7f0f5;
  --c-warn: #b54a18;
  --c-warn-soft: #fdecdc;
  --c-good: #28714a;
  --c-good-soft: #e2f0e6;
  --c-water: #2a7fb6;
  --c-water-soft: #d8ecf7;
  --radius: .5rem;
  --pad: 1rem;
  --maxw: 1800px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --font-body: -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--c-text);
  background: var(--c-bg);
}

a { color: var(--c-accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3 { line-height: 1.25; margin-top: 0; }
h1 { font-size: 1.85rem; margin-bottom: 1rem; }
h2 { font-size: 1.35rem; margin-top: 1.6rem; margin-bottom: .6rem; }
h3 { font-size: 1.1rem; margin-top: 1.2rem; margin-bottom: .4rem; }

p { margin: 0 0 .8rem; }
ul, ol { margin: 0 0 .8rem; padding-left: 1.4rem; }
li { margin: .25rem 0; }

code, kbd, pre { font-family: var(--font-mono); font-size: .92em; }
code { background: #f0eee6; padding: .1em .35em; border-radius: .2em; }
pre { background: #1f2329; color: #e8eef4; padding: .7rem .9rem; border-radius: var(--radius); overflow-x: auto; }
pre code { background: transparent; padding: 0; color: inherit; }

table { border-collapse: collapse; width: 100%; margin: .8rem 0 1.2rem; font-size: .94rem; }
th, td { text-align: left; padding: .35rem .6rem; border-bottom: 1px solid var(--c-line); }
th { background: var(--c-accent-soft); font-weight: 600; }

blockquote {
  border-left: 3px solid var(--c-accent); padding: .2rem .9rem;
  background: var(--c-accent-soft); margin: .8rem 0; border-radius: 0 var(--radius) var(--radius) 0;
}

hr { border: none; border-top: 1px solid var(--c-line); margin: 1.2rem 0; }

/* ----------------------- Layout ------------------------------- */
.site-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
  padding: .8rem var(--pad);
}
.site-header__inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.site-header a.brand { font-weight: 700; color: var(--c-text); text-decoration: none; }
.site-header nav a,
.site-header nav .current {
  margin-left: 1rem;
  display: inline-block;
  position: relative;
  text-align: center;
}
/* Ghost-Pseudoelement reserviert die Breite der Bold-Variante,
   damit der Wechsel a ↔ span beim Klicken die Layoutbreite nicht ändert. */
.site-header nav a::after,
.site-header nav .current::after {
  content: attr(data-text);
  display: block;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-weight: 800;
}
.site-header nav .current {
  font-weight: 800;
  color: var(--c-text);
}

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem var(--pad) 2rem;
}

/* ----------------------- Übersichtsseite ---------------------- */
.intro {
  max-width: 820px;
  margin-bottom: 2rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
  margin: 1rem 0 2rem;
}
.card {
  display: flex; flex-direction: column;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  padding: 1.4rem 1.2rem;
  text-decoration: none; color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card__icon { font-size: 2rem; }
.card__title { font-size: 1.25rem; font-weight: 700; margin: .4rem 0 .3rem; }
.card__lead { color: var(--c-muted); flex-grow: 1; }
.card__cta { margin-top: 1rem; color: var(--c-accent); font-weight: 600; }

/* ----------------------- Themen-Layout (split scroll) --------- */

/* Auf Themenseiten: Body wird zum Vollbild-Layout, das Scrollen
   findet in den beiden Spalten statt — nicht im Body. */
body.theme-page {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.theme-page .site-header,
body.theme-page .site-footer {
  flex: 0 0 auto;
}
body.theme-page main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}
body.theme-page main > h1 { margin-top: 0; flex: 0 0 auto; }

.theme {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 1.5rem;
}
.theme > .calc,
.theme > .theory {
  min-width: 0;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;     /* die Box selbst clipt — Scrollen findet im .panel-body statt */
  display: flex;
  flex-direction: column;
}
/* Innerer Scrollbereich */
.panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  padding: 1.1rem 1.2rem;
  /* Firefox */
  scrollbar-width: auto;
  scrollbar-color: var(--c-accent) #e1e6ec;
}
.theory .panel-body { padding-bottom: 2rem; }
/* WebKit / Chromium / Safari — `-webkit-appearance: none` erzwingt das
   Custom-Styling, sonst rendert macOS standardmäßig Overlay-Scrollbars,
   die komplett unsichtbar sind, bis der User scrollt. */
.panel-body::-webkit-scrollbar {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  background: #e1e6ec;
}
.panel-body::-webkit-scrollbar-track {
  background: #e1e6ec;
  box-shadow: inset 0 0 0 1px #cdd5dd;
}
.panel-body::-webkit-scrollbar-thumb {
  background: var(--c-accent);
  border-radius: 8px;
  border: 3px solid #e1e6ec;
  background-clip: padding-box;
  min-height: 60px;
}
.panel-body::-webkit-scrollbar-thumb:hover {
  background: #1f4659;
  background-clip: padding-box;
}

@media (max-width: 900px) {
  body.theme-page {
    height: auto;
    max-height: none;
    overflow: auto;
  }
  body.theme-page main { display: block; padding-bottom: 1rem; }
  .theme {
    display: block;
  }
  .theme > .calc,
  .theme > .theory {
    overflow-y: visible;
    max-height: none;
    padding-right: 0;
  }
  .theme > .calc { margin-bottom: 1.5rem; }
}

.theory,
.calc {
  background: var(--c-surface);
  border: 1px solid #c5cdd6;
  border-radius: var(--radius);
  padding: 0;                     /* kein eigenes Padding — der innere Wrapper sorgt dafür */
  box-shadow: 0 2px 10px rgba(20, 35, 50, 0.07);
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
}

.panel-title {
  flex: 0 0 auto;
  margin: 0;
  padding: .55rem 1.2rem;
  background: var(--c-accent);
  color: white;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  font-size: 1rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  font-weight: 700;
}

.panel-body > .lead {
  font-size: 1rem;
  color: var(--c-muted);
  margin-top: 0;
  margin-bottom: 1.1rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--c-line);
}

.theory section { scroll-margin-top: 1rem; }
.theory .panel-body > section:first-of-type h2 { margin-top: 0; }
.theory .toc {
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  padding: .7rem 1rem;
  margin: 0 0 1.2rem;
  font-size: .92rem;
}
.theory .toc strong { display: block; margin-bottom: .3rem; }
.theory .toc ol { margin: 0; padding-left: 1.2rem; }

.calc .input-group { margin: .7rem 0; }
.calc .input-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: .9rem;
  margin: .7rem 0;
}
.calc .input-row .input-group--inline { margin: 0; }
@media (max-width: 600px) {
  .calc .input-row { grid-template-columns: 1fr; }
}
.calc label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.calc label .hint { font-weight: 400; color: var(--c-muted); font-size: .85em; }
.calc input[type="number"], .calc select {
  width: 100%; padding: .35rem .5rem;
  border: 1px solid var(--c-line); border-radius: var(--radius);
  font: inherit; background: var(--c-bg);
}
.calc input[type="range"] { width: 100%; }
.calc .range-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center; }
.calc .range-value { font-family: var(--font-mono); font-size: .9rem; min-width: 4rem; text-align: right; }
.calc .toggle { display: inline-flex; gap: 0; border: 1px solid var(--c-line); border-radius: var(--radius); overflow: hidden; }
.calc .toggle button {
  padding: .25rem .7rem; background: var(--c-bg); border: none;
  font: inherit; cursor: pointer;
}
.calc .toggle button.active { background: var(--c-accent); color: white; }

.calc .results {
  margin-top: 1rem; padding-top: .8rem;
  border-top: 1px solid var(--c-line);
}
.calc .result-row { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; }
.calc .result-row .label { color: var(--c-muted); }
.calc .result-row .value { font-family: var(--font-mono); font-weight: 600; }
.calc .result-row.big .value { font-size: 1.15rem; color: var(--c-accent); }

.calc .narrative p { margin: 0 0 .9rem; line-height: 1.6; }
.calc .narrative .num {
  font-family: var(--font-mono);
  font-weight: 700;
  background: var(--c-accent-soft);
  color: var(--c-accent);
  padding: .05em .35em;
  border-radius: .25em;
  white-space: nowrap;
}
.calc .narrative p.bigline {
  margin-top: 1.1rem;
  padding-top: .9rem;
  border-top: 1px solid var(--c-line);
  font-size: 1.05rem;
  text-align: center;
}
.calc .narrative p.bigline .num {
  background: var(--c-accent);
  color: white;
}

.calc .badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  font-size: .8rem; font-weight: 600; margin-left: .4rem;
}
.calc .badge.warn { background: var(--c-warn-soft); color: var(--c-warn); }
.calc .badge.good { background: var(--c-good-soft); color: var(--c-good); }
.calc .badge.info { background: var(--c-accent-soft); color: var(--c-accent); }

.calc .viz {
  margin-top: 1.2rem;
  background: var(--c-bg);
  border-radius: var(--radius);
  padding: .5rem;
}
.calc .viz svg { display: block; max-width: 100%; height: auto; }

/* Quellen */
.sources li { font-size: .92rem; }
.sources ol { padding-left: 1.6rem; }
.sources li { padding-left: .2rem; }
sup.cite { font-size: .72em; line-height: 0; vertical-align: super; }
sup.cite a {
  text-decoration: none;
  padding: 0 .15em;
  color: var(--c-accent);
  font-weight: 600;
}
sup.cite a:hover { text-decoration: underline; }
sup.cite + sup.cite::before { content: ", "; color: var(--c-muted); font-weight: 400; }

/* Form-Hilfe */
small.note { color: var(--c-muted); display: block; margin-top: .2rem; }

/* Kompakte Datenblatt-Tabelle */
.datasheet td:first-child { color: var(--c-muted); }
.datasheet td:last-child { font-family: var(--font-mono); }

/* Druckansicht */
@media print {
  .site-header nav, .calc { display: none; }
  body { background: white; }
}
