/*
 * styles.css — OnTrack Web
 * Dark LED departure-board aesthetic, matching the iOS app.
 */

/* MARK: - Fonts */
@font-face {
  font-family: "LED";
  src: url("../fonts/LED.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "BR-Regular";
  src: url("../fonts/SansSerif-Regular.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "BR-Bold";
  src: url("../fonts/SansSerif-Bold.ttf") format("truetype");
  font-display: swap;
}

/* MARK: - Theme tokens */
:root {
  --bg: #000000;
  --surface: #0d0d0f;
  --surface-2: #16161a;
  --border: #26262c;

  /* Colour semantics (mirrors the iOS app). */
  --white: #f5f5f5;
  --green: #34c759;
  --orange: #ff9f0a;
  --red: #ff453a;
  --secondary: #8e8e93;

  --touch: 48px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--white);
  font-family: "BR-Regular", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body.modal-open {
  overflow: hidden;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 0 calc(24px + env(safe-area-inset-bottom));
}

.screen[hidden] {
  display: none;
}

/* MARK: - Colour utility classes */
.c-white {
  color: var(--white);
}
.c-green {
  color: var(--green);
}
.c-orange {
  color: var(--orange);
}
.c-red {
  color: var(--red);
}
.c-secondary {
  color: var(--secondary);
}

/* All LED text is a single uniform size and line height; meaning is conveyed by
   colour only. The LED glyphs are tall, so a generous line-height stops stacked
   and wrapped lines from nearly touching. */
.led {
  font-family: "LED", monospace;
  letter-spacing: 0.04em;
  font-size: 1rem;
  line-height: 1.5;
}

/* MARK: - Landing */
.app-title {
  font-family: "BR-Bold", sans-serif;
  font-size: 2.5rem;
  margin: 24px 0 4px;
  text-align: center;
}
.app-subtitle {
  font-family: "LED", monospace;
  color: var(--orange);
  text-align: center;
  margin: 0 0 40px;
  letter-spacing: 0.08em;
}

.direction-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.direction-button {
  display: block;
  font-family: "BR-Bold", sans-serif;
  font-size: 1.4rem;
  color: var(--white);
  text-decoration: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 20px;
  min-height: var(--touch);
  cursor: pointer;
  text-align: left;
}
.direction-button:hover {
  background: #1e1e24;
}
.direction-button:active {
  transform: scale(0.99);
}

/* MARK: - Navigation bar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
  max-width: 640px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-family: "BR-Bold", sans-serif;
  font-size: 1.5rem;
  color: var(--white);
  text-decoration: none;
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.nav-button {
  font-family: "BR-Regular", sans-serif;
  font-size: 1rem;
  color: var(--orange);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  min-height: var(--touch);
  cursor: pointer;
}
.nav-button[hidden] {
  display: none;
}
.last-updated {
  color: var(--secondary);
}

/* MARK: - Route / direction section */
.route-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.section-header {
  font-family: "BR-Bold", sans-serif;
  font-size: 1.5rem;
  margin: 18px 14px 8px;
  color: var(--white);
}

/* MARK: - Departure rows */
.departure-list {
  display: flex;
  flex-direction: column;
}
.departure-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 16px;
  cursor: pointer;
  font-size: 1rem;
}
.departure-row:last-child {
  border-bottom: none;
}
.departure-row:hover {
  background: var(--surface-2);
}
.row-grid {
  display: grid;
  /* Fixed 5-column layout: station | > | station | > | station. */
  grid-template-columns: repeat(5, 1fr);
  width: 100%;
  column-gap: 6px;
  row-gap: 2px;
  align-items: start;
}
.row-sep {
  justify-self: center;
}

/* MARK: - States */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 16px;
  text-align: center;
}
.state-text {
  font-family: "BR-Regular", sans-serif;
  margin: 0;
}
.state-detail {
  font-family: "BR-Regular", sans-serif;
  color: var(--secondary);
  margin: 0;
  font-size: 0.9rem;
}
.retry-button,
.disruptions-button {
  font-family: "BR-Regular", sans-serif;
  font-size: 1rem;
  color: var(--white);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  min-height: var(--touch);
  cursor: pointer;
}
.disruptions-button {
  color: var(--orange);
  width: 100%;
  margin-bottom: 8px;
}
.retry-button {
  color: var(--orange);
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* MARK: - Modal */
.modal[hidden] {
  display: none;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.modal-panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
}
.modal-body {
  padding: 16px;
}
@media (min-width: 560px) {
  .modal {
    align-items: center;
  }
  .modal-panel {
    border-radius: 18px;
  }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  background: var(--surface);
  padding: 16px;
}
.modal-title {
  font-family: "BR-Bold", sans-serif;
  font-size: 1.4rem;
  margin: 0;
}
.modal-close {
  font-family: "BR-Regular", sans-serif;
  font-size: 1rem;
  color: var(--green);
  background: transparent;
  border: none;
  padding: 10px 8px;
  min-height: var(--touch);
  cursor: pointer;
}

/* MARK: - Detail */
.detail {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.leg {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.leg-grid {
  display: grid;
  /* origin | > | arrival; the ">" column is narrow. */
  grid-template-columns: 4fr 1fr 4fr;
  column-gap: 12px;
  row-gap: 2px;
  align-items: start;
}
.leg-sep {
  justify-self: center;
}

/* MARK: - Disruptions */
.disruptions {
  gap: 16px;
}
.disruption-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.disruption-icon {
  color: var(--orange);
  flex-shrink: 0;
}

/* MARK: - Focus visibility */
button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}
