/* ============================================================================
   Rufo — „Cockpit bei Nacht"
   ----------------------------------------------------------------------------
   Die Bühne ist das nächtliche Instrumentenbrett: tiefes Blauschwarz, Bernstein
   wie Panelbeleuchtung, Funksprüche in Schreibmaschinenschrift wie auf dem
   Streifen. Die App-Screens leuchten darin wie Instrumente.
   Markenanker aus der App (lib/config/theme.dart): Terracotta, Sol, Himmel,
   Sand — hier als Akzente auf dunklem Grund statt als Grundfläche.
   ========================================================================= */

@font-face {
  font-family: 'Fraunces';
  src: url('../fonts/Fraunces.ttf') format('truetype-variations');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Karla';
  src: url('../fonts/Karla.ttf') format('truetype-variations');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  /* Marke */
  --terracotta: #C8553D;
  --terra-hell: #E2725B;
  --sol: #F2B441;
  --sol-hell: #F8D389;
  --himmel: #3577A8;
  --sand: #FAF1E3;
  --oliva: #7A8450;

  /* Nachtcockpit */
  --nacht: #0B141C;
  --nacht-tief: #070D13;
  --panel: #122029;
  --panel-hoch: #182B37;
  --linie: rgba(242, 180, 65, .14);
  --linie-stark: rgba(242, 180, 65, .3);
  --text: #ECE3D4;
  --text-leise: #8FA3B0;
  --gruen: #5FD08A;

  --grund: var(--nacht);
  --spalte: 1200px;
  --radius: 18px;
  --radius-klein: 12px;
  --mono: 'SFMono-Regular', ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace;

  color-scheme: dark;
}

/* Wer ausdrücklich Helligkeit wählt, bekommt den Tag-Anstrich der App. */
:root[data-thema="hell"] {
  --nacht: #FAF1E3;
  --nacht-tief: #F2E3CC;
  --panel: #FFFDF8;
  --panel-hoch: #FFFFFF;
  --linie: rgba(43, 38, 32, .12);
  --linie-stark: rgba(200, 85, 61, .35);
  --text: #2B2620;
  --text-leise: #6B6154;
  --grund: var(--nacht);
  color-scheme: light;
}

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

body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font-family: 'Karla', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Feines Rauschen über allem — nimmt dem Dunkel das Digitale. */
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 999; pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3, h4 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -.02em;
  margin: 0 0 .5em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.7rem, 6.5vw, 5.2rem); font-weight: 900; }
h2 { font-size: clamp(1.9rem, 3.6vw, 3rem); }
h3 { font-size: clamp(1.2rem, 1.9vw, 1.5rem); }
p { margin: 0 0 1.1em; max-width: 66ch; }

a { color: var(--sol); text-decoration-color: rgba(242, 180, 65, .35); text-underline-offset: 4px; }
a:hover { text-decoration-color: currentColor; }

img { max-width: 100%; height: auto; display: block; }

.spalte { width: min(var(--spalte), 100% - 2.5rem); margin-inline: auto; }
.schmal { width: min(740px, 100% - 2.5rem); margin-inline: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--sol); outline-offset: 3px; border-radius: 4px; }

/* ---------- Kopfzeile ---------------------------------------------------- */
.kopf {
  position: sticky; top: 0; z-index: 80;
  background: color-mix(in srgb, var(--nacht) 88%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--linie);
}
.kopf-innen { display: flex; align-items: center; gap: 1.6rem; padding: .65rem 0; }
.marke {
  display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text);
  font-family: 'Fraunces', serif; font-weight: 900; font-size: 1.25rem; letter-spacing: -.02em;
}
.marke img { width: 36px; height: 36px; border-radius: 10px; }
.menue { display: flex; gap: 1.6rem; margin-left: auto; align-items: center; }
.menue a { color: var(--text-leise); text-decoration: none; font-weight: 600; font-size: .94rem; }
.menue a:hover, .menue a[aria-current="page"] { color: var(--text); }
.menue-schalter { display: none; }

