/* =========================================================================
   Potegli design system — "хартиено разписание"
   Warm timetable paper, warm ink, signal red as the single brand accent,
   amber reserved for tight-connection warnings. Wix Madefor Display + Text
   (SIL OFL 1.1, self-hosted) with Bulgarian Cyrillic forms via lang="bg".
   NOTE: the --pine* custom properties are historical names; since v0.5 they
   carry the signal-red accent. Tokens → base → components → pages → motion.
   ========================================================================= */

@font-face {
  font-family: "Potegli Display";
  font-style: normal;
  font-display: swap;
  font-weight: 400 800;
  src: url("fonts/wix-madefor-display-cyrillic.woff2") format("woff2-variations");
}
@font-face {
  font-family: "Potegli Display";
  font-style: normal;
  font-display: swap;
  font-weight: 400 800;
  src: url("fonts/wix-madefor-display-latin.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122;
}
@font-face {
  font-family: "Potegli Text";
  font-style: normal;
  font-display: swap;
  font-weight: 400 800;
  src: url("fonts/wix-madefor-text-cyrillic.woff2") format("woff2-variations");
}
@font-face {
  font-family: "Potegli Text";
  font-style: normal;
  font-display: swap;
  font-weight: 400 800;
  src: url("fonts/wix-madefor-text-latin.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122;
}

/* ---------- Tokens ---------- */
:root {
  /* colour — warm timetable paper, warm ink, signal red accent */
  --canvas: #f3efe6;
  --surface: #fbf8f1;
  --surface-2: #ebe6d9;
  --field: #fffdf8;
  --ink: #1e1b14;
  --ink-2: #55503f;
  --ink-3: #6d6753;
  --rule: #ddd7c8;
  --rule-strong: #c6bfab;
  --field-border: #857e68; /* ≥3:1 against field and panel (WCAG 1.4.11) */
  --pine: #147a72;          /* signal red (historical var name) */
  --pine-strong: #0d5e58;
  --pine-tint: #dcf1ee;
  --pine-on: #ffffff;
  --amber: #e8734a;
  --amber-ink: #b8461f;
  --amber-tint: #fde4d8;
  --focus: #147a72;
  --shadow-panel: 0 1px 2px rgb(30 27 20 / .04), 0 16px 40px -24px rgb(30 27 20 / .25);
  --shadow-pop: 0 2px 6px rgb(30 27 20 / .06), 0 20px 48px -18px rgb(30 27 20 / .3);
  --shadow-card: none;

  /* illustration palette (original SVG fallbacks) */
  --tr-body: #efe9dc;
  --tr-outline: #97907c;
  --tr-band: #bc2f14;
  --tr-glass: #33302a;
  --tr-dark: #3a362c;
  --tr-hub: #a29b87;
  --tr-roof: #cdc5b1;
  --tr-seam: #ddd5c2;
  --tr-door: #e5ddca;
  --tr-grille: #cfc7b3;
  --tr-lamp: #e8b25a;

  /* type */
  --font: "Potegli Text", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --font-display: "Potegli Display", "Potegli Text", system-ui, sans-serif;
  --fs-xs: .78125rem;   /* 12.5 */
  --fs-sm: .875rem;     /* 14 */
  --fs-md: 1rem;        /* 16 */
  --fs-lg: 1.125rem;    /* 18 */
  --fs-xl: 1.375rem;    /* 22 */
  --fs-2xl: 1.875rem;   /* 30 */

  /* space (4 px grid) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* shape */
  --r-sm: 4px; --r-md: 8px; --r-lg: 12px; --r-pill: 999px;

  /* motion */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --fast: 140ms;
  --base: 220ms;

  --wrap: 1120px;
  --gutter: 16px;
  color-scheme: light;
}

:root[data-theme="dark"] {
    --canvas: #16130e;
    --surface: #1e1a14;
    --surface-2: #282318;
    --field: #14110c;
    --ink: #f1eadb;
    --ink-2: #c0b7a2;
    --ink-3: #99917c;
    --rule: #332e23;
    --rule-strong: #4a4433;
    --field-border: #6f6753;
    --pine: #5fc9bd;
    --pine-strong: #86dcd2;
    --pine-tint: #16332f;
    --pine-on: #062825;
    --amber: #f19169;
    --amber-ink: #f7ad8c;
    --amber-tint: #3a2016;
    --focus: #86dcd2;
    --shadow-panel: 0 1px 2px rgb(0 0 0 / .3), 0 12px 32px -18px rgb(0 0 0 / .7);
    --shadow-pop: 0 16px 40px -12px rgb(0 0 0 / .7);
    --shadow-card: none;
    --tr-body: #4a4433;
    --tr-outline: #8a8168;
    --tr-band: #ff8a68;
    --tr-glass: #100d08;
    --tr-dark: #5c5440;
    --tr-hub: #a89f87;
    --tr-roof: #6f6753;
    --tr-seam: #5c5440;
    --tr-door: #55503f;
    --tr-glass: #100d08;
    --tr-grille: #6f6753;
    --tr-lamp: #f0c882;
    color-scheme: dark;
}

@media (min-width: 640px) { :root { --gutter: 24px; } }
@media (min-width: 1024px) { :root { --gutter: 32px; } }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--ink);
  font: 400 var(--fs-md)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
main { flex: 1; outline: none; }
h1, h2, h3, p, ul, ol, dl, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--pine); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--pine-strong); text-decoration-thickness: 2px; }
strong { font-weight: 620; }
abbr[title] { text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--pine-tint); }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: var(--s4); top: -100px; z-index: 50; background: var(--ink); color: var(--canvas); padding: var(--s2) var(--s4); border-radius: var(--r-sm); }
.skip:focus { top: var(--s2); }
.muted { color: var(--ink-2); }
.small { font-size: var(--fs-sm); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: var(--fs-xs); overflow-wrap: anywhere; }

