/* =========================================================
   Rentenlücken-Rechner – Stylesheet
   Mobile-first, Light-/Dark-Theme über prefers-color-scheme
   ========================================================= */

:root {
  /* Farbpalette – "Nordsee-Petrol" mit warmem Amber-Akzent */
  --color-bg: #f4f7f6;
  --color-surface: #ffffff;
  --color-surface-alt: #e8efee;
  --color-text: #1c2a29;
  --color-text-muted: #55706d;
  --color-primary: #0f5c5a;
  --color-primary-strong: #0a4342;
  --color-primary-contrast: #ffffff;
  --color-accent: #d98324;
  --color-accent-soft: #f7e3c8;
  --color-border: #cfdedd;
  --color-danger: #b3402e;
  --color-chart-rente: #2f8f8c;
  --color-chart-luecke: #d98324;
  --color-chart-line: #0f5c5a;
  --color-chart-grid: #cfdedd;
  --shadow-card: 0 1px 2px rgba(16, 42, 41, 0.06), 0 8px 24px rgba(16, 42, 41, 0.07);
  --radius: 14px;
  --radius-small: 8px;
  --font-body: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Spline Sans Mono", "Consolas", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0d1717;
    --color-surface: #142222;
    --color-surface-alt: #1b2e2d;
    --color-text: #e2ecea;
    --color-text-muted: #93aca9;
    --color-primary: #4fb3ae;
    --color-primary-strong: #6cc9c4;
    --color-primary-contrast: #0d1717;
    --color-accent: #e9a253;
    --color-accent-soft: #3a2c17;
    --color-border: #274240;
    --color-danger: #e07b62;
    --color-chart-rente: #3aa39f;
    --color-chart-luecke: #e9a253;
    --color-chart-line: #6cc9c4;
    --color-chart-grid: #274240;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: min(100% - 2rem, 68rem);
  margin-inline: auto;
}

h1, h2, h3 {
  line-height: 1.2;
  font-weight: 800;
  margin: 0 0 0.6em;
}

h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1em; }

/* ---------- Header ---------- */

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.7rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--color-primary);
  text-decoration: none;
}

.brand-mark { width: 1.9rem; height: 1.9rem; }

.brand-name {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

/* ---------- Buttons ---------- */

.btn {
  font: inherit;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn:disabled { cursor: not-allowed; opacity: 0.55; }

.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
}

.btn-primary:not(:disabled):hover { background: var(--color-primary-strong); }

.btn-premium {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border-color: var(--color-accent);
  font-size: 0.9rem;
  white-space: nowrap;
}

.btn-premium:hover { background: var(--color-accent); color: var(--color-primary-contrast); }

.btn-ghost {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-border);
}

.btn-ghost:hover { background: var(--color-surface-alt); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.help-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--color-text-muted);
}

.help-btn:hover { color: var(--color-primary); }

.link-btn {
  font: inherit;
  background: none;
  border: none;
  padding: 0;
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
}

.link-btn:hover { color: var(--color-primary-strong); }

/* ---------- Intro & Layout ---------- */

.intro { padding-block: 1.8rem 0.6rem; max-width: 46rem; }

.intro p { color: var(--color-text-muted); }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.4rem;
  padding-block: 1rem 2.5rem;
}

@media (min-width: 60rem) {
  .layout { grid-template-columns: minmax(20rem, 26rem) 1fr; align-items: start; }
  .panel-inputs { position: sticky; top: 4.4rem; }
}

