/* ST Tracker v2 (beta) — a bold, card-forward design system in the quick-commerce style
   (Zepto/Blinkit/Swiggy-adjacent): big live numbers, color-blocked hero, pill status chips,
   bottom tab bar. Distinct on purpose from v1's palette so the two never get confused. */

:root {
  --bg: #F6F5FB;
  --surface: #FFFFFF;
  --surface-2: #F0EEFA;
  --text: #17151F;
  --text-dim: #6B6879;
  --border: #E7E4F2;

  --primary: #6D28D9;
  --primary-2: #9333EA;
  --primary-soft: #F1E9FE;
  --on-primary: #FFFFFF;
  --hero-1: #7C3AED;
  --hero-2: #A21CAF;

  --good: #16A34A;
  --good-soft: #DCFCE7;
  --warn: #D97706;
  --warn-soft: #FEF3C7;
  --bad: #DC2626;
  --bad-soft: #FEE2E2;

  /* Category colors — one per tile, so the quick-action grid reads at a glance instead of
     being four identical purple squares. */
  --cat-track: #7C3AED;   --cat-track-soft: #F1E9FE;
  --cat-routes: #2563EB;  --cat-routes-soft: #DBEAFE;
  --cat-nearby: #0D9488;  --cat-nearby-soft: #CCFBF1;
  --cat-you: #C2410C;     --cat-you-soft: #FFEDD5;

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  --shadow: 0 8px 24px -12px rgba(23, 21, 31, 0.25);
  --shadow-sm: 0 2px 8px -4px rgba(23, 21, 31, 0.15);

  --space-1: 6px;
  --space-2: 12px;
  --space-3: 20px;
  --space-4: 28px;

  --tabbar-h: 68px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121017;
    --surface: #1C1A24;
    --surface-2: #26232F;
    --text: #F3F1FA;
    --text-dim: #A6A2B8;
    --border: #2E2B3A;
    --primary: #A855F7;
    --primary-2: #C084FC;
    --primary-soft: #2C2140;
    --on-primary: #17151F;
    /* A darker, deeper hero than the light theme's — the light gradient's saturation reused
       verbatim against a near-black page reads as neon rather than premium. */
    --hero-1: #5B21B6;
    --hero-2: #86198F;
    --good-soft: #103820;
    --warn-soft: #3A2A08;
    --bad-soft: #3B1418;
    --cat-track: #C084FC;  --cat-track-soft: #2C2140;
    --cat-routes: #60A5FA; --cat-routes-soft: #1B2A4A;
    --cat-nearby: #2DD4BF; --cat-nearby-soft: #0F2E2A;
    --cat-you: #FB923C;    --cat-you-soft: #3A2410;
  }
}
:root[data-theme="dark"] {
  --bg: #121017;
  --surface: #1C1A24;
  --surface-2: #26232F;
  --text: #F3F1FA;
  --text-dim: #A6A2B8;
  --border: #2E2B3A;
  --primary: #A855F7;
  --primary-2: #C084FC;
  --primary-soft: #2C2140;
  --on-primary: #17151F;
  --hero-1: #5B21B6;
  --hero-2: #86198F;
  --good-soft: #103820;
  --warn-soft: #3A2A08;
  --bad-soft: #3B1418;
  --cat-track: #C084FC;  --cat-track-soft: #2C2140;
  --cat-routes: #60A5FA; --cat-routes-soft: #1B2A4A;
  --cat-nearby: #2DD4BF; --cat-nearby-soft: #0F2E2A;
  --cat-you: #FB923C;    --cat-you-soft: #3A2410;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  min-height: 100dvh;
  background: var(--bg);
  /* A fixed, faint glow anchored at the top instead of a flat fill — so a short screen's empty
     space below the content reads as atmosphere, not as a hole where something should be. */
  background-image: radial-gradient(600px 400px at 15% -10%, color-mix(in srgb, var(--hero-1) 16%, transparent), transparent);
  background-repeat: no-repeat;
  background-attachment: fixed;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: scale(0.97); }

/* ---------------------------------------------------------------- topbar */
.topbar {
  padding: calc(var(--space-3) + env(safe-area-inset-top, 0px)) var(--space-3) var(--space-2);
}
.brand { display: flex; align-items: center; gap: var(--space-2); }
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.beta-chip {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--primary);
}

/* ---------------------------------------------------------------- screen */
.screen {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ---------------------------------------------------------------- hero */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-3);
  background: linear-gradient(155deg, var(--hero-1) 0%, var(--hero-2) 100%);
  color: #FFFFFF;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 168px;
  justify-content: center;
}
/* A soft diagonal shine plus a giant faded watermark icon — flat two-tone gradients read as a
   placeholder banner rather than a live status card without some texture on top. */
