/* system.css — the GoFlow interface system.
 *
 * The reference is Uber: monochrome-led, type-driven hierarchy, one large
 * action within thumb reach, content on sheets that rise from the bottom.
 * What we take is the *method*, not the skin — the parts of it that suit an
 * app used one-handed, outdoors, on a cheap Android, on a slow connection,
 * which is the situation nearly every GoFlow screen is actually used in.
 *
 * Three decisions carry most of it:
 *
 * 1. Black is the action colour, blue is the brand colour.
 *    Every page here used to make its primary button brand blue, so on a
 *    screen with six blue things the one you are meant to press did not stand
 *    out. Near-black for the primary action, blue for links, active states and
 *    the logo. This is the change you will notice first, and it is the one
 *    worth arguing about — see --ui-action.
 *
 * 2. Size carries hierarchy, not colour or borders.
 *    A status is 32px. Its explanation is 16px grey. There is no card border
 *    between them. Boxes-inside-boxes is what made the old pages feel busy.
 *
 * 3. One primary action per screen, full width, at the bottom.
 *    A rider holding a parcel in one hand and a phone in the other cannot
 *    reach the top of a 6.7" screen.
 *
 * Built on tokens.css, which must load first. Works light (customer) and dark
 * (driver, admin) — set data-ui="dark" on <html>.
 *
 * Naming: every class is u- prefixed so this can be adopted one page at a time
 * without colliding with the styles a page already has.
 */

:root {
  /* ── Surfaces ─────────────────────────────────────────────────────── */
  --ui-bg:        #FFFFFF;
  --ui-surface:   #F6F6F6;
  --ui-raised:    #FFFFFF;
  --ui-line:      #E8E8E8;
  --ui-line-soft: #F0F0F0;

  /* ── Ink ──────────────────────────────────────────────────────────── */
  --ui-text:      #000000;
  --ui-text-2:    #6B6B6B;
  --ui-text-3:    #AFAFAF;
  --ui-inverse:   #FFFFFF;

  /* ── Action ───────────────────────────────────────────────────────────
   * Not the brand blue. A primary button is the one thing on the screen you
   * are meant to press, and it earns that by being the only near-black
   * object on a white page. Blue stays for links and brand. */
  --ui-action:       #000000;
  --ui-action-hover: #1F1F1F;
  --ui-action-text:  #FFFFFF;

  /* ── Meaning ──────────────────────────────────────────────────────────
   * Deliberately few. Green means done, amber means attention, red means
   * stopped. Anything else is grey. */
  --ui-go:     var(--gf-green);
  --ui-go-bg:  #E7F7F0;
  --ui-wait:   #B25E02;
  --ui-wait-bg:#FDF3E4;
  --ui-stop:   var(--gf-red);
  --ui-stop-bg:#FDECEC;
  --ui-info:   var(--gf-blue);
  --ui-info-bg:#E7F2FB;

  /* ── Type ─────────────────────────────────────────────────────────────
   * Uber Move is proprietary, so Inter, tightened. The jumps are large on
   * purpose: 32 next to 16 reads instantly, 20 next to 16 does not. */
  --ui-display: 700 34px/38px var(--gf-font);
  --ui-title-1: 700 26px/32px var(--gf-font);
  --ui-title-2: 600 20px/26px var(--gf-font);
  --ui-title-3: 600 17px/24px var(--gf-font);
  --ui-body:    400 16px/24px var(--gf-font);
  --ui-body-sb: 500 16px/24px var(--gf-font);
  --ui-label:   500 14px/20px var(--gf-font);
  --ui-caption: 400 13px/18px var(--gf-font);
  --ui-micro:   600 11px/14px var(--gf-font);

  /* ── Rhythm — 4px grid ────────────────────────────────────────────── */
  --ui-1: 4px;   --ui-2: 8px;   --ui-3: 12px;  --ui-4: 16px;
  --ui-5: 20px;  --ui-6: 24px;  --ui-8: 32px;  --ui-10: 40px;
  --ui-12: 48px; --ui-16: 64px;

  /* ── Shape ────────────────────────────────────────────────────────── */
  --ui-r:      8px;
  --ui-r-card: 12px;
  --ui-r-sheet:20px;
  --ui-r-pill: 999px;

  /* ── Motion — quick, never decorative ─────────────────────────────── */
  --ui-fast: 120ms cubic-bezier(.2,0,0,1);
  --ui-base: 200ms cubic-bezier(.2,0,0,1);

  /* Thumb reach. Nothing interactive is smaller than this. */
  --ui-tap: 48px;
}

