#030 style light mobile: native-first Transit & Signage

Swiss Railway Timetable

Precision Swiss Federal Railways departure board, live Mondaine station clock, SBB red accents, and tabular schedules.

Inspired by SBB Digital Design System ↗

Download .html
Fullscreen ↗

WHY THIS AESTHETIC IS UNIQUE

Combines the iconic Swiss Railway clock (complete with its signature red paddle second hand) with ultra-scannable tabular departure boards and zero visual ambiguity.

BEST FOR

Real-time transit & flight dashboardsScheduling & logistics toolsPublic-sector design systemsOperational status boards

TAGS

COLOR PALETTE (CLICK TO COPY HEX)

TYPOGRAPHY

Display
Inter
Body
Inter
Mono
IBM Plex Mono
Scale
Strict tabular numerals for departure times and platform numbers, high-contrast bold destination names, and SBB red line badges.

Google Fonts Stylesheet ↗

ARCHITECTURE & MOBILE NOTES

LAYOUT

Top station header featuring a live SVG Swiss Railway clock, interactive line/destination filter bar, high-contrast departure table, and slide-down train composition detail panel.

INTERACTION

Live ticking Mondaine-style SVG clock, interactive platform/train-type filters (IC, IR, S-Bahn), and clickable departure rows revealing stop-by-stop schedules and occupancy bars.

MOBILE

Transforms the departure table into clean scannable rail cards at 390px with >=44px row targets and a compact header clock.

AI AGENT GUARDRAILS

