/* Swiss railway timetable look (SBB / ÖBB): white paper, one signal red, charcoal rules, flat marks. */

@font-face { font-family: "Public Sans"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("fonts/public-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("fonts/public-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("fonts/public-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("fonts/public-sans-latin-700-normal.woff2") format("woff2"); }

:root {
  --red: #E2001A;
  --red-dark: #B30015;
  --blue: #0C4DA2;
  --ink: #2D2D2D;
  --muted: #686868;
  --bar: #6B6B6B;
  --line: #D5D5D5;
  --panel: #F4F4F4;
  --gray-mid: #9A9A9A;
  --gray-light: #DCDCDC;
  --field-border: #767676;
  --font: "Public Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  border-top: 6px solid var(--red);
}

.wrap { max-width: 1200px; margin: 0 auto; padding-inline: 24px; }
@media (max-width: 640px) { .wrap { padding-inline: 16px; } }

a { color: var(--ink); text-underline-offset: 3px; }

:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 20;
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 2px;
}
.skip-link:focus { top: 8px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Masthead */
.masthead { border-bottom: 1px solid var(--line); }
.masthead-row {
  display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 4px 16px; padding-block: 16px 12px;
}
.wordmark { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.source { font-size: 14px; color: var(--muted); }

.title {
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 40px 0 16px;
}
.intro { max-width: 62ch; font-size: 18px; line-height: 1.5; margin: 0 0 32px; }

/* Filters */
.filters {
  display: grid;
  gap: 16px 24px;
  grid-template-columns: 1fr;
  background: var(--panel);
  padding: 20px;
  margin-bottom: 24px;
  border-radius: 2px;
}
@media (min-width: 56rem) {
  .filters { grid-template-columns: 1.15fr 1.1fr 1fr; align-items: start; }
}

.field { margin: 0; padding: 0; border: 0; min-width: 0; }
.field > label, .field > legend { display: block; padding: 0; margin: 0 0 8px; font-size: 14px; font-weight: 600; }

.control {
  display: block; width: 100%; min-height: 48px; padding: 8px 12px;
  background: #fff; color: var(--ink); font: inherit;
  border: 1px solid var(--field-border); border-radius: 2px;
}
input.control::placeholder { color: var(--muted); opacity: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 16px; font: inherit; font-weight: 600; font-size: 15px;
  background: #fff; color: var(--ink);
  border: 1px solid var(--field-border); border-radius: 999px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip:hover { border-color: var(--ink); }

/* Manufacturer menu */
.menu { position: relative; }
.menu-button {
  text-align: left; cursor: pointer; position: relative; padding-right: 40px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu-button::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  transform: translateY(-70%) rotate(45deg);
}
.menu-button[aria-expanded="true"]::after { transform: translateY(-30%) rotate(-135deg); }
.menu-panel {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid var(--ink); border-radius: 2px;
  padding: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.menu-panel[hidden] { display: none; }
.menu-list { list-style: none; margin: 8px 0; padding: 0; max-height: 264px; overflow-y: auto; }
.menu-list li { margin: 0; }
.menu-list label {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 4px; cursor: pointer;
}
.menu-list input { width: 20px; height: 20px; accent-color: var(--red); flex: none; }
.menu-list .n { margin-left: auto; color: var(--muted); font-size: 14px; }
.menu-empty { padding: 12px 4px; color: var(--muted); }
.link-button {
  background: none; border: 0; padding: 0 4px; min-height: 44px; font: inherit; font-weight: 600;
  color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

/* Notice: an alert strip, like a service message on a timetable */
.notice {
  border-left: 4px solid var(--red); background: var(--panel);
  padding: 12px 16px; font-size: 15px; line-height: 1.45; margin: 8px 0 16px;
}

/* Departure board: the headline numbers */
.board {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 3px solid var(--ink); border-bottom: 1px solid var(--line);
  margin: 8px 0 40px;
}
.cell { padding: 16px 20px 18px 0; }
.cell + .cell { padding-left: 20px; border-left: 1px solid var(--line); }
.num { font-size: clamp(36px, 5vw, 60px); line-height: 1; font-weight: 700; letter-spacing: -0.03em; }
.num.signal { color: var(--red); }
.cell-label { font-size: 14px; color: var(--muted); margin-top: 8px; line-height: 1.3; }
@media (max-width: 720px) {
  .board { grid-template-columns: repeat(2, 1fr); }
  .cell:nth-child(3) { padding-left: 0; border-left: 0; }
  .cell:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

/* Tabs */
.tabs {
  display: flex; gap: 28px; border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: thin;
}
.tabs [role="tab"] {
  flex: none; min-height: 48px; padding: 12px 0; background: transparent; border: 0;
  font: inherit; font-size: 17px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tabs [role="tab"]:hover, .tabs [role="tab"][aria-selected="true"] { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"] { box-shadow: inset 0 -4px 0 var(--red); }

[role="tabpanel"] { padding-bottom: 8px; }
[role="tabpanel"]:focus-visible { outline-offset: 4px; }

/* Headings and notes */
.h2 { font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; margin: 24px 0 4px; }
.h3 { font-size: 18px; line-height: 1.25; font-weight: 700; margin: 16px 0 2px; }
.note { font-size: 14px; line-height: 1.45; color: var(--muted); max-width: 70ch; margin: 0 0 12px; }

.pair { display: grid; gap: 0 48px; grid-template-columns: 1fr; }
@media (min-width: 56rem) { .pair { grid-template-columns: 1fr 1fr; } }
.pair > * { min-width: 0; }

/* Ranking: flat bars, values printed at the bar ends, the leader in red */
.rank { list-style: none; margin: 8px 0 0; padding: 0; }
.rank li {
  display: grid; grid-template-columns: minmax(6.5rem, 38%) minmax(0, 1fr);
  align-items: center; gap: 12px; min-height: 30px; font-size: 15px;
}
.rank .label { overflow-wrap: anywhere; padding-block: 3px; line-height: 1.25; }
.rank .track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rank .bar { flex: none; height: 18px; background: var(--bar); min-width: 2px; }
.rank .lead .bar { background: var(--red); }
.rank .val { font-weight: 600; white-space: nowrap; }

/* Columns: vertical bars for an ordered scale */
.cols {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; align-items: end;
  height: 260px; margin-top: 8px; border-bottom: 2px solid var(--ink);
}
.col { display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; text-align: center; }
.col .v { font-weight: 600; font-size: 15px; padding-bottom: 4px; }
.col .b { background: var(--bar); min-height: 2px; }
.col.peak .b { background: var(--red); }
.col-labels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 6px; text-align: center; font-size: 14px; }
.col-labels span { overflow-wrap: anywhere; }

/* Trend: one red line, one marker per model year */
.trend { width: 100%; }
.trend svg { display: block; width: 100%; height: auto; overflow: visible; }
.trend text { font-family: var(--font); font-variant-numeric: tabular-nums; }

/* Composition: one 100% bar */
.legend { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 4px 0 10px; font-size: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 12px; height: 12px; display: inline-block; flex: none; }
.comp { display: flex; height: 56px; }
.comp .seg {
  display: flex; align-items: center; justify-content: center; min-width: 0;
  font-size: 16px; font-weight: 600; box-shadow: inset -2px 0 0 #fff, inset 2px 0 0 #fff;
}
.comp-axis { position: relative; height: 24px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.comp-axis span { position: absolute; top: 0; transform: translateX(-50%); }
.comp-axis span:first-child { transform: none; }
.comp-axis span:last-child { transform: translateX(-100%); }

.picker { max-width: 22rem; margin: 4px 0 16px; }
.picker label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
select.control { appearance: auto; }

/* Data table */
.table-wrap {
  max-height: 560px; overflow: auto; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line);
  margin: 8px 0 16px;
}
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 8px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.data thead th { position: sticky; top: 0; background: #fff; padding: 0; border-bottom: 2px solid var(--ink); z-index: 1; }
table.data th button {
  width: 100%; min-height: 44px; padding: 0 12px; background: none; border: 0; font: inherit; font-weight: 600;
  text-align: left; cursor: pointer; color: var(--ink); display: flex; align-items: center; gap: 6px;
}
table.data th[aria-sort="ascending"] button::after { content: "↑"; color: var(--red); }
table.data th[aria-sort="descending"] button::after { content: "↓"; color: var(--red); }
table.data td.num-cell { text-align: right; }
.pbar {
  display: inline-block; min-width: 4.5rem; padding: 0 6px; text-align: right;
  background: linear-gradient(to right, var(--gray-light) var(--p), transparent var(--p));
}
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin: 8px 0 16px; }
.btn {
  min-height: 48px; padding: 0 24px; font: inherit; font-weight: 600; font-size: 16px;
  background: var(--red); color: #fff; border: 0; border-radius: 2px; cursor: pointer;
}
.btn:hover { background: var(--red-dark); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--ink); }
.btn.ghost:hover { background: var(--panel); }

/* Footer */
.footer {
  margin-top: 56px; padding: 16px 0 40px; border-top: 1px solid var(--line);
  font-size: 14px; line-height: 1.5; color: var(--muted);
}
.footer p { margin: 0 0 8px; max-width: 80ch; }
.footer a { color: var(--ink); }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