.eyebrow { font-size: var(--fs-sm); font-weight: 600; color: var(--pine); letter-spacing: .01em; }
.section-title { font-size: var(--fs-lg); font-weight: 650; letter-spacing: -.01em; }

.banner { background: var(--amber-ink); color: #fff; text-align: center; padding: var(--s2) var(--gutter); font-size: var(--fs-sm); }
[data-theme="dark"] .banner { color: #1b1208; background: var(--amber); }

/* ---------- Header / footer ---------- */
.site-header { border-bottom: 1px solid var(--rule); background: var(--canvas); }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand__mark { width: 30px; height: 30px; }
.brand__tile { fill: var(--pine); transition: fill var(--fast); }
.brand:hover .brand__tile { fill: var(--pine-strong); }
.brand__rail { fill: none; stroke: var(--canvas); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.brand__word { font-family: var(--font-display); font-size: 1.375rem; font-weight: 750; letter-spacing: -.015em; }
.site-nav { display: flex; align-items: center; gap: var(--s1); }
@media (max-width: 479px) { .site-nav a { padding: 10px 8px; } .site-nav a[href="/"] { display: none; } .brand__word { font-size: 1.125rem; } .theme-toggle { margin-left: 0; } }
.theme-toggle { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--ink-2); border-radius: var(--r-pill); margin-left: var(--s1); }
.theme-toggle:hover { background: var(--surface-2); color: var(--ink); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle__sun, [data-theme="dark"] .theme-toggle__moon { display: none; }
[data-theme="dark"] .theme-toggle__sun { display: block; }
.site-nav a {
  color: var(--ink-2); text-decoration: none; font-weight: 550; font-size: .9375rem; white-space: nowrap;
  padding: 10px 12px; border-radius: var(--r-sm); position: relative;
}
.site-nav a:hover { color: var(--ink); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 4px; height: 2px; border-radius: 2px; background: var(--pine);
}

.site-footer { border-top: 1px solid var(--rule); margin-top: var(--s6); padding: var(--s4) 0 var(--s5); color: var(--ink-2); font-size: var(--fs-sm); }
.site-footer__inner { display: grid; gap: var(--s2); }
.site-footer__fine { color: var(--ink-3); }
.site-footer__love { color: var(--ink-2); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--pine); margin-right: 6px; vertical-align: 1px; box-shadow: 0 0 0 3px var(--pine-tint); }
.dot--warn { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-tint); }

/* ---------- Buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 48px; padding: 0 var(--s5); border-radius: var(--r-md); border: 1px solid transparent;
  font-weight: 600; font-size: var(--fs-md); text-decoration: none; white-space: nowrap;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--pine); color: var(--pine-on); }
.btn--primary:hover { background: var(--pine-strong); color: var(--pine-on); text-decoration: none; }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--rule-strong); }
.btn--secondary:hover { border-color: var(--ink-3); color: var(--ink); text-decoration: none; }
.btn--quiet { background: transparent; color: var(--pine); min-height: 44px; padding: 0 var(--s3); }
.btn--quiet:hover { background: var(--pine-tint); text-decoration: none; }
.btn__spinner { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; }
.is-loading .btn__spinner { display: inline-block; animation: spin .7s linear infinite; }

.chip {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--s3);
  border: 1px solid var(--rule-strong); border-radius: var(--r-pill); background: var(--surface);
  color: var(--ink); text-decoration: none; font-size: var(--fs-sm); font-weight: 550;
}
.chip:hover { border-color: var(--pine); color: var(--pine); text-decoration: none; }

.flag {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 20px; white-space: nowrap;
}
.flag--tight { background: var(--amber-tint); color: var(--amber-ink); }
.flag--tight::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }

.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 22px; padding: 0 6px;
  border-radius: 5px; font-size: .75rem; font-weight: 700; letter-spacing: .02em; cursor: help;
  background: var(--surface-2); color: var(--ink);
}
.badge--bv { background: var(--pine); color: var(--pine-on); }
.badge--mbv { background: var(--ink); color: var(--canvas); }
.badge--kpv { background: var(--pine-tint); color: var(--pine-strong); }
.badge--unknown { background: transparent; border: 1px dashed var(--ink-3); }

/* ---------- Hero ---------- */
.hero { position: relative; padding: var(--s5) 0 0; }
.hero__inner { display: grid; gap: var(--s4); position: relative; z-index: 1; }
.hero__copy { max-width: 34rem; }
.hero__title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem); line-height: 1.05; font-weight: 760; letter-spacing: -.025em;
}
.hero__title em { font-style: normal; color: var(--pine); }
.hero__lede { margin-top: var(--s1); font-size: var(--fs-md); line-height: 1.5; color: var(--ink-2); max-width: 28rem; }
/* Hero strip: one traction drawing rides the page-wide rail, tail cropped by the edge. */
.hero__strip { position: relative; height: 76px; margin-top: var(--s4); overflow: hidden; border-bottom: 2px solid var(--ink); }
.hero__trainbox { position: absolute; bottom: 0; line-height: 0; }
.hero__trainbox--loco { right: var(--gutter); }
.hero__trainbox--long { left: var(--gutter); }
.hero__train { display: block; }
.hero__trainsvg { width: 420px; height: auto; }
@media (max-width: 700px) {
  .hero__strip { height: 72px; margin-top: var(--s4); }
  .hero__trainbox--loco { right: var(--gutter); }
  .hero__trainsvg { width: 320px; }
}

