/* ══════════════════════════════════════════════════════════════════════════════════════
   ESCARGO — AUTHENTICATED WORKSPACE DESIGN SYSTEM
   Founder visual-quality commission, 2026-08-15.

   ── WHY THIS FILE EXISTS ──────────────────────────────────────────────────────────────
   Customer (/drive), Business (/garage) and Driver (/app/driver) each grew their own
   colours, radii, shadows and type sizes. The result is a visual cliff after sign-in: the
   landing page looks designed, the workspace looks developer-built. Twenty screens were
   each solving the same styling problem separately.

   Every token below is MEASURED from the founder's reference design
   (escargot-mobile-design), not invented, so the authenticated product converges on the
   brand rather than on my taste.

   ── THE RULE THAT KEEPS THIS SAFE ─────────────────────────────────────────────────────
   This file is ADDITIVE. It defines tokens and `.ew-*` primitives. It does NOT restyle
   existing selectors, because the garage responsive + orientation suites (216 assertions
   across five viewports) pass against the current layout, and a global override would
   silently move geometry they measure. Surfaces adopt these classes deliberately, one at
   a time, and re-prove.

   ── THE SIGNATURE ─────────────────────────────────────────────────────────────────────
   Elevation is GREEN-TINTED, never neutral black — rgba(23,60,40,…) / rgba(7,59,36,…).
   That single decision is most of what separates "premium automotive software" from a
   bootstrap card. Blur is used sparingly; the reference leans on a crisp 2px solid ledge
   far more than on glass.
   ══════════════════════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Brand, measured from the reference ─────────────────────────────────────────── */
  --ew-forest: #073b24;
  --ew-deep:   #052c1b;
  --ew-green:  #0c4a2e;
  --ew-lime:   #80bf20;

  /* ── Text hierarchy. THREE weights of meaning, never one grey for everything. ───── */
  --ew-ink:    #17201b;   /* titles, numbers that matter          */
  --ew-text:   #3d463f;   /* body                                  */
  --ew-muted:  #707972;   /* metadata, timestamps, helper text     */

  /* ── Surfaces ───────────────────────────────────────────────────────────────────── */
  --ew-canvas: #f6f7f3;   /* page background                       */
  --ew-surface:#ffffff;   /* primary card                          */
  --ew-mist:   #eaf0e9;   /* secondary / inset panel               */
  --ew-line:   #dfe5dc;   /* borders + the solid ledge             */

  /* ── Semantic. Backgrounds only — paired with --ew-ink for AA contrast. ─────────── */
  --ew-good:   #dff5e5;
  --ew-warn:   #fff0c2;
  --ew-bad:    #ffe1de;
  --ew-info:   #dff1ff;
  --ew-good-ink: #0d5c31;
  --ew-warn-ink: #6b4e00;
  --ew-bad-ink:  #8c2119;
  --ew-info-ink: #10456b;

  /* ── Radius. Three steps, not twelve. ───────────────────────────────────────────── */
  --ew-r-sm: 10px;
  --ew-r:    12px;   /* the dominant radius in the reference */
  --ew-r-lg: 16px;   /* cards, sheets                        */
  --ew-r-pill: 999px;

  /* ── Elevation. Green-tinted, in four deliberate steps. ─────────────────────────── */
  --ew-ledge:   0 2px 0 0 var(--ew-line);                 /* crisp, flat, no blur     */
  --ew-e1:      0 4px 14px rgba(23,60,40,.125);           /* raised card              */
  --ew-e2:      0 12px 26px rgba(7,59,36,.145);           /* modal, popover           */
  --ew-e-sheet: 0 -8px 24px rgba(23,60,40,.063);          /* bottom sheet, upward     */
  --ew-e-cta:   0 8px 24px rgba(7,59,36,.333);            /* primary action           */

  /* ── Type scale. Deliberately non-adjacent so hierarchy survives a squint test. ── */
  --ew-t-display: 700 28px/1.15 var(--ew-font);
  --ew-t-page:    700 22px/1.2  var(--ew-font);
  --ew-t-section: 700 17px/1.3  var(--ew-font);
  --ew-t-card:    700 16px/1.35 var(--ew-font);
  --ew-t-body:    400 15px/1.5  var(--ew-font);
  --ew-t-meta:    400 13px/1.45 var(--ew-font);
  --ew-t-label:   700 11px/1.2  var(--ew-font);
  --ew-font: 'Geist', Inter, system-ui, -apple-system, sans-serif;

  --ew-tap: 48px;          /* minimum touch target */
  --ew-ease: cubic-bezier(.2,.7,.3,1);
}

