/* ═══════════════════════════════════════════════════════════════
   RAILWAY STATUS — Premium design system
   ═══════════════════════════════════════════════════════════════ */

/* ── RESET & TOKENS ───────────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Palette */
  --white:     #ffffff;
  --off-white: #f8f9fa;
  --grey-50:   #fafafa;
  --grey-100:  #f5f5f5;
  --grey-200:  #e8e8e8;
  --grey-300:  #d4d4d4;
  --grey-400:  #a3a3a3;
  --grey-500:  #737373;
  --grey-600:  #525252;
  --grey-700:  #404040;
  --black:     #171717;
  --ink:       #0a0a0a;

  /* Accent */
  --accent:    #2563eb;
  --accent-light: #dbeafe;
  --accent-dark:  #1d4ed8;

  /* Status */
  --green:     #16a34a;
  --green-bg:  #dcfce7;
  --green-soft:#f0fdf4;
  --orange:    #ea580c;
  --orange-bg: #fff7ed;
  --orange-soft:#fffbeb;
  --red:       #dc2626;
  --red-bg:    #fef2f2;
  --red-soft:  #fff1f2;
  --blue:      #2563eb;
  --blue-bg:   #eff6ff;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --fs-xs:   0.6875rem;
  --fs-sm:   0.8125rem;
  --fs-base: 0.9375rem;
  --fs-lg:   1.125rem;
  --fs-xl:   1.5rem;
  --fs-2xl:  1.875rem;
  --fs-3xl:  2.25rem;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.08);
  --shadow-xl: 0 20px 60px rgba(0,0,0,.1);

  /* Motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur:  0.4s;
  --dur-fast: 0.2s;
  --dur-slow: 0.6s;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-weight: 400;
  color: var(--black);
  background: var(--off-white);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ───────────────────────────────────────────────────── */
#site-header {
  padding: var(--sp-5) var(--sp-6);
  text-align: center;
  background: var(--white);
  border-bottom: 1px solid var(--grey-200);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,.85);
}

.logo {
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink);
}

.logo-icon {
  display: inline-block;
  margin-right: var(--sp-2);
  font-size: 1.2em;
  vertical-align: -2px;
}

/* ── MAIN ─────────────────────────────────────────────────────── */
main {
  flex: 1;
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
  padding: var(--sp-10) var(--sp-5) var(--sp-12);
}

/* ── HERO ─────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  margin-bottom: var(--sp-8);
}

.hero h1 {
  font-size: var(--fs-2xl);
  font-weight: 300;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: var(--sp-2);
}

.subtitle {
  font-size: var(--fs-sm);
  color: var(--grey-500);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── TAB SWITCHER ─────────────────────────────────────────────── */
.tab-switcher {
  display: flex;
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--r-full);
  padding: 3px;
  margin-bottom: var(--sp-8);
  position: relative;
  box-shadow: var(--shadow-sm);
}

.tab-btn {
  flex: 1;
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--grey-500);
  background: transparent;
  border: none;
  border-radius: var(--r-full);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  position: relative;
  z-index: 1;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--grey-700);
}

.tab-btn.active {
  color: var(--white);
  background: var(--ink);
  box-shadow: var(--shadow-md);
}

.tab-btn .tab-icon {
  margin-right: var(--sp-1);
  font-size: 1.1em;
}

/* ── TAB PANELS ───────────────────────────────────────────────── */
.tab-panel {
  display: none;
  animation: panelIn var(--dur) var(--ease) both;
}

.tab-panel.active {
  display: block;
}

@keyframes panelIn {
  0%   { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ── INPUT GROUP ──────────────────────────────────────────────── */
.input-group {
  display: flex;
  gap: 0;
  background: var(--white);
  border: 1.5px solid var(--grey-300);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  box-shadow: var(--shadow-sm);
}

.input-group:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(10,10,10,.06);
}

.form-input {
  flex: 1;
  padding: var(--sp-4) var(--sp-5);
  font-family: var(--font);
  font-size: var(--fs-base);
  font-weight: 400;
  color: var(--ink);
  border: none;
  outline: none;
  background: transparent;
  letter-spacing: 0.1em;
  min-width: 0;
}

.form-input::placeholder {
  color: var(--grey-400);
  letter-spacing: 0.04em;
}

.submit-btn {
  padding: var(--sp-4) var(--sp-5);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--white);
  background: var(--ink);
  border: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-spring), opacity var(--dur-fast);
  white-space: nowrap;
  border-radius: 0 var(--r-md) var(--r-md) 0;
}

.submit-btn:hover {
  background: #333;
}

.submit-btn:active {
  transform: scale(0.97);
}

.submit-btn:disabled {
  background: var(--grey-400);
  cursor: not-allowed;
}

/* ── TRAIN FORM EXTRAS ────────────────────────────────────────── */
.train-form-row {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
}

.day-selector {
  display: flex;
  background: var(--white);
  border: 1.5px solid var(--grey-300);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.day-selector label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--grey-500);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;
  border-right: 1px solid var(--grey-200);
}

