
/* Adler S-Bahn – Farben: Blau, Weiß, Rot. Dunkelmodus per Systemeinstellung oder manuell. */

:root {
  --blue: #0a3b86;
  --blue-2: #1456c4;
  --red: #d4001a;

  --bg: #eef2f9;
  --card: #ffffff;
  --card-2: #f4f7fc;
  --text: #0e1a2b;
  --muted: #5a6b82;
  --line: #dde5f1;
  --shadow: 0 1px 2px rgba(10, 30, 70, .06), 0 8px 24px rgba(10, 30, 70, .08);

  --ok: #0f8a5f;
  --ok-bg: #e3f6ee;
  --leicht: #9a6700;
  --leicht-bg: #fdf3d6;
  --spaet: #c2410c;
  --spaet-bg: #ffe9dd;
  --aus: #d4001a;
  --aus-bg: #fde4e7;

  --radius: 20px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #080f1d;
    --card: #111b2e;
    --card-2: #17233a;
    --text: #eaf0fa;
    --muted: #93a3bd;
    --line: #223250;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --ok: #4ade9c;
    --ok-bg: #0f2f25;
    --leicht: #f5c542;
    --leicht-bg: #33290c;
    --spaet: #ff9a5c;
    --spaet-bg: #3a1e10;
    --aus: #ff6b7d;
    --aus-bg: #3b1219;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #080f1d;
  --card: #111b2e;
  --card-2: #17233a;
  --text: #eaf0fa;
  --muted: #93a3bd;
  --line: #223250;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --ok: #4ade9c;
  --ok-bg: #0f2f25;
  --leicht: #f5c542;
  --leicht-bg: #33290c;
  --spaet: #ff9a5c;
  --spaet-bg: #3a1e10;
  --aus: #ff6b7d;
  --aus-bg: #3b1219;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3, p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Kopfbereich */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-2) 100%);
  color: #fff;
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 4px 18px rgba(10, 40, 100, .25);
}
.top__inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand__logo { width: 40px; height: 40px; object-fit: contain; flex: none; }
.brand h1 { font-size: 1.15rem; font-weight: 750; letter-spacing: .2px; }
.brand p { font-size: .8rem; opacity: .85; }

.theme-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit; font-size: .85rem; font-weight: 600;
  cursor: pointer;
}
.theme-btn:active { transform: scale(.97); }

.refresh { height: 3px; background: rgba(255, 255, 255, .18); }
.refresh span {
  display: block; height: 100%; width: 0;
  background: var(--red);
}
@keyframes fill { from { width: 0; } to { width: 100%; } }

/* Layout */
.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  border: 1px solid var(--line);
}

.banner {
  border-radius: 14px;
  padding: 10px 14px;
  font-size: .9rem;
  font-weight: 600;
  background: var(--leicht-bg);
  color: var(--leicht);
  border: 1px solid color-mix(in srgb, var(--leicht) 30%, transparent);
}
.banner--err { background: var(--aus-bg); color: var(--aus); border-color: color-mix(in srgb, var(--aus) 30%, transparent); }

/* Spielkarte */
.spiel { position: relative; overflow: hidden; }
.spiel::before {
  content: "";
  position: absolute; inset: 0 auto 0 0; width: 5px;
  background: linear-gradient(var(--blue-2), var(--red));
}
.spiel__chips { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.tag-chip {
  background: var(--red); color: #fff;
  font-size: .72rem; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
}
.art-chip {
  background: var(--card-2); color: var(--muted);
  font-size: .72rem; font-weight: 700; letter-spacing: .4px;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line);
}
.spiel__datum { color: var(--muted); font-size: .9rem; }
.spiel__zeit {
  font-size: 2.6rem; font-weight: 800; line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: -.5px;
  margin: 2px 0 8px;
}
.spiel__zeit small { font-size: 1rem; font-weight: 600; color: var(--muted); margin-left: 4px; }
.teams { display: grid; gap: 2px; font-size: 1.1rem; }
.teams .heim { font-weight: 750; }
.teams .vs { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .8px; }
.countdown { margin-top: 10px; color: var(--blue-2); font-weight: 650; font-size: .9rem; }
:root[data-theme="dark"] .countdown { color: #7fb0ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .countdown { color: #7fb0ff; } }

/* Richtungskarten */
.fold-btn__text { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; flex: 1; min-width: 0; gap: 2px 10px; }
.route h2 { font-size: 1.25rem; font-weight: 800; }
.route__regel { color: var(--muted); font-size: .8rem; font-weight: 400; }
.route__weg {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 6px 0 14px; font-size: .9rem; color: var(--muted); font-weight: 600;
}
.route__weg .pfeil { color: var(--red); font-weight: 800; }

.label {
  font-size: .72rem; font-weight: 800; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted); margin: 14px 0 8px;
}
.label:first-of-type { margin-top: 0; }

.gruppe {
  --akzent: var(--ok);
  position: relative;
  border-radius: 16px;
  padding: 14px 14px 12px 18px;
  background: var(--card-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.gruppe::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--akzent);
}
.gruppe--puenktlich { --akzent: var(--ok); }
.gruppe--leicht { --akzent: var(--leicht); }
.gruppe--verspaetet { --akzent: var(--spaet); }
.gruppe--ausfall { --akzent: var(--aus); }

