/* ICE Maxxing. Layout: schmale Kopfzeile mit Logo, darunter Filter-Panel und Verbindungen. */
:root {
  --paper: #f3f5f4;
  --panel: #ffffff;
  --ink: #16202a;
  --muted: #5b6874;
  --line: #d9dfe3;
  --accent: #2b5d8a;
  --go: #1b7a4a;
  --wait: #a86400;
  --wait-soft: #f8e7cc;
  --stop: #b3261e;
  --font:
    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --r: 8px;
  --shade: rgb(0 0 0 / 0.14);
  /* Zugstreifen wie auf bahn.de, Garantie-Status als Segment mit paralleler Schräge */
  --p-fern: #282d37;
  --p-re: #878c96;
  --p-s: #408335;
  --seg-go: #185fa5;
  --seg-warn: #a86400;
  --slant: 10px;
  --board: #13202c;
  --board-ink: #eef3f6;
  --board-muted: #b4bec7;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f161c;
    --panel: #17212a;
    --ink: #e6ecf0;
    --muted: #94a3ae;
    --line: #2a3742;
    --accent: #7fb0dc;
    --go: #4cc485;
    --wait: #e5a54a;
    --wait-soft: #3a2a12;
    --stop: #f07167;
    --shade: rgb(0 0 0 / 0.5);
    --p-fern: #4a5260;
    /* Tafel heller als die Karten, damit sie sich vom dunklen Hintergrund abhebt */
    --board: #24333f;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px 40px;
}

.top-in,
main {
  max-width: 980px;
  margin-inline: auto;
}

main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

h1,
h2 {
  text-wrap: balance;
  margin: 0;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
}

button {
  font: inherit;
  color: inherit;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Kopfzeile über die volle Breite, bleibt beim Scrollen oben stehen */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: -12px calc(-1 * max(16px, env(safe-area-inset-right, 0px))) 12px
    calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  background: var(--paper);
  box-shadow:
    0 1px 0 transparent,
    0 4px 14px transparent;
  transition: box-shadow 0.2s;
}

/* Trennlinie und Schatten erst, sobald die Seite gescrollt ist */
.scrolled .top {
  box-shadow:
    0 1px 0 var(--line),
    0 4px 14px var(--shade);
}

.top-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  width: 44px;
  height: auto;
  flex: none;
}

.name {
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.sub {
  color: var(--muted);
  font-size: 0.8rem;
}

.pill {
  border-radius: 999px;
  padding: 2px 10px;
  background: var(--wait-soft);
  color: var(--wait);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Linienauswahl als Karte über den Verbindungen */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 3px 12px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--panel);
}

.connections {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.conn-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.stamp {
  color: var(--muted);
  font-size: 0.8rem;
}

.trains {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Lagehinweis als dunkle Tafel (wie die Bahnsteig-Tafel im ersten Prototyp), in beiden Modi dunkel.
   Die Randfarbe als innerer Schatten, damit sie auf dem Handy auch randlos erhalten bleibt. */
.notice {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 16px 12px 19px;
  border-radius: 6px;
  background: var(--board);
  color: var(--board-ink);
  box-shadow: inset 5px 0 0 var(--edge);
}

.notice p {
  margin: 0;
}

.n-go {
  --edge: #378add;
  --edge-ink: #85b7eb;
}
.n-warn {
  --edge: #ef9f27;
  --edge-ink: #fac775;
}
.n-none {
  --edge: #888780;
  --edge-ink: #d3d1c7;
}

.notice-state {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--edge-ink);
}

.notice-title {
  font-size: 1.25rem;
  font-weight: 650;
  line-height: 1.2;
}

/* Teile nur zwischen sich umbrechen, nicht in sich */
.notice-sub {
  display: flex;
  flex-wrap: wrap;
  column-gap: 0.35em;
  font-size: 0.88rem;
  color: var(--board-muted);
}

.notice-sub span {
  white-space: nowrap;
}
.notice-sub span:not(:last-child)::after {
  content: " ·";
}

.more {
  align-self: stretch;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 9px 0;
}

.error {
  color: var(--stop);
}

/* Verbindungen als Karten im Stil der DB-App, aufklappbar */
.trains li.conn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.conn-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 10px 0;
  cursor: pointer;
}