[data-ui="dark"] {
  --ui-bg:        var(--gf-d-bg);
  --ui-surface:   var(--gf-d-surface);
  --ui-raised:    var(--gf-d-raised);
  --ui-line:      var(--gf-d-border);
  --ui-line-soft: #23273450;

  --ui-text:      var(--gf-d-text);
  --ui-text-2:    var(--gf-d-text-2);
  --ui-text-3:    var(--gf-d-text-3);
  --ui-inverse:   #000000;

  /* Inverted: on a near-black page the thing you press is white. */
  --ui-action:       #FFFFFF;
  --ui-action-hover: #E4E4E4;
  --ui-action-text:  #000000;

  --ui-go-bg:   var(--gf-green-alpha);
  --ui-wait:    #E9A13B;
  --ui-wait-bg: var(--gf-amber-alpha);
  --ui-stop-bg: var(--gf-red-alpha);
  --ui-info-bg: rgba(11,138,209,.16);
}

/* ══ Reset ══════════════════════════════════════════════════════════ */
.u *, .u *::before, .u *::after { box-sizing: border-box; }

.u {
  background: var(--ui-bg);
  color: var(--ui-text);
  font: var(--ui-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ══ Type ═══════════════════════════════════════════════════════════ */
.u-display { font: var(--ui-display); letter-spacing: -.6px; }
.u-t1      { font: var(--ui-title-1); letter-spacing: -.4px; }
.u-t2      { font: var(--ui-title-2); letter-spacing: -.2px; }
.u-t3      { font: var(--ui-title-3); }
.u-body    { font: var(--ui-body); }
.u-label   { font: var(--ui-label); }
.u-caption { font: var(--ui-caption); color: var(--ui-text-2); }
.u-micro   { font: var(--ui-micro); letter-spacing: .8px; text-transform: uppercase;
             color: var(--ui-text-3); }
.u-dim     { color: var(--ui-text-2); }
.u-num     { font-variant-numeric: tabular-nums; }

/* ══ App bar ════════════════════════════════════════════════════════
 * Deliberately plain. On a working screen the bar is orientation, not
 * decoration — the content below it is the point. */
.u-bar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: var(--ui-3);
  min-height: 56px; padding: 0 var(--ui-4);
  background: var(--ui-bg);
  border-bottom: 1px solid var(--ui-line);
}
.u-bar__title { font: var(--ui-title-3); flex: 1; min-width: 0;
                overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-bar__icon {
  width: var(--ui-tap); height: var(--ui-tap); margin-left: calc(var(--ui-3) * -1);
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; color: inherit; cursor: pointer;
  border-radius: var(--ui-r-pill);
}
.u-bar__icon:hover { background: var(--ui-surface); }

/* ══ Layout ═════════════════════════════════════════════════════════ */
.u-page  { max-width: 720px; margin: 0 auto; padding: calc(var(--gf-nav-h,68px) + var(--gf-hero-air,80px)) var(--ui-4) var(--ui-16); }
.u-page--wide { max-width: 1180px; }
.u-stack > * + * { margin-top: var(--ui-4); }
.u-stack-2 > * + * { margin-top: var(--ui-2); }

/* ══ Hero ═══════════════════════════════════════════════════════════
 * The one thing the page is about. On /track this is the status; on the
 * driver home it is what they have earned. It is big enough to read at
 * arm's length in daylight. */
.u-hero        { padding: var(--ui-6) 0 var(--ui-5); }
.u-hero__eyebrow { font: var(--ui-micro); color: var(--ui-text-3); margin-bottom: var(--ui-2); }
.u-hero__title { font: var(--ui-display); letter-spacing: -.8px; margin-bottom: var(--ui-2); }
.u-hero__sub   { font: var(--ui-body); color: var(--ui-text-2); }

/* ══ Buttons ════════════════════════════════════════════════════════ */
.u-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--ui-2);
  min-height: var(--ui-tap); padding: 0 var(--ui-5);
  font: var(--ui-body-sb); font-family: var(--gf-font);
  border: 0; border-radius: var(--ui-r); cursor: pointer;
  text-decoration: none; white-space: nowrap;
  background: var(--ui-action); color: var(--ui-action-text);
  transition: background var(--ui-fast), transform var(--ui-fast);
}
.u-btn:hover:not(:disabled)  { background: var(--ui-action-hover); }
.u-btn:active:not(:disabled) { transform: scale(.985); }
.u-btn:disabled { opacity: .38; cursor: not-allowed; }
.u-btn--full  { width: 100%; }
.u-btn--lg    { min-height: 56px; font: var(--ui-title-3); font-family: var(--gf-font); }