.hero--compact { padding: var(--s4) 0 0; }

/* ---------- Search panel ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-lg);
  padding: var(--s4); box-shadow: var(--shadow-panel);
}
@media (min-width: 640px) { .panel { padding: var(--s4) var(--s5); } }

.search { display: grid; gap: var(--s3); }
.search__form-error { color: var(--amber-ink); font-weight: 550; }
.search__route { position: relative; display: grid; gap: var(--s3); }
.field--station:first-child:not(.is-invalid) .field__control::after { /* dotted "track" joining the two pins */
  content: ""; position: absolute; left: 21px; top: calc(100% - 12px); height: 50px; border-left: 2px dotted var(--rule-strong); pointer-events: none;
}
.field--station:first-child .field__error, .field--station:first-child .suggest { padding-right: 52px; }
.combo:has(.combo__list:not([hidden]))::after, .combo:has(.combo__list:not([hidden])) .swap { visibility: hidden; }
.search__when { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--s3); align-items: start; }
.search__submit { grid-column: 1 / -1; min-height: 46px; font-size: var(--fs-md); }

.field { display: grid; gap: 6px; min-width: 0; }
.field__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.field__control { position: relative; min-width: 0; }
.field__input {
  width: 100%; height: 52px; padding: 0 var(--s4); border-radius: var(--r-md);
  border: 1px solid var(--field-border); background: var(--field); color: var(--ink);
  font-size: 1.0625rem; font-weight: 520; letter-spacing: -.005em;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
  -webkit-appearance: none; appearance: none;
}
.field__input::placeholder { color: var(--ink-3); font-weight: 400; }
.field__input:hover { border-color: var(--ink-2); }
.field__input:focus { outline: none; border-color: var(--pine); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pine) 22%, transparent); }
.is-invalid .field__input { border-color: var(--amber-ink); }
.is-invalid .field__input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 28%, transparent); }
.field__error { display: flex; gap: 6px; color: var(--amber-ink); font-size: var(--fs-sm); font-weight: 550; }
.field__error::before { content: "!"; flex: none; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-top: 2px; border-radius: 50%; background: var(--amber-ink); color: var(--surface); font-size: 11px; font-weight: 800; }
.field__error[hidden] { display: none; }
.field__icon { position: absolute; right: 14px; top: 50%; width: 20px; height: 20px; margin-top: -10px; fill: none; stroke: var(--ink-3); stroke-width: 1.6; stroke-linecap: round; pointer-events: none; }