/* ── TYPOGRAPHY ───────────────────────────────────────────────────────────────────────
   Page title, section title and card title must never be the same size AND weight —
   that similarity is what makes a correct layout look unfinished. */
.ew-display { font: var(--ew-t-display); letter-spacing: -.02em; color: var(--ew-ink); margin: 0; }
.ew-h1      { font: var(--ew-t-page);    letter-spacing: -.015em; color: var(--ew-ink); margin: 0; }
.ew-h2      { font: var(--ew-t-section); letter-spacing: -.01em;  color: var(--ew-ink); margin: 0; }
.ew-h3      { font: var(--ew-t-card);    color: var(--ew-ink); margin: 0; }
.ew-body    { font: var(--ew-t-body);    color: var(--ew-text); margin: 0; }
.ew-meta    { font: var(--ew-t-meta);    color: var(--ew-muted); margin: 0; }
.ew-label   { font: var(--ew-t-label);   color: var(--ew-muted); text-transform: uppercase;
              letter-spacing: .07em; margin: 0; }
/* Prices and counts read as data, not prose — tabular figures stop columns dancing. */
.ew-figure  { font: 700 20px/1.2 var(--ew-font); color: var(--ew-ink);
              font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* ── SURFACES ─────────────────────────────────────────────────────────────────────── */
.ew-card {
  background: var(--ew-surface); border: 1px solid var(--ew-line);
  border-radius: var(--ew-r-lg); padding: 16px;
}
.ew-card--quiet   { background: var(--ew-mist); border-color: transparent; }
.ew-card--raised  { box-shadow: var(--ew-e1); border-color: transparent; }
.ew-card--ledge   { box-shadow: var(--ew-ledge); }

/* An interactive card must LOOK interactive before it is touched, and confirm the touch. */
.ew-card--action {
  cursor: pointer; text-align: left; width: 100%; display: block;
  transition: transform .16s var(--ew-ease), box-shadow .16s var(--ew-ease);
}
.ew-card--action:hover  { box-shadow: var(--ew-e1); }
.ew-card--action:active { transform: translateY(1px) scale(.995); box-shadow: none; }

/* The one place glass earns its keep: a bar floating OVER scrolling content. Backdrop
   filter is progressive — the solid colour underneath is the fallback, never a
   low-contrast surprise. */
.ew-glass {
  background: rgba(255,255,255,.82); border: 1px solid rgba(255,255,255,.5);
  box-shadow: var(--ew-e1);
}
@supports (backdrop-filter: blur(1px)) {
  .ew-glass { backdrop-filter: saturate(1.6) blur(14px); background: rgba(255,255,255,.68); }
}

/* ── CONTROLS ─────────────────────────────────────────────────────────────────────── */
.ew-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--ew-tap); padding: 0 20px; border-radius: var(--ew-r);
  font: 700 15px/1 var(--ew-font); letter-spacing: -.005em;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform .12s var(--ew-ease), box-shadow .12s var(--ew-ease), background .12s;
}
.ew-btn:active   { transform: translateY(1px); }
.ew-btn:disabled, .ew-btn[aria-disabled="true"] {
  opacity: .5; cursor: not-allowed; transform: none; box-shadow: none;
}
.ew-btn--primary   { background: var(--ew-forest); color: #fff; box-shadow: var(--ew-e-cta); }
.ew-btn--primary:hover  { background: var(--ew-green); }
.ew-btn--primary:active { box-shadow: 0 3px 10px rgba(7,59,36,.3); }
.ew-btn--lime      { background: var(--ew-lime); color: #14311f; box-shadow: var(--ew-e-cta); }
.ew-btn--secondary { background: var(--ew-surface); color: var(--ew-ink); border-color: var(--ew-line);
                     box-shadow: var(--ew-ledge); }
.ew-btn--ghost     { background: transparent; color: var(--ew-ink); }
.ew-btn--ghost:hover { background: var(--ew-mist); }
.ew-btn--danger    { background: #b3261e; color: #fff; box-shadow: 0 8px 24px rgba(179,38,30,.28); }
.ew-btn--block     { width: 100%; }

.ew-iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--ew-tap); height: var(--ew-tap); border-radius: var(--ew-r);
  background: transparent; border: 0; cursor: pointer; color: var(--ew-ink);
}
.ew-iconbtn:hover { background: var(--ew-mist); }

.ew-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: var(--ew-r-pill); border: 1px solid var(--ew-line);
  background: var(--ew-surface); color: var(--ew-text);
  font: 600 13px/1 var(--ew-font); white-space: nowrap; cursor: pointer;
}
.ew-chip[aria-pressed="true"], .ew-chip.on {
  background: var(--ew-forest); border-color: var(--ew-forest); color: #fff;
}
/* A horizontal chip row on a phone scrolls; it must never wrap into a second line that
   pushes content down, and the scrollbar must not be visible chrome. */