.hero::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(115deg, rgba(255,255,255,0.16) 0%, transparent 40%),
              radial-gradient(220px 220px at 105% 115%, rgba(255,255,255,0.14), transparent);
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute;
  right: -18px; bottom: -22px;
  width: 130px; height: 130px;
  background: rgba(255, 255, 255, 0.10);
  border-radius: 50%;
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.hero-plate {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.9;
}
.hero-eta {
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
}
.hero-eta-num {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hero-eta-unit {
  font-size: 18px;
  font-weight: 700;
  opacity: 0.85;
}
.hero-sub {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.9;
}

/* status chip: neutral by default, colored variants set via [data-tone] */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
}
.chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.chip[data-tone="good"] { background: var(--good-soft); color: var(--good); }
.chip[data-tone="warn"] { background: var(--warn-soft); color: var(--warn); }
.chip[data-tone="bad"] { background: var(--bad-soft); color: var(--bad); }

/* ---------------------------------------------------------------- search */
.searchbar {
  display: flex;
  gap: var(--space-2);
}
.plate-input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.plate-input:focus { outline: none; border-color: var(--primary); }
.track-btn {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 800;
  font-size: 15px;
  padding: 0 24px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------------- grid */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}
.tile {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-1) var(--space-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}
.tile-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Category color per tile — data-tone set in markup — so the grid reads at a glance instead
   of four identical purple squares. */
.tile[data-tone="track"] .tile-icon  { background: var(--cat-track-soft);  color: var(--cat-track); }
.tile[data-tone="routes"] .tile-icon { background: var(--cat-routes-soft); color: var(--cat-routes); }
.tile[data-tone="nearby"] .tile-icon { background: var(--cat-nearby-soft); color: var(--cat-nearby); }
.tile[data-tone="you"] .tile-icon    { background: var(--cat-you-soft);    color: var(--cat-you); }
.tile-label {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text);
  text-align: center;
}

/* ---------------------------------------------------------------- sections */
.section-title {
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 var(--space-2);
}
.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
}

/* ---------------------------------------------------------------- tabbar */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-dim);
}
.tab-icon { display: flex; opacity: 0.55; }
.tab-label { font-size: 11px; font-weight: 700; }
.tab.is-active { color: var(--primary); }
.tab.is-active .tab-icon { opacity: 1; }

@media (prefers-reduced-motion: no-preference) {
  .hero-eta-num { transition: opacity 0.15s ease; }
}

/* ---------------------------------------------------------------- fields */
.field {
  position: relative;
}
.field-input {
  width: 100%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
}
.field-input:focus { outline: none; border-color: var(--primary); }
.field-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  display: block;
}
.suggest {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow-y: auto;
  z-index: 20;
}
.suggest-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover, .suggest-item:active { background: var(--surface-2); }
.suggest-sub { display: block; font-size: 12px; font-weight: 500; color: var(--text-dim); }

.route-pair {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.route-pair .field { flex: 1; }
.swap-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 800;
  font-size: 15px;
  padding: 15px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------------- result / list cards */
.result-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.result-time {
  font-size: 20px;
  font-weight: 900;
  min-width: 76px;
  font-variant-numeric: tabular-nums;
}
.result-main { flex: 1; min-width: 0; }
.result-route {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-plate { font-size: 12px; color: var(--text-dim); font-weight: 600; }

.station-row {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.station-name { font-size: 14px; font-weight: 700; }
.station-dist {
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: var(--space-4) var(--space-3);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
}

/* Fills the "nothing searched yet" gap with something intentional instead of a blank void. */
.placeholder-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
  padding: var(--space-4) var(--space-3);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
}
.placeholder-panel .tile-icon {
  width: 64px;
  height: 64px;
  background: var(--primary-soft);
  color: var(--primary);
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  border-radius: var(--radius-md);
  height: 64px;
}
@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: shimmer 1.4s ease infinite; }
}
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ---------------------------------------------------------------- settings rows */
.settings-row {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.settings-label { font-size: 14px; font-weight: 700; }
.settings-sub { font-size: 12px; color: var(--text-dim); font-weight: 500; margin-top: 2px; }
.seg {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 3px;
}
.seg button {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 800;
  color: var(--text-dim);
}
.seg button.is-active { background: var(--primary); color: var(--on-primary); }

.link-row {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}