.field--station .field__input { padding-left: 44px; padding-right: 52px; }
.field__pin { position: absolute; left: 16px; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; z-index: 1; pointer-events: none; }
.field__pin--from { background: var(--pine); box-shadow: 0 0 0 3px var(--pine-tint); }
.field__pin--to { border: 3px solid var(--pine); background: var(--field); }

.suggest { display: flex; flex-wrap: wrap; gap: var(--s2); }

.swap {
  position: absolute; right: 10px; top: calc(100% - 10px); z-index: 3;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--field-border); background: var(--surface);
  display: grid; place-items: center; color: var(--ink-2);
  transition: transform var(--base) var(--ease), border-color var(--fast), color var(--fast);
}
.swap svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.swap:hover { border-color: var(--pine); color: var(--pine); }
.swap.is-swapped { transform: rotate(180deg); }

.quick { display: inline-flex; gap: 2px; }
.quick__btn {
  border: 0; background: none; color: var(--pine); font-size: var(--fs-sm); font-weight: 600;
  padding: 4px 8px; margin: -4px -4px -4px 0; border-radius: var(--r-sm); min-height: 28px;
}
.quick__btn:hover { background: var(--pine-tint); }
.quick__btn[aria-pressed="true"] { color: var(--ink); background: var(--surface-2); }

/* Date: native control; with JS a Bulgarian face sits on top of it. */
.date__input { padding-right: 44px; min-width: 0; }
.date__input::-webkit-calendar-picker-indicator { opacity: 0; position: absolute; right: 0; width: 48px; height: 100%; cursor: pointer; }
.date__face { display: none; }
.js .date__face {
  display: flex; align-items: center; position: absolute; inset: 1px 44px 1px 1px; padding-left: 15px;
  background: var(--field); border-radius: var(--r-md) 0 0 var(--r-md); pointer-events: none;
  font-size: 1.0625rem; font-weight: 520; color: var(--ink); white-space: nowrap; overflow: hidden;
}
.js.kbd .date__input:focus + .date__face { display: none; }

/* Station combobox */
.combo__list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; max-height: 312px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-md); box-shadow: var(--shadow-pop);
  padding: 6px; overscroll-behavior: contain;
}
.combo__list[hidden] { display: none; }
.combo__option { display: flex; align-items: center; gap: var(--s3); min-height: 44px; padding: 0 var(--s3); border-radius: var(--r-sm); cursor: pointer; }
.combo__option::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--rule-strong); flex: none; }
.combo__option mark { background: none; color: inherit; font-weight: 700; }
.combo__option[aria-selected="true"], .combo__option:hover { background: var(--pine-tint); }
.combo__option[aria-selected="true"]::before { border-color: var(--pine); background: var(--pine); }
.combo__empty { padding: var(--s3); color: var(--ink-3); font-size: var(--fs-sm); }

/* One-row search on wide screens (home and results) */
@media (min-width: 1024px) {
  .search--row { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; gap: var(--s3); }
  .search--row .search__route { grid-template-columns: 1fr 1fr; column-gap: var(--s3); }
  .search--row .field--station:first-child .field__control::after { display: none; }
  .search--row .swap { right: -26px; top: 6px; width: 40px; height: 40px; }
  .search--row .field--station:first-child .field__error { padding-right: 0; }
  .search--row .search__when { grid-template-columns: minmax(0, 1.2fr) minmax(0, .9fr) auto; }
  .search--row .search__submit { grid-column: auto; margin-top: 26px; padding: 0 var(--s5); font-size: var(--fs-md); }
  .search--results .quick { display: none; }
  .search--row .field--station:last-child .field__input { padding-left: 48px; }
}
.results__arrow, .route-link__arrow {
  display: inline-block; flex: none; width: 18px; height: 2px; background: currentColor; position: relative; vertical-align: middle; opacity: .55;
}
.results__arrow::after, .route-link__arrow::after {
  content: ""; position: absolute; right: -1px; top: -3px; width: 7px; height: 7px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg);
}
.js .page-results .panel.is-collapsed { display: none; }

