/* Ride — design system.
   Reference object: the Chinese fleet 三联派车单 (carbonless dispatch slip):
   pale blue-grey stock, deep ink-blue printing, one red chop. Field labels are
   wide-tracked and small; values are large. Times use tabular monospace so a
   column of departures reads like an instrument.

   No webfonts on purpose — drivers are on Chinese mobile networks where
   fonts.googleapis.com is unreliable. Personality lives in the numerals. */

:root {
  --paper:    #F2F5F7;
  --paper-2:  #FFFFFF;
  --carbon:   #DCE7EC;
  --ink:      #12293C;
  --ink-2:    #5A7385;
  --stamp:    #C0392B;
  --route:    #C77A12;
  --ok:       #1E7A5A;
  --shadow:   0 1px 2px rgba(18,41,60,.06), 0 8px 24px -12px rgba(18,41,60,.18);
  --r:        10px;

  --cjk: "PingFang SC", "HarmonyOS Sans SC", "Noto Sans CJK SC", "Microsoft YaHei",
         system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:   #0B1620;
    --paper-2: #12222E;
    --carbon:  #223949;
    --ink:     #E8F0F4;
    --ink-2:   #90A8B8;
    --stamp:   #E2604F;
    --route:   #F0AB48;
    --ok:      #3FA97F;
    --shadow:  0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }
/* .topbar/.tabs set display:flex, which outranks the UA's [hidden] rule. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--cjk);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

.wrap { max-width: 34rem; margin: 0 auto; padding: 0 1rem 5rem; }

/* --- slip chrome ------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  padding: calc(env(safe-area-inset-top) + .7rem) 1rem .7rem;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--carbon);
}
.topbar h1 {
  margin: 0; font-size: .9375rem; font-weight: 700; letter-spacing: .16em;
}
.topbar .sub { color: var(--ink-2); font-size: .8125rem; letter-spacing: .04em; }
.spacer { flex: 1; }

/* Field label, straight off the printed form. */
.lab {
  font-size: .6875rem; font-weight: 600; letter-spacing: .18em;
  color: var(--ink-2);
}

/* Times, dates, counts — the instrument face. */
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.card {
  background: var(--paper-2);
  border: 1px solid var(--carbon);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: .75rem;
}

/* --- the chop: the one red thing in the product ----------------------- */
.chop {
  display: inline-flex; align-items: baseline; gap: .45rem;
  padding: .3rem .6rem;
  border: 1.5px solid var(--stamp);
  box-shadow: inset 0 0 0 1px var(--paper-2), 0 0 0 1px color-mix(in srgb, var(--stamp) 30%, transparent);
  border-radius: 3px;
  color: var(--stamp);
  transform: rotate(-1.2deg);       /* applied by hand, not printed */
  transform-origin: left center;
}
.chop .lab { color: inherit; opacity: .8; }
.chop b { font-size: 1rem; font-weight: 700; letter-spacing: .02em; }
.chop.pending { --stamp: var(--ink-2); }

/* --- route: pickup -> dropoff, connected because it is a journey ------ */
.route { display: grid; grid-template-columns: 1rem 1fr; gap: 0 .7rem; }
.route .dot {
  position: relative; display: flex; justify-content: center; padding-top: .5rem;
}
.route .dot::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: var(--ink); flex: none;
}
.route .dot.end::before { background: none; border: 2px solid var(--ink); }
.route .dot.line::after {
  content: ""; position: absolute; top: 1.1rem; bottom: -.35rem; width: 1px;
  background: repeating-linear-gradient(var(--carbon) 0 3px, transparent 3px 6px);
}
.route .place { padding: .25rem 0 .35rem; min-width: 0; }
.route .place b { font-weight: 600; }
.route .place small { display: block; color: var(--ink-2); font-size: .8125rem; }

