/* ============================================================
   LIGN.ES — Mobile Departure Board
   ============================================================ */

:root {
  --bg-deep: #060609;
  --bg-board: #0b0b10;
  --bg-card: #10101a;
  --bg-card-hover: #161625;

  --text-primary: #e8e8f0;
  --text-secondary: #9a9ab4;
  --text-muted: #6a6a84;
  --text-accent: #f0c040;

  --status-delayed: #e8854a;
  --status-early: #4ae862;
  --status-realtime: #4ae862;

  --rule-color: #1e1e30;
  --badge-text: #fff;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

.screen {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100dvh;
}

.screen[hidden] {
  display: none;
}

/* ============================================================
   LOCATION SCREEN
   ============================================================ */

#locationScreen {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-board);
}

.loc-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.loc-brand {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 32px;
  letter-spacing: 2px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.loc-tagline {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.loc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--bg-deep);
  background: var(--text-accent);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.loc-btn:active {
  opacity: 0.85;
}

.loc-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.loc-btn-icon {
  font-size: 20px;
}

.loc-status {
  font-size: 14px;
  color: var(--text-muted);
  min-height: 1.4em;
  margin-top: 10px;
}

.loc-status.error {
  color: var(--status-delayed);
}

.loc-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.loc-divider::before,
.loc-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule-color);
}

.loc-search {
  text-align: left;
}

.loc-input {
  width: 100%;
  padding: 14px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 2px solid var(--rule-color);
  border-radius: var(--radius-md);
  outline: none;
  caret-color: var(--text-accent);
  transition: border-color var(--transition-fast);
}

.loc-input::placeholder {
  color: var(--text-muted);
}

.loc-input:focus {
  border-color: var(--text-accent);
}

.loc-suggestions {
  margin-top: 4px;
}

.loc-suggestion {
  display: block;
  width: 100%;
  padding: 12px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule-color);
  text-align: left;
  cursor: pointer;
}

.loc-suggestion:active {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.loc-suggestion-ctx {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
   HEADER
   ============================================================ */

.header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-board);
  border-bottom: 1px solid var(--rule-color);
}

.header-clock {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.header-spacer {
  flex: 1;
}

.header-source {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-right: 12px;
}

.header-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-muted);
}

.refresh-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition-fast);
}

.refresh-dot.active {
  background: var(--status-realtime);
  animation: pulse-dot 1s ease infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   ALERT BANNER
   ============================================================ */

.alert-banner {
  overflow: hidden;
  padding: 8px 16px;
  background: rgba(240, 192, 64, 0.1);
  border-bottom: 1px solid rgba(240, 192, 64, 0.2);
  color: var(--text-accent);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.alert-banner[hidden] {
  display: none;
}

.alert-banner .alert-text {
  display: inline-block;
  animation: marquee 30s linear infinite;
}

.alert-banner .alert-text.no-scroll {
  animation: none;
}

@keyframes marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ============================================================
   STOPS CONTAINER
   ============================================================ */

.stops {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 80px;
}

.stops.refreshing .stop-card {
  opacity: 0.4;
  transition: opacity var(--transition-fast);
}

.stops.stale .stop-card {
  opacity: 0.5;
}

/* ============================================================
   STOP CARD
   ============================================================ */

.stop-card {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--rule-color);
}

.stop-card-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.stop-name {
  font-weight: 700;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stop-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============================================================
   DEPARTURE ROW
   ============================================================ */

.dep-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dep-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  transition: background var(--transition-normal), border-color var(--transition-normal);
}

.dep-badge {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 12px;
  text-align: center;
  padding: 3px 2px;
  border-radius: var(--radius-sm);
  color: var(--badge-text);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dep-headsign {
  font-size: 15px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dep-time-group {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.dep-countdown {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 15px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: color 0.6s ease;
}

.dep-countdown.imminent {
  color: var(--text-accent);
  font-weight: 700;
  animation: countdown-pulse 1.5s ease-in-out infinite;
}

.dep-countdown.now {
  color: var(--text-accent);
  font-weight: 700;
  animation: countdown-pulse 1s ease-in-out infinite;
}

@keyframes countdown-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.dep-countdown.delayed {
  color: var(--status-delayed);
}

.dep-countdown.early {
  color: var(--status-early);
}

.dep-rt {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-realtime);
  flex-shrink: 0;
}

.dep-go {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 10px;
  color: var(--bg-deep);
  background: var(--text-accent);
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

/* Sweet spot row */
.dep-row.sweet-spot {
  background: rgba(240, 192, 64, 0.07);
  border-left-color: var(--text-accent);
}

.dep-row.sweet-spot .dep-countdown {
  color: var(--text-accent);
  font-weight: 700;
}

.dep-row.sweet-spot .dep-headsign {
  color: var(--text-primary);
}

/* Departing animation */
.dep-row.departing {
  opacity: 0;
  max-height: 0;
  padding: 0 4px;
  overflow: hidden;
  transition: opacity var(--transition-normal), max-height var(--transition-normal), padding var(--transition-normal);
}

/* ============================================================
   EMPTY / ERROR STATES
   ============================================================ */

.empty-state {
  padding: 48px 16px;
  text-align: center;
  font-size: 17px;
  color: var(--text-muted);
}

/* Loading spinner */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 64px 16px;
}

.loading-rat {
  width: 64px;
  image-rendering: pixelated;
}

.loading-text {
  font-size: 15px;
  color: var(--text-muted);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.stop-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 4px;
}

.no-deps {
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px;
}

/* ============================================================
   FOOTER
   ============================================================ */

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--bg-board);
  border-top: 1px solid var(--rule-color);
  z-index: 5;
}

.footer-location {
  flex: 1;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.footer-change {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-accent);
  background: transparent;
  border: 1px solid rgba(240, 192, 64, 0.3);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 10px;
}

.footer-change:active {
  background: rgba(240, 192, 64, 0.1);
}

/* ============================================================
   PULL TO REFRESH INDICATOR
   ============================================================ */

.pull-indicator {
  text-align: center;
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: opacity var(--transition-fast);
}