/* ---------- Home: popular routes ---------- */
.popular { margin-top: var(--s5); display: grid; gap: var(--s1); }
.popular .section-title { color: var(--ink-3); font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .08em; }
.popular__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 0 var(--s6); }
.route-link {
  display: flex; align-items: center; gap: var(--s3); min-height: 44px;
  border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none;
  font-family: var(--font-display); font-weight: 620; font-size: .9375rem;
  transition: color var(--fast) var(--ease);
}
.route-link:hover { color: var(--pine); text-decoration: none; }
.route-link__arrow {
  display: inline-block; flex: none; width: 18px; height: 2px; background: var(--pine); position: relative;
  transition: transform var(--fast) var(--ease);
}
.route-link__arrow::after {
  content: ""; position: absolute; right: -1px; top: -3px; width: 7px; height: 7px;
  border-top: 2px solid var(--pine); border-right: 2px solid var(--pine); transform: rotate(45deg);
}
.route-link:hover .route-link__arrow { transform: translateX(4px); }

/* ---------- Results ---------- */
.results { margin-top: var(--s5); }
.results > * { max-width: 680px; }
.results__head { display: grid; gap: var(--s1); justify-items: start; }
.results__edit { margin-top: var(--s3); min-height: 44px; }
.hero--compact + .results { margin-top: var(--s5); }
.results__title { font-family: var(--font-display); font-size: clamp(1.375rem, 1.1rem + 1vw, 1.75rem); line-height: 1.08; font-weight: 760; letter-spacing: -.02em; display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--s3); }
.results__arrow { width: 26px; height: 2.5px; opacity: .4; }
.results__meta { color: var(--ink-2); }
.journeys { display: grid; gap: var(--s3); margin-top: var(--s3); }
.results__more { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s5); }
[aria-busy="true"] .journeys { opacity: .45; transition: opacity var(--base); }

/* Journey card */
.jc { background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-lg); overflow: hidden; transition: border-color var(--fast) var(--ease); }
.jc:hover { border-color: var(--ink-3); }
.site-header { background: var(--surface); }
.jc__top { display: grid; grid-template-columns: minmax(0, max-content) minmax(88px, 1fr); column-gap: var(--s4); row-gap: 2px; align-items: start; padding: var(--s3) var(--s4); }
@media (min-width: 640px) { .jc__top { padding: var(--s4) var(--s5) var(--s3); column-gap: var(--s5); } }
.jc__headline { display: grid; gap: 2px; }
.jc__to { color: var(--ink); }
.jc__times { display: flex; align-items: baseline; gap: 2px; font-family: var(--font-display); font-size: 1.5rem; line-height: 1.05; font-weight: 720; letter-spacing: -.015em; }
@media (max-width: 359px) { .jc__times { font-size: 1.3125rem; } }
.plusday { font-size: .5em; font-weight: 700; color: var(--amber-ink); vertical-align: super; margin-left: 2px; letter-spacing: 0; }
.jc__facts { color: var(--ink-2); font-size: var(--fs-sm); }

/* Traction art: a wide train riding the rail line, full card width, SJ-style. */
.jc__headline, .jc__consist { grid-column: 1; }
/* Trains sit top-right; the strip bleeds to the card edge, which crops the tail. */
.jc__art { grid-column: 2; grid-row: 1 / span 2; align-self: center; position: relative; height: 60px; overflow: hidden; margin-right: calc(-1 * var(--s4)); }
@media (min-width: 640px) { .jc__art { margin-right: calc(-1 * var(--s5)); } }
.jc__art-row { position: absolute; bottom: 0; left: 0; display: flex; align-items: flex-end; gap: 24px; }
/* Short locomotives hug the right edge with the tail cropped; long units keep their nose in view. */
.jc__art:not(:has(.drawing--long)) .jc__art-row { left: auto; right: -28px; }
.jc__art .drawing { flex: none; }
.jc__art .drawing img { display: block; }
.jc__art-row > img { display: block; }
.jc__art .tr { flex: none; height: 56px; width: auto; }
.jc__consist { margin-top: 2px; color: var(--ink-2); font-size: var(--fs-sm); }
.leg__art .drawing { max-width: 100%; justify-content: flex-end; display: flex; }
.leg__art .drawing img { max-height: 44px; max-width: 100%; width: auto; height: auto; }