@media (max-width: 880px) {
  .menue {
    position: fixed; inset: 57px 0 auto 0; flex-direction: column; gap: 0; align-items: stretch;
    background: var(--panel); border-bottom: 1px solid var(--linie); padding: .25rem 1.25rem 1.25rem;
  }
  .menue[hidden] { display: none; }
  .menue a { padding: .9rem 0; border-bottom: 1px solid var(--linie); font-size: 1.05rem; }
  .menue .knopf { margin-top: .9rem; justify-content: center; }
  .menue-schalter {
    display: inline-flex; margin-left: auto; width: 42px; height: 42px; align-items: center;
    justify-content: center; border-radius: 10px; border: 1px solid var(--linie);
    background: transparent; color: var(--text); cursor: pointer;
  }
}

/* ---------- Knöpfe ------------------------------------------------------- */
.knopf {
  display: inline-flex; align-items: center; gap: .5rem; border: 0; cursor: pointer;
  padding: .85rem 1.5rem; border-radius: 999px; font-family: inherit;
  background: var(--terracotta); color: #fff; font-weight: 700; font-size: 1rem;
  text-decoration: none; letter-spacing: .01em;
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 10px 30px rgba(200,85,61,.35);
  transition: transform .18s cubic-bezier(.34,1.4,.64,1), box-shadow .18s, background .18s;
}
.knopf:hover { transform: translateY(-2px); background: var(--terra-hell); box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 16px 40px rgba(226,114,91,.4); }
.knopf:active { transform: translateY(0); }
.knopf.gold { background: var(--sol); color: #2B2010; box-shadow: 0 1px 0 rgba(255,255,255,.35) inset, 0 10px 30px rgba(242,180,65,.3); }
.knopf.gold:hover { background: var(--sol-hell); }
.knopf.leer {
  background: transparent; color: var(--text); border: 1px solid var(--linie-stark); box-shadow: none;
}
.knopf.leer:hover { background: var(--panel-hoch); border-color: var(--sol); box-shadow: none; }

/* ---------- Aufmacher ---------------------------------------------------- */
.aufmacher { position: relative; padding: clamp(3rem, 7vw, 6rem) 0 clamp(2.5rem, 5vw, 4rem); overflow: hidden; }
.aufmacher::before {
  /* Horizont: die Erdkrümmung von oben, wie aus Reiseflughöhe bei Nacht. */
  content: ''; position: absolute; left: 50%; top: -62vw; width: 150vw; height: 130vw;
  transform: translateX(-50%); border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(53,119,168,.30), rgba(53,119,168,.10) 55%, transparent 72%);
}
.aufmacher::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(700px 300px at 12% 8%, rgba(242,180,65,.12), transparent 70%),
    radial-gradient(500px 260px at 88% 22%, rgba(200,85,61,.14), transparent 70%);
}
.aufmacher > * { position: relative; z-index: 1; }

.aufmacher-raster {
  display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(2rem, 5vw, 4.5rem); align-items: center;
}
@media (max-width: 940px) { .aufmacher-raster { grid-template-columns: 1fr; } }

.kicker {
  display: inline-flex; align-items: center; gap: .55rem; margin-bottom: 1.5rem;
  font-family: var(--mono); font-size: .76rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--sol); border: 1px solid var(--linie-stark); border-radius: 999px; padding: .4rem .9rem;
  background: rgba(242,180,65,.07);
}
.kicker .punkt {
  width: 7px; height: 7px; border-radius: 50%; background: var(--gruen);
  box-shadow: 0 0 0 0 rgba(95,208,138,.6); animation: puls 2.4s infinite;
}
@keyframes puls {
  0% { box-shadow: 0 0 0 0 rgba(95,208,138,.55); }
  70% { box-shadow: 0 0 0 9px rgba(95,208,138,0); }
  100% { box-shadow: 0 0 0 0 rgba(95,208,138,0); }
}