DO

  • Enforce tabular-nums on every time, delay (+2'), and track number for vertical alignment.
  • Use SBB Signal Red (#EB0000) strictly for train badges, clock paddle, and active delay alerts.
  • Prioritize immediate glanceability over decorative flourishes.

DON'T

  • Never use low-contrast gray text for critical departure times or platform numbers.
  • Avoid sluggish animations that obscure live schedule updates.
STANDALONE SOURCE · demos/swiss-railway-timetable.html (32.3 KB)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SBB CFF FFS — Zürich HB Live Departure Board</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@500;600&family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<style>
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  :root {
    --sbb-red: #eb0000;
    --sbb-red-dark: #c60018;
    --white: #ffffff;
    --cloud: #f4f5f7;
    --slate-line: #d8dde6;
    --board-bg: #152238;
    --board-row: #1c2c47;
    --board-hover: #243758;
    --board-line: #2d4266;
    --ink: #111827;
    --muted: #5a6577;
    --amber: #f5b700;
    --ok: #16a34a;
    --font-sans: 'Inter', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  }
  html, body {
    background: var(--cloud);
    color: var(--ink);
    font-family: var(--font-sans);
    line-height: 1.45;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
  }

  /* SBB Top Header */
  header {
    background: var(--white);
    border-bottom: 1px solid var(--slate-line);
    position: sticky;
    top: 0;
    z-index: 35;
  }
  .header-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .sbb-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--ink);
  }
  .sbb-flag {
    width: 46px;
    height: 24px;
    background: var(--sbb-red);
    display: grid;
    place-items: center;
    flex-shrink: 0;
  }
  .sbb-brand-text {
    font-weight: 800;
    font-size: 0.92rem;
    letter-spacing: 0.04em;
  }
  .sbb-brand-text span {
    display: block;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.02em;
  }
  .nav-links {
    display: none;
    list-style: none;
    gap: 24px;
  }
  .nav-links a {
    text-decoration: none;
    color: var(--ink);
    font-size: 0.84rem;
    font-weight: 600;
    padding: 10px 0;
    border-bottom: 2px solid transparent;
  }
  .nav-links a:hover { border-bottom-color: var(--sbb-red); }
  .menu-btn {
    min-width: 44px;
    min-height: 44px;
    border: 1px solid var(--slate-line);
    background: var(--white);
    color: var(--ink);
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.78rem;
    padding: 0 12px;
    cursor: pointer;
  }
  .mobile-nav {
    display: none;
    flex-direction: column;
    background: var(--white);
    border-bottom: 1px solid var(--slate-line);
    padding: 4px 20px 12px;
  }
  .mobile-nav.open { display: flex; }
  .mobile-nav a {
    min-height: 44px;
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--ink);
    font-weight: 600;
    font-size: 0.88rem;
    border-top: 1px solid var(--slate-line);
  }

  /* Main Container */
  .page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 16px 72px;
  }

  /* Station Hero + Live Mondaine Railway Clock */
  .station-hero {
    background: var(--white);
    border: 1px solid var(--slate-line);
    border-top: 4px solid var(--sbb-red);
    padding: 22px 20px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    align-items: center;
    margin-bottom: 24px;
  }
  .station-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--sbb-red);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
  }
  .live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sbb-red);
  }
  h1 {
    font-size: clamp(1.85rem, 4.8vw, 2.85rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.06;
    margin-bottom: 8px;
  }
  .station-sub {
    color: var(--muted);
    font-size: 0.94rem;
    max-width: 52ch;
    margin-bottom: 16px;
  }
  .kpi-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--slate-line);
  }
  .kpi span {
    display: block;
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .kpi strong {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
  }

  /* Clock Card */
  .clock-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--cloud);
    border: 1px solid var(--slate-line);
    padding: 18px 16px;
  }
  #sbbClock {
    width: 176px;
    height: 176px;
    display: block;
  }
  .clock-readout {
    margin-top: 12px;
    text-align: center;
  }
  .digital-time {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
  }
  .clock-note {
    display: block;
    font-size: 0.68rem;
    color: var(--muted);
    margin-top: 2px;
  }
  .clock-note.pausing { color: var(--sbb-red); font-weight: 600; }

  /* Filter Toolbar */
  .controls-bar {
    background: var(--white);
    border: 1px solid var(--slate-line);
    padding: 16px;
    margin-bottom: 18px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .search-input, .platform-select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1.5px solid #aeb7c4;
    background: var(--white);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
  }
  .search-input:focus, .platform-select:focus {
    outline: 2px solid var(--sbb-red);
    border-color: var(--sbb-red);
  }
  .cat-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .cat-btn {
    min-height: 44px;
    padding: 0 14px;
    border: 1.5px solid var(--slate-line);
    background: var(--cloud);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.14s;
  }
  .cat-btn.active {
    background: var(--sbb-red);
    border-color: var(--sbb-red);
    color: var(--white);
  }

  /* Industrial Slate Departure Board */
  .board {
    background: var(--board-bg);
    color: var(--white);
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 14px 36px rgba(15, 25, 42, 0.16);
  }
  .board-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    background: #0f192b;
    border-bottom: 2px solid var(--sbb-red);
  }
  .board-title {
    font-weight: 800;
    font-size: 0.92rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .board-count {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: #9bb0cf;
  }

  .board-cols {
    display: none;
    grid-template-columns: 76px 90px 1fr 120px 84px 110px;
    gap: 12px;
    padding: 10px 18px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8fa6c9;
    border-bottom: 1px solid var(--board-line);
  }

  .dep-list {
    display: flex;
    flex-direction: column;
  }
  .dep-row {
    width: 100%;
    min-height: 70px;
    padding: 14px 16px;
    background: var(--board-row);
    border: none;
    border-bottom: 1px solid var(--board-line);
    color: var(--white);
    font-family: var(--font-sans);
    text-align: left;
    cursor: pointer;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    grid-template-areas:
      "time dest plat"
      "cat via status";
    gap: 6px 10px;
    align-items: center;
    transition: background 0.12s;
  }
  .dep-row:nth-child(even) { background: var(--board-bg); }
  .dep-row:hover { background: var(--board-hover); }

  .dep-time {
    grid-area: time;
    font-family: var(--font-mono);
    font-size: 1.08rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }
  .dep-cat {
    grid-area: cat;
  }
  .train-pill {
    display: inline-block;
    padding: 3px 7px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 2px;
    background: var(--sbb-red);
    color: var(--white);
  }
  .train-pill.ir { background: #ffffff; color: var(--sbb-red); }
  .train-pill.ec { background: #1d4ed8; color: var(--white); }
  .train-pill.sbahn { background: #334155; color: var(--white); }

  .dep-dest {
    grid-area: dest;
    font-size: 1.02rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .dep-via {
    grid-area: via;
    font-size: 0.74rem;
    color: #9cb0ce;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .dep-plat {
    grid-area: plat;
    justify-self: end;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 30px;
    padding: 0 8px;
    background: var(--white);
    color: var(--ink);
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.84rem;
    border-radius: 2px;
  }
  .dep-status {
    grid-area: status;
    justify-self: end;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    color: #4ade80;
  }
  .dep-status.delay { color: var(--amber); }

  .empty-state {
    padding: 36px 20px;
    text-align: center;
    color: #9bb0cf;
    font-size: 0.9rem;
  }

  /* Train Detail Slide-Over Drawer */
  .drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.56);
    z-index: 60;
    display: none;
    justify-content: flex-end;
  }
  .drawer-backdrop.open { display: flex; }
  .drawer {
    width: 100%;
    max-width: 440px;
    background: var(--white);
    color: var(--ink);
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: -12px 0 36px rgba(0,0,0,0.25);
  }
  .drawer-head {
    background: var(--board-bg);
    color: var(--white);
    padding: 18px 20px;
    border-bottom: 4px solid var(--sbb-red);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }
  .drawer-close {
    min-width: 44px;
    min-height: 44px;
    border: 1px solid rgba(255,255,255,0.3);
    background: transparent;
    color: var(--white);
    font-family: var(--font-sans);
    font-size: 1.2rem;
    cursor: pointer;
    flex-shrink: 0;
  }
  .drawer-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  .drawer-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    background: var(--cloud);
    border: 1px solid var(--slate-line);
    padding: 12px;
  }
  .drawer-meta span {
    display: block;
    font-size: 0.68rem;
    color: var(--muted);
    text-transform: uppercase;
  }
  .drawer-meta strong {
    font-family: var(--font-mono);
    font-size: 0.92rem;
  }

  /* Carriage Formation Strip */
  .formation-title {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 10px;
  }
  .formation-cars {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }
  .car-box {
    border: 1.5px solid var(--ink);
    padding: 8px 6px;
    text-align: center;
    background: var(--white);
    border-top: 4px solid var(--ink);
  }
  .car-box.first { border-top-color: var(--amber); }
  .car-box.bistro { border-top-color: var(--sbb-red); }
  .car-box strong {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.82rem;
  }
  .car-box span {
    font-size: 0.66rem;
    color: var(--muted);
  }

  /* Stopping Pattern Timeline */
  .stops-list {
    list-style: none;
    border-left: 2px solid var(--sbb-red);
    margin-left: 8px;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }
  .stops-list li {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
  }
  .stops-list li::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--white);
    border: 2.5px solid var(--sbb-red);
  }
  .stops-list li:first-child::before,
  .stops-list li:last-child::before {
    background: var(--sbb-red);
  }
  .stop-name { font-weight: 600; font-size: 0.92rem; }
  .stop-time { font-family: var(--font-mono); font-size: 0.84rem; color: var(--muted); }

  footer {
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px 16px 36px;
    border-top: 1px solid var(--slate-line);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.74rem;
    color: var(--muted);
  }

  @media (min-width: 780px) {
    .nav-links { display: flex; }
    .menu-btn { display: none; }
    .mobile-nav { display: none !important; }
    .station-hero { grid-template-columns: 1.4fr 0.75fr; padding: 28px 30px; }
    .controls-bar { grid-template-columns: 1.2fr 180px auto; align-items: center; }
    .board-cols { display: grid; }
    .dep-row {
      grid-template-columns: 76px 90px 1fr 120px 84px 110px;
      grid-template-areas: "time cat dest via plat status";
      padding: 14px 18px;
    }
    .dep-plat { justify-self: start; }
  }
