:root {
  /* jasny motyw */
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --border: #e2e8f0;
  --row-line: #edf1f5;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #f5a524;          /* logo, wyróżnienie najbliższego odjazdu */
  --live: #059669;            /* czas wg GPS */
  --sched: #b45309;           /* czas wg rozkładu */
  /* kolory linii */
  --bus: #16a34a;             /* autobusy – zielone */
  --fast: #dc2626;            /* pośpieszne A, B, C – czerwone */
  --tram: #2563eb;            /* tramwaje – niebieskie */
  --night: #1e293b;           /* nocne */
  --access: #2563eb;
  --tm: #b45309;              /* ikony automatu */
  --danger: #dc2626;
  --warn: #f59e0b;
  --radius: 18px;
  /* skaluje całą tablicę do rozmiaru ekranu */
  --fs: clamp(14px, .72vw + .55vh, 30px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}
body {
  display: flex;
  flex-direction: column;
  font-size: var(--fs);
  background: var(--bg);
}

/* ---------- Pasek górny ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1em;
  padding: .7em 1.2em .55em;
}
.brand { display: flex; align-items: center; gap: .7em; min-width: 0; }
/* logo uczelni – PNG ma białe tło, multiply "wtapia" je w jasne tło strony */
.uni-logo {
  height: 2.6em;
  width: auto;
  flex: none;
  display: block;
  mix-blend-mode: multiply;
}
.divider { width: 1px; height: 1.8em; background: var(--border); flex: none; }
.logo {
  font-weight: 800;
  font-size: .75em;
  letter-spacing: .04em;
  padding: .35em .6em;
  border-radius: 8px;
  background: var(--accent);
  color: #1a1205;
}
.brand h1 {
  margin: 0;
  font-size: 1.35em;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.right { display: flex; align-items: center; gap: .8em; margin-left: auto; }
.clockbox { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.clock { font-size: 2em; font-weight: 800; letter-spacing: -.02em; }
.date { font-size: .6em; color: var(--muted); margin-top: .25em; }
.status { font-size: .55em; color: var(--muted); }
.status.error { color: var(--danger); }

/* ---------- Panele przystanków ---------- */
.panels {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 1em;
  padding: 0 1.2em .8em;
}
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9em 1em .4em;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .05);
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1em; }
.panel-name { margin: 0; font-size: 1.45em; font-weight: 800; letter-spacing: -.02em; }
.panel-posts { color: var(--muted); font-size: .6em; white-space: nowrap; }

.row {
  display: grid;
  grid-template-columns: 3.3em minmax(0, 1fr) 4em 4.4em 6.8em;
  align-items: center;
  gap: .7em;
  padding: .42em .5em;
  border-bottom: 1px solid var(--row-line);
}
.row-head {
  font-size: .58em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding-top: 1.2em;
  border-bottom-color: var(--border);
  /* kolumny liczone w em – przelicz względem mniejszej czcionki nagłówka */
  grid-template-columns: calc(3.3em / .58) minmax(0, 1fr) calc(4em / .58) calc(4.4em / .58) calc(6.8em / .58);
  gap: calc(.7em / .58);
  padding-left: calc(.5em / .58);
  padding-right: calc(.5em / .58);
}
.rows { flex: 1; min-height: 0; overflow: hidden; }
.row[hidden] { display: none; }   /* display:grid nadpisałby atrybut hidden */
.rows .row:last-child { border-bottom: none; }
.rows .row.first {
  background: linear-gradient(90deg, rgba(245, 165, 36, .16), rgba(245, 165, 36, 0) 75%);
  border-radius: 10px;
}
.c-post { text-align: center; white-space: nowrap; }
.c-veh { text-align: center; }
.c-time { text-align: right; }

.badge {
  display: inline-block;
  width: 100%;
  padding: .18em 0;
  border-radius: 8px;
  text-align: center;
  font-weight: 800;
  color: #fff;
  background: var(--bus);
  position: relative;
}
.badge.tram { background: var(--tram); }
.badge.fast { background: var(--fast); }
.badge.night { background: var(--night); }
/* znaczek utrudnień: trójkąt ostrzegawczy w prawym górnym rogu numeru linii */
.warn {
  position: absolute;
  top: -.5em; right: -.55em;
  width: .95em; height: .95em;
}
.warn svg { width: 100%; height: 100%; display: block; overflow: visible; }
.warn .tri { fill: var(--warn); stroke: var(--surface); stroke-width: 2.5; stroke-linejoin: round; paint-order: stroke; }
.warn .mark { fill: #1a1205; }

.dir { min-width: 0; }
.dir-name {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note {
  display: block;
  font-size: .62em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note.post-inline { display: none; }   /* nr przystanku pod kierunkiem – tylko na telefonie */

.post {
  display: inline-block;
  font-size: .62em;
  font-weight: 600;
  color: var(--muted);
  padding: .2em .5em;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* czas */
.time { display: inline-block; font-weight: 800; font-size: 1.1em; white-space: nowrap; }
.t-live, .time.live { color: var(--live); }
.t-sched, .time.sched { color: var(--sched); }
.time.live::before {
  content: "";
  display: inline-block;
  width: .32em; height: .32em;
  margin-right: .35em;
  border-radius: 50%;
  background: var(--live);
  vertical-align: middle;
  /* tylko transform/opacity – animuje GPU, bez przemalowywania strony.
     Fazę po odświeżeniu wyrównuje syncAnimations() w app.js */
  animation: pulse 1.8s ease-in-out infinite;
  will-change: transform, opacity;
}
/* "teraz": płynne pulsowanie zamiast skokowego mrugania */
.time.now {
  animation: breathe 1.4s ease-in-out infinite;
  will-change: opacity;
  backface-visibility: hidden;
}
.time.canceled { color: var(--danger); text-decoration: line-through; }
/* opóźniony: czas (już z wliczonym opóźnieniem) na czerwono */
.time.live.late { color: var(--danger); }
.time.live.late::before { background: var(--danger); }
.t-late { color: var(--danger); }
.delay { display: block; font-size: .55em; font-weight: 600; color: var(--danger); white-space: nowrap; }
.delay .plan { color: var(--muted); font-weight: 500; }
.delay.early { color: var(--live); }

/* ikony pojazdu: [niskopodłogowość][automat], ciasno obok siebie, całość
   wyśrodkowana. Slot automatu ma stałą szerokość (2 ikony), więc kolumny ikon
   w każdym wierszu stoją w tym samym miejscu. */
.veh {
  display: grid;
  grid-template-columns: 1.45em 2.95em;
  column-gap: .15em;
  justify-content: center;
  align-items: center;
}
.slot { display: flex; align-items: center; justify-content: flex-start; gap: .05em; height: 1.45em; }
.slot:first-child { justify-content: center; }
.ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45em; height: 1.45em;
  border-radius: 6px;
  vertical-align: middle;
  flex: none;
}
.ico svg { width: 100%; height: 100%; display: block; }
.ico.ok { background: var(--access); color: #fff; padding: .12em; }
.ico.maybe { border: 2px dashed var(--access); color: var(--access); padding: .06em; }
.ico.tm { color: var(--tm); }
.unknown, .no {
  display: inline-flex;
  justify-content: center;
  width: 1.45em;
  color: var(--muted);
  opacity: .6;
  font-size: .8em;
  font-weight: 600;
  line-height: 1;
}

.empty { color: var(--muted); padding: 2em .5em; text-align: center; }

/* ---------- Stopka: pasek komunikatów + legenda ---------- */
.footer { padding: 0 1.2em .6em; }

.ticker {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border-radius: 12px;
  --ticker-bg: #fff8eb;              /* pełny kolor – potrzebny do wygaszania krawędzi */
  background: var(--ticker-bg);
  border: 1px solid #f6d28b;
  margin-bottom: .5em;
}
.ticker[hidden] { display: none; }
.ticker-label {
  flex: none;
  display: flex;
  align-items: center;
  gap: .4em;
  padding: 0 .9em;
  background: var(--warn);
  color: #1a1205;
  font-weight: 800;
  font-size: .7em;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.ticker-label::before { content: "⚠"; font-size: 1.2em; }
.ticker-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  contain: paint;                    /* przesuwanie nie wpływa na resztę strony */
}
/* wygaszone krawędzie – statyczne nakładki zamiast mask-image (maska kosztuje
   przeliczanie przy każdej klatce) */
.ticker-viewport::before,
.ticker-viewport::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 2.5em;
  z-index: 1;
  pointer-events: none;
}
.ticker-viewport::before { left: 0; background: linear-gradient(90deg, var(--ticker-bg), transparent); }
.ticker-viewport::after { right: 0; background: linear-gradient(270deg, var(--ticker-bg), transparent); }
.ticker-track {
  display: inline-flex;
  white-space: nowrap;
  padding: .45em 0;
  /* osobna warstwa GPU – animacja działa na wątku kompozytora */
  will-change: transform;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  animation: ticker var(--ticker-duration, 60s) linear infinite;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-item { display: inline-flex; align-items: center; gap: .45em; padding-right: 3em; font-size: .85em; }
.ticker-item b { font-weight: 700; }
.ticker-item .desc { color: #334155; }
.ticker-item.mine b { color: #b45309; }
.ticker-item .mini {
  display: inline-block;
  min-width: 2.2em;
  padding: .05em .35em;
  border-radius: 6px;
  text-align: center;
  font-weight: 800;
  font-size: .85em;
  background: var(--bus);
  color: #fff;
}
.ticker-item .mini.tram { background: var(--tram); }
.ticker-item .mini.fast { background: var(--fast); }
.ticker-item .mini.night { background: var(--night); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: .3em 1.6em;
  align-items: center;
  font-size: .55em;
  color: var(--muted);
}
.legend > span { display: inline-flex; align-items: center; gap: .35em; }
.legend .ico { width: 1.7em; height: 1.7em; }
.legend .warn { position: static; width: 1.6em; height: 1.6em; }
.legend .no, .legend .unknown { font-size: 1.2em; width: auto; }
.legend .swatch {
  display: inline-block;
  min-width: 2.4em;
  padding: .1em .4em;
  border-radius: 6px;
  color: #fff;
  font-weight: 800;
  text-align: center;
}
.swatch.bus { background: var(--bus); }
.swatch.fast { background: var(--fast); }
.swatch.tram { background: var(--tram); }
.swatch.night { background: var(--night); }

@keyframes ticker { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-50%, 0, 0); } }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(.6); opacity: .45; }
}
@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; white-space: normal; flex-wrap: wrap; }
  .ticker-track .dup { display: none; }
  .time.live::before, .time.now { animation: none; }
}

/* ---------- Ekran pionowy (docelowo 4K: 2160×3840) ----------
   Panele jeden pod drugim, każdy na pełną szerokość i pół wysokości.
   Czcionka liczona od szerokości ekranu, więc wygląd jest ten sam przy
   skalowaniu systemu 100% (2160 px) i 200% (1080 px). */
@media (orientation: portrait) and (min-width: 761px) {
  :root { --fs: 2vw; }
  .panels {
    grid-auto-flow: row;
    grid-auto-rows: minmax(0, 1fr);
    grid-auto-columns: auto;
  }
  .panel-name { font-size: 1.6em; }
  .legend { font-size: .5em; gap: .3em 1.4em; }
}

/* ---------- Telefon: panele jeden pod drugim, przewijanie ---------- */
@media (max-width: 760px) {
  :root { --fs: 15px; }
  html, body { height: auto; }
  .topbar { padding: .6em 12px .4em; }
  .uni-logo { height: 38px; }
  .brand .divider, .brand .logo, .brand h1 { display: none; }
  .panels { flex: none; grid-auto-flow: row; padding: 0 12px .8em; }
  .panel, .rows { min-height: auto; overflow: visible; }
  .footer { padding: 0 12px .6em; }
  .status { display: none; }
  .row { grid-template-columns: 2.9em minmax(0, 1fr) 4.6em 4.4em; gap: .5em; padding: .45em .2em; }
  .row-head { grid-template-columns: calc(2.9em / .58) minmax(0, 1fr) calc(4.6em / .58) calc(4.4em / .58); gap: calc(.5em / .58); }
  .row .c-post { display: none; }
  .note.post-inline { display: block; }
  .delay .plan { display: none; }   /* na telefonie samo "+4 min" */
}