.day-selector label:last-child {
  border-right: none;
}

.day-selector input[type="radio"] {
  display: none;
}

.day-selector input[type="radio"]:checked + span {
  color: var(--ink);
  font-weight: 600;
}

.day-selector label:has(input:checked) {
  background: var(--grey-100);
}

.hint {
  display: block;
  margin-top: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--red);
  min-height: 1.2em;
}

/* ── RESULT CARD ──────────────────────────────────────────────── */
.result-card {
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  margin-top: var(--sp-5);
  animation: fadeSlideUp var(--dur) var(--ease) both;
  box-shadow: var(--shadow-md);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--sp-3) 0;
}

.result-row .label {
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--grey-500);
  flex-shrink: 0;
}

.result-row .value {
  font-size: var(--fs-base);
  font-weight: 400;
  color: var(--ink);
  text-align: right;
  max-width: 65%;
}

.divider {
  border: none;
  height: 1px;
  background: var(--grey-200);
  margin: var(--sp-2) 0;
}

/* ── STATUS BADGE ─────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.04em;
  border-radius: var(--r-sm);
}

.status-confirmed {
  color: var(--green);
  background: var(--green-bg);
}

.status-rac {
  color: var(--orange);
  background: var(--orange-bg);
}

.status-waitlist {
  color: var(--red);
  background: var(--red-bg);
}

.status-unknown {
  color: var(--grey-600);
  background: var(--grey-100);
}

/* ── PREDICTION ───────────────────────────────────────────────── */
.prediction-high   { color: var(--green); font-weight: 500; }
.prediction-medium { color: var(--orange); font-weight: 500; }
.prediction-low    { color: var(--red); font-weight: 500; }

/* ── ADVICE ───────────────────────────────────────────────────── */
.advice-row {
  flex-direction: column;
  gap: var(--sp-2);
}

.advice-text {
  text-align: left !important;
  max-width: 100% !important;
  line-height: 1.7;
  font-size: var(--fs-sm) !important;
  color: var(--grey-600) !important;
}

/* ═══════════════════════════════════════════════════════════════
   LIVE TRAIN STATUS — Train Tracker
   ═══════════════════════════════════════════════════════════════ */

.train-header {
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  margin-top: var(--sp-5);
  box-shadow: var(--shadow-md);
  animation: fadeSlideUp var(--dur) var(--ease) both;
}

.train-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--sp-5);
}

.train-identity h2 {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.train-identity .train-number {
  font-size: var(--fs-xs);
  color: var(--grey-500);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: var(--sp-1);
}

.delay-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  animation: chipPop var(--dur) var(--ease-spring) both;
}

.delay-chip.on-time {
  background: var(--green-bg);
  color: var(--green);
}

.delay-chip.late {
  background: var(--red-bg);
  color: var(--red);
}

.delay-chip.slight-delay {
  background: var(--orange-bg);
  color: var(--orange);
}

@keyframes chipPop {
  0%   { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}

/* ── Route progress bar ───────────────────────────────────────── */
.route-progress {
  margin-top: var(--sp-4);
}

.route-endpoints {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--sp-3);
}

.route-endpoint {
  text-align: center;
}

.route-endpoint:last-child {
  text-align: right;
}

.route-endpoint:first-child {
  text-align: left;
}

.route-endpoint .stn-code {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.04em;
}

.route-endpoint .stn-name {
  font-size: var(--fs-xs);
  color: var(--grey-500);
  display: block;
  max-width: 100px;
  line-height: 1.3;
}

.progress-track {
  position: relative;
  height: 6px;
  background: var(--grey-200);
  border-radius: var(--r-full);
  overflow: visible;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--accent));
  border-radius: var(--r-full);
  transition: width 1.2s var(--ease);
  position: relative;
}

.progress-train {
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.15));
  animation: trainBounce 2s ease-in-out infinite;
  z-index: 2;
}

@keyframes trainBounce {
  0%, 100% { transform: translateY(-50%) translateX(0); }
  50%      { transform: translateY(-55%) translateX(2px); }
}

.progress-percentage {
  text-align: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--grey-500);
  margin-top: var(--sp-2);
  letter-spacing: 0.04em;
}

/* ── Current location card ────────────────────────────────────── */
.current-location {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--blue-bg);
  border: 1px solid var(--accent-light);
  border-radius: var(--r-md);
  margin-top: var(--sp-5);
}

.location-icon {
  font-size: 1.5rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .6; transform: scale(1.1); }
}

.location-details {
  flex: 1;
}

.location-details .loc-label {
  font-size: var(--fs-xs);
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.location-details .loc-station {
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--ink);
}

.location-details .loc-meta {
  font-size: var(--fs-xs);
  color: var(--grey-500);
  margin-top: 2px;
}

/* ── Train info grid ──────────────────────────────────────────── */
.train-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}

.info-tile {
  padding: var(--sp-4);
  background: var(--grey-50);
  border-radius: var(--r-md);
  border: 1px solid var(--grey-200);
}

