/* Chaos Inventory on a phone.
 *
 * >>> Built for a phone held in one hand while the other holds a box of cards.
 *     That is not a slogan: it is why the tabs are at the bottom, why nothing
 *     that gets tapped is under 44px, and why there are no hover states doing
 *     any real work.
 *
 * >>> Matches the desktop app's colours so the two feel like one thing.
 */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #9aa4b2;
  --accent: #e3b341;
  --accent-ink: #1a1200;
  --link: #58a6ff;
  --bad: #f85149;
  --ok: #3fb950;
  /* The notch and the home bar. Without these the bottom tabs sit underneath
     the iPhone's gesture bar and get swallowed. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* >>> 16px minimum on inputs, or iOS zooms the page in when one is focused
     and never zooms back out. The most common reason a web app feels broken
     on a phone. */
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.screen { min-height: 100%; display: flex; flex-direction: column; }

/* ------------------------------- sign in -------------------------------- */

#signin { justify-content: center; padding: 24px 20px calc(24px + var(--safe-bottom)); }
.signin-box { width: 100%; max-width: 380px; margin: 0 auto; }
.signin-box h1 { font-size: 24px; margin: 0 0 4px; }
.signin-box form { margin-top: 22px; display: flex; flex-direction: column; gap: 6px; }

label { font-size: 13px; color: var(--muted); margin-top: 10px; }

input {
  font: inherit;                 /* inherits the 16px — see the note above */
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 13px 14px;
  width: 100%;
}
input:focus { outline: 2px solid var(--link); outline-offset: -1px; border-color: var(--link); }

.btn {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  /* >>> 44px minimum. Anything smaller is genuinely hard to hit with a thumb,
     and this gets used standing up. */
  min-height: 46px;
  padding: 0 16px;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; margin-top: 18px; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.small { min-height: 34px; font-size: 13px; padding: 0 10px; }
.btn[disabled] { opacity: .55; cursor: default; }

.msg { min-height: 20px; margin: 10px 0 0; font-size: 14px; }
.msg.bad { color: var(--bad); }
.msg.ok { color: var(--ok); }

/* --------------------------------- app ---------------------------------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}

.pane {
  flex: 1 1 auto;
  padding: 14px;
  /* Room for the bottom tabs, which float over the content. */
  padding-bottom: calc(76px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.tab {
  font: inherit; font-size: 12px;
  background: none; border: 0; color: var(--muted);
  padding: 11px 4px 12px;
  min-height: 52px;
  cursor: pointer;
}
.tab.on { color: var(--accent); font-weight: 600; box-shadow: inset 0 2px 0 var(--accent); }

/* ------------------------------- lists ---------------------------------- */

.row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border);
}
.row .name { flex: 1 1 auto; }
.row .num { color: var(--muted); font-size: 13px; white-space: nowrap; }
.row .val { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- inside a bag: deciding cards ---- */
/* >>> Rows are taller than a list row because each carries three buttons that
   get tapped a thousand times with a thumb. A mis-tap here changes what happens
   to a card, so the targets are generous on purpose. */
.vrow {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid var(--border);
}
.vname { flex: 1 1 auto; min-width: 0; font-size: 15px; line-height: 1.3; }
.vname .num { color: var(--muted); font-size: 12px; }
.vacts { display: flex; gap: 6px; flex: 0 0 auto; }
.vbtn {
  font: inherit; font-size: 17px; line-height: 1;
  width: 46px; height: 44px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; color: var(--muted); cursor: pointer;
}
.vbtn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.vbtn:active { transform: translateY(1px); }

/* A decided row is tinted down the edge, so the state is readable while
   scrolling fast rather than only from the button. */
.vrow.ok   { border-left: 3px solid var(--ok); padding-left: 8px; }
.vrow.warn { border-left: 3px solid var(--accent); padding-left: 8px; }
.vrow.bad  { border-left: 3px solid var(--bad); padding-left: 8px; opacity: .55; }

.row.tap { cursor: pointer; }
.row.tap:active { background: var(--surface-2); }

/* >>> Sits above the tab bar, not under it. A message you cannot read is the
   same as no message. */
#toast {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(74px + var(--safe-bottom));
  background: var(--bad); color: #fff;
  padding: 12px 14px; border-radius: 10px; font-size: 14px;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .15s, transform .15s; z-index: 9;
}
#toast.on { opacity: 1; transform: none; }