/* Secondary: same weight of presence, none of the pull. */
.u-btn--soft  { background: var(--ui-surface); color: var(--ui-text); }
.u-btn--soft:hover:not(:disabled) { background: var(--ui-line); }
.u-btn--line  { background: transparent; color: var(--ui-text);
                box-shadow: inset 0 0 0 1px var(--ui-line); }
.u-btn--line:hover:not(:disabled) { background: var(--ui-surface); }
.u-btn--ghost { background: transparent; color: var(--ui-text); padding: 0 var(--ui-3); }
.u-btn--ghost:hover:not(:disabled) { background: var(--ui-surface); }
.u-btn--go    { background: var(--ui-go);   color: #fff; }
.u-btn--stop  { background: var(--ui-stop); color: #fff; }

/* The action bar. Pinned to the bottom, above the safe area, because that is
 * where a thumb is. Every screen has at most one. */
.u-actionbar {
  position: sticky; bottom: 0; z-index: 30;
  padding: var(--ui-3) var(--ui-4) calc(var(--ui-3) + env(safe-area-inset-bottom, 0px));
  background: var(--ui-bg);
  border-top: 1px solid var(--ui-line);
  display: flex; gap: var(--ui-2);
}
.u-actionbar .u-btn { flex: 1; }

/* ══ Cards and rows ═════════════════════════════════════════════════
 * A card is a grouping, not a frame. Fill, no border, no shadow. */
.u-card {
  background: var(--ui-surface);
  border-radius: var(--ui-r-card);
  padding: var(--ui-4);
}
.u-card--raised { background: var(--ui-raised); box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04); }
[data-ui="dark"] .u-card--raised { box-shadow: none; background: var(--ui-raised); }

/* Key/value rows. Separated by a hairline, never by a box each. */
.u-rows { display: flex; flex-direction: column; }
.u-row {
  display: flex; align-items: baseline; gap: var(--ui-4);
  padding: var(--ui-3) 0;
  border-bottom: 1px solid var(--ui-line-soft);
}
.u-row:last-child { border-bottom: 0; }
.u-row__k { font: var(--ui-body); color: var(--ui-text-2); flex: 0 0 auto; }
.u-row__v { font: var(--ui-body-sb); margin-left: auto; text-align: right; min-width: 0;
            overflow-wrap: anywhere; }

/* A row you can press — a job, an order, a person. */
.u-item {
  display: flex; align-items: center; gap: var(--ui-3);
  width: 100%; min-height: var(--ui-tap);
  padding: var(--ui-3) var(--ui-4); margin: 0 calc(var(--ui-4) * -1);
  background: none; border: 0; border-radius: var(--ui-r-card);
  color: inherit; font: var(--ui-body); text-align: left; cursor: pointer;
  text-decoration: none;
}
.u-item:hover { background: var(--ui-surface); }
.u-item__main { flex: 1; min-width: 0; }
.u-item__title { font: var(--ui-body-sb); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-item__sub   { font: var(--ui-caption); color: var(--ui-text-2); }

/* ══ Status ═════════════════════════════════════════════════════════ */
.u-tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: var(--ui-r-pill);
  font: var(--ui-micro); letter-spacing: .4px;
  background: var(--ui-surface); color: var(--ui-text-2);
}
.u-tag--go   { background: var(--ui-go-bg);   color: var(--ui-go); }
.u-tag--wait { background: var(--ui-wait-bg); color: var(--ui-wait); }
.u-tag--stop { background: var(--ui-stop-bg); color: var(--ui-stop); }
.u-tag--info { background: var(--ui-info-bg); color: var(--ui-info); }

/* Filter chips. Horizontally scrollable, never wrapped onto three lines. */
.u-chips { display: flex; gap: var(--ui-2); overflow-x: auto; padding-bottom: var(--ui-1);
           scrollbar-width: none; }
.u-chips::-webkit-scrollbar { display: none; }
.u-chip {
  flex: 0 0 auto; height: 36px; padding: 0 var(--ui-4);
  display: inline-flex; align-items: center;
  border: 0; border-radius: var(--ui-r-pill); cursor: pointer;
  font: var(--ui-label); font-family: var(--gf-font);
  background: var(--ui-surface); color: var(--ui-text-2);
  transition: background var(--ui-fast), color var(--ui-fast);
}
.u-chip[aria-pressed="true"] { background: var(--ui-action); color: var(--ui-action-text); }

/* ══ Progress ═══════════════════════════════════════════════════════
 * A journey as a line, not a list of five paragraphs. The old tracker gave
 * every step equal weight; here the step you are on is the only one in full
 * contrast. */
.u-track { display: flex; align-items: flex-start; gap: 0; margin: var(--ui-5) 0; }
.u-track__step { flex: 1; display: flex; flex-direction: column; gap: var(--ui-2); min-width: 0; }
.u-track__line { display: flex; align-items: center; }
.u-track__dot {
  width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto;
  background: var(--ui-line); transition: background var(--ui-base);
}
.u-track__bar { height: 2px; flex: 1; background: var(--ui-line); }
.u-track__step:last-child .u-track__bar { display: none; }
.u-track__label { font: var(--ui-caption); color: var(--ui-text-3); padding-right: var(--ui-2); }

.u-track__step.is-done .u-track__dot,
.u-track__step.is-done .u-track__bar { background: var(--ui-go); }
.u-track__step.is-done .u-track__label { color: var(--ui-text-2); }

.u-track__step.is-now .u-track__dot {
  background: var(--ui-action); box-shadow: 0 0 0 4px var(--ui-surface);
}
.u-track__step.is-now .u-track__label { color: var(--ui-text); font-weight: 600; }

.u-track__step.is-stop .u-track__dot { background: var(--ui-stop); }
.u-track__step.is-stop .u-track__label { color: var(--ui-stop); font-weight: 600; }

/* ══ Person ═════════════════════════════════════════════════════════
 * Who is at your door, or who you are collecting from. A face, a name and a
 * plate — the three things that identify somebody. */
.u-person { display: flex; align-items: center; gap: var(--ui-3); }
.u-avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: 0 0 auto;
  object-fit: cover; background: var(--ui-surface);
  display: flex; align-items: center; justify-content: center;
  font: var(--ui-title-2); color: var(--ui-text-3);
}
.u-plate {
  display: inline-block; margin-top: var(--ui-1);
  font: 600 13px/18px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .5px; padding: 2px 8px; border-radius: 4px;
  background: var(--ui-surface); color: var(--ui-text-2);
}

