/* Abfahrtsmonitor Wien – Stil einer LED-Abfahrtsanzeige */

@font-face {
  font-family: "Doto";
  src: url("/fonts/doto-latin.woff2") format("woff2");
  font-weight: 500 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Doto";
  src: url("/fonts/doto-latin-ext.woff2") format("woff2");
  font-weight: 500 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #0b0c0e;
  --text: #f2f1ec;
  --muted: #a0a2a9;
  --faint: #6c6f77;
  --edge: #30333a;
  --housing-top: #2a2d33;
  --housing-bottom: #1b1d21;
  --led: #ffb000;
  --led-hot: #ffd27a;
  --led-glow: rgba(255, 150, 0, 0.42);
  --led-off: rgba(255, 176, 0, 0.075);
  --red: #e3000f;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --dot: "Doto", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 16px;
  color-scheme: dark;
}

/* Linienfarben der Wiener Linien */
.lc-u1 { --lc: #e3000f; }
.lc-u2 { --lc: #a862a4; }
.lc-u3 { --lc: #ee7d00; }
.lc-u4 { --lc: #319f49; }
.lc-u5 { --lc: #008f95; }
.lc-u6 { --lc: #a0652a; }
.lc-tram { --lc: #d52b1e; }
.lc-wlb { --lc: #1f63b5; }
.lc-bus { --lc: #1c5dab; }
.lc-night { --lc: #22325c; --lf: #ffd23f; }
.lc-other { --lc: #5a5d66; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 520px at 50% -180px, #1d2027 0%, rgba(11, 12, 14, 0) 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
body.has-ticker { padding-bottom: calc(52px + env(safe-area-inset-bottom)); }

button { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--led); outline-offset: 2px; }

svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------ LED-Grundlook */

.led {
  position: relative;
  background-color: #070707;
  background-image: radial-gradient(circle, var(--led-off) 0 0.9px, transparent 1.3px);
  background-size: 4px 4px;
  color: var(--led);
  font-family: var(--dot);
  font-weight: 800;
  text-shadow: 0 0 1px var(--led-hot), 0 0 9px var(--led-glow);
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px #000,
    inset 0 8px 22px rgba(0, 0, 0, 0.85),
    0 0 0 3px #0d0e10,
    0 0 0 4px rgba(255, 255, 255, 0.05);
}
.led::after {  /* Glasreflex */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(168deg, rgba(255, 255, 255, 0.055) 0%, rgba(255, 255, 255, 0) 38%);
  pointer-events: none;
}

/* ------------------------------------------------------------ Kopfzeile */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(11, 12, 14, 0.8);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 16px;
  align-items: center;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; flex: none; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08); }
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 1.2rem; line-height: 1.2; letter-spacing: 0.005em; }
.status {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clock {
  font-size: 1.9rem;
  line-height: 1;
  padding: 6px 12px 7px;
  letter-spacing: 0.04em;
  min-width: 5.2ch;
  text-align: center;
}
.clock .colon { display: inline-block; margin: 0 0.02em; }
.clock.tick .colon { opacity: 0.25; }

.toolbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 1px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px 6px 10px;
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--c);
  opacity: 0.35;
  transition: opacity 0.15s;
}
.chip.m-metro { --c: #e3000f; }
.chip.m-tram { --c: #d52b1e; }
.chip.m-bus { --c: #2f74c8; }
.chip.m-night { --c: #ffd23f; }
.chip[aria-pressed="true"] { background: #f2f1ec; border-color: #f2f1ec; color: #121316; }
.chip[aria-pressed="true"]::before { opacity: 1; }
.chip:hover { border-color: #4a4e57; }

.actions { display: flex; gap: 6px; flex: none; }
.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { border-color: #4a4e57; background: rgba(255, 255, 255, 0.06); }
.icon-btn.active { color: var(--led); border-color: rgba(255, 176, 0, 0.5); }
.icon-btn[aria-expanded="true"] { background: #f2f1ec; color: #121316; border-color: #f2f1ec; }

/* ------------------------------------------------------------ Suche */

.search { grid-column: 1 / -1; position: relative; }
.search input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: #121317;
  color: var(--text);
  font: 500 1rem var(--sans);
  outline: none;
}
.search input:focus { border-color: rgba(255, 176, 0, 0.6); box-shadow: 0 0 0 3px rgba(255, 176, 0, 0.12); }
.search-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #16181c;
  border: 1px solid var(--edge);
}
.search-results:empty { display: none; }
.search-results li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
}
.search-results li + li { border-top: 1px solid rgba(255, 255, 255, 0.05); }
.search-results li[aria-selected="true"] { background: rgba(255, 176, 0, 0.1); }
.search-results li.empty { color: var(--muted); cursor: default; display: block; }
.res-name { font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.res-name small { color: var(--muted); font-weight: 500; }
.res-lines { grid-column: 1; display: flex; flex-wrap: wrap; gap: 3px; }
.res-dist { grid-column: 2; grid-row: 1 / span 2; color: var(--muted); font-size: 0.82rem; }

/* ------------------------------------------------------------ Tafeln */

.boards {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 16px 8px;
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 390px), 1fr));
  align-items: start;
}

.board {
  position: relative;
  padding: 12px 12px 14px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--housing-top) 0%, var(--housing-bottom) 100%);
  border: 1px solid #353840;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 22px 40px -24px rgba(0, 0, 0, 0.9),
    0 2px 6px rgba(0, 0, 0, 0.35);
  animation: rise 0.35s ease-out both;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.board-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  padding: 2px 4px 12px;
}
.board-title { min-width: 0; }
.board-head h2 {
  margin: 0;
  font-size: 1.14rem;
  line-height: 1.25;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.board-head h2 > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-logo {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 1.3em;
  height: 1.3em;
  border-radius: 3px;
  background: #1a4198;
  color: #fff;
  font: 800 0.82em/1 var(--sans);
}
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}
.walk { display: inline-flex; align-items: center; gap: 3px; }
.ico { width: 15px; height: 15px; }
.route {
  align-self: start;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.route .ico { width: 18px; height: 18px; }
.route:hover { color: var(--text); border-color: var(--edge); background: rgba(255, 255, 255, 0.04); }

.line-chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.lchip {
  display: inline-block;
  min-width: 2em;
  padding: 3px 5px;
  border-radius: 4px;
  background: var(--lc, #555);
  color: var(--lf, #fff);
  font: 700 0.72rem/1.05 var(--sans);
  text-align: center;
  letter-spacing: 0.01em;
}
.lchip.lc-u1, .lchip.lc-u2, .lchip.lc-u3, .lchip.lc-u4, .lchip.lc-u5, .lchip.lc-u6 { border-radius: 3px; }

/* ------------------------------------------------------------ LED-Anzeige */

.board-led { padding: 8px 12px; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: 3.3em minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  font-size: 1.22rem;
  line-height: 1.2;
}
.row + .row { border-top: 1px solid rgba(255, 176, 0, 0.07); }
.r-line { position: relative; padding-left: 10px; white-space: nowrap; }
.r-line::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.08em;
  bottom: 0.08em;
  width: 4px;
  border-radius: 2px;
  background: var(--lc);
  box-shadow: 0 0 7px var(--lc);
}
.lc-night.r-line::before { background: #ffd23f; box-shadow: 0 0 7px rgba(255, 210, 63, 0.6); }
.r-dest { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.r-times {
  display: grid;
  grid-template-columns: 2.7ch 2.2ch 2.2ch;   /* feste Spalten: Zahlen stehen untereinander */
  gap: 0.7ch;
  text-align: right;
  white-space: nowrap;
}
.clock-mode .r-times { grid-template-columns: 5ch 5ch; gap: 1ch; }
.t { font-size: 0.82em; opacity: 0.55; }
.t.first { font-size: 1.14em; opacity: 1; }
.t.pad { visibility: hidden; }
.t.planned { color: #ffcf66; }
.t.gone { opacity: 0.24; }
.t.first.gone { opacity: 0.32; }
.t.now { animation: blink 1.1s steps(1, end) infinite; }
@keyframes blink { 55% { opacity: 0.08; } }

.led-msg { padding: 10px 0; font-size: 1.15rem; }
.led-msg.dim { opacity: 0.55; }
.dots::after { content: ""; animation: dots 1.4s steps(4, end) infinite; }
@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

/* Hinweis-Tafel (kein Standort, laden …) */
.notice { grid-column: 1 / -1; max-width: 560px; justify-self: center; width: 100%; }
.notice-led { padding: 18px 16px; font-size: 1.45rem; text-align: center; }
.notice-text { margin: 14px 6px 4px; color: var(--muted); text-align: center; }
.notice-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.btn {
  border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: #4a4e57; }
.btn.primary { background: var(--led); border-color: var(--led); color: #1a1100; }

.far-note { grid-column: 1 / -1; margin: 0; color: var(--muted); text-align: center; }

.more-wrap { display: flex; justify-content: center; padding: 6px 16px 0; }
.more {
  border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 999px;
  padding: 10px 18px;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.more:hover { color: var(--text); border-color: #4a4e57; }

.credits {
  max-width: 640px;
  margin: 22px auto 26px;
  padding: 0 16px;
  color: var(--faint);
  font-size: 0.76rem;
  text-align: center;
}

/* ------------------------------------------------------------ Laufschrift */

.ticker {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: #050505;
  border-top: 1px solid #25272c;
  padding-bottom: env(safe-area-inset-bottom);
}
.ticker-btn {
  display: flex;
  width: 100%;
  height: 52px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
}
.ticker-label {
  flex: none;
  display: grid;
  place-items: center;
  padding: 0 14px;
  background: var(--red);
  color: #fff;
  font: 800 0.72rem/1 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.ticker-label.lift { background: #3a3d45; }
.ticker-track {
  flex: 1;
  display: flex;
  align-items: center;
  overflow: hidden;
  border-radius: 0;
  box-shadow: inset 0 6px 14px rgba(0, 0, 0, 0.8);
  font-size: 1.15rem;
}
.ticker-text {
  display: inline-block;
  white-space: nowrap;
  padding-left: 100%;
  animation: marquee var(--dur, 30s) linear infinite;
}
@keyframes marquee { to { transform: translateX(-100%); } }

/* ------------------------------------------------------------ Meldungs-Dialog */

.sheet {
  width: min(640px, calc(100% - 24px));
  max-height: min(80dvh, 720px);
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: 18px;
  background: #16181c;
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sheet-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px 20px;
  background: #16181c;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.sheet-head h2 { margin: 0; font-size: 1.05rem; }
.sheet-list { list-style: none; margin: 0; padding: 6px 20px 18px; }
.sheet-item { padding: 12px 0; }
.sheet-item + .sheet-item { border-top: 1px solid rgba(255, 255, 255, 0.06); }
.sheet-item p { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
.sheet-lines { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.sheet-lines:empty { display: none; }

.noscript { text-align: center; color: var(--muted); }

/* ------------------------------------------------------------ Groessere Bildschirme */

@media (min-width: 720px) {
  .topbar { padding-left: 24px; padding-right: 24px; }
  .topbar-inner { grid-template-columns: minmax(0, 1fr) auto auto; }
  .toolbar { grid-column: 2; grid-row: 1; }
  .clock { grid-column: 3; font-size: 2.2rem; }
  .boards { padding: 24px 24px 8px; gap: 22px; }
  .row { font-size: 1.3rem; }
}

@media (max-width: 460px) {
  /* schmale Handys: nur zwei Zeiten, damit das Ziel lesbar bleibt */
  .r-times { grid-template-columns: 2.7ch 2.2ch; }
  .r-times > :nth-child(3) { display: none; }
  .row { gap: 9px; grid-template-columns: 3.1em minmax(0, 1fr) auto; }
  .board { padding: 10px 10px 12px; }
  .board-led { padding: 6px 10px; }
  .chips { gap: 5px; }
  .chip { padding: 6px 9px 6px 8px; gap: 6px; font-size: 0.8rem; }
  .actions { gap: 4px; }
  .icon-btn { width: 34px; height: 34px; }
}

@media (max-width: 370px) {
  .row { font-size: 1.08rem; gap: 7px; grid-template-columns: 2.9em minmax(0, 1fr) auto; }
  .clock { font-size: 1.6rem; }
  .chip::before { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .board { animation: none; }
  .t.now { animation: none; }
  .ticker-text { animation: none; padding-left: 12px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.95rem; }
  .ticker-btn { height: auto; min-height: 52px; }
}

/* Stationen ohne aktuelle Abfahrten: gesammelt in einem kompakten Block */
.board.quiet { padding: 12px 16px 8px; background: linear-gradient(180deg, #202226 0%, #191b1e 100%); }
.board.quiet h2 { margin: 0 0 4px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.quiet-list { list-style: none; margin: 0; padding: 0; }
.quiet-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 4.2em;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.quiet-list li + li { border-top: 1px solid rgba(255, 255, 255, 0.05); }
.q-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-lines { display: flex; gap: 3px; opacity: 0.7; justify-content: flex-end; }
.q-dist { font-size: 0.8rem; text-align: right; color: var(--faint); }