.tr { overflow: visible; }
.tr-body { fill: var(--tr-body); stroke: var(--tr-outline); stroke-width: .8; }
.tr-band { fill: var(--tr-band); }
.tr-body-line { fill: var(--tr-body); opacity: .85; }
.tr-glass { fill: var(--tr-glass); }
.tr-dark { fill: var(--tr-dark); }
.tr-hub { fill: var(--tr-hub); }
.tr-roof { fill: var(--tr-roof); }
.tr-seam { fill: none; stroke: var(--tr-outline); stroke-width: .8; opacity: .8; }
.tr-door { fill: var(--tr-door); stroke: var(--tr-outline); stroke-width: .6; }
.tr-grille { fill: var(--tr-outline); opacity: .55; }
.tr-lamp { fill: var(--tr-lamp); }
.tr-wire { fill: none; stroke: var(--tr-dark); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Details */
.jc__details { border-top: 1px solid var(--rule); }
.jc__details > summary {
  display: flex; align-items: center; gap: var(--s3); min-height: 40px; padding: 0 var(--s4); cursor: pointer; list-style: none;
  font-weight: 600; font-size: .9375rem; color: var(--ink);
}
.jc__details > summary::-webkit-details-marker { display: none; }
.jc__details > summary::after {
  content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2);
  transform: translateY(-2px) rotate(45deg); transition: transform var(--base) var(--ease);
}
.jc__details[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.jc__details > summary:hover { background: var(--surface-2); }
@media (min-width: 640px) { .jc__details > summary { padding: 0 var(--s5); } }
.jc__details[open] > .legs { animation: reveal var(--base) var(--ease); }

.legs { display: grid; gap: var(--s3); padding: var(--s2) var(--s4) var(--s4); }
@media (min-width: 640px) { .legs { padding: var(--s2) var(--s5) var(--s5); } }
.leg { display: grid; gap: var(--s3); }
.leg__head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); }
.leg__train { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.leg__number { font-family: var(--font-display); font-weight: 730; font-size: 1.1875rem; }
.leg__dir { color: var(--ink-2); font-size: var(--fs-sm); }
.leg__art { flex: 0 1 auto; min-width: 0; max-width: 50%; }
.leg__art .tr { width: 132px; height: auto; display: block; margin-left: auto; }

.stops { position: relative; display: grid; padding-left: 26px; }
.stops::before { content: ""; position: absolute; left: 7px; top: 12px; bottom: 12px; width: 2px; background: var(--pine); }
.stop { position: relative; display: flex; gap: var(--s3); align-items: baseline; padding: 3px 0; font-size: var(--fs-sm); color: var(--ink-2); }
.stop::before { content: ""; position: absolute; left: -22px; top: 50%; margin-top: -3px; width: 6px; height: 6px; border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 2px var(--pine); }
.stop time { min-width: 3.4em; color: var(--ink-3); }
.stop--end { font-size: var(--fs-md); font-weight: 600; color: var(--ink); padding: 5px 0; }
.stop--end time { color: var(--ink); font-weight: 650; }
.stop--end::before { left: -24px; margin-top: -5px; width: 10px; height: 10px; box-shadow: 0 0 0 3px var(--pine); }
.between { border-left: 3px solid var(--rule-strong); background: var(--surface-2); border-radius: 0 var(--r-sm) var(--r-sm) 0; padding: 10px var(--s3); font-size: .9375rem; }
.between__sub { color: var(--ink-2); font-size: var(--fs-sm); margin-top: 2px; }
.between--tight { border-left-color: var(--amber); background: var(--amber-tint); }
.between--tight strong { color: var(--amber-ink); }
.between--relaxed, .between--normal { border-left-color: var(--ink-3); }
.between--stay { border-left-color: var(--pine); background: var(--pine-tint); }

/* ---------- States ---------- */
.state { margin-top: var(--s5); padding: var(--s5); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); display: grid; gap: var(--s3); max-width: 640px; }
.state__title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 720; letter-spacing: -.01em; line-height: 1.2; }
.state p { color: var(--ink-2); }
.state__actions { margin-top: var(--s2); display: flex; flex-wrap: wrap; gap: var(--s2); }
.state--page { margin: var(--s7) auto 0; background: none; border: 0; text-align: left; }
.state__art .tr { width: min(100%, 360px); height: auto; margin-top: var(--s4); }