/* ══ Bottom sheet ═══════════════════════════════════════════════════
 * The signature pattern, and the one that most improves this product: a
 * decision arrives from the bottom, over what you were looking at, without
 * taking you to another page and losing your place. */
.u-scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,.45);
  opacity: 0; pointer-events: none;
  transition: opacity var(--ui-base);
}
.u-scrim.is-open { opacity: 1; pointer-events: auto; }

.u-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 91;
  max-height: 88vh; overflow-y: auto;
  background: var(--ui-bg);
  border-radius: var(--ui-r-sheet) var(--ui-r-sheet) 0 0;
  padding: var(--ui-2) var(--ui-4) calc(var(--ui-6) + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform var(--ui-base);
  /* Closed still means "fully present, just moved" via transform — and at
     640px+ (below) closed is opacity:0 in place, not moved at all. Either
     way, without this an invisible sheet sits at z-index:91 over whatever
     is centered on the page and swallows every click under it. u-scrim
     already guards the same way; this component didn't. */
  pointer-events: none;
}
.u-sheet.is-open { transform: none; pointer-events: auto; }
.u-sheet__grip {
  width: 36px; height: 4px; border-radius: 2px; background: var(--ui-line);
  margin: var(--ui-2) auto var(--ui-4);
}
.u-sheet__title { font: var(--ui-title-2); margin-bottom: var(--ui-4); }

