/* ==========================================================================
   poezda.org.ua — modern redesign
   Design system: single stylesheet, no build step, dark-mode aware.
   ========================================================================== */

:root {
  /* Brand */
  --brand:        #1f6feb;
  --brand-600:    #1a5fd0;
  --brand-700:    #164ba8;
  --brand-tint:   #e8f0fe;
  --accent:       #10b981;   /* departures / positive */
  --warn:         #f59e0b;

  /* Surfaces */
  --bg:           #f4f6fb;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --border:       #e5e9f0;
  --border-strong:#cbd5e1;

  /* Text */
  --text:         #0f172a;
  --text-muted:   #64748b;
  --text-faint:   #94a3b8;

  /* Shape */
  --radius:       14px;
  --radius-sm:    9px;
  --shadow:       0 1px 2px rgba(15,23,42,.06), 0 8px 24px -12px rgba(15,23,42,.18);
  --shadow-sm:    0 1px 2px rgba(15,23,42,.08);
  --maxw:         1120px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0b1220;
    --surface:       #111a2b;
    --surface-2:     #0f1830;
    --border:        #1e2a44;
    --border-strong: #2a3a5c;
    --text:          #e6edf7;
    --text-muted:    #93a4c0;
    --text-faint:    #64748b;
    --brand-tint:    #14233f;
    --shadow:        0 1px 2px rgba(0,0,0,.4), 0 12px 30px -14px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex; align-items: center; gap: 20px;
  height: 62px;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800;
  font-size: 19px; color: var(--text); letter-spacing: -.01em; }
.logo:hover { text-decoration: none; }
.logo .mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: grid; place-items: center; color: #fff; flex: none;
}
.logo .mark svg { width: 20px; height: 20px; }
.logo b { color: var(--brand); }
.nav { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.nav a { color: var(--text-muted); font-weight: 600; font-size: 14px;
  padding: 8px 12px; border-radius: 8px; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

/* ---------- Hero + search ---------- */
.hero {
  background:
    radial-gradient(1200px 400px at 80% -10%, color-mix(in srgb, var(--brand) 18%, transparent), transparent),
    radial-gradient(900px 380px at 0% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent);
  padding: 48px 0 36px;
  border-bottom: 1px solid var(--border);
}
.hero h1 { font-size: clamp(26px, 4vw, 40px); line-height: 1.15;
  margin: 0 0 10px; letter-spacing: -.02em; }
.hero p { color: var(--text-muted); font-size: 17px; margin: 0 0 24px; max-width: 620px; }

.searchbar {
  display: flex; gap: 8px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 8px; box-shadow: var(--shadow); max-width: 640px;
}
.searchbar input {
  flex: 1; border: 0; background: transparent; font-size: 16px;
  color: var(--text); padding: 10px 12px; outline: none; min-width: 0;
}
.searchbar input::placeholder { color: var(--text-faint); }
.btn {
  border: 0; cursor: pointer; font-weight: 700; font-size: 15px;
  color: #fff; background: var(--brand); padding: 12px 20px;
  border-radius: var(--radius-sm); transition: background .15s;
}
.btn:hover { background: var(--brand-600); }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--border); }

/* Alphabet strip */
.alpha { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 18px; }
.alpha a {
  display: grid; place-items: center; min-width: 30px; height: 30px;
  border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--border);
}
.alpha a:hover { background: var(--brand); color: #fff; border-color: var(--brand);
  text-decoration: none; }

