:root {
  color-scheme: light;
  --ink: #18232d;
  --muted: #64717d;
  --surface: #ffffff;
  --surface-2: #f3f6f8;
  --line: #dce2e7;
  --green: #087f5b;
  --amber: #b86b00;
  --red: #d71920;
  --blue: #315e7d;
  --local: #1261a0;
  --intercity: #d71920;
  --freight: #9a5b00;
  --maintenance: #6b4fa1;
  --other-train: #53616d;
  --cream: #263746;
  --shadow: 0 20px 55px rgba(24, 35, 45, 0.12);
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

html {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f2f5f7;
  color: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 80% 0%, rgba(215, 25, 32, 0.07), transparent 36rem),
    linear-gradient(180deg, #fafbfc 0%, #eef2f5 100%);
}

a {
  color: inherit;
}

.site-header,
main,
footer {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(215, 25, 32, 0.45);
  border-radius: 12px;
  color: #fff;
  background: var(--red);
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

nav {
  display: flex;
  gap: 8px;
}

nav a,
.text-link {
  padding: 9px 13px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
}

nav a:hover,
.text-link:hover {
  color: var(--ink);
  background: rgba(24, 35, 45, 0.06);
}

main {
  padding: 56px 0 80px;
}

.hero {
  margin-bottom: 22px;
}

.eyebrow {
  display: block;
  margin-bottom: 12px;
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.status-card {
  position: relative;
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 32px;
  align-items: center;
  min-height: 240px;
  padding: 38px;
  overflow: hidden;
  border: 1px solid rgba(8, 127, 91, 0.24);
  border-radius: 28px;
  background:
    linear-gradient(120deg, rgba(8, 127, 91, 0.08), transparent 58%),
    var(--surface);
  box-shadow: var(--shadow);
}

.status-card::after {
  position: absolute;
  right: -100px;
  bottom: -180px;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(24, 35, 45, 0.07);
  border-radius: 50%;
  content: "";
}

.status-card h1,
.page-heading h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 7vw, 6.8rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.92;
}

.status-kicker {
  margin: 0 0 14px;
  color: var(--muted);
}

.status-detail {
  max-width: 630px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.status-visual {
  position: relative;
  display: grid;
  width: 150px;
  height: 150px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
}

.gate {
  --gate-stripe: 16px;
  width: 92px;
  height: 10px;
  border-radius: 9px;
  background: repeating-linear-gradient(
    90deg,
    var(--surface) 0 var(--gate-stripe),
    var(--red) var(--gate-stripe) calc(2 * var(--gate-stripe))
  );
  transform: rotate(-48deg);
  transform-origin: 12px center;
  transition: transform 500ms ease;
}

.status-closed .gate {
  transform: rotate(0deg);
}

.signal-light {
  position: absolute;
  top: 66px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 16px rgba(8, 127, 91, 0.45);
}

.signal-light-left {
  left: 15px;
}

.signal-light-right {
  right: 15px;
}

.status-closed .signal-light {
  background: var(--red);
  box-shadow: 0 0 16px rgba(215, 25, 32, 0.45);
  animation: pulse 1.1s infinite alternate;
}

.status-closingsoon .signal-light {
  background: var(--amber);
  box-shadow: 0 0 16px rgba(184, 107, 0, 0.4);
}

.status-unknown {
  filter: saturate(0.45);
}

.status-closed {
  border-color: rgba(215, 25, 32, 0.3);
  background:
    linear-gradient(120deg, rgba(215, 25, 32, 0.08), transparent 58%),
    var(--surface);
}

.status-closingsoon {
  border-color: rgba(184, 107, 0, 0.3);
  background:
    linear-gradient(120deg, rgba(184, 107, 0, 0.08), transparent 58%),
    var(--surface);
}

.metric-grid,
.dashboard-grid {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.metric-grid {
  grid-template-columns: repeat(3, 1fr);
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  align-items: start;
}

.side-stack {
  display: grid;
  gap: 16px;
}

.metric,
.panel,
.data-note {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
}

.metric {
  display: grid;
  gap: 5px;
  padding: 22px;
}

.metric-label,
.metric small,
.train small,
.history-row small,
.page-heading p {
  color: var(--muted);
}

.metric strong {
  font-family: Georgia, serif;
  font-size: 1.65rem;
  font-weight: 500;
}

.panel {
  min-width: 0;
  padding: 26px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-heading .eyebrow {
  margin-bottom: 6px;
}

.panel h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 1.8rem;
  font-weight: 500;
}

.live-pill {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid rgba(8, 127, 91, 0.25);
  border-radius: 999px;
  color: var(--green);
  font-size: 0.78rem;
}

.live-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(8, 127, 91, 0.4);
}

.history-list {
  display: grid;
  gap: 9px;
}

.route-board {
  --route-inset: 14px;
  --route-gap: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
}

.block-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
}

.block-legend span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.block-legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: #e4e9ed;
}

.block-legend .legend-local {
  background: var(--local);
}

.block-legend .legend-intercity {
  background: var(--intercity);
}

.block-legend .legend-freight {
  background: var(--freight);
}

.block-legend .legend-maintenance {
  background: var(--maintenance);
}

.block-legend .legend-other {
  background: var(--other-train);
}

.block-legend .legend-crossing {
  outline: 1px solid var(--amber);
  background: rgba(184, 107, 0, 0.12);
}

.diagram-note {
  margin: 0;
  padding: 8px var(--route-inset);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.7rem;
}

.route-board-head,
.route-lane-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--route-gap);
}

