/* ============================================================================
   LAYOUT: Dark theme, full-screen flex layout with sticky footer
   ============================================================================ */
body {
  background:#050505;
  color:#f5f5f5;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin:0;
  min-height:100vh;
  display:flex;
  flex-direction:column;
}

/* Main content area - expands to fill available space */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 40px 16px;
  flex:1 0 auto;   /* expands to push footer down */
}

h1 {
  text-align:center;
  margin: 12px 0 4px 0;
  font-size: 2.2rem;
}

.subtitle {
  text-align:center;
  color:#bbb;
  margin-bottom: 4px;
}

.status {
  text-align:center;
  font-size:0.9rem;
  color:#888;
  margin-bottom: 10px;
  min-height: 1.2em;  /* maintain height even when empty */
}

/* Statistics display cards */
.statsbar {
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  margin: 10px 0 14px;
}

.stat {
  background:#0d0d0d;
  border:1px solid #222;
  border-radius:10px;
  padding:10px 12px;
  flex: 1 1 180px;
  min-width: 160px;
  box-shadow:0 0 18px rgba(0,0,0,0.35);
}

.stat .k {
  color:#aaa;
  font-size:.82rem;
  margin-bottom:6px;
}

.stat .v {
  font-size:1.15rem;
  font-weight:700;
}

.stat .sub {
  color:#888;
  font-weight:600;
  margin-left:6px;
  font-size:.9rem;
}

.stats-meta {
  margin-top: 4px;
  font-size: 0.75rem;
  color: #777;
  text-align: right;
  opacity: 0.8;
}

/* Header images section - responsive layout */
.header-images {
  display:flex;
  justify-content:center;
  gap:12px;
  margin: 12px auto 8px auto;
  max-width: 1100px;
  flex-wrap:wrap;           /* allow wrapping on small screens */
}

.header-images img {
  flex: 1 1 0;
  min-width: 260px;         /* desktop: two images side by side */
  max-width:520px;
  height:220px;
  object-fit:cover;
  border-radius:10px;
  box-shadow:0 0 18px rgba(0,0,0,0.5);
  display:block;
}

/* Top actions (GitHub link) */
.top-actions {
  display:flex;
  justify-content:center;
  margin-top:6px;
  margin-bottom:4px;
}

.repo-button {
  display:inline-block;
  background:#24292e; /* GitHub dark */
  color:#ffffff;
  padding:8px 14px;
  border-radius:8px;
  text-decoration:none;
  font-weight:600;
  box-shadow:0 4px 10px rgba(0,0,0,0.4);
}

.repo-button:hover {
  background:#2f3640;
}

h2 {
  margin-top: 26px;
  margin-bottom: 6px;
  font-size:1.2rem;
}

.table-wrapper {
  width:100%;
  overflow-x:auto;         /* horizontal scroll on mobile */
  border-radius:6px;
  border:1px solid #222;
  background:#0d0d0d;
}

table {
  width:100%;
  border-collapse:collapse;
  min-width: 480px;
}

th, td {
  padding:6px 8px;
  border-bottom:1px solid #222;
  font-size:0.95rem;
  white-space:nowrap;
}

th {
  text-align:left;
  color:#aaa;
  font-weight:600;
  background:#101010;
  position:sticky;
  top:0;
}

td.time {
  font-family:monospace;
  font-size:0.9rem;
}

td.distance {
  text-align:right;
}

tr:nth-child(even) td {
  background:#090909;
}

tr:nth-child(odd) td {
  background:#050505;
}

.empty-row td {
  text-align:center;
  padding:10px 8px;
  color:#888;
}

/* Animation for new trains entering observation radius */
@keyframes newTrainPulse {
  0%   { background-color:#102615; }
  40%  { background-color:#1f7a2f; }
  100% { background-color:#102615; }
}

tr.new-train td {
  animation: newTrainPulse 1.6s ease-out 0s 1;
}

/* ============================================================================
   FOOTER: Sticky footer with gradient and attribution
   ============================================================================ */
.footer {
  flex-shrink:0;                        /* does not shrink, stays at bottom */
  margin-top:40px;
  padding:16px 10px 18px 10px;
  text-align:center;
  font-size:0.85rem;
  color:#aaa;
  opacity:0.80;
  letter-spacing:0.3px;
  border-top:1px solid rgba(255,255,255,0.12);
  background:linear-gradient(180deg,#050505 0%,#020202 100%);
  box-shadow:0 -4px 18px rgba(0,0,0,0.9);  /* dark glow at top edge */
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  gap:8px;
}

.footer-text a {
  color:#7fb8ff;
  text-decoration:none;
  font-weight:500;
}

.footer-text a:hover {
  color:#bcdfff;
  text-decoration:underline;
}

/* Footer repo link */
.footer-right {
  display:flex;
  align-items:center;
  justify-content:center;
}

.repo-link {
  display:inline-flex;
  gap:8px;
  align-items:center;
  color:#fff;
  text-decoration:none;
  background:transparent;
  padding:6px 10px;
  border-radius:8px;
}

.repo-link svg {
  fill: #fff;
}

.repo-link span {
  color:#fff;
  font-weight:600;
}

@media (max-width: 640px) {
  .footer {
    flex-direction:column;
    gap:8px;
    text-align:center;
  }
}

/* Mobile layout (max 768px width) */
@media (max-width: 768px) {
  .page {
    padding:10px 8px 24px 8px;
  }
  h1 {
    font-size:1.6rem;
  }
  .header-images {
    flex-direction:column;
    align-items:center;
  }
  .header-images img {
    width:100%;
    max-width:100%;
    height:190px;
  }
  th, td {
    padding:5px 6px;
    font-size:0.85rem;
    white-space: normal;
  }
  table {
    min-width: 0;
  }
}

/* Tablet and larger layout (min 1024px) */
@media (min-width: 1024px) {
  .header-images {
    max-width: 1200px;
    margin-top: 18px;
    margin-bottom: 12px;
  }

  .header-images img {
    height: 300px;      /* increase for larger screens */
    max-width: 580px;   /* slightly wider */
  }
}

/* Desktop refinements (min 900px) */
@media (min-width:900px) {
  .footer {
    font-size:0.78rem;
    opacity:0.65;
    margin-top:50px;
  }
}