</style>
</head>
<body>
<header>
  <div class="header-inner">
    <a href="#top" class="sbb-brand">
      <div class="sbb-flag" aria-hidden="true">
        <svg viewBox="0 0 46 24" width="38" height="20">
          <rect x="21" y="4" width="4" height="16" fill="#ffffff"/>
          <rect x="13" y="10" width="20" height="4" fill="#ffffff"/>
          <polygon points="4,12 11,5 15,5 10,10 15,10 15,14 10,14 15,19 11,19" fill="#ffffff"/>
          <polygon points="42,12 35,5 31,5 36,10 31,10 31,14 36,14 31,19 35,19" fill="#ffffff"/>
        </svg>
      </div>
      <div class="sbb-brand-text">
        SBB CFF FFS
        <span>Digital Timetable System</span>
      </div>
    </a>
    <nav>
      <ul class="nav-links">
        <li><a href="#station">Zürich HB</a></li>
        <li><a href="#departures">Departures</a></li>
        <li><a href="#info">Network Status</a></li>
      </ul>
    </nav>
    <button class="menu-btn" id="menuBtn" aria-expanded="false" aria-controls="mobileNav">Menu</button>
  </div>
  <div class="mobile-nav" id="mobileNav">
    <a href="#station">Station Clock &amp; Overview</a>
    <a href="#departures">Live Departure Board</a>
    <a href="#info">Network Operations</a>
  </div>