.route-board-head {
  padding: 9px var(--route-inset);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.route-board-head span:last-child {
  text-align: right;
}

.route-board-head b {
  color: var(--red);
  font-size: 0.9rem;
}

.route-board-body {
  padding: 4px var(--route-inset) 12px;
}

.route-lane-row {
  min-height: 34px;
}

.route-slot {
  position: relative;
  display: grid;
  align-items: center;
  min-width: 0;
}

.route-slot::before {
  position: absolute;
  z-index: 0;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  border-radius: 3px;
  background: #82909a;
  content: "";
  transform: translateX(-50%);
}

.route-station {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 31px;
  margin: 5px 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: #fff;
  font-size: 0.72rem;
  box-shadow: 0 4px 14px rgba(24, 35, 45, 0.05);
}

.route-station-mark {
  width: 10px;
  height: 10px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 1px var(--blue);
}

.route-station-focus {
  border-color: rgba(215, 25, 32, 0.35);
  color: var(--red);
  background: rgba(215, 25, 32, 0.06);
}

.route-station-focus .route-station-mark {
  background: var(--red);
  box-shadow: 0 0 0 1px var(--red), 0 0 12px rgba(215, 25, 32, 0.25);
}

.crossing-signal-row {
  min-height: 42px;
}

.crossing-signal {
  position: relative;
  z-index: 1;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-self: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.7rem;
}

.crossing-signal > span:not(.block-signal) {
  color: var(--muted);
}

.route-crossing {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 9px;
  align-items: center;
  min-height: 48px;
  margin-inline: calc(-1 * var(--route-inset));
  color: var(--surface);
  background: var(--muted);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.crossing-tracks {
  position: absolute;
  inset: 0 var(--route-inset);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--route-gap);
}

.crossing-tracks i {
  justify-self: center;
  width: 4px;
  background: var(--line);
}

.road-marking {
  height: 2px;
  background: repeating-linear-gradient(
    90deg,
    transparent 0 8px,
    var(--surface) 8px 18px
  );
}

.road-label {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--ink);
  text-align: center;
}

.road-state {
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
}

.road-barrier {
  position: absolute;
  z-index: 1;
  top: 50%;
  width: 42px;
  height: 38px;
  transform: translateY(-50%);
}

.road-barrier-left {
  left: 8px;
}

.road-barrier-right {
  right: 8px;
  transform: translateY(-50%) scaleX(-1);
}

.road-barrier::before {
  position: absolute;
  bottom: 1px;
  left: 3px;
  width: 7px;
  height: 12px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--line);
  content: "";
}

.road-barrier::after {
  position: absolute;
  top: 27px;
  left: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink);
  content: "";
}

.road-barrier .gate {
  --gate-stripe: 5px;
  position: absolute;
  top: 26px;
  left: 4px;
  width: 32px;
  height: 6px;
  border-radius: 2px;
  visibility: hidden;
  transform: rotate(var(--road-barrier-angle, 0deg));
  transform-origin: 3px center;
}

.road-barrier-unknown {
  position: absolute;
  top: 2px;
  left: 0;
  width: 100%;
  font-size: 18px;
  line-height: 24px;
  text-align: center;
  transition: none;
}

.road-barrier-right .road-barrier-unknown {
  transform: scaleX(-1);
}

.route-crossing[data-state="open"] {
  --road-barrier-angle: -70deg;
}

.route-crossing[data-state="open"] .road-barrier .gate,
.route-crossing[data-state="closed"] .road-barrier .gate {
  visibility: visible;
}

.route-crossing[data-state="open"] .road-barrier-unknown,
.route-crossing[data-state="closed"] .road-barrier-unknown {
  visibility: hidden;
}