/* ---------- Layout ---------- */
main { padding: 32px 0 64px; }
.grid { display: grid; grid-template-columns: 1fr 300px; gap: 28px; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card + .card { margin-top: 20px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.card-body { padding: 20px; }

/* Section title tiles on home */
.tiles { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
@media (max-width: 760px) { .tiles { grid-template-columns: 1fr; } }
.tile { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.tile h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.tile h3 .ico { color: var(--brand); }
.linklist { list-style: none; margin: 0; padding: 0; }
.linklist li { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.linklist li:last-child { border-bottom: 0; }
.linklist a { color: var(--text); font-weight: 500; font-size: 14px; display: flex;
  justify-content: space-between; gap: 8px; }
.linklist a:hover { color: var(--brand); text-decoration: none; }
.linklist .muted { color: var(--text-faint); font-weight: 400; font-size: 12px; }

/* ---------- Breadcrumbs ---------- */
.crumbs { font-size: 13px; color: var(--text-muted); margin: 0 0 14px; display: flex;
  gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs a { color: var(--text-muted); }
.crumbs .sep { color: var(--text-faint); }

/* ---------- Page title block ---------- */
.page-title { margin: 0 0 4px; font-size: clamp(22px,3vw,30px); letter-spacing: -.02em; }
.subtitle { color: var(--text-muted); margin: 0 0 20px; }

/* Route summary chips (train page) */
.summary { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 22px; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 16px; box-shadow: var(--shadow-sm); }
.chip .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); font-weight: 700; }
.chip .v { font-size: 16px; font-weight: 700; }

/* Route line: from -> to */
.route-line { display: flex; align-items: center; gap: 14px; font-weight: 800;
  font-size: clamp(20px,3vw,26px); margin: 0 0 6px; letter-spacing: -.01em; }
.route-line .arrow { color: var(--brand); flex: none; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--brand-tint); color: var(--brand-700); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data thead th {
  position: sticky; top: 0; background: var(--surface-2);
  text-align: left; font-weight: 700; font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted); padding: 12px 14px;
  border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none;
}
table.data thead th.sort-asc::after { content: " ↑"; color: var(--brand); }
table.data thead th.sort-desc::after { content: " ↓"; color: var(--brand); }
table.data tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle; }
table.data tbody tr:hover { background: var(--brand-tint); }
table.data tbody tr:last-child td { border-bottom: 0; }
.t-num { font-weight: 800; color: var(--brand); white-space: nowrap; }
.t-time { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.t-time.dep { color: var(--accent); }
.t-station { font-weight: 600; }
.t-meta { color: var(--text-muted); font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }

/* Timeline for a single train's stops */
.stops { list-style: none; margin: 0; padding: 0; }
.stops li { display: grid; grid-template-columns: 84px 1fr 84px; gap: 12px;
  align-items: center; padding: 12px 4px; position: relative; }
.stops li:not(:last-child)::before {
  content: ""; position: absolute; left: 93px; top: 30px; bottom: -12px;
  width: 2px; background: var(--border-strong);
}
.stops .dot { justify-self: end; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--brand); position: relative; z-index: 1; }
.stops li:first-child .dot { border-color: var(--accent); }
.stops li:last-child .dot { border-color: var(--warn); }
.stops .name { font-weight: 600; }
.stops .arr { color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }
.stops .dep { color: var(--accent); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* Filter box above tables */
.filter { display: flex; gap: 10px; align-items: center; margin: 0 0 16px; }
.filter input { flex: 1; padding: 10px 14px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font-size: 14px; outline: none; }
.filter input:focus { border-color: var(--brand); }
.count { color: var(--text-faint); font-size: 13px; white-space: nowrap; }

/* Related links / tag cloud */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags a { background: var(--surface-2); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--text); }
.tags a:hover { background: var(--brand); color: #fff; border-color: var(--brand);
  text-decoration: none; }

/* Alphabetical index columns */
.cols { columns: 4 200px; column-gap: 24px; }
.cols a { display: block; padding: 5px 0; color: var(--text); break-inside: avoid; }
.cols a:hover { color: var(--brand); }

/* Sidebar */
.side .card-body { padding: 16px 20px; }
.side .linklist a { font-size: 13.5px; }
.notice { font-size: 13px; color: var(--text-muted); background: var(--surface-2);
  border: 1px solid var(--border); border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm); padding: 12px 14px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface);
  padding: 28px 0; color: var(--text-muted); font-size: 13px; margin-top: 40px; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: 16px;
  justify-content: space-between; align-items: center; }
.site-footer a { color: var(--text-muted); }

.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); font-weight: 800; margin: 28px 0 12px; }