</header>

<main class="page" id="top">
  <section class="station-hero" id="station">
    <div>
      <div class="station-badge"><span class="live-dot"></span> Bahnhof Zürich HB &middot; Gleise 3–44</div>
      <h1>Abfahrt / Departures</h1>
      <p class="station-sub">
        Real-time Swiss Federal Railways timetable synchronized to the master impulse clock. Select any departure row to inspect stopping pattern, sector boarding, and carriage occupancy.
      </p>
      <div class="kpi-strip">
        <div class="kpi">
          <span>Punctuality</span>
          <strong>93.8%</strong>
        </div>
        <div class="kpi">
          <span>Active Tracks</span>
          <strong>26 / 26</strong>
        </div>
        <div class="kpi">
          <span>Sync Cycle</span>
          <strong>58.5s + 1.5s</strong>
        </div>
      </div>
    </div>

    <!-- Live Ticking Mondaine-Style Swiss Railway Clock -->
    <div class="clock-card">
      <svg id="sbbClock" viewBox="0 0 200 200" role="img" aria-label="Live ticking Swiss Railway Station Clock">
        <!-- Brushed Aluminum Rim -->
        <circle cx="100" cy="100" r="96" fill="#d8dde4" stroke="#9aa3b2" stroke-width="2"/>
        <circle cx="100" cy="100" r="89" fill="#ffffff" stroke="#e2e6ec" stroke-width="1"/>
        <!-- Hour & Minute Baton Markers (populated by JS) -->
        <g id="clockMarkers"></g>
        <!-- Hour Hand -->
        <g id="sbbHour" transform="translate(100,100)">
          <polygon points="-4.5,18 4.5,18 3.6,-52 -3.6,-52" fill="#111827"/>
        </g>
        <!-- Minute Hand -->
        <g id="sbbMin" transform="translate(100,100)">
          <polygon points="-3.6,20 3.6,20 2.6,-76 -2.6,-76" fill="#111827"/>
        </g>
        <!-- Iconic Pausing Red Paddle Second Hand -->
        <g id="sbbSec" transform="translate(100,100)">
          <rect x="-1.4" y="-58" width="2.8" height="82" fill="#eb0000"/>
          <circle cx="0" cy="-58" r="7.2" fill="#eb0000"/>
          <circle cx="0" cy="0" r="3.4" fill="#eb0000"/>
        </g>
      </svg>
      <div class="clock-readout">
        <div class="digital-time" id="digitalTime">12:00:00</div>
        <span class="clock-note" id="clockPhase">Continuous sweep (58.5s)</span>
      </div>
    </div>
  </section>

  <!-- Filter & Search Controls -->
  <section class="controls-bar" id="departures" aria-label="Departure Board Filters">
    <input type="search" id="destSearch" class="search-input" placeholder="Filter destination, via stop, or train (e.g. Bern, Basel, IC 1)…" aria-label="Search destination or train">
    <select id="platformSelect" class="platform-select" aria-label="Filter by platform">
      <option value="all">All Platforms (Gleise)</option>
      <option value="4">Gleis 4</option>
      <option value="7">Gleis 7</option>
      <option value="9">Gleis 9</option>
      <option value="12">Gleis 12</option>
      <option value="16">Gleis 16</option>
      <option value="31">Gleis 31</option>
      <option value="33">Gleis 33</option>
    </select>
    <div class="cat-filters" role="group" aria-label="Train Category Filter">
      <button type="button" class="cat-btn active" data-cat="all">All</button>
      <button type="button" class="cat-btn" data-cat="IC">IC</button>
      <button type="button" class="cat-btn" data-cat="IR">IR</button>
      <button type="button" class="cat-btn" data-cat="EC">EC</button>
      <button type="button" class="cat-btn" data-cat="S">S-Bahn</button>
    </div>
  </section>

  <!-- Live Departure Board -->
  <section class="board" aria-label="Live Train Departures">
    <div class="board-head">
      <span class="board-title">Zürich HB &middot; Next Departures</span>
      <span class="board-count" id="boardCount">8 TRAINS SHOWN</span>
    </div>
    <div class="board-cols" aria-hidden="true">
      <span>Dep.</span>
      <span>Train</span>
      <span>Destination</span>
      <span>Via</span>
      <span>Gleis</span>
      <span style="text-align:right">Status</span>
    </div>
    <div class="dep-list" id="depList"></div>
  </section>