/* ---------- Cards & Form ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.1rem 1.2rem;
}

fieldset {
  border: none;
  margin: 0 0 1.1rem;
  padding: 0;
}

legend {
  font-weight: 800;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 0.55rem;
  padding: 0;
}

.field { margin-bottom: 0.85rem; }

.field label,
.stacked-label {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 0.25rem;
}

.stacked-label { margin-top: 0.7rem; }

input[type="number"] {
  width: 100%;
  font: inherit;
  font-family: var(--font-mono);
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  padding: 0.5rem 0.65rem;
}

input[type="number"]:focus-visible,
.btn:focus-visible,
.link-btn:focus-visible,
input[type="range"]:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--color-primary);
}

.range-row output {
  font-family: var(--font-mono);
  font-weight: 700;
  min-width: 3.6rem;
  text-align: right;
}

.hint {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin: 0.3rem 0 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.7rem;
}

.field-grid .field { margin-bottom: 0; }

.form-actions { display: flex; justify-content: flex-end; }

/* Segmented Control (Rentenmodus) */

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  background: var(--color-surface-alt);
  border-radius: var(--radius-small);
  padding: 0.3rem;
  margin-bottom: 0.85rem;
}

.segment { position: relative; }

.segment input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.segment span {
  display: block;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.42rem 0.4rem;
  border-radius: calc(var(--radius-small) - 2px);
  color: var(--color-text-muted);
  cursor: pointer;
}

.segment span em { font-style: normal; font-weight: 400; }

.segment input:checked + span {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.segment input:focus-visible + span {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.is-hidden { display: none; }

/* ---------- Ergebnisse ---------- */

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.2rem;
}

.stat h3 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 0.3rem;
}

.stat-accent .stat-value { color: var(--color-accent); }

.stat-sub {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin: 0;
}

.notice {
  background: var(--color-accent-soft);
  color: var(--color-text);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-small);
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  margin-bottom: 1.2rem;
}

.chart-card { margin-bottom: 1.2rem; }

.chart-card canvas {
  width: 100%;
  height: auto;
  display: block;
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  margin: 0.7rem 0 0;
  padding: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.legend li { display: inline-flex; align-items: center; gap: 0.4rem; }

.swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
  display: inline-block;
}

.swatch-rente { background: var(--color-chart-rente); }
.swatch-luecke { background: var(--color-chart-luecke); }

/* Sensitivitätstabelle */

.table-scroll { overflow-x: auto; }

.sens-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 22rem;
}

.sens-table th,
.sens-table td {
  text-align: right;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--color-border);
}

.sens-table thead th { color: var(--color-text-muted); font-weight: 700; }

.sens-table tbody th { text-align: left; font-weight: 700; }

.sens-table td { font-family: var(--font-mono); }

/* "Wie wird gerechnet?" */

.how-it-works { margin-top: 1.2rem; }

.how-it-works summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.how-it-works summary::-webkit-details-marker { display: none; }

.how-it-works summary::before {
  content: "▸";
  color: var(--color-accent);
  transition: transform 0.15s ease;
}

.how-it-works[open] summary::before { transform: rotate(90deg); }

.how-it-works summary h3 { margin: 0; }

.how-body { margin-top: 0.8rem; }

.how-body ol { margin: 0; padding-left: 1.2rem; }

.how-body li { margin-bottom: 0.7rem; font-size: 0.92rem; }

/* ---------- Ad-Slot, Disclaimer, Footer ---------- */

.ad-slot {
  margin-top: 1.4rem;
  min-height: 5.5rem;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-alt);
}

.ad-slot-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-muted);
}

.disclaimer {
  margin-top: 1.4rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding-block: 1.1rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.footer-inner p { margin: 0; }

.footer-inner nav { display: flex; gap: 1rem; }

/* ---------- Modals ---------- */

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(100% - 2rem, 30rem);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.modal::backdrop { background: rgba(10, 24, 23, 0.55); }

.modal-body { padding: 1.4rem 1.5rem; }

.modal-body h2 { margin-bottom: 0.7rem; }

.modal-actions {
  display: flex;
  gap: 0.7rem;
  justify-content: flex-end;
  margin-top: 1.2rem;
  flex-wrap: wrap;
}

/* Erste-Schritte-Hilfe */

.help-steps {
  margin: 0 0 1em;
  padding-left: 1.3rem;
}

.help-steps li {
  margin-bottom: 0.6rem;
  font-size: 0.92rem;
}

.help-subtitle {
  margin: 1rem 0 0.4rem;
  font-size: 0.95rem;
}

.help-know {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.help-know li { margin-bottom: 0.35rem; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