/* ---------- Data page ---------- */
.doc { max-width: 820px; padding-top: var(--s7); }
.doc__title { font-family: var(--font-display); font-size: clamp(2.25rem, 1.6rem + 2.6vw, 3.25rem); font-weight: 770; letter-spacing: -.025em; line-height: 1.0; margin-top: var(--s2); }
.doc__lede { margin-top: var(--s3); font-size: var(--fs-lg); color: var(--ink-2); max-width: 36rem; }
.doc__section { margin-top: var(--s7); display: grid; gap: var(--s4); }
.doc__section > p { color: var(--ink-2); max-width: 40rem; }
.doc__section > p strong { color: var(--ink); }

.status { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: var(--s4) var(--s5); display: grid; gap: var(--s4); }
.status__main { display: flex; gap: var(--s3); align-items: baseline; }
.status__title { font-weight: 650; font-size: var(--fs-lg); }
.status__sub { color: var(--ink-2); }
.status__facts { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-top: 1px solid var(--rule); padding-top: var(--s4); }
.status__facts dt, .facts dt { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 600; }
.status__facts dd, .facts dd { margin: 0; font-weight: 520; }

.legend { display: grid; gap: var(--s4); }
.legend li { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: var(--s4); align-items: center; }
.legend p { color: var(--ink-2); font-size: .9375rem; }
.legend p strong { color: var(--ink); }
.legend__visual { display: flex; }
.legend__stay { font-size: var(--fs-xs); font-weight: 650; color: var(--pine-strong); background: var(--pine-tint); border-left: 3px solid var(--pine); padding: 2px 8px; border-radius: 0 4px 4px 0; }
@media (max-width: 519px) { .legend li { grid-template-columns: 1fr; gap: var(--s2); } }

.art-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.art-grid figure { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); padding: var(--s3) var(--s3) 0; display: grid; gap: var(--s2); overflow: hidden; }
.art-grid .tr { width: 100%; height: auto; display: block; margin-bottom: -2px; }
.art-grid figcaption { font-size: var(--fs-xs); color: var(--ink-2); font-weight: 600; }
@media (max-width: 519px) { .art-grid { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th, .table td { text-align: left; padding: 10px var(--s3); border-bottom: 1px solid var(--rule); vertical-align: top; }
.table thead th { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 650; background: var(--surface-2); }
.table tbody tr:last-child > * { border-bottom: 0; }
.status-pill { display: inline-block; font-size: .75rem; font-weight: 650; padding: 1px 8px; border-radius: var(--r-pill); white-space: nowrap; }
.status-pill--candidate, .status-pill--confirmed { background: var(--pine-tint); color: var(--pine-strong); }
.status-pill--conflicting, .status-pill--unresolved { background: var(--amber-tint); color: var(--amber-ink); }

.plain-list { display: grid; gap: var(--s2); color: var(--ink-2); }
.plain-list li { padding-left: var(--s4); position: relative; }
.plain-list li::before { content: ""; position: absolute; left: 0; top: .65em; width: 6px; height: 6px; border-radius: 50%; background: var(--pine); }
.plain-list strong { color: var(--ink); }
.facts { display: grid; gap: var(--s3); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); padding: var(--s4); }
@media (min-width: 640px) { .facts > div { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: var(--s4); } }

/* ---------- Motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes hero-in { from { transform: translateX(min(32vw, 280px)); } to { transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .js [data-reveal] { animation: reveal 320ms var(--ease) both; }
  .journeys > li:nth-child(2) [data-reveal] { animation-delay: 40ms; }
  .journeys > li:nth-child(3) [data-reveal] { animation-delay: 80ms; }
  .journeys > li:nth-child(4) [data-reveal] { animation-delay: 120ms; }
  .journeys > li:nth-child(5) [data-reveal] { animation-delay: 160ms; }
  .journeys > li:nth-child(6) [data-reveal] { animation-delay: 200ms; }
  .js .hero__trainbox { animation: hero-in 950ms cubic-bezier(.16, .8, .3, 1) 120ms both; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

@media print {
  .site-header, .site-footer, .hero, .results__more, .jc__art, .jc__rail { display: none; }
  .jc__details > * { display: block; }
}
@media (max-width: 559px) { .jc__art-train { display: none; } }