</main>

<!-- Train Detail Drawer -->
<div class="drawer-backdrop" id="drawerBackdrop" role="dialog" aria-modal="true" aria-labelledby="drawerTitle">
  <div class="drawer">
    <div class="drawer-head">
      <div>
        <div id="drawerTrainPill" style="margin-bottom:6px;"></div>
        <h2 id="drawerTitle" style="font-size:1.35rem;font-weight:800;line-height:1.15;">Genève-Aéroport</h2>
        <p id="drawerSub" style="font-size:0.8rem;color:#a8bddc;margin-top:4px;">Direct InterCity Service</p>
      </div>
      <button type="button" class="drawer-close" id="drawerClose" aria-label="Close train details">&times;</button>
    </div>
    <div class="drawer-body">
      <div class="drawer-meta">
        <div><span>Departure</span><strong id="dTime">14:02</strong></div>
        <div><span>Platform</span><strong id="dPlat">Gleis 31</strong></div>
        <div><span>Sector</span><strong id="dSector">A – D</strong></div>
      </div>

      <div>
        <p class="formation-title">Carriage Formation &amp; Occupancy</p>
        <div class="formation-cars" id="dFormation"></div>
      </div>

      <div>
        <p class="formation-title">Stopping Pattern</p>
        <ul class="stops-list" id="dStops"></ul>
      </div>
    </div>
  </div>
</div>

<footer id="info">
  <span>SBB CFF FFS &middot; SWISS FEDERAL RAILWAYS INDUSTRIAL SIGNAGE</span>
  <span>HANS HILFIKER CLOCK SYSTEM (1944)</span>
</footer>