@media (min-width: 640px) {
  /* On a desktop a sheet is a dialog. Same markup, same code. */
  .u-sheet {
    left: 50%; bottom: auto; top: 50%;
    width: min(480px, calc(100vw - 48px));
    transform: translate(-50%, -46%) scale(.98);
    border-radius: var(--ui-r-sheet);
    opacity: 0; transition: opacity var(--ui-base), transform var(--ui-base);
  }
  .u-sheet.is-open { transform: translate(-50%, -50%); opacity: 1; }
  .u-sheet__grip { display: none; }
}

/* ══ Fields ═════════════════════════════════════════════════════════ */
.u-field { display: flex; flex-direction: column; gap: 6px; }
.u-field > label { font: var(--ui-label); color: var(--ui-text-2); }
.u-field input, .u-field select, .u-field textarea {
  min-height: var(--ui-tap); width: 100%;
  padding: var(--ui-3) var(--ui-4);
  font: var(--ui-body); font-family: var(--gf-font);
  color: var(--ui-text); background: var(--ui-bg);
  border: 1px solid var(--ui-line); border-radius: var(--ui-r);
  outline: none; transition: border-color var(--ui-fast), box-shadow var(--ui-fast);
}
/* 16px minimum, or iOS Safari zooms the whole page when the field is focused. */
.u-field input:focus, .u-field select:focus, .u-field textarea:focus {
  border-color: var(--ui-text); box-shadow: 0 0 0 3px var(--ui-line-soft);
}
.u-field__hint { font: var(--ui-caption); color: var(--ui-text-2); }

/* ══ Empty and loading ══════════════════════════════════════════════ */
.u-empty { text-align: center; padding: var(--ui-16) var(--ui-4); }
.u-empty__icon { font-size: 40px; margin-bottom: var(--ui-3); opacity: .5; }
.u-empty__title { font: var(--ui-title-3); margin-bottom: var(--ui-1); }
.u-empty__sub { font: var(--ui-caption); color: var(--ui-text-2); }

/* A shape where the content will be, so the page does not jump when it
 * arrives. Better than a spinner: it says what is coming. */
.u-skeleton {
  background: linear-gradient(90deg, var(--ui-surface) 25%, var(--ui-line-soft) 37%, var(--ui-surface) 63%);
  background-size: 400% 100%;
  animation: u-shimmer 1.2s ease-in-out infinite;
  border-radius: var(--ui-r);
}
@keyframes u-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

@media (prefers-reduced-motion: reduce) {
  .u-skeleton { animation: none; }
  .u-sheet, .u-scrim, .u-btn { transition: none; }
}

/* ══ Utility ════════════════════════════════════════════════════════ */
.u-hidden { display: none !important; }
.u-divider { height: 1px; background: var(--ui-line); margin: var(--ui-5) 0; }
.u-spread { display: flex; align-items: center; justify-content: space-between; gap: var(--ui-3); }