h1 .zeile { display: block; }
h1 .hervor {
  background: linear-gradient(180deg, var(--sol-hell), var(--sol));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.vorspann { font-size: clamp(1.05rem, 1.5vw, 1.22rem); color: var(--text-leise); max-width: 52ch; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 2.1rem; align-items: center; }
.kleingedruckt { font-size: .88rem; color: var(--text-leise); margin-top: 1.4rem; }

/* Auftakt: gestaffeltes Einblenden beim Laden. */
.js .stufe { opacity: 0; transform: translateY(22px); animation: rein .9s cubic-bezier(.22,1,.36,1) forwards; }
.js .stufe:nth-child(1) { animation-delay: .05s; }
.js .stufe:nth-child(2) { animation-delay: .14s; }
.js .stufe:nth-child(3) { animation-delay: .23s; }
.js .stufe:nth-child(4) { animation-delay: .32s; }
.js .stufe:nth-child(5) { animation-delay: .41s; }
@keyframes rein { to { opacity: 1; transform: none; } }

/* ---------- Funkgerät (Kernstück des Aufmachers) ------------------------- */
.funkgeraet {
  background: linear-gradient(168deg, var(--panel-hoch), var(--panel));
  border: 1px solid var(--linie); border-radius: var(--radius);
  box-shadow: 0 2px 0 rgba(255,255,255,.05) inset, 0 30px 70px rgba(0,0,0,.55);
  overflow: hidden;
}
:root[data-thema="hell"] .funkgeraet { box-shadow: 0 2px 0 rgba(255,255,255,.7) inset, 0 24px 48px rgba(43,38,32,.14); }

.funk-kopf {
  display: flex; align-items: center; gap: .8rem; padding: .8rem 1.1rem;
  border-bottom: 1px solid var(--linie); background: rgba(0,0,0,.22);
}
:root[data-thema="hell"] .funk-kopf { background: rgba(43,38,32,.04); }
.funk-kopf .frequenz {
  font-family: var(--mono); font-size: 1.15rem; color: var(--sol); letter-spacing: .04em;
  text-shadow: 0 0 14px rgba(242,180,65,.45);
}
.funk-kopf .beschriftung { font-family: var(--mono); font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: var(--text-leise); }
.funk-kopf select {
  margin-left: auto; background: transparent; color: var(--text); border: 1px solid var(--linie);
  border-radius: 8px; padding: .35rem .6rem; font-family: inherit; font-size: .85rem; cursor: pointer;
  max-width: 48%;
}
.funk-kopf select:focus-visible { border-color: var(--sol); }

.funk-band { height: 2px; background: var(--linie); position: relative; overflow: hidden; }
.funk-band i { position: absolute; inset: 0 100% 0 0; background: var(--sol); transition: right .25s linear; }

.funk-streifen { padding: .6rem 0 .3rem; max-height: 330px; overflow-y: auto; scrollbar-width: thin; }
.funk-zeile {
  display: grid; grid-template-columns: 72px 1fr; gap: .9rem; padding: .6rem 1.1rem;
  opacity: .38; transition: opacity .3s, background .3s; border-left: 2px solid transparent;
}
.funk-zeile.aktiv { opacity: 1; background: rgba(242,180,65,.07); border-left-color: var(--sol); }
.funk-zeile .wer {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--himmel); padding-top: .25rem;
}
.funk-zeile.du .wer { color: var(--terra-hell); }
.funk-zeile .av { font-family: var(--mono); font-size: .93rem; line-height: 1.5; margin: 0; color: var(--text); }
.funk-zeile .de { font-size: .85rem; color: var(--text-leise); margin: .2rem 0 0; }

.funk-fuss { display: flex; align-items: center; gap: .9rem; padding: .85rem 1.1rem; border-top: 1px solid var(--linie); }
.funk-fuss .knopf { padding: .6rem 1.15rem; font-size: .92rem; }
.funk-fuss .funk-quelle {
  font-size: .8rem; color: var(--text-leise); margin: 0 0 0 auto; text-align: right;
  border: 0; background: none; padding: 0;
}

/* ---------- Abschnitte --------------------------------------------------- */
.abschnitt { padding: clamp(3.5rem, 7vw, 6.5rem) 0; position: relative; }
.abschnitt.panelgrund { background: var(--nacht-tief); border-block: 1px solid var(--linie); }
.abschnitt-kopf { max-width: 62ch; margin-bottom: clamp(2rem, 4vw, 3.4rem); }
.abschnitt-kopf p { color: var(--text-leise); font-size: 1.1rem; }
.marke-zeile {
  font-family: var(--mono); font-size: .74rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--sol); margin-bottom: .9rem; display: flex; align-items: center; gap: .7rem;
}
.marke-zeile::after { content: ''; flex: 1; height: 1px; background: var(--linie); }