/* --- buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: 0 1rem;
  border: 1px solid var(--carbon); border-radius: 8px;
  background: var(--paper-2); color: var(--ink);
  font-weight: 600; cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}
.btn:active { transform: scale(.985); }
.btn:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }
.btn.primary { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }
.btn.danger  { color: var(--stamp); border-color: color-mix(in srgb, var(--stamp) 45%, var(--carbon)); }
.btn.ghost   { background: transparent; }
.btn.wide    { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* The driver's one action. Sized to be hit without looking. */
.btn.huge {
  min-height: 68px; font-size: 1.25rem; letter-spacing: .08em;
  border-radius: 12px; width: 100%;
}

.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .55rem; border-radius: 999px;
  border: 1px solid var(--carbon); background: var(--paper);
  font-size: .75rem; font-weight: 600; letter-spacing: .04em;
}
.chip.live  { color: var(--stamp); border-color: color-mix(in srgb, var(--stamp) 40%, var(--carbon)); }
.chip.route { color: var(--route); border-color: color-mix(in srgb, var(--route) 40%, var(--carbon)); }
.chip.ok    { color: var(--ok);    border-color: color-mix(in srgb, var(--ok) 40%, var(--carbon)); }

.field { margin-bottom: .85rem; }
.field .lab { display: block; margin-bottom: .3rem; }
.input {
  width: 100%; min-height: 44px; padding: .5rem .7rem;
  background: var(--paper-2); border: 1px solid var(--carbon);
  border-radius: 8px;
}
.input:focus-visible { outline: 2px solid var(--ink); outline-offset: -1px; }
textarea.input { min-height: 5rem; resize: vertical; }

.row { display: flex; align-items: center; gap: .6rem; }
.muted { color: var(--ink-2); }
.hr { height: 1px; background: var(--carbon); margin: .9rem -1rem; }

/* Day heading: the slip's date band. */
.dayband {
  display: flex; align-items: baseline; gap: .6rem;
  margin: 1.4rem 0 .6rem; padding-bottom: .35rem;
  border-bottom: 2px solid var(--ink);
}
.dayband .d { font-size: 1.0625rem; font-weight: 700; letter-spacing: .04em; }

.sheet {
  position: fixed; inset: 0; z-index: 50; display: none;
  /* Opaque enough that the list underneath stops competing for attention --
     this is where the dispatch decision gets made. */
  background: rgba(6, 16, 24, .66);
  backdrop-filter: blur(2px);
}
.sheet.open { display: block; }
.sheet .panel {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 34rem;
  max-height: 92vh; overflow: auto; overscroll-behavior: contain;
  background: var(--paper);
  border: 1px solid var(--carbon); border-bottom: 0;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 40px -8px rgba(6, 16, 24, .45);
  padding: 1rem 1rem calc(env(safe-area-inset-bottom) + 1.5rem);
  animation: rise .22s cubic-bezier(.2,.8,.3,1);
}
@keyframes rise { from { transform: translate(-50%, 14px); opacity: .6; } }
.sheet .grab {
  width: 36px; height: 4px; border-radius: 2px; background: var(--carbon);
  margin: 0 auto .9rem;
}

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 1.2rem);
  transform: translateX(-50%);
  background: var(--ink); color: var(--paper-2);
  padding: .6rem 1rem; border-radius: 999px; font-size: .875rem;
  z-index: 90; box-shadow: var(--shadow); max-width: 90vw;
}

.empty { text-align: center; padding: 3.5rem 1rem; color: var(--ink-2); }
.empty .big { font-size: 1.0625rem; color: var(--ink); font-weight: 600; margin-bottom: .35rem; }

.tabs { display: flex; gap: .3rem; padding: .6rem 0; }
.tabs button {
  flex: 1; min-height: 38px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--ink-2); font-weight: 600; cursor: pointer;
}
.tabs button[aria-selected="true"] {
  background: var(--paper-2); border-color: var(--carbon); color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .chop { transform: none; }
}
