/* ============================================================
   TCO Kauf vs. Miete — Design-System (Token-basiert, vanilla CSS)
   Angelehnt an das lohnabstand-Design: keine externen Ressourcen,
   System-Fonts, keine Tracker.
   ============================================================ */

:root {
  /* Farben — semantische Tokens, hell */
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --border: #ddd9d0;
  --border-strong: #b8b2a6;
  --foreground: #1c1b18;
  --muted-foreground: #5d5a52;
  --accent: #b34a2e;
  --accent-strong: #8f381f;
  --accent-soft: #f6e3dc;
  --link: #8f381f;
  --success: #2e6b45;
  --success-soft: #e2efe7;
  --warning: #8a6a1f;
  --warning-soft: #f5eeda;
  --danger: #a02c2c;
  --danger-soft: #f6e2e2;
  --rent: #5b5a8f;
  --rent-soft: #e7e6f4;

  /* Typografie */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;

  /* Abstände & Radien */
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --shadow-s: 0 1px 2px rgb(28 27 24 / .06);
  --shadow-m: 0 4px 16px rgb(28 27 24 / .09);
  --measure: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a;
    --surface: #201f24;
    --surface-2: #2a2930;
    --border: #3a393f;
    --border-strong: #55535c;
    --foreground: #ececea;
    --muted-foreground: #a3a1a8;
    --accent: #e0704e;
    --accent-strong: #eb8a6d;
    --accent-soft: #3a2721;
    --link: #eb8a6d;
    --success: #6db78c;
    --success-soft: #22352b;
    --warning: #c9a44f;
    --warning-soft: #36301f;
    --danger: #d97070;
    --danger-soft: #3a2525;
    --rent: #9b9ad1;
    --rent-soft: #2c2b40;
  }
}

/* ---------- Basis ---------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-underline-offset: .18em; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

main { max-width: 56rem; margin: 0 auto; padding: 0 1.25rem 4rem; }
.measure { max-width: var(--measure); }

/* ---------- Kopf & Navigation ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.site-header .inner {
  max-width: 56rem; margin: 0 auto; padding: .9rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.brand {
  font-weight: 700; letter-spacing: -.01em; text-decoration: none;
  color: var(--foreground); font-size: 1.05rem;
}
.brand span { color: var(--accent); }
.site-nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.site-nav a { text-decoration: none; color: var(--muted-foreground); font-size: .95rem; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--foreground); }
.lang-switch {
  display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-s);
  overflow: hidden; font-size: .85rem;
}
.lang-switch a {
  padding: .25rem .6rem; text-decoration: none; color: var(--muted-foreground);
}
.lang-switch a[aria-current="true"] {
  background: var(--accent); color: #fff; font-weight: 600;
}

/* ---------- Hero ---------- */
.hero { padding: 3.5rem 0 2rem; }
.kicker {
  display: inline-block; font-size: .8rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent-strong);
  background: var(--accent-soft); border-radius: 999px; padding: .25rem .75rem;
  margin-bottom: 1rem;
}
h1 {
  font-size: clamp(2rem, 5vw, 3rem); line-height: 1.15; letter-spacing: -.02em;
  margin: 0 0 1rem; max-width: 22ch;
}
.lede { font-size: 1.2rem; color: var(--muted-foreground); max-width: 44ch; margin: 0 0 1.5rem; }
.hero-actions { display: flex; gap: .75rem; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: .65rem 1.2rem; border-radius: var(--radius-m);
  text-decoration: none; font-weight: 600; font-size: .98rem; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--foreground); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-strong); }

/* ---------- Sections ---------- */
section { padding: 2.75rem 0; border-top: 1px solid var(--border); }
section:first-of-type { border-top: 0; }
.section-lede { color: var(--muted-foreground); max-width: var(--measure); margin-top: -.25rem; }
h2 { font-size: 1.7rem; letter-spacing: -.015em; margin: 0 0 .75rem; }
h3 { font-size: 1.15rem; margin: 1.75rem 0 .5rem; }