.ew-chiprow {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding-bottom: 2px; -webkit-overflow-scrolling: touch;
}
.ew-chiprow::-webkit-scrollbar { display: none; }

.ew-field { display: block; }
.ew-field > span { display: block; font: var(--ew-t-label); color: var(--ew-muted);
                   text-transform: uppercase; letter-spacing: .07em; margin-bottom: 6px; }
/* 16px is not cosmetic: below it iOS zooms the page on focus. */
.ew-input, .ew-select, .ew-textarea {
  width: 100%; min-height: var(--ew-tap); padding: 12px 14px; font: 400 16px/1.4 var(--ew-font);
  color: var(--ew-ink); background: var(--ew-surface);
  border: 1px solid var(--ew-line); border-radius: var(--ew-r);
}
.ew-input:focus-visible, .ew-select:focus-visible, .ew-textarea:focus-visible,
.ew-btn:focus-visible, .ew-chip:focus-visible, .ew-iconbtn:focus-visible {
  outline: 2px solid var(--ew-lime); outline-offset: 2px;
}
.ew-textarea { min-height: 96px; resize: vertical; }

/* ── FEEDBACK ─────────────────────────────────────────────────────────────────────── */
.ew-status {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: var(--ew-r-pill); font: 700 12px/1.4 var(--ew-font);
}
.ew-status--good { background: var(--ew-good); color: var(--ew-good-ink); }
.ew-status--warn { background: var(--ew-warn); color: var(--ew-warn-ink); }
.ew-status--bad  { background: var(--ew-bad);  color: var(--ew-bad-ink); }
.ew-status--info { background: var(--ew-info); color: var(--ew-info-ink); }
.ew-status--idle { background: var(--ew-mist); color: var(--ew-muted); }

.ew-skeleton {
  border-radius: var(--ew-r-sm); min-height: 14px;
  background: linear-gradient(90deg, var(--ew-mist), #f7faf7, var(--ew-mist));
  background-size: 200% 100%; animation: ew-shimmer 1.2s linear infinite;
}
@keyframes ew-shimmer { to { background-position: -200% 0; } }

.ew-empty {
  text-align: center; padding: 32px 20px; border-radius: var(--ew-r-lg);
  background: var(--ew-mist); color: var(--ew-muted); font: var(--ew-t-body);
}
.ew-empty strong { display: block; font: var(--ew-t-section); color: var(--ew-ink); margin-bottom: 6px; }

/* ── LAYOUT ───────────────────────────────────────────────────────────────────────── */
/* Desktop should use width intelligently — not by enlarging phone cards. */
.ew-page { max-width: 1120px; margin: 0 auto; padding: 24px 20px 40px; }
.ew-stack   { display: grid; gap: 12px; }
.ew-stack-lg{ display: grid; gap: 20px; }
.ew-row     { display: flex; align-items: center; gap: 10px; }
.ew-spread  { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* A section header states WHERE YOU ARE and WHAT YOU CAN DO, in that order. */
.ew-pagehead { display: flex; align-items: flex-start; justify-content: space-between;
               gap: 16px; margin-bottom: 20px; }

/* ── MOBILE ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 719px) {
  .ew-page { padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); }
  .ew-display { font-size: 24px; }
  .ew-h1 { font-size: 20px; }
  .ew-pagehead { flex-direction: column; align-items: stretch; gap: 12px; }
  /* On a phone the primary action is full width — not a small button in a corner. */
  .ew-pagehead .ew-btn { width: 100%; }
  .ew-card { padding: 14px; border-radius: var(--ew-r); }
  /* A sticky action bar must clear the bottom navigation AND the home indicator. */
  .ew-sticky-cta {
    position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 40;
    padding: 10px 0;
  }
}

/* ── MOTION ───────────────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ew-card--action, .ew-btn { transition: none; }
  .ew-card--action:active, .ew-btn:active { transform: none; }
  .ew-skeleton { animation: none; }
}
