/* MAV FIELD PORTAL — shell styles.
 *
 * Written for one hand, a glove, and direct sun on a truck deck.
 *   - Every interactive target is >= 48px; primary actions are 56px.
 *   - Nothing is hover-only. Hover does not exist on a phone.
 *   - Default palette is LIGHT + high contrast, because a phone in sunlight is
 *     more readable dark-on-light at full brightness. A night palette is one
 *     tap away for inside a dark plant, and is remembered.
 *   - Redacted fields render as the word "hidden", never as 0. A withheld number
 *     that looks like a zero is how somebody quotes a job wrong.
 *   - `stated` values (someone said it) get a dotted underline + a "heard" chip
 *     so they never read identically to a measured one.
 */

:root {
  --bg: #f4f6f8;
  --surface: #fafbfc;
  --surface-2: #e8ecf1;
  --ink: #0b0f14;
  --ink-2: #3d4753;
  --line: #b9c2cd;
  --accent: #854008;
  --accent-ink: #ffffff;
  --ok: #0f5132;
  --warn: #6b4306;
  --bad: #991b1b;
  --stated: #5b21b6;
  --focus: #1d4ed8;
  --tap: 48px;
  --tap-lg: 56px;
  --radius: 12px;
  --pad: 14px;
  color-scheme: light;
}

[data-theme='night'] {
  --bg: #0b0f14;
  --surface: #151b23;
  --surface-2: #1e2733;
  --ink: #f8fafc;
  --ink-2: #b6c2d1;
  --line: #37455a;
  --accent: #f59e0b;
  --accent-ink: #12161c;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #fb9393;
  --stated: #c4b5fd;
  --focus: #93c5fd;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  font-size: 17px;              /* not 14 — this is read at arm's length */
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- header -- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(env(safe-area-inset-top) + 10px) var(--pad) 10px;
  background: var(--surface);
  border-bottom: 2px solid var(--line);
}
.brand {
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 1.05rem;
  margin-right: auto;
}
.brand small {
  display: block;
  font-weight: 500;
  font-size: .85rem;
  color: var(--ink-2);
  letter-spacing: 0;
}
.iconbtn {
  min-width: var(--tap);
  min-height: var(--tap);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 1.15rem;
  cursor: pointer;
}
.iconbtn:active { transform: translateY(1px); }

/* --------------------------------------------------------------- status --- */
.statusbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px var(--pad);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: .88rem;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  white-space: nowrap;
}
.pill.ok    { color: var(--ok);   border-color: currentColor; }
.pill.warn  { color: var(--warn); border-color: currentColor; }
.pill.bad   { color: var(--bad);  border-color: currentColor; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

/* ----------------------------------------------------------------- main --- */
main {
  flex: 1;
  padding: var(--pad);
  padding-bottom: calc(var(--tap-lg) + 42px + env(safe-area-inset-bottom));
}
.panel[hidden] { display: none !important; }

h1 { font-size: 1.3rem; margin: 0 0 4px; }
h2 { font-size: 1.08rem; margin: 20px 0 8px; }
p  { margin: 0 0 12px; color: var(--ink-2); }

.card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 12px;
}
.card h3 { margin: 0 0 6px; font-size: 1rem; }

/* --------------------------------------------------------------- fields --- */
label { display: block; font-weight: 700; margin: 0 0 6px; font-size: .95rem; }
input[type='text'], input[type='search'], textarea, select {
  width: 100%;
  min-height: var(--tap);
  padding: 12px;
  font-size: 17px;                /* < 16px makes iOS zoom on focus */
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap-lg);
  padding: 0 20px;
  width: 100%;
  font-size: 1.05rem;
  font-weight: 800;
  border-radius: var(--radius);
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------ data rows --- */
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--ink-2); font-size: .9rem; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }

/* A withheld field. NEVER styled to look like a value, never rendered as 0. */
.redacted {
  color: var(--ink-2);
  font-weight: 600;
  font-style: italic;
  opacity: .85;
}
.redacted::before { content: '\1F512\FE0E'; margin-right: 5px; font-style: normal; }

/* Data honesty. `stated` = a person said it. It must never render identically
   to a measured number. Dotted underline + chip, in both palettes. */
.origin-stated {
  border-bottom: 2px dotted var(--stated);
  padding-bottom: 1px;
}
.chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;
  border: 1px solid currentColor;
  vertical-align: middle;
}
.chip.stated      { color: var(--stated); }
.chip.placeholder { color: var(--warn); }
.chip.measured    { color: var(--ok); }
.chip.field       { color: var(--ink-2); }

.empty {
  padding: 22px 14px;
  text-align: center;
  color: var(--ink-2);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
}

/* ----------------------------------------------------------- lane mounts --- */
/* Owned by other agents. Until a lane loads, the slot says so out loud rather
   than presenting a control that does nothing. */
.lane-host:empty::after {
  content: attr(data-empty);
  display: block;
  padding: 20px 14px;
  text-align: center;
  color: var(--ink-2);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  font-size: .92rem;
}

/* ----------------------------------------------------------------- nav ---- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  background: var(--surface);
  border-top: 2px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  min-height: var(--tap-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-top: 4px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
}
.tabbar button .ico { font-size: 1.3rem; line-height: 1; }
.tabbar button[aria-selected='true'] { color: var(--ink); border-top-color: var(--accent); background: var(--surface-2); }

/* --------------------------------------------------------------- toasts --- */
.toasts {
  position: fixed;
  left: 10px; right: 10px;
  bottom: calc(var(--tap-lg) + 16px + env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.toast.ok  { border-color: var(--ok); }
.toast.bad { border-color: var(--bad); }

/* -------------------------------------------------------------- gate ------ */
.gate {
  margin: auto;
  max-width: 30rem;
  width: 100%;
  padding: var(--pad);
}

.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: .85rem; word-break: break-all; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (min-width: 720px) {
  main { max-width: 46rem; margin: 0 auto; width: 100%; }
  .tabbar { position: sticky; }
}

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