/* ==========================================================================
   Tankvergleich — Vorplatz-Optik: kühler Beton, Petrolblau, Preistafel-Amber.
   Themes: folgt dem System, lässt sich per data-theme überschreiben.
   ========================================================================== */

:root {
  --font-display: 'IBM Plex Sans Condensed', 'Roboto Condensed', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 4px;
  --radius-lg: 8px;
  --gap: 1.5rem;
  --maxw: 1180px;

  /* Hell */
  --bg: #e7ebec;
  --panel: #ffffff;
  --panel-2: #f2f5f5;
  --ink: #0b1f24;
  --muted: #5d7378;
  --line: #d2dadb;
  --teal: #0f6e68;
  --teal-soft: #dfeeec;
  --amber: #b57706;
  --rust: #a8412a;
  --slab: #0b1f24;
  --slab-ink: #f7c948;
  --slab-muted: #7fa0a6;
  --shadow: 0 1px 2px rgba(11, 31, 36, .06), 0 8px 24px -16px rgba(11, 31, 36, .35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) { color-scheme: dark; }
  :root:not([data-theme='light']) {
    --bg: #081619;
    --panel: #0f252a;
    --panel-2: #143036;
    --ink: #e7efef;
    --muted: #8fa6ab;
    --line: #1e3d44;
    --teal: #3aada2;
    --teal-soft: #10373a;
    --amber: #f7c948;
    --rust: #e0714f;
    --slab: #041014;
    --slab-ink: #f7c948;
    --slab-muted: #6f8f96;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -16px rgba(0, 0, 0, .8);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #081619;
  --panel: #0f252a;
  --panel-2: #143036;
  --ink: #e7efef;
  --muted: #8fa6ab;
  --line: #1e3d44;
  --teal: #3aada2;
  --teal-soft: #10373a;
  --amber: #f7c948;
  --rust: #e0714f;
  --slab: #041014;
  --slab-ink: #f7c948;
  --slab-muted: #6f8f96;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -16px rgba(0, 0, 0, .8);
}

/* --------------------------------------------------------------- Basis -- */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; margin: 0; line-height: 1.05; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

button, input, select { font: inherit; color: inherit; }

/* Muss nach den Layout-Regeln greifen, sonst schlägt display:grid das hidden-Attribut. */
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 2px;
}

.shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3.5rem) clamp(1rem, 4vw, 2.5rem) 3rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.panel__title {
  font-size: .8rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

/* ----------------------------------------------------------- Masthead -- */

.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gap);
  padding-bottom: 2rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--ink);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: .75rem;
}

.masthead h1 {
  font-size: clamp(2rem, 5.5vw, 3.4rem);
  letter-spacing: -.015em;
}

.lede {
  max-width: 46ch;
  margin-top: 1rem;
  color: var(--muted);
}

.theme-toggle {
  flex: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: .4rem .9rem;
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover { border-color: var(--teal); color: var(--teal); }

/* ------------------------------------------------------------- Layout -- */

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: var(--gap);
  align-items: start;
}

/* ----------------------------------------------------------- Eingaben -- */

.controls {
  padding: 1.5rem;
  display: grid;
  gap: 1.5rem;
  position: sticky;
  top: 1.5rem;
}

.field { display: grid; gap: .55rem; border: 0; padding: 0; margin: 0; min-width: 0; }

.field__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  font-size: .95rem;
  font-weight: 500;
  padding: 0;
}

.field__value {
  font-family: var(--font-mono);
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
  color: var(--teal);
}

.field__hint, .field__scale { font-size: .75rem; color: var(--muted); font-weight: 400; }

.field__scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  margin-top: -.25rem;
}

.field__note { font-size: .78rem; color: var(--rust); }

/* Regler */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: transparent;
  cursor: pointer;
  margin: .4rem 0;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}
input[type='range']::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--teal);
  border: 3px solid var(--panel);
  box-shadow: 0 0 0 1px var(--teal);
}
input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--teal);
  border: 3px solid var(--panel);
  box-shadow: 0 0 0 1px var(--teal);
}

/* Umschalter Kraftstoff */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }

.segmented span {
  display: block;
  padding: .5rem;
  text-align: center;
  border-radius: 2px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--muted);
  transition: background .12s ease, color .12s ease;
}