.signal-block {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 8px auto minmax(0, 1fr) auto;
  width: 100%;
  min-height: 30px;
  gap: 7px;
  align-items: center;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.signal-block-occupied {
  --train-color: var(--other-train);
  border-color: color-mix(in srgb, var(--train-color) 65%, white);
  background: color-mix(in srgb, var(--train-color) 9%, white);
  box-shadow: inset 4px 0 0 var(--train-color);
}

.signal-block-local {
  --train-color: var(--local);
}

.signal-block-intercity {
  --train-color: var(--intercity);
}

.signal-block-freight {
  --train-color: var(--freight);
}

.signal-block-maintenance {
  --train-color: var(--maintenance);
}

.signal-block-other {
  --train-color: var(--other-train);
}

.signal-block-bramley {
  border-color: rgba(184, 107, 0, 0.75);
  box-shadow: inset 4px 0 0 rgba(184, 107, 0, 0.65);
}

.signal-block-bramley.signal-block-occupied {
  box-shadow:
    inset 4px 0 0 var(--train-color),
    inset 0 0 0 1px rgba(184, 107, 0, 0.45);
}

.block-berth {
  grid-column: 2;
  grid-row: 1;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.6rem;
}

.block-topline {
  display: contents;
}

.block-arrow {
  grid-column: 4;
  grid-row: 1;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.block-train {
  grid-column: 3;
  grid-row: 1;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1;
  text-align: right;
}

.block-signal {
  grid-column: 1;
  grid-row: 1;
  width: 8px;
  height: 8px;
  border: 1px solid rgba(24, 35, 45, 0.18);
  border-radius: 50%;
  background: #aab3ba;
  box-shadow: 0 0 0 2px #fff;
}

.signal-aspect-red {
  background: var(--red);
  box-shadow: 0 0 0 2px #fff, 0 0 7px rgba(215, 25, 32, 0.55);
}

.signal-aspect-cleared {
  background: var(--green);
  box-shadow: 0 0 0 2px #fff, 0 0 7px rgba(8, 127, 91, 0.5);
}

.arrivals-list {
  display: grid;
  gap: 8px;
}

.arrival-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 13px;
  background: var(--surface-2);
}

.arrival-row time {
  font-family: Georgia, serif;
  font-size: 1.25rem;
}

.arrival-row div {
  display: grid;
  min-width: 0;
}

.arrival-row strong,
.arrival-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arrival-row small,
.arrivals-updated {
  color: var(--muted);
  font-size: 0.7rem;
}

.arrival-expected {
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 800;
}

.arrival-platform {
  padding: 4px 6px;
  border-radius: 6px;
  color: #fff;
  background: var(--ink);
  font-size: 0.68rem;
  font-weight: 800;
}

.arrival-cancelled .arrival-expected {
  color: var(--red);
}

.signal-block-occupied .block-train {
  color: var(--train-color);
  font-weight: 800;
}

.signal-block:not(.signal-block-occupied) .block-train {
  font-weight: 500;
}

.signal-block small {
  display: none;
}

.signal-block .block-signal-reference {
  display: block;
  grid-column: 2 / -1;
  grid-row: 2;
  color: var(--muted);
  font-size: 0.6rem;
}

.history-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border-radius: 14px;
  background: var(--surface-2);
}

.history-row div {
  display: grid;
}

.history-marker {
  width: 9px;
  height: 36px;
  border-radius: 8px;
  background: var(--amber);
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.data-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  margin-top: 16px;
  padding: 18px 22px;
  color: var(--muted);
  font-size: 0.88rem;
}

.data-note strong {
  color: var(--cream);
}

.page-heading {
  margin-bottom: 34px;
}

.page-heading h1 {
  font-size: clamp(3rem, 7vw, 5rem);
}

.history-table-panel {
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 15px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 0 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
}

@keyframes pulse {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 820px) {
  main {
    padding-top: 30px;
  }

  .status-card {
    grid-template-columns: 110px 1fr;
    gap: 20px;
    padding: 26px;
  }

  .status-visual {
    width: 105px;
    height: 105px;
  }

  .gate {
    width: 67px;
  }

  .signal-light {
    top: 46px;
  }

  .metric-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .site-header,
  main,
  footer {
    width: min(100% - 20px, 1180px);
  }

  .site-header {
    padding-block: 14px;
  }

  .brand small {
    display: none;
  }

  nav a {
    padding-inline: 9px;
  }

  .status-card {
    grid-template-columns: 1fr;
    padding: 24px;
  }

  .status-visual {
    width: 84px;
    height: 84px;
  }

  .signal-light {
    top: 35px;
  }

  .gate {
    width: 55px;
    height: 8px;
  }

  .status-card h1 {
    font-size: 3.5rem;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .metric:first-child {
    grid-column: 1 / -1;
  }

  .panel {
    padding: 20px;
  }

  .route-board {
    --route-inset: 10px;
    --route-gap: 8px;
    margin-inline: -6px;
  }

  .route-board-head {
    font-size: 0.58rem;
  }

  .signal-block {
    min-height: 31px;
    gap: 4px;
    padding: 4px 5px;
  }

  .block-berth {
    font-size: 0.58rem;
  }

  .block-train {
    font-size: 0.72rem;
  }

  .route-station {
    min-height: 29px;
    margin-block: 4px;
    font-size: 0.66rem;
  }

  .data-note,
  footer {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