.conn-btn > span {
  display: flex;
}

.conn.dim .conn-btn {
  opacity: 0.45;
}

.conn.dim .conn-btn:hover,
.conn.dim .conn-btn[aria-expanded="true"] {
  opacity: 0.8;
}

.conn-head {
  align-items: baseline;
  gap: 8px;
}

.conn-plan {
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
}

.conn-dur {
  color: var(--muted);
  white-space: nowrap;
}

.conn-head .spacer {
  flex: 1;
}

.chev {
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  transition: transform 0.15s;
}

.conn-btn[aria-expanded="true"] .chev {
  transform: rotate(90deg);
}

.conn-rt {
  gap: 18px;
  font-size: 1.1rem;
}

.rt.ok {
  color: var(--go);
}

.rt.late {
  color: var(--stop);
}

.conn-row {
  align-items: stretch;
  min-height: 28px;
  margin-top: 4px;
}

.conn-line {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: var(--p-re);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
}

.conn.p-fern .conn-line {
  background: var(--p-fern);
}
.conn.p-s .conn-line {
  background: var(--p-s);
}

.has-seg .conn-line {
  border-radius: 5px 0 0 5px;
  clip-path: polygon(0 0, 100% 0, calc(100% - var(--slant)) 100%, 0 100%);
}

.conn-seg {
  display: flex;
  align-items: center;
  margin-left: calc(4px - var(--slant));
  padding: 0 12px 0 calc(var(--slant) + 7px);
  border-radius: 0 5px 5px 0;
  clip-path: polygon(var(--slant) 0, 100% 0, 100% 100%, 0 100%);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.seg-go {
  background: var(--seg-go);
}
.seg-warn {
  background: var(--seg-warn);
}
/* Hinweis ohne Garantie: neutral, damit er nicht mit einer Option verwechselt wird */
.seg-none {
  background: var(--line);
  color: var(--ink);
  font-weight: 600;
}

.conn-meta {
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.conn-route {
  min-width: 0;
}

.platform {
  flex-shrink: 0;
  white-space: nowrap;
  font-weight: 600;
  color: var(--ink);
}

.platform.changed {
  color: var(--stop);
}

/* Aufgeklappte Details ohne eigenen Kasten */
.drawer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0 12px;
  border-top: 1px solid var(--line);
}

.drawer-text {
  margin: 0;
  font-size: 0.92rem;
}

.steps {
  margin: 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--muted);
  font-size: 0.88rem;
}

.steps b {
  font-family: var(--mono);
  color: var(--ink);
}

.db-link {
  align-self: flex-start;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
}

.db-link.wait {
  color: var(--muted);
  font-weight: 400;
}

.badge {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 1px 9px;
  border: 1px solid var(--line);
  white-space: nowrap;
}

.badge.wait {
  background: var(--wait-soft);
  border-color: transparent;
  color: var(--wait);
}

.mini {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mini li {
  display: grid;
  grid-template-columns: 3.4rem auto 1fr auto;
  gap: 8px;
  align-items: baseline;
  font-size: 0.9rem;
}

.mini-time {
  font-family: var(--mono);
  font-weight: 600;
}

.mini-name {
  font-weight: 600;
  white-space: nowrap;
}

.mini-meta {
  color: var(--muted);
  min-width: 0;
}

.mini.dim {
  opacity: 0.55;
}

/* Auf dem Handy reichen Linienauswahl und Verbindungskarten bis an den Bildschirmrand (wie in der DB-App) */
@media (max-width: 520px) {
  .filters,
  .notice,
  .trains li.conn {
    margin-inline: calc(-1 * max(16px, env(safe-area-inset-left, 0px)))
      calc(-1 * max(16px, env(safe-area-inset-right, 0px)));
    padding-inline: max(16px, env(safe-area-inset-left, 0px))
      max(16px, env(safe-area-inset-right, 0px));
    border-inline: 0;
    border-radius: 0;
  }
}