.segmented input:checked + span { background: var(--teal); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Auswahl + Zahleneingabe */
select, input[type='number'] {
  width: 100%;
  padding: .55rem .7rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: .95rem;
}

/* Schalter Betriebskosten */
.field--switch { gap: .8rem; }

.switch { display: flex; align-items: center; gap: .7rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch__track {
  flex: none;
  width: 40px;
  height: 22px;
  border-radius: 100px;
  background: var(--line);
  position: relative;
  transition: background .15s ease;
}

.switch__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--panel);
  transition: transform .15s ease;
}

.switch input:checked + .switch__track { background: var(--teal); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--teal); outline-offset: 2px; }
.switch__label { font-size: .95rem; font-weight: 500; }

.subfield {
  display: grid;
  gap: .4rem;
  padding-left: 3.1rem;
  font-size: .8rem;
  color: var(--muted);
}

.subfield__input { display: flex; align-items: center; gap: .5rem; }
.subfield__input input { width: 5.5rem; }
.subfield__input span { font-family: var(--font-mono); }

.controls__footer {
  display: grid;
  gap: .6rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.button {
  padding: .6rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border: 0;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
}

.button:hover { background: var(--teal); color: #fff; }
.button[disabled] { opacity: .5; cursor: progress; }

.stamp { font-family: var(--font-mono); font-size: .72rem; color: var(--muted); }

/* ---------------------------------------------------------- Ergebnis --- */

.results { display: grid; gap: var(--gap); min-width: 0; }

.warnings {
  display: grid;
  gap: .35rem;
  padding: .85rem 1rem;
  border-left: 3px solid var(--rust);
  background: var(--panel);
  border-radius: var(--radius);
  font-size: .82rem;
  color: var(--muted);
}

/* Kopfzahl: der eigentliche Punkt der Seite */
.headline {
  padding: 1.5rem;
  display: grid;
  gap: .3rem;
  border-left: 3px solid var(--teal);
}

.headline__label {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.headline__value {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 3rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--teal);
}

.headline__detail { color: var(--muted); font-size: .9rem; max-width: 60ch; }

/* Karten */
.cards { display: grid; gap: 1rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem 1.1rem;
  display: grid;
  gap: 1rem;
}

.card--best { border-top-color: var(--amber); }
.card--unavailable { opacity: .55; }

.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.card__name { font-family: var(--font-display); font-size: 1.35rem; }
.card__sub { font-size: .78rem; color: var(--muted); margin-top: .15rem; }

.badge {
  flex: none;
  font-family: var(--font-mono);
  font-size: .65rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .25rem .5rem;
  border-radius: 2px;
  background: var(--amber);
  color: #0b1f24;
  font-weight: 600;
}

.badge--muted { background: var(--panel-2); color: var(--muted); }

/* Signatur: Preistafel — in beiden Themes dunkel, wie am Straßenrand */
.slab {
  background: var(--slab);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.slab__total {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--slab-ink);
  letter-spacing: -.02em;
}

.slab__side { text-align: right; font-family: var(--font-mono); font-size: .78rem; color: var(--slab-muted); }
.slab__side strong { display: block; font-size: 1rem; font-weight: 500; color: #e7efef; }

.bar { height: 4px; background: var(--panel-2); border-radius: 2px; overflow: hidden; }
.bar__fill { height: 100%; background: var(--teal); transition: width .25s ease; }
.card--best .bar__fill { background: var(--amber); }

.rows { display: grid; gap: .35rem; font-size: .87rem; }

.row { display: flex; justify-content: space-between; gap: 1rem; }
.row dt { color: var(--muted); }
.row dd {
  margin: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.row--total dd { font-weight: 600; }
.row--gain dd { color: var(--teal); }
.row--loss dd { color: var(--rust); }

/* ------------------------------------------------------------ Fußwerk -- */

.assumptions { font-size: .85rem; color: var(--muted); }
.assumptions summary { cursor: pointer; font-weight: 500; color: var(--ink); }
.assumptions ul { margin-top: .75rem; display: grid; gap: .4rem; }
.assumptions li { padding-left: 1rem; position: relative; }
.assumptions li::before { content: '—'; position: absolute; left: 0; color: var(--teal); }

.colophon {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: .75rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* ----------------------------------------------------------- Responsiv -- */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .controls { position: static; }
  .masthead { flex-direction: column-reverse; align-items: flex-start; }
  .theme-toggle { align-self: flex-end; }
}

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