/* Work Order List — hand-written, no build step. CLAUDE.md §0/§3.
 *
 * Designed for a phone held one-handed, outdoors, possibly with gloves on.
 * Priorities in order: legible in sunlight, big targets, thumb-reachable
 * actions, never scrolls sideways. Desktop is an afterthought that happens
 * to work.
 *
 * Target sizes: Apple's HIG says 44px minimum, Android's Material says 48dp.
 * We use 48 everywhere so both are satisfied.
 */

:root {
  --bg:        #f2f4f7;
  --surface:   #ffffff;
  --border:    #d3d8e0;
  --text:      #111418;
  --muted:     #5b636e;
  --accent:    #1546c4;   /* darkened for sunlight contrast */
  --danger:    #b3261e;
  --radius:    12px;
  --tap:       48px;      /* satisfies both iOS 44 and Android 48 */
  --shadow:    0 1px 2px rgba(0,0,0,.07), 0 2px 10px rgba(0,0,0,.04);
  --navh:      60px;      /* bottom nav height */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #0f1115;
    --surface: #191c22;
    --border:  #2c313a;
    --text:    #f0f2f5;
    --muted:   #98a1ad;
    --accent:  #7aa2ff;
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;   /* iOS: don't reflow text on rotate */
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  /* Kill the grey flash Android Chrome paints on tap */
  -webkit-tap-highlight-color: transparent;
  /* Stop the whole page rubber-banding on iOS when a list is short */
  overscroll-behavior-y: none;
  /* Nothing should ever scroll sideways on a phone */
  overflow-x: hidden;
}

/* Leave room for the fixed bottom nav plus the iPhone home indicator */
body.has-nav main {
  padding-bottom: calc(var(--navh) + env(safe-area-inset-bottom) + 16px);
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-left)) 16px max(16px, env(safe-area-inset-right));
}

/* ---------- Header ---------- */
.site-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-head h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.site-head form { margin: 0; }
.site-head button {
  background: none; border: 0; color: var(--muted);
  font-size: 15px; cursor: pointer;
  min-height: var(--tap); padding: 0 4px;   /* still a real target */
}

/* ---------- Bottom nav — thumb zone, where field apps put navigation ------ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);   /* iPhone home indicator */
}
.tabbar a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  min-height: var(--navh);
  text-decoration: none;
  color: var(--muted);
  font-size: 11px; font-weight: 600;
  letter-spacing: .01em;
}
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar .glyph { font-size: 19px; line-height: 1; }
.tabbar .badge {
  position: absolute; transform: translate(16px, -14px);
  background: var(--danger); color: #fff;
  border-radius: 999px; font-size: 10px; padding: 1px 5px; font-weight: 700;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 14px; }
.card h2 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.02em; }
.card .sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.field input, .field select, .field textarea {
  width: 100%; min-height: var(--tap);
  padding: 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text);
  /* MUST stay >=16px: anything smaller makes iOS Safari zoom on focus,
     which then leaves the page scrolled sideways. */
  font-size: 16px;
  appearance: none; -webkit-appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.field .hint { margin-top: 6px; font-size: 13px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; min-height: var(--tap);
  padding: 13px 18px;
  border: 0; border-radius: 10px;
  background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;   /* removes the 300ms double-tap-zoom delay */
}
.btn:active { transform: translateY(1px); }
.btn-secondary {
  background: var(--surface); color: var(--accent); border: 1px solid var(--border);
}

.row-links {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-top: 8px; font-size: 15px; flex-wrap: wrap;
}
.row-links a {
  color: var(--accent); text-decoration: none;
  min-height: var(--tap); display: inline-flex; align-items: center;
}

/* ---------- Feedback ---------- */
.alert {
  padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 15px;
  border: 1px solid transparent;
}
.alert-error   { background: #fdeaea; border-color: #f0b9b9; color: #7a1c1c; }
.alert-success { background: #e7f6ec; border-color: #b3dfc3; color: #14532d; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

@media (prefers-color-scheme: dark) {
  .alert-error   { background: #3a1b1b; border-color: #7d2a2a; color: #ffd9d9; }
  .alert-success { background: #14301e; border-color: #2e6b44; color: #ccf0d9; }
}

/* ---------- Status chips (colour comes from the account, not from here) --- */
.chip {
  display: inline-block; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap;
  letter-spacing: .01em;
}

/* ---------- Work order list ---------- */
.wo-list { list-style: none; margin: 0; padding: 0; }
.wo-item {
  display: block; padding: 15px 16px;
  text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 10px; box-shadow: var(--shadow);
  touch-action: manipulation;
}
.wo-item:active { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.wo-item .top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.wo-item .ident {
  font-weight: 680; font-size: 17px; letter-spacing: -.01em; margin-top: 9px;
  /* Long store names truncate rather than forcing a sideways scroll */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wo-item .meta {
  margin-top: 3px; color: var(--muted); font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wo-item .age {
  font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap;
}
.wo-item .age.old { color: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 44px 16px; }

/* ---------- Detail actions: full-width, stacked, thumb-friendly ---------- */
.actions { display: grid; gap: 10px; margin-top: 16px; }
@media (min-width: 560px) {
  .actions { grid-template-columns: 1fr 1fr; }
}

/* Long addresses and complaints must wrap, never overflow */
.wrapline { overflow-wrap: anywhere; }

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
