/* HTML hidden attribute must not be overridden by display rules */
[hidden] { display: none !important; }

/* ── RESET & ROOT ─────────────────────────────────────────────── */
:root {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface2:  #263347;
  --border:    #334155;
  --text:      #f1f5f9;
  --muted:     #94a3b8;
  --faint:     #475569;
  --accent:    #3b82f6;
  --green:     #22c55e;
  --red:       #ef4444;
  --r:         12px;
  --rs:        8px;
  --nav-h:     56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.45;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.4s;
}
body.has-alert { background: #130a0a; }

/* ── HEADER ───────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(160deg, #0f172a 0%, #1a2540 100%);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-icon { font-size: 28px; line-height: 1; }
.brand-name { font-size: 18px; font-weight: 800; letter-spacing: -.3px; }
.brand-sub  { font-size: 11px; color: var(--muted); margin-top: 1px; }
.time-block { text-align: right; flex-shrink: 0; }
#clock {
  font-size: 22px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px; color: var(--accent);
}
#clockSub { font-size: 10px; color: var(--muted); margin-top: 2px; white-space: nowrap; }

/* ── PAGES ────────────────────────────────────────────────────── */
.page {
  padding: 12px 12px calc(var(--nav-h) + 20px + env(safe-area-inset-bottom, 0px));
  max-width: 520px;
  margin: 0 auto;
}

/* ── BOTTOM NAV ───────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}
.nav-btn {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  transition: color .15s;
  padding: 8px 0;
}
.nav-btn.active { color: var(--accent); }
.nav-icon  { font-size: 20px; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 600; letter-spacing: .2px; }

/* ── ALERT BANNER ─────────────────────────────────────────────── */
.alert-banner {
  display: flex; flex-direction: column;
  background: rgba(239,68,68,.12);
  border: 1.5px solid var(--red);
  border-radius: var(--r);
  padding: 14px 16px 0;
  margin-bottom: 12px;
  overflow: hidden;
  animation: pulse-border 1.3s ease-in-out infinite;
}
@keyframes pulse-border {
  0%,100% { border-color: var(--red); }
  50%      { border-color: rgba(239,68,68,.3); }
}

/* Yuxarı hissə: nöqtə + mətn */
.alert-top {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 12px;
}

.alert-dot {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--red); flex-shrink: 0;
  animation: pulse-dot 1.3s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%,100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.4); opacity: .65; }
}
.alert-label { font-size: 10px; font-weight: 700; letter-spacing: .7px; color: var(--red); text-transform: uppercase; margin-bottom: 3px; }
#alertRoute  { font-size: 16px; font-weight: 600; color: var(--text); }
#alertEta    { font-size: 13px; color: var(--red); margin-top: 2px; }

/* Aşağı hissə: qatar keçdiyi yol */
.alert-track {
  position: relative;
  height: 38px;
  border-top: 1px solid rgba(239,68,68,.25);
  overflow: hidden;
}

/* ── LOAD MORE BUTTONS ────────────────────────────────────────── */
.load-more-btn {
  display: block;
  width: 100%; padding: 10px 14px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--rs);
  color: var(--muted);
  font-size: 13px; text-align: center;
  cursor: pointer; margin-bottom: 8px;
  transition: all .15s;
}
.load-more-btn:active { background: var(--surface2); color: var(--text); border-style: solid; }
.load-more-btn.top { margin-bottom: 8px; }
.load-more-btn.bot { margin-top: 8px; margin-bottom: 0; }

/* ── TRAIN LIST ───────────────────────────────────────────────── */
.train-list { display: flex; flex-direction: column; gap: 7px; }
.empty { text-align: center; color: var(--faint); font-size: 13px; padding: 28px 0; }

/* ── TRAIN CARD ───────────────────────────────────────────────── */
.card {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: opacity .2s;
}
.card.past   { opacity: .28; }
.card.urgent { border-color: rgba(239,68,68,.5); box-shadow: 0 0 0 1px rgba(239,68,68,.15); }
.card-bar  { width: 4px; flex-shrink: 0; }
.card-inner { flex: 1; padding: 11px 12px; min-width: 0; }
.card-head  { display: flex; align-items: baseline; gap: 10px; margin-bottom: 5px; }
.card-time  {
  font-size: 21px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: .5px; flex-shrink: 0;
}
.card-route {
  font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-tags  { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 5px; }
.tag { font-size: 11px; font-weight: 500; padding: 2px 7px; border-radius: 4px; background: var(--surface2); color: var(--muted); }
.tag.muted { color: var(--faint); background: transparent; padding-left: 0; }
.card-eta            { font-size: 12px; color: var(--muted); }
.card-eta.eta-urgent { color: var(--red); font-weight: 600; }
.card-eta.eta-past   { color: var(--faint); }

/* ── SCHEDULE PAGE ────────────────────────────────────────────── */
.sch-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.filter-sel {
  flex: 1; min-width: 100px;
  padding: 7px 28px 7px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--rs);
  color: var(--text); font-size: 13px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%2394a3b8' d='M5 7l5 5 5-5H5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 16px;
}
.sort-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 9px; }
.sort-label { font-size: 12px; color: var(--faint); }
.sort-btn {
  padding: 4px 13px; border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2); color: var(--muted);
  font-size: 12px; cursor: pointer; transition: all .15s;
}
.sort-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sch-count { margin-left: auto; font-size: 12px; color: var(--muted); }

/* ── DAY DIVIDER ──────────────────────────────────────────────── */
.day-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 0 8px;
  color: var(--faint);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
}
.day-divider::before,
.day-divider::after {
  content: '';
  flex: 1; height: 1px;
  background: var(--border);
}

/* ── TRAIN ANIMATION — ALERT-TRACK İÇİNDƏ ───────────────────── */
.train-in-banner {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 26px;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

/* Bakıya gələn: sağdan → sola */
@keyframes banner-rtl {
  0%   { left: calc(100% + 20px); opacity: 0; }
  6%   { opacity: 1; }
  94%  { opacity: 1; }
  100% { left: -160px; opacity: 0; }
}

/* Bakıdan gedən: soldan → sağa */
@keyframes banner-ltr {
  0%   { left: -160px; opacity: 0; }
  6%   { opacity: 1; }
  94%  { opacity: 1; }
  100% { left: calc(100% + 20px); opacity: 0; }
}

/* Sonsuz döngü — stopAnimation() class-ı sıfırlayır */
.train-in-banner.rtl { animation: banner-rtl 5s linear infinite; }
.train-in-banner.ltr { animation: banner-ltr 5s linear infinite; }
