/* ════════════════════════════════════════════════════════════════
   DANWOOD SACHSEN — Finanzierungsrechner
   Gleiche Tokens wie die Hauptseite (Papierweiß, Anthrazit, Danwood-Rot,
   Archivo). Volle Breite, Abstand über Padding. Zahlen immer tabular.
   ════════════════════════════════════════════════════════════════ */

:root {
  --red: #d2232a;
  --red-deep: #a51920;
  --ink: #1c1b1a;
  --ink-soft: #4c4845;
  --ink-mute: #7a7570;
  --paper: #f7f3ec;
  --paper-warm: #efe9df;
  --white: #fffdf9;
  --line: rgba(28, 27, 26, .14);
  --line-soft: rgba(28, 27, 26, .08);
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.22, .8, .26, .99);
  --pad: clamp(1.25rem, 4vw, 3rem);
  --header-h: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { overflow-x: clip; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 17px; line-height: 1.55;
  color: var(--ink); background: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
::selection { background: var(--red); color: var(--white); }
input::selection { background: var(--ink); color: var(--paper); }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 700; font-stretch: 125%; line-height: 1.06; letter-spacing: -.025em; }
h1 em, h2 em { font-style: normal; color: var(--red); }
:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; border-radius: 2px; }
[hidden] { display: none !important; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ── Header ───────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1rem;
  min-height: var(--header-h);
  padding: .7rem var(--pad);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; min-width: 0; }
.brand-mark { width: 32px; height: 32px; fill: var(--red); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: .88rem; letter-spacing: .14em; }
.brand-text small { font-size: .66rem; letter-spacing: .04em; color: var(--ink-soft); }
.rate-mini {
  display: flex; flex-direction: column; align-items: flex-end; margin-left: auto; line-height: 1.15;
  opacity: 0; transition: opacity .25s;
}
.rate-mini.show { opacity: 1; }
.rate-mini-label { font-size: .66rem; color: var(--ink-soft); letter-spacing: .04em; }
.rate-mini-value { font-size: 1.05rem; font-weight: 800; white-space: nowrap; }
.header-cta {
  display: inline-flex; align-items: center; gap: .5rem; flex: none;
  padding: .6rem 1rem; border-radius: 2px;
  background: var(--red); color: var(--white);
  font-size: .9rem; font-weight: 700; letter-spacing: .03em; text-decoration: none;
}
.header-cta:hover { background: var(--red-deep); }
.header-cta svg { width: 1em; height: 1em; fill: currentColor; }
.rate-mini + .header-cta { margin-left: 0; }
.rate-mini[hidden] + .header-cta { margin-left: auto; }