<script>
(function () {
  // Mobile Nav
  const menuBtn = document.getElementById('menuBtn');
  const mobileNav = document.getElementById('mobileNav');
  menuBtn.addEventListener('click', () => {
    const open = mobileNav.classList.toggle('open');
    menuBtn.setAttribute('aria-expanded', String(open));
  });
  mobileNav.querySelectorAll('a').forEach(a => a.addEventListener('click', () => {
    mobileNav.classList.remove('open');
    menuBtn.setAttribute('aria-expanded', 'false');
  }));

  // Build Swiss Railway Clock Baton Markers
  const markers = document.getElementById('clockMarkers');
  const ns = 'http://www.w3.org/2000/svg';
  for (let i = 0; i < 60; i++) {
    const isHour = i % 5 === 0;
    const rect = document.createElementNS(ns, 'rect');
    rect.setAttribute('x', isHour ? '-2.8' : '-1.1');
    rect.setAttribute('y', isHour ? '-82' : '-82');
    rect.setAttribute('width', isHour ? '5.6' : '2.2');
    rect.setAttribute('height', isHour ? '20' : '7');
    rect.setAttribute('fill', '#111827');
    rect.setAttribute('transform', `translate(100,100) rotate(${i * 6})`);
    markers.appendChild(rect);
  }

  // Authentic Swiss Railway Clock Loop (58.5s sweep + 1.5s pause at 12 o'clock)
  const sbbHour = document.getElementById('sbbHour');
  const sbbMin = document.getElementById('sbbMin');
  const sbbSec = document.getElementById('sbbSec');
  const digitalTime = document.getElementById('digitalTime');
  const clockPhase = document.getElementById('clockPhase');

  function pad(n) { return String(n).padStart(2, '0'); }

  function updateClock() {
    const now = new Date();
    const h = now.getHours();
    const m = now.getMinutes();
    const s = now.getSeconds();
    const ms = now.getMilliseconds();
    const exactSec = s + ms / 1000;

    // Complete 360 deg in 58.5s, pause at 0 deg from 58.5s to 60.0s
    let secDeg;
    const isPausing = exactSec >= 58.5;
    if (isPausing) {
      secDeg = 0;
    } else {
      secDeg = (exactSec / 58.5) * 360;
    }

    // Minute hand snaps cleanly at each minute impulse
    const minDeg = m * 6;
    const hourDeg = ((h % 12) + m / 60) * 30;

    sbbSec.setAttribute('transform', `translate(100,100) rotate(${secDeg.toFixed(2)})`);
    sbbMin.setAttribute('transform', `translate(100,100) rotate(${minDeg.toFixed(1)})`);
    sbbHour.setAttribute('transform', `translate(100,100) rotate(${hourDeg.toFixed(2)})`);

    digitalTime.textContent = `${pad(h)}:${pad(m)}:${pad(s)}`;
    clockPhase.textContent = isPausing ? 'Synchronization pause at 12:00 (1.5s)' : 'Continuous sweep (58.5s cycle)';
    clockPhase.classList.toggle('pausing', isPausing);

    requestAnimationFrame(updateClock);
  }
  requestAnimationFrame(updateClock);

  // Timetable Dataset (dynamically offset from current local minute for live realism)
  const baseDate = new Date();
  function fmtOffset(mins) {
    const d = new Date(baseDate.getTime() + mins * 60000);
    return `${pad(d.getHours())}:${pad(d.getMinutes())}`;
  }

  const departures = [
    {
      id: 'ic1', cat: 'IC', num: 'IC 1', pillCls: '',
      dest: 'Genève-Aéroport', via: 'Bern – Fribourg – Lausanne',
      offset: 4, plat: '31', sector: 'A – D', status: 'On time', delay: false,
      note: 'Double-deck FV-Dosto · Restaurant open',
      cars: [
        { cls: 'first', label: '1st Cl.', occ: 'Low' },
        { cls: 'bistro', label: 'Bistro', occ: 'Open' },
        { cls: '', label: '2nd Cl.', occ: 'Medium' },
        { cls: '', label: '2nd Cl.', occ: 'Low' }
      ],
      stops: [
        { name: 'Zürich HB', off: 4 },
        { name: 'Bern', off: 60 },
        { name: 'Fribourg/Freiburg', off: 82 },
        { name: 'Lausanne', off: 126 },
        { name: 'Genève', off: 162 },
        { name: 'Genève-Aéroport', off: 170 }
      ]
    },
    {
      id: 'ir36', cat: 'IR', num: 'IR 36', pillCls: 'ir',
      dest: 'Basel SBB', via: 'Baden – Brugg AG – Frick',
      offset: 7, plat: '16', sector: 'B – D', status: 'On time', delay: false,
      note: 'Low-floor step-free boarding · Bike hooks',
      cars: [
        { cls: 'first', label: '1st Cl.', occ: 'Low' },
        { cls: '', label: '2nd Cl.', occ: 'Medium' },
        { cls: '', label: '2nd Cl.', occ: 'Medium' },
        { cls: '', label: 'Bike / 2nd', occ: 'Low' }
      ],
      stops: [
        { name: 'Zürich HB', off: 7 },
        { name: 'Baden', off: 23 },
        { name: 'Brugg AG', off: 32 },
        { name: 'Frick', off: 45 },
        { name: 'Basel SBB', off: 70 }
      ]
    },
    {
      id: 'ec315', cat: 'EC', num: 'EC 315', pillCls: 'ec',
      dest: 'Milano Centrale', via: 'Arth-Goldau – Gotthard Base – Lugano',
      offset: 11, plat: '7', sector: 'A – C', status: '+3 min', delay: true,
      note: 'Giruno EuroCity · Cross-border ID required',
      cars: [
        { cls: 'first', label: '1st Cl.', occ: 'Medium' },
        { cls: 'bistro', label: 'Ristorante', occ: 'Open' },
        { cls: '', label: '2nd Cl.', occ: 'High' },
        { cls: '', label: 'Quiet 2nd', occ: 'Medium' }
      ],
      stops: [
        { name: 'Zürich HB', off: 11 },
        { name: 'Zug', off: 34 },
        { name: 'Arth-Goldau', off: 49 },
        { name: 'Bellinzona', off: 109 },
        { name: 'Lugano', off: 125 },
        { name: 'Milano Centrale', off: 205 }
      ]
    },
    {
      id: 'ic3', cat: 'IC', num: 'IC 3', pillCls: '',
      dest: 'Chur', via: 'Sargans – Landquart',
      offset: 15, plat: '9', sector: 'A – D', status: 'On time', delay: false,
      note: 'Connection in Landquart to RhB Davos / St. Moritz',
      cars: [
        { cls: 'first', label: '1st Cl.', occ: 'Low' },
        { cls: 'bistro', label: 'Bistro', occ: 'Open' },
        { cls: '', label: '2nd Cl.', occ: 'Medium' },
        { cls: '', label: 'Family', occ: 'Low' }
      ],
      stops: [
        { name: 'Zürich HB', off: 15 },
        { name: 'Sargans', off: 69 },
        { name: 'Landquart', off: 79 },
        { name: 'Chur', off: 90 }
      ]
    },
    {
      id: 's12', cat: 'S', num: 'S 12', pillCls: 'sbahn',
      dest: 'Winterthur', via: 'Zürich Stadelhofen – Stettbach',
      offset: 18, plat: '33', sector: 'A – C', status: 'On time', delay: false,
      note: 'ZVV Urban S-Bahn · Double-deck commuter set',
      cars: [
        { cls: 'first', label: '1st Cl.', occ: 'Low' },
        { cls: '', label: '2nd Cl.', occ: 'High' },
        { cls: '', label: '2nd Cl.', occ: 'Medium' },
        { cls: '', label: '2nd Cl.', occ: 'Low' }
      ],
      stops: [
        { name: 'Zürich HB', off: 18 },
        { name: 'Zürich Stadelhofen', off: 22 },
        { name: 'Stettbach', off: 28 },
        { name: 'Effretikon', off: 38 },
        { name: 'Winterthur', off: 46 }
      ]
    },
    {
      id: 'ir75', cat: 'IR', num: 'IR 75', pillCls: 'ir',
      dest: 'Luzern', via: 'Thalwil – Zug – Rotkreuz',
      offset: 22, plat: '4', sector: 'B – D', status: 'On time', delay: false,
      note: 'Lake Zug panoramic corridor · Wi-Fi Free',
      cars: [
        { cls: 'first', label: '1st Cl.', occ: 'Low' },
        { cls: '', label: '2nd Cl.', occ: 'Medium' },
        { cls: '', label: '2nd Cl.', occ: 'Low' },
        { cls: '', label: 'Quiet 2nd', occ: 'Low' }
      ],
      stops: [
        { name: 'Zürich HB', off: 22 },
        { name: 'Thalwil', off: 32 },
        { name: 'Zug', off: 45 },
        { name: 'Rotkreuz', off: 54 },
        { name: 'Luzern', off: 69 }
      ]
    },
    {
      id: 'ic5', cat: 'IC', num: 'IC 5', pillCls: '',
      dest: 'St. Gallen', via: 'Zürich Flughafen – Winterthur – Wil',
      offset: 26, plat: '12', sector: 'A – D', status: 'On time', delay: false,
      note: 'Tilting ICN InterCity · Airport express link',
      cars: [
        { cls: 'first', label: '1st Cl.', occ: 'Low' },
        { cls: 'bistro', label: 'Bistro', occ: 'Open' },
        { cls: '', label: '2nd Cl.', occ: 'Medium' },
        { cls: '', label: '2nd Cl.', occ: 'Low' }
      ],
      stops: [
        { name: 'Zürich HB', off: 26 },
        { name: 'Zürich Flughafen', off: 36 },
        { name: 'Winterthur', off: 49 },
        { name: 'Wil SG', off: 67 },
        { name: 'St. Gallen', off: 88 }
      ]
    },
    {
      id: 'ec195', cat: 'EC', num: 'EC 195', pillCls: 'ec',
      dest: 'München Hbf', via: 'St. Margrethen – Bregenz – Lindau',
      offset: 33, plat: '9', sector: 'A – C', status: '+2 min', delay: true,
      note: 'Astoro EuroCity · Seat reservation recommended',
      cars: [
        { cls: 'first', label: '1st Cl.', occ: 'Medium' },
        { cls: 'bistro', label: 'Bistro', occ: 'Open' },
        { cls: '', label: '2nd Cl.', occ: 'Medium' },
        { cls: '', label: '2nd Cl.', occ: 'Medium' }
      ],
      stops: [
        { name: 'Zürich HB', off: 33 },
        { name: 'Winterthur', off: 55 },
        { name: 'St. Gallen', off: 93 },
        { name: 'Bregenz', off: 124 },
        { name: 'München Hbf', off: 243 }
      ]
    }
  ];

  let activeCat = 'all';
  const destSearch = document.getElementById('destSearch');
  const platformSelect = document.getElementById('platformSelect');
  const depList = document.getElementById('depList');
  const boardCount = document.getElementById('boardCount');

  function renderBoard() {
    const q = destSearch.value.trim().toLowerCase();
    const plat = platformSelect.value;

    const list = departures.filter(d => {
      if (activeCat !== 'all' && d.cat !== activeCat) return false;
      if (plat !== 'all' && d.plat !== plat) return false;
      if (q) {
        const hay = `${d.num} ${d.dest} ${d.via}`.toLowerCase();
        if (!hay.includes(q)) return false;
      }
      return true;
    });

    boardCount.textContent = `${list.length} ${list.length === 1 ? 'TRAIN' : 'TRAINS'} SHOWN`;
    depList.innerHTML = '';

    if (list.length === 0) {
      depList.innerHTML = '<div class="empty-state">No departures match your current filter. Clear search or select All Platforms.</div>';
      return;
    }

    list.forEach(d => {
      const btn = document.createElement('button');
      btn.type = 'button';
      btn.className = 'dep-row';
      btn.innerHTML = `
        <span class="dep-time">${fmtOffset(d.offset)}</span>
        <span class="dep-cat"><span class="train-pill ${d.pillCls}">${d.num}</span></span>
        <span class="dep-dest">${d.dest}</span>
        <span class="dep-via">${d.via}</span>
        <span class="dep-plat">${d.plat}</span>
        <span class="dep-status ${d.delay ? 'delay' : ''}">${d.status}</span>
      `;
      btn.addEventListener('click', () => openDrawer(d));
      depList.appendChild(btn);
    });
  }

  // Detail Drawer
  const backdrop = document.getElementById('drawerBackdrop');
  const drawerClose = document.getElementById('drawerClose');

  function openDrawer(d) {
    document.getElementById('drawerTrainPill').innerHTML = `<span class="train-pill ${d.pillCls}">${d.num}</span>`;
    document.getElementById('drawerTitle').textContent = d.dest;
    document.getElementById('drawerSub').textContent = d.note;
    document.getElementById('dTime').textContent = fmtOffset(d.offset);
    document.getElementById('dPlat').textContent = `Gleis ${d.plat}`;
    document.getElementById('dSector').textContent = d.sector;

    const formEl = document.getElementById('dFormation');
    formEl.innerHTML = d.cars.map(c => `
      <div class="car-box ${c.cls}">
        <strong>${c.label}</strong>
        <span>${c.occ}</span>
      </div>
    `).join('');

    const stopsEl = document.getElementById('dStops');
    stopsEl.innerHTML = d.stops.map(s => `
      <li>
        <span class="stop-name">${s.name}</span>
        <span class="stop-time">${fmtOffset(s.off)}</span>
      </li>
    `).join('');

    backdrop.classList.add('open');
    drawerClose.focus();
  }

  function closeDrawer() {
    backdrop.classList.remove('open');
  }
  drawerClose.addEventListener('click', closeDrawer);
  backdrop.addEventListener('click', e => { if (e.target === backdrop) closeDrawer(); });
  document.addEventListener('keydown', e => { if (e.key === 'Escape') closeDrawer(); });

  destSearch.addEventListener('input', renderBoard);
  platformSelect.addEventListener('change', renderBoard);
  document.querySelectorAll('.cat-btn').forEach(b => {
    b.addEventListener('click', () => {
      activeCat = b.dataset.cat;
      document.querySelectorAll('.cat-btn').forEach(x => x.classList.toggle('active', x === b));
      renderBoard();
    });
  });

  renderBoard();
})();
</script>
</body>
</html>