/* ---------- Stat-Karten ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem; margin: 1.5rem 0;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-m); padding: 1.1rem 1.2rem; box-shadow: var(--shadow-s);
}
.stat-value { font-size: 1.9rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
.stat-value small { font-size: 1rem; font-weight: 500; color: var(--muted-foreground); }
.stat-label { color: var(--muted-foreground); font-size: .92rem; margin-top: .3rem; }
.stat.accent { border-color: var(--accent); }
.stat.accent .stat-value { color: var(--accent-strong); }
.stat.rent { border-color: var(--rent); }
.stat.rent .stat-value { color: var(--rent); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td {
  border: 1px solid var(--border); padding: .55rem .7rem; text-align: left; vertical-align: top;
}
th { background: var(--surface-2); font-weight: 650; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:nth-child(even) { background: var(--surface-2); }
tr.rent-row td:first-child { box-shadow: inset 3px 0 0 var(--rent); }
tr.best td { background: var(--success-soft); font-weight: 600; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; border-radius: 999px; padding: .12rem .5rem; vertical-align: middle;
}
.badge-kauf { background: var(--accent-soft); color: var(--accent-strong); }
.badge-miete { background: var(--rent-soft); color: var(--rent); }

/* ---------- Callouts ---------- */
.callout {
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  background: var(--surface); border-radius: var(--radius-s);
  padding: .9rem 1.1rem; margin: 1.25rem 0; max-width: var(--measure);
}
.callout.warn { border-left-color: var(--warning); background: var(--warning-soft); }
.callout.note { border-left-color: var(--rent); background: var(--rent-soft); }
.callout p { margin: .35rem 0; }
.callout p:first-child { margin-top: 0; }

/* ---------- Karten ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l);
  padding: 1.4rem 1.5rem; margin: 1.25rem 0; box-shadow: var(--shadow-s);
}

/* ---------- Rechner ---------- */
.calc-controls { display: flex; flex-direction: column; gap: 1.25rem; margin: 1.5rem 0; }
.calc-group { border: 0; padding: 0; margin: 0; }
.calc-group legend { font-weight: 700; font-size: .95rem; margin-bottom: .5rem; padding: 0; }
.seg {
  display: flex; flex-wrap: wrap; gap: .5rem;
}
.seg button {
  font: inherit; font-size: .92rem; padding: .5rem .9rem; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius-m);
  background: var(--surface); color: var(--foreground);
}
.seg button[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.stepper { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.stepper button {
  font: inherit; font-size: 1.1rem; font-weight: 700; width: 2.6rem; height: 2.6rem;
  border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; color: var(--foreground);
}
.stepper button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-strong); }
.stepper button:disabled { opacity: .35; cursor: not-allowed; }
.stepper output {
  font-size: 1.6rem; font-weight: 750; min-width: 7ch; text-align: center;
  font-variant-numeric: tabular-nums;
}
.stepper .unit { color: var(--muted-foreground); font-size: .95rem; }

.calc-results { margin-top: 1.75rem; }
.bar-row { display: grid; grid-template-columns: minmax(14rem, 22rem) 1fr minmax(6rem, auto); gap: .75rem; align-items: center; margin: .55rem 0; }
.bar-label { font-size: .92rem; line-height: 1.35; }
.bar-track { background: var(--surface-2); border-radius: 999px; height: 1.5rem; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); min-width: 2px; }
.bar-fill.rent { background: var(--rent); }
.bar-value { font-variant-numeric: tabular-nums; font-weight: 650; font-size: .95rem; text-align: right; }
.calc-note { color: var(--muted-foreground); font-size: .88rem; margin-top: .75rem; }

/* ---------- Quellen ---------- */
.sources ul { margin: .5rem 0; padding-left: 1.25rem; }
.sources li { margin: .3rem 0; font-size: .93rem; }
.sources .src-note { color: var(--muted-foreground); font-size: .88rem; margin-top: .75rem; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border); padding: 1.5rem 0 2.5rem;
  color: var(--muted-foreground); font-size: .88rem;
}
.site-footer .inner { max-width: 56rem; margin: 0 auto; padding: 0 1.25rem; }

/* ---------- Utility ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1rem; }
.muted { color: var(--muted-foreground); }
