/**
 * Transit Route Design System - Design Tokens
 * v0.1.0-draft
 *
 * This file defines all design tokens (colors, spacing, typography, etc.)
 * to ensure consistency across the application.
 */

:root {
  /* ========================================
     Color System
     ======================================== */

  /* Brand Colors */
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-light: #dbeafe;
  --color-secondary: #64748b;

  /* Status Colors - Delay/On-time indicators */
  --status-ontime: #22c55e;       /* Green - On time or early */
  --status-slight: #84cc16;       /* Light green - Slight delay <2min */
  --status-delayed: #f59e0b;      /* Orange - Delayed 2-5min */
  --status-late: #ef4444;         /* Red - Late >5min */
  --status-unknown: #9ca3af;      /* Gray - No real-time data */
  --status-scheduled: #6b7280;    /* Dark gray - Scheduled only */

  /* Alert Severity Colors */
  --alert-info: #3b82f6;
  --alert-warning: #f59e0b;
  --alert-severe: #ef4444;
  --alert-info-bg: #eff6ff;
  --alert-warning-bg: #fffbeb;
  --alert-severe-bg: #fef2f2;

  /* Background Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-dark: #1e293b;
  --bg-overlay: rgba(0, 0, 0, 0.5);

  /* Text Colors */
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --text-inverse: #ffffff;
  --text-link: #3b82f6;
  --text-link-hover: #2563eb;

  /* Border Colors */
  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-dark: #94a3b8;
  --border-focus: #3b82f6;

  /* Vehicle Type Colors (GTFS route_type) */
  --vehicle-tram: #9333ea;        /* Purple - Tram/Streetcar */
  --vehicle-subway: #dc2626;      /* Red - Subway/Metro */
  --vehicle-rail: #ea580c;        /* Orange - Rail/Train */
  --vehicle-bus: #16a34a;         /* Green - Bus */
  --vehicle-ferry: #0284c7;       /* Blue - Ferry */
  --vehicle-cable: #7c3aed;       /* Violet - Cable car */
  --vehicle-gondola: #be185d;     /* Pink - Gondola */
  --vehicle-funicular: #b45309;   /* Amber - Funicular */

  /* ========================================
     Spacing System (4px base)
     ======================================== */
  --spacing-0: 0;
  --spacing-1: 4px;
  --spacing-2: 8px;
  --spacing-3: 12px;
  --spacing-4: 16px;
  --spacing-5: 20px;
  --spacing-6: 24px;
  --spacing-8: 32px;
  --spacing-10: 40px;
  --spacing-12: 48px;
  --spacing-16: 64px;

  /* Semantic spacing aliases */
  --spacing-xs: var(--spacing-1);
  --spacing-sm: var(--spacing-2);
  --spacing-md: var(--spacing-4);
  --spacing-lg: var(--spacing-6);
  --spacing-xl: var(--spacing-8);

  /* ========================================
     Typography
     ======================================== */

  /* Font Family */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, 'Noto Sans', 'PingFang SC',
               'Microsoft YaHei', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo,
               Consolas, 'Liberation Mono', monospace;

  /* Font Size */
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 14px;
  --font-size-md: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 30px;

  /* Font Weight */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Line Height */
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

  /* ========================================
     Border Radius
     ======================================== */
  --radius-none: 0;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* ========================================
     Shadows
     ======================================== */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* ========================================
     Z-Index Scale
     ======================================== */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal-backdrop: 300;
  --z-modal: 400;
  --z-toast: 500;
  --z-tooltip: 600;

  /* ========================================
     Animation
     ======================================== */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;

  --animation-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  --animation-spin: spin 1s linear infinite;
  --animation-bounce: bounce 1s infinite;

  /* ========================================
     Component Specific Tokens
     ======================================== */

  /* Timeline */
  --timeline-line-width: 2px;
  --timeline-line-color: var(--border-light);
  --timeline-node-size: 12px;
  --timeline-node-size-lg: 16px;
  --timeline-vehicle-size: 28px;

  /* Progress bar */
  --progress-height: 4px;
  --progress-bg: var(--bg-tertiary);
  --progress-fill: var(--color-primary);

  /* Cards */
  --card-padding: var(--spacing-4);
  --card-radius: var(--radius-lg);
  --card-shadow: var(--shadow-md);
  --card-border: 1px solid var(--border-light);

  /* Buttons */
  --btn-height-sm: 32px;
  --btn-height-md: 40px;
  --btn-height-lg: 48px;
  --btn-min-touch-target: 44px; /* Accessibility - min touch target */

  /* Header */
  --header-height: 56px;
  --header-height-mobile: 48px;

  /* Tab bar */
  --tab-height: 44px;
  --tab-indicator-height: 3px;
}

/* ========================================
   Dark Mode Support (optional)
   ======================================== */
@media (prefers-color-scheme: dark) {
  :root.auto-dark-mode {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;

    --border-light: #334155;
    --border-medium: #475569;
    --border-dark: #64748b;

    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
  }
}

/* ========================================
   Keyframes
   ======================================== */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

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

@keyframes bounce {
  0%, 100% {
    transform: translateY(-5%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

@keyframes flash {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* ========================================
   Utility Classes
   ======================================== */

/* Status color utilities */
.status-ontime { color: var(--status-ontime); }
.status-slight { color: var(--status-slight); }
.status-delayed { color: var(--status-delayed); }
.status-late { color: var(--status-late); }
.status-unknown { color: var(--status-unknown); }

.bg-status-ontime { background-color: var(--status-ontime); }
.bg-status-slight { background-color: var(--status-slight); }
.bg-status-delayed { background-color: var(--status-delayed); }
.bg-status-late { background-color: var(--status-late); }
.bg-status-unknown { background-color: var(--status-unknown); }

/* Text utilities */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

/* Spacing utilities */
.mt-1 { margin-top: var(--spacing-1); }
.mt-2 { margin-top: var(--spacing-2); }
.mt-3 { margin-top: var(--spacing-3); }
.mt-4 { margin-top: var(--spacing-4); }

.mb-1 { margin-bottom: var(--spacing-1); }
.mb-2 { margin-bottom: var(--spacing-2); }
.mb-3 { margin-bottom: var(--spacing-3); }
.mb-4 { margin-bottom: var(--spacing-4); }

.p-1 { padding: var(--spacing-1); }
.p-2 { padding: var(--spacing-2); }
.p-3 { padding: var(--spacing-3); }
.p-4 { padding: var(--spacing-4); }

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

/* Responsive visibility */
@media (max-width: 767px) {
  .hide-mobile { display: none !important; }
}

@media (min-width: 768px) {
  .hide-desktop { display: none !important; }
}