.gruppe--haupt .zeit { font-size: 2.2rem; }
.gruppe--folge { padding-top: 10px; padding-bottom: 8px; }
.gruppe--folge .zeit { font-size: 1.5rem; }

.zeit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.3px;
}

.zeit .alt { color: var(--muted); text-decoration: line-through; font-weight: 600; font-size: .6em; }
.zeit .neu { color: var(--akzent); }
.gruppe--ausfall .zeit .plan { text-decoration: line-through; color: var(--muted); }

.wagenliste {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
  min-width: 0;
}

.wagen {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-size: .75rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: 0;
  white-space: nowrap;
}

.wagen--fehler {
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--line);
}

.zuege { display: grid; gap: 8px; margin-top: 8px; }
.zug { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.linie {
  background: #00875a; color: #fff;
  font-weight: 800; font-size: .85rem;
  min-width: 36px; text-align: center;
  padding: 3px 8px; border-radius: 8px;
}
.chip {
  font-size: .8rem; font-weight: 750;
  padding: 3px 10px; border-radius: 999px;
}
.chip--puenktlich { background: var(--ok-bg); color: var(--ok); }
.chip--leicht { background: var(--leicht-bg); color: var(--leicht); }
.chip--verspaetet { background: var(--spaet-bg); color: var(--spaet); }
.chip--ausfall { background: var(--aus-bg); color: var(--aus); }
.info { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.info b { color: var(--text); font-weight: 650; }

.leer { color: var(--muted); font-size: .95rem; padding: 6px 0; }

/* Benachrichtigungen */
.push h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 4px; }
.switch {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-top: 1px solid var(--line); margin-top: 10px; cursor: pointer;
}
.switch__text { font-weight: 650; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__ui {
  position: relative; width: 50px; height: 30px; border-radius: 999px;
  background: var(--line); transition: background .2s; flex: none;
}
.switch__ui::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s;
}
.switch input:checked + .switch__ui { background: var(--blue-2); }
.switch input:checked + .switch__ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__ui { outline: 3px solid color-mix(in srgb, var(--blue-2) 50%, transparent); outline-offset: 2px; }
.push .small { margin-top: 8px; }
.push.is-collapsed h2 { margin-bottom: 0; }

/* Fußzeile */
.foot {
  max-width: 640px; margin: 0 auto; padding: 4px 16px 28px;
  text-align: center; color: var(--muted); font-size: .8rem; display: grid; gap: 4px;
}
.foot a { color: inherit; }

/* Ladezustand */
.skeleton {
  height: 120px; border-radius: 14px;
  background: linear-gradient(90deg, var(--card-2) 25%, var(--line) 50%, var(--card-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite linear;
}
.skeleton--lg { height: 150px; }

@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .switch__ui, .switch__ui::after { transition: none; }
}

@media (min-width: 480px) {
  .spiel__zeit { font-size: 3rem; }
  .gruppe--haupt .zeit { font-size: 2.5rem; }
}

/* ---------- Einklappbare Karten ---------- */

.card__head { margin: 0; }

.fold-btn {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 10px;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.fold-btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue-2) 50%, transparent);
  outline-offset: 4px;
}

.chev {
  flex: none;
  width: 9px;
  height: 9px;
  margin-right: 4px;
  border-right: 2.5px solid var(--muted);
  border-bottom: 2.5px solid var(--muted);
  transform: translateY(-2px) rotate(45deg);
  transition: transform .25s ease;
}
.fold-btn:hover .chev { border-color: var(--text); }
.fold-btn[aria-expanded="true"] .chev { transform: translateY(2px) rotate(225deg); }

/* Inhalt blendet per Zeilenhöhe 1fr -> 0fr weich ein/aus */
.fold {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows .28s ease;
}
.is-collapsed > .fold {
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows .28s ease, visibility 0s linear .28s;
}
.fold__inner {
  min-height: 0;
  overflow: hidden;
  margin: 0 -6px;
  padding: 0 6px;
}

/* Spielkachel: Logo rechts, Kurzfassung im eingeklappten Zustand */
.spiel__kopf { margin: 0; }
.spiel__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
}
.spiel__logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
  border-radius: 20px;
  box-shadow: 0 2px 10px rgba(10, 40, 100, .18);
}
.spiel__kurz {
  display: none;
  margin-top: 8px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.spiel.is-collapsed .spiel__kurz { display: block; }

@media (max-width: 380px) {
  .spiel__logo { width: 64px; height: 64px; border-radius: 16px; }
}

/* Push: Hauptschalter und untergeordnete Schalter */
.switch--main .switch__text { font-weight: 750; }
.switch--sub { margin-top: 0; padding-left: 14px; }
.switch.is-disabled { cursor: not-allowed; }
.switch.is-disabled .switch__text { color: var(--muted); }
.switch input:disabled + .switch__ui { opacity: .45; }

@media (prefers-reduced-motion: reduce) {
  .fold, .is-collapsed > .fold, .chev { transition: none; }
}