/* ── Bausteine ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
  padding: 1rem 1.6rem; border: 0; border-radius: 2px; cursor: pointer;
  font-weight: 700; font-size: 1rem; letter-spacing: .02em; text-decoration: none;
  transition: background .2s, transform .25s var(--ease), box-shadow .25s var(--ease);
}
.btn svg { width: 1.05em; height: 1.05em; fill: currentColor; }
.btn-red { background: var(--red); color: var(--white); box-shadow: 0 10px 24px -12px rgba(210, 35, 42, .6); }
.btn-red:hover { background: var(--red-deep); transform: translateY(-1px); }
.btn-red:disabled { opacity: .55; cursor: wait; transform: none; }
.btn-wide { width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .55rem .95rem; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--white); color: var(--ink);
  font-size: .9rem; font-weight: 600; line-height: 1.2;
  transition: border-color .2s, background .2s, color .2s;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-checked="true"], .chip[aria-selected="true"] {
  background: var(--ink); border-color: var(--ink); color: var(--paper);
}
.chip b { font-weight: 800; }

.field { display: flex; flex-direction: column; gap: .35rem; }
.field > span:first-child { font-size: .8rem; font-weight: 700; letter-spacing: .02em; color: var(--ink-soft); }
.field input[type="text"], .field input[type="email"], .field input[type="tel"] {
  width: 100%; padding: .85rem 1rem;
  border: 1.5px solid var(--line); border-radius: 2px; background: var(--white);
  font-size: 1.05rem; transition: border-color .2s;
}
.field input:focus { border-color: var(--ink); outline: none; }
.field input.invalid { border-color: var(--red); }
.field small { font-size: .78rem; color: var(--ink-mute); line-height: 1.35; }
.money { position: relative; display: block; }
.money input { padding-right: 2.4rem !important; text-align: right; font-weight: 700; }
.money b { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--ink-soft); }
.consent { display: flex; gap: .7rem; align-items: flex-start; font-size: .85rem; color: var(--ink-soft); line-height: 1.4; cursor: pointer; }
.consent input { width: 20px; height: 20px; flex: none; margin-top: .1rem; accent-color: var(--red); }
.consent a { color: var(--red); font-weight: 600; }
.form-error, .calc-error { color: var(--red); font-weight: 600; font-size: .92rem; }

/* ── Einstieg ─────────────────────────────────────────────────── */
.start {
  display: grid; grid-template-columns: 1fr; gap: 2.5rem;
  padding: clamp(2rem, 5vw, 4.5rem) var(--pad) clamp(3rem, 6vw, 5rem);
}
.start h1 { font-size: clamp(2rem, 6.4vw, 3.6rem); max-width: 16ch; }
.lede { margin-top: 1.1rem; font-size: 1.08rem; color: var(--ink-soft); max-width: 36rem; }
.facts { list-style: none; margin-top: 1.6rem; display: grid; gap: .7rem; max-width: 36rem; }
.facts li { display: flex; gap: .7rem; align-items: flex-start; font-size: .95rem; }
.facts svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--red); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.start-form {
  display: grid; gap: 1rem; align-content: start;
  padding: clamp(1.4rem, 3vw, 2.2rem);
  background: var(--white); border: 1px solid var(--line); border-radius: 4px;
}
.form-title { font-weight: 700; font-stretch: 110%; font-size: 1.25rem; letter-spacing: -.01em; }
.form-sub { font-size: .92rem; color: var(--ink-soft); line-height: 1.45; }
.form-sub b { color: var(--ink); }
.start-forms { display: grid; gap: 1rem; align-content: start; }
.chips-mode .chip { padding: .7rem 1.1rem; }
.link-sent { justify-items: start; }
.link-sent svg { width: 40px; height: 40px; fill: none; stroke: var(--red); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Rechner: Eingaben ────────────────────────────────────────── */
.rechner { padding: clamp(1.4rem, 3vw, 2.5rem) var(--pad) 7rem; display: grid; gap: clamp(1.6rem, 3vw, 2.6rem); }
.eingaben {
  display: grid; grid-template-columns: 1fr; gap: 1.1rem 1.6rem;
  padding: clamp(1.2rem, 2.6vw, 1.8rem);
  background: var(--white); border: 1px solid var(--line); border-radius: 4px;
}
.field-main input { font-size: 1.5rem !important; padding: .9rem 2.6rem .9rem 1rem !important; }
.switches { display: grid; grid-template-columns: 1fr; gap: .55rem .9rem; }
.switch { display: flex; align-items: flex-start; gap: .8rem; cursor: pointer; padding: .55rem 0; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  flex: none; width: 46px; height: 26px; margin-top: .1rem; border-radius: 999px;
  background: rgba(28, 27, 26, .18); position: relative; transition: background .2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--white); transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.switch input:checked + .track { background: var(--red); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 3px solid var(--red); outline-offset: 3px; }
.switch-text { display: flex; flex-direction: column; line-height: 1.3; }
.switch-text b { font-size: .95rem; }
.switch-text small { font-size: .78rem; color: var(--ink-mute); }

/* ── Rate ─────────────────────────────────────────────────────── */
.rate-panel {
  display: grid; grid-template-columns: 1fr; gap: 1.4rem;
  padding: clamp(1.4rem, 3vw, 2.4rem);
  background: var(--ink); color: var(--paper); border-radius: 4px;
  border-top: 4px solid var(--red);
}
.rate-label { font-size: .85rem; font-weight: 600; letter-spacing: .02em; color: rgba(247, 243, 236, .7); }
.rate-value {
  display: flex; align-items: baseline; gap: .35rem; margin-top: .2rem;
  font-size: clamp(3.4rem, 13vw, 6.4rem); font-weight: 800; font-stretch: 110%;
  line-height: 1; letter-spacing: -.035em;
}
.rate-unit { font-size: .45em; font-weight: 700; color: rgba(247, 243, 236, .8); letter-spacing: 0; }
.rate-sub { margin-top: .7rem; font-size: .95rem; color: rgba(247, 243, 236, .82); max-width: 40rem; }
.rate-sub b { color: var(--paper); font-weight: 700; }
.rate-side { display: grid; gap: .9rem; align-content: start; }
.chips-variants .chip { background: transparent; border-color: rgba(247, 243, 236, .3); color: var(--paper); }
.chips-variants .chip:hover { border-color: var(--paper); }
.chips-variants .chip[aria-selected="true"] { background: var(--paper); border-color: var(--paper); color: var(--ink); }
.chips-variants .chip small { font-weight: 500; opacity: .8; }
.chips-variants .chip[aria-selected="true"] small { opacity: .7; }
.rate-empf { font-size: .92rem; color: rgba(247, 243, 236, .85); line-height: 1.45; max-width: 44rem; }
.rate-empf b { color: var(--paper); }

/* ── Blöcke: Beschreibung + Tabelle ───────────────────────────── */
.block {
  display: grid; grid-template-columns: 1fr; gap: 1rem 2.5rem;
  padding-top: 1.6rem; border-top: 1px solid var(--line);
}
.block-desc h2 { font-size: clamp(1.35rem, 2.4vw, 1.75rem); }
.block-desc p { margin-top: .6rem; font-size: .95rem; color: var(--ink-soft); max-width: 40rem; }
.block-desc p.muted { color: var(--ink-mute); font-size: .85rem; }
.block-desc-wide p { max-width: 52rem; }
.block-tag {
  display: inline-flex; align-items: center; gap: .4rem; margin-bottom: .6rem;
  padding: .3rem .7rem; border-radius: 999px; background: var(--red); color: var(--white);
  font-size: .74rem; font-weight: 700; letter-spacing: .04em;
}
.block-tag svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.block.is-empf .block-desc { border-left: 3px solid var(--red); padding-left: 1rem; }

.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: 4px; min-width: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { padding: .75rem .9rem; text-align: right; vertical-align: top; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.tbl th { font-size: .74rem; font-weight: 700; letter-spacing: .03em; color: var(--ink-mute); }
.tbl th:first-child, .tbl td:first-child { text-align: left; white-space: normal; min-width: 11rem; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .sum td { font-weight: 800; border-top: 2px solid var(--ink); background: var(--paper); }
.tbl .sub td { color: var(--ink-soft); font-size: .88rem; }
.tbl .sub td:first-child { padding-left: 1.8rem; }
.tbl .neg td { color: var(--ink-soft); }
.tbl .hl td { font-weight: 800; }
.tbl td small { display: block; font-size: .78rem; color: var(--ink-mute); font-weight: 500; white-space: normal; }
.tbl .c-fine { display: none; }
.tbl tfoot td { color: var(--ink-soft); font-size: .85rem; white-space: normal; text-align: left; background: var(--paper); }
.tbl .rate-cell { font-weight: 800; }

.zinsstand { font-size: .82rem; color: var(--ink-mute); line-height: 1.5; max-width: 60rem; }
.zinsstand b { color: var(--ink-soft); }

/* ── Häuser ───────────────────────────────────────────────────── */
.haeuser { padding-top: 1.6rem; border-top: 1px solid var(--line); display: grid; gap: 1.4rem; }
.haus-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.haus-card {
  display: flex; flex-direction: column; text-align: left; cursor: pointer;
  background: var(--white); border: 1.5px solid var(--line); border-radius: 4px; overflow: hidden;
  padding: 0; transition: border-color .2s, transform .3s var(--ease), box-shadow .3s var(--ease);
  position: relative;
}
.haus-card:hover { border-color: var(--ink); transform: translateY(-3px); box-shadow: 0 22px 34px -24px rgba(28, 27, 26, .4); }
.haus-card[aria-checked="true"] { border-color: var(--red); box-shadow: 0 0 0 2px var(--red); }
.haus-img { display: block; aspect-ratio: 4 / 3; overflow: hidden; background: var(--paper-warm); }
.haus-img img { width: 100%; height: 100%; object-fit: cover; }
.haus-check {
  position: absolute; top: .7rem; right: .7rem; width: 32px; height: 32px; border-radius: 50%;
  background: var(--red); color: var(--white); display: none; align-items: center; justify-content: center;
}
.haus-check svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.haus-card[aria-checked="true"] .haus-check { display: flex; }
.haus-meta { padding: .9rem 1rem 1rem; display: grid; gap: .15rem; }
.haus-line { font-size: .72rem; font-weight: 700; letter-spacing: .06em; color: var(--red); }
.haus-meta h3 { font-size: 1.1rem; font-stretch: 110%; }
.haus-meta p { font-size: .85rem; color: var(--ink-soft); }
.haus-price { margin-top: .4rem; font-size: 1rem; font-weight: 800; }
.haus-price small { font-weight: 500; color: var(--ink-mute); font-size: .78rem; margin-left: .3rem; }
.haus-empty { color: var(--ink-mute); font-size: .92rem; }

/* ── CTA-Leiste ───────────────────────────────────────────────── */
.cta-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; gap: 1rem;
  padding: .8rem var(--pad) calc(.8rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--white) 94%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.cta-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.cta-haus { font-size: .85rem; font-weight: 700; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cta-rate { font-size: .78rem; color: var(--ink-soft); }
.btn-cta { margin-left: auto; flex: none; padding: .9rem 1.3rem; }
.cta-note { font-size: .85rem; color: var(--ink-mute); max-width: 44rem; }

/* ── Footer ───────────────────────────────────────────────────── */
.site-footer { padding: 1.6rem var(--pad) 6.5rem; border-top: 1px solid var(--line); background: var(--paper-warm); font-size: .8rem; color: var(--ink-soft); }
.site-footer a { color: var(--ink); font-weight: 600; }
body.on-start .site-footer { padding-bottom: 1.6rem; }

/* ── Bewegung nur auf Aktion ──────────────────────────────────── */
.rate-value.bump { animation: bump .35s var(--ease); }
@keyframes bump { 0% { transform: translateY(4px); opacity: .6; } 100% { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── Breiter ──────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .haus-grid { grid-template-columns: repeat(2, 1fr); }
  .switches { grid-template-columns: repeat(2, 1fr); }
  .btn-cta { padding: 1rem 1.8rem; }
  .cta-haus { font-size: .95rem; }
}
@media (min-width: 900px) {
  .start { grid-template-columns: 1.15fr 1fr; align-items: center; gap: clamp(2.5rem, 6vw, 6rem); }
  .eingaben { grid-template-columns: 1.3fr 1fr 1fr; }
  .switches { grid-column: 1 / -1; grid-template-columns: repeat(3, 1fr); }
  .rate-panel { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: center; }
  .block { grid-template-columns: minmax(240px, 1fr) minmax(0, 2.3fr); }
  .tbl .c-fine { display: table-cell; }
  .tbl td small.m-only { display: none; }
  .haus-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1300px) {
  .switches { grid-template-columns: repeat(5, 1fr); }
  .block { grid-template-columns: minmax(280px, 1fr) minmax(0, 2.6fr); }
}
@media (max-width: 899px) {
  .tbl th.c-fine, .tbl td.c-fine { display: none; }
}
@media (max-width: 639px) {
  /* Mobil: die Rate zuerst — sie ist der Grund, warum man hier ist; die
     Eingaben folgen direkt darunter und ändern sie live. */
  .rate-panel { order: -1; }
  .tbl { font-size: .9rem; }
  .tbl th, .tbl td { padding: .6rem .6rem; }
  .tbl th:first-child, .tbl td:first-child { min-width: 7.5rem; }
  .tbl .c-5j { display: none; }
  .header-cta span { display: none; }
  .header-cta { padding: .6rem .7rem; }
  .brand-text small { display: none; }
  .brand { flex: none; }
  .rate-mini { min-width: 0; }
  .rate-mini-value { font-size: .98rem; }
  /* Sobald das kleine Zahlwerk im Kopf steht, weicht die Wortmarke (Bildmarke bleibt). */
  .site-header:has(.rate-mini.show) .brand-text { display: none; }
  .btn-cta { padding: .85rem 1rem; font-size: .95rem; }
  .btn-cta svg { display: none; }
}