.raster { display: grid; gap: 1.3rem; }
.raster.zwei { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.raster.drei { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }

.karte {
  position: relative; background: var(--panel); border: 1px solid var(--linie);
  border-radius: var(--radius); padding: 1.7rem; overflow: hidden;
  transition: transform .25s cubic-bezier(.22,1,.36,1), border-color .25s, box-shadow .25s;
}
.karte::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--linie-stark), transparent);
}
.karte:hover { transform: translateY(-5px); border-color: var(--linie-stark); box-shadow: 0 24px 50px rgba(0,0,0,.4); }
.karte h3 { margin-bottom: .4rem; }
.karte p { color: var(--text-leise); font-size: .97rem; margin-bottom: 0; }
.karte .weiter {
  display: inline-flex; align-items: center; gap: .35rem; margin-top: 1.1rem;
  font-weight: 700; font-size: .92rem; text-decoration: none;
}
.karte .weiter::after { content: '→'; transition: transform .2s; }
.karte:hover .weiter::after { transform: translateX(4px); }
.karte .nummer {
  position: absolute; right: 1.1rem; top: .9rem; font-family: var(--mono); font-size: .72rem;
  color: var(--text-leise); opacity: .5; letter-spacing: .1em;
}

.symbol {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; margin-bottom: 1.1rem;
  background: rgba(53,119,168,.16); color: #7FB6DE; border: 1px solid rgba(53,119,168,.28);
}
.symbol.warm { background: rgba(200,85,61,.16); color: var(--terra-hell); border-color: rgba(200,85,61,.3); }
.symbol.gold { background: rgba(242,180,65,.14); color: var(--sol); border-color: rgba(242,180,65,.3); }
.symbol.gruen { background: rgba(122,132,80,.18); color: #A9B87A; border-color: rgba(122,132,80,.34); }
.symbol svg { width: 23px; height: 23px; }

/* ---------- Zahlenband --------------------------------------------------- */
.zahlen { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 1px; background: var(--linie); border: 1px solid var(--linie); border-radius: var(--radius); overflow: hidden; }
.zahl { background: var(--panel); padding: 1.6rem 1.2rem; text-align: center; }
.zahl b {
  display: block; font-family: 'Fraunces', serif; font-weight: 900; line-height: 1;
  font-size: clamp(2.1rem, 3.6vw, 2.9rem); color: var(--sol); letter-spacing: -.03em;
  text-shadow: 0 0 26px rgba(242,180,65,.25);
}
.zahl span { display: block; margin-top: .6rem; font-size: .89rem; color: var(--text-leise); }

/* ---------- Geräterahmen ------------------------------------------------- */
.geraet {
  position: relative; width: 100%; max-width: 300px; margin-inline: auto;
  border-radius: 40px; padding: 10px;
  background: linear-gradient(155deg, #4a4a4d, #1b1b1e 42%, #313134);
  box-shadow: 0 30px 60px rgba(0,0,0,.55), inset 0 0 0 1.5px rgba(255,255,255,.12);
}
.geraet::after {
  content: ''; position: absolute; top: 19px; left: 50%; transform: translateX(-50%);
  width: 80px; height: 21px; background: #0b0b0c; border-radius: 999px; z-index: 2;
}
.geraet img { border-radius: 31px; aspect-ratio: 9/19.5; object-fit: cover; object-position: top; background: #0b0b0c; }
.geraet.klein { max-width: 214px; border-radius: 30px; padding: 8px; }
.geraet.klein::after { width: 58px; height: 15px; top: 14px; }
.geraet.klein img { border-radius: 23px; }

.faecher { display: flex; justify-content: center; align-items: flex-end; }
.faecher .geraet:nth-child(1) { transform: rotate(-8deg) translateX(16%) scale(.88); z-index: 1; }
.faecher .geraet:nth-child(2) { z-index: 3; }
.faecher .geraet:nth-child(3) { transform: rotate(8deg) translateX(-16%) scale(.88); z-index: 1; }

/* ---------- Wechselblöcke ------------------------------------------------ */
.zug { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 5vw, 5rem); align-items: center; margin-bottom: clamp(3rem, 6vw, 5.5rem); }
.zug:last-child { margin-bottom: 0; }
.zug:nth-child(even) .zug-bild { order: -1; }
@media (max-width: 900px) { .zug { grid-template-columns: 1fr; } .zug:nth-child(even) .zug-bild { order: 0; } }
.zug ul { list-style: none; margin: 1.3rem 0 0; padding: 0; }
.zug li { position: relative; padding-left: 1.9rem; margin-bottom: .75rem; color: var(--text-leise); }
.zug li::before {
  content: ''; position: absolute; left: 0; top: .52em; width: .95rem; height: .95rem;
  border-radius: 3px; border: 1.5px solid var(--oliva); background: rgba(122,132,80,.2);
}
.zug li::after {
  content: ''; position: absolute; left: .28rem; top: .72em; width: .34rem; height: .17rem;
  border-left: 1.6px solid #A9B87A; border-bottom: 1.6px solid #A9B87A; transform: rotate(-45deg);
}

/* ---------- Werkzeuge (Fristenrechner, Filter) --------------------------- */
.werkzeug {
  background: var(--panel); border: 1px solid var(--linie); border-radius: var(--radius);
  padding: clamp(1.4rem, 3vw, 2.2rem);
}
.feld { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.feld label { display: block; font-size: .82rem; color: var(--text-leise); margin-bottom: .35rem; }
.feld input[type="date"], .feld select {
  background: var(--nacht); color: var(--text); border: 1px solid var(--linie-stark);
  border-radius: 10px; padding: .7rem .9rem; font-family: inherit; font-size: 1rem;
}
.feld input[type="date"]:focus-visible, .feld select:focus-visible { border-color: var(--sol); }
.ergebnis {
  margin-top: 1.4rem; padding: 1.1rem 1.3rem; border-radius: var(--radius-klein);
  border-left: 3px solid var(--sol); background: rgba(242,180,65,.08);
}
.ergebnis strong { color: var(--sol); }
.ergebnis.warn { border-left-color: var(--terra-hell); background: rgba(226,114,91,.1); }
.ergebnis.warn strong { color: var(--terra-hell); }
.ergebnis p { margin: 0; }
.ergebnis p + p { margin-top: .5rem; }

/* Schieberegler für den Funkfilter */
.regler { display: flex; align-items: center; gap: 1rem; margin-top: 1.2rem; }
.regler input[type="range"] { flex: 1; accent-color: var(--sol); }
.regler .wert { font-family: var(--mono); font-size: .85rem; color: var(--sol); min-width: 5ch; text-align: right; }

/* ---------- Hinweiskasten ------------------------------------------------ */
.hinweis {
  border-left: 3px solid var(--sol); background: rgba(242,180,65,.07);
  padding: 1.1rem 1.3rem; border-radius: 0 var(--radius-klein) var(--radius-klein) 0; margin: 1.6rem 0;
}
.hinweis p:last-child { margin-bottom: 0; }

/* ---------- Tabellen ----------------------------------------------------- */
.tabelle { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: .97rem; }
.tabelle th { text-align: left; font-family: var(--mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-leise); padding: .7rem .6rem; border-bottom: 1px solid var(--linie-stark); }
.tabelle td { padding: .8rem .6rem; border-bottom: 1px solid var(--linie); }
.tabelle tr:last-child td { border-bottom: 0; }

/* ---------- Beim Scrollen auftauchen ------------------------------------- */
.js .auftauchen { opacity: 0; transform: translateY(20px); transition: opacity .7s ease, transform .7s cubic-bezier(.22,1,.36,1); }
.js .auftauchen.da { opacity: 1; transform: none; }

/* ---------- Fußzeile ----------------------------------------------------- */
.fuss { background: var(--nacht-tief); border-top: 1px solid var(--linie); padding: clamp(3rem,5vw,4rem) 0 2rem; margin-top: clamp(3rem,6vw,5rem); }
.fuss-raster { display: grid; grid-template-columns: 1.7fr repeat(3, 1fr); gap: 2rem; }
@media (max-width: 820px) { .fuss-raster { grid-template-columns: 1fr 1fr; } }
.fuss h4 { font-family: var(--mono); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--text-leise); margin-bottom: 1rem; font-weight: 600; }
.fuss ul { list-style: none; margin: 0; padding: 0; }
.fuss li { margin-bottom: .6rem; font-size: .94rem; }
.fuss a { color: var(--text-leise); text-decoration: none; }
.fuss a:hover { color: var(--sol); }
.fuss-unten { border-top: 1px solid var(--linie); margin-top: 2.4rem; padding-top: 1.4rem; display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; font-size: .86rem; color: var(--text-leise); }
.fuss-unten .rechts { margin-left: auto; }