.info-tile .tile-label {
  font-size: var(--fs-xs);
  color: var(--grey-500);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--sp-1);
}

.info-tile .tile-value {
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--ink);
}

/* ── Upcoming stations ────────────────────────────────────────── */
.upcoming-section {
  margin-top: var(--sp-5);
  animation: fadeSlideUp var(--dur-slow) var(--ease) 0.15s both;
}

.section-title {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--grey-500);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--grey-200);
}

.station-timeline {
  position: relative;
  padding-left: var(--sp-8);
}

.station-timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--grey-200);
  border-radius: var(--r-full);
}

.station-item {
  position: relative;
  padding: var(--sp-3) 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: stationSlide var(--dur) var(--ease) both;
}

.station-item:nth-child(1) { animation-delay: 0.05s; }
.station-item:nth-child(2) { animation-delay: 0.1s; }
.station-item:nth-child(3) { animation-delay: 0.15s; }
.station-item:nth-child(4) { animation-delay: 0.2s; }
.station-item:nth-child(5) { animation-delay: 0.25s; }

@keyframes stationSlide {
  0%   { opacity: 0; transform: translateX(-8px); }
  100% { opacity: 1; transform: translateX(0); }
}

.station-dot {
  position: absolute;
  left: calc(-1 * var(--sp-8) + 4px);
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--grey-300);
  z-index: 1;
  transition: all var(--dur-fast) var(--ease);
}

.station-item.next-stop .station-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light);
}

.station-info {
  flex: 1;
}

.station-info .stn-name {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
}

.station-info .stn-code-small {
  font-size: var(--fs-xs);
  color: var(--grey-400);
  margin-left: var(--sp-1);
  letter-spacing: 0.04em;
}

.station-info .stn-distance {
  font-size: var(--fs-xs);
  color: var(--grey-500);
}

.station-times {
  text-align: right;
  flex-shrink: 0;
}

.station-times .time-eta {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
}

.station-times .time-scheduled {
  font-size: var(--fs-xs);
  color: var(--grey-400);
  text-decoration: line-through;
}

.station-times .time-delay {
  font-size: var(--fs-xs);
  font-weight: 600;
  margin-left: var(--sp-1);
}

.time-delay.delayed {
  color: var(--red);
}

.time-delay.on-time {
  color: var(--green);
}

.station-platform {
  display: inline-block;
  font-size: var(--fs-xs);
  color: var(--grey-500);
  background: var(--grey-100);
  padding: 1px var(--sp-2);
  border-radius: var(--r-sm);
  margin-top: 2px;
}

/* ── ERROR CARD ───────────────────────────────────────────────── */
.error-card {
  text-align: center;
  padding: var(--sp-5);
  margin-top: var(--sp-5);
  border: 1px solid var(--red);
  background: var(--red-bg);
  color: var(--red);
  font-size: var(--fs-sm);
  border-radius: var(--r-md);
  animation: fadeSlideUp var(--dur) var(--ease) both;
}

/* ── SKELETON ─────────────────────────────────────────────────── */
.skeleton {
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}

.skeleton .skel-line {
  height: 14px;
  background: linear-gradient(90deg, var(--grey-200) 25%, var(--grey-100) 50%, var(--grey-200) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.6s ease infinite;
  border-radius: var(--r-sm);
  margin-bottom: var(--sp-4);
}

.skel-w40 { width: 40%; }
.skel-w50 { width: 50%; }
.skel-w60 { width: 60%; }
.skel-w70 { width: 70%; }
.skel-w80 { width: 80%; }

/* ── FOOTER ───────────────────────────────────────────────────── */
#site-footer {
  padding: var(--sp-6);
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--grey-400);
  letter-spacing: 0.04em;
  border-top: 1px solid var(--grey-200);
  background: var(--white);
}

/* ── UTILITIES ────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── ANIMATIONS ───────────────────────────────────────────────── */
@keyframes fadeSlideUp {
  0%   { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: -100% 50%; }
}

@keyframes fadeIn {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

/* ── RESPONSIVE ───────────────────────────────────────────────── */
@media (max-width: 560px) {
  main {
    padding: var(--sp-8) var(--sp-4) var(--sp-8);
  }
  .hero h1 {
    font-size: var(--fs-xl);
  }
  .input-group {
    flex-direction: column;
    border-radius: var(--r-md);
  }
  .submit-btn {
    width: 100%;
    padding: var(--sp-4);
    border-radius: 0 0 var(--r-md) var(--r-md);
  }
  .result-row {
    flex-direction: column;
    gap: var(--sp-1);
  }
  .result-row .value {
    text-align: left;
    max-width: 100%;
  }
  .tab-btn {
    font-size: var(--fs-xs);
    padding: var(--sp-3) var(--sp-2);
  }
  .train-form-row {
    flex-direction: column;
  }
  .day-selector {
    width: 100%;
  }
  .train-info-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
  }
  .train-header-top {
    flex-direction: column;
    gap: var(--sp-3);
  }
  .route-endpoint .stn-name {
    max-width: 80px;
    font-size: 0.625rem;
  }
}
