/* The project's one stylesheet (Design D5). No framework, no design
   system, no build step -- plain CSS served same-origin, compatible with
   this project's `style-src 'self'` CSP (no inline <style>/style=
   anywhere in the template tree; see app/tests/navigation/test_nav_shell.py
   and app/tests/mobile for the real-browser proof).

   Phone first, because that is where the work happens: a warehouse
   operator holding a part in one hand. Everything below scales up to a
   desk without a second layout -- the nav becomes a row and the content
   gains a reading width, and nothing else changes. */

:root {
  --ink: #16202a;
  --muted: #5b6b7a;
  --line: #d6dde4;
  --surface: #f5f7f9;
  --accent: #0b4f7a;
  --accent-ink: #ffffff;
  --warn-ink: #6a4b00;
  --warn-bg: #fff7e0;
  --error-ink: #601410;
  --error-line: #b3261e;
  --error-bg: #fdecea;
  --radius: 6px;
}

html {
  /* Below 16px, iOS Safari zooms in on input focus -- an operator typing a
     barcode by hand on a phone should never trigger that (Design D5). */
  font-size: 16px;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background: #ffffff;
}

/* --- navigation ------------------------------------------------------- */

#site-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

#site-nav ul {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  max-width: 60rem;
}

#site-nav a {
  display: block;
  box-sizing: border-box;
  min-height: 44px;
  min-width: 44px;
  padding: 0.7rem 1rem;
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

#site-nav a:hover,
#site-nav a:focus-visible {
  background: #ffffff;
  text-decoration: underline;
}

/* Design D6: never hidden, but visibly distinguished as "you'll be asked
   to authorize this" rather than looking identical to an open capability. */
#site-nav a[data-requires-permission] {
  color: var(--warn-ink);
  background: var(--warn-bg);
}

#site-nav a[data-requires-permission]::after {
  content: " (requires permission)";
  font-size: 0.85em;
  font-weight: 400;
}

/* --- content ---------------------------------------------------------- */

main {
  padding: 1.25rem 1rem 3rem;
  box-sizing: border-box;
  /* A reading width. Without this, a line of text on a desk monitor runs
     the full width of the screen and the page looks broken. */
  max-width: 60rem;
  margin: 0 auto;
}

h1 {
  font-size: 1.6rem;
  line-height: 1.25;
  margin: 0 0 0.75rem;
}

h2 {
  font-size: 1.2rem;
  margin: 1.75rem 0 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

p {
  margin: 0.5rem 0;
}

a {
  color: var(--accent);
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* --- controls --------------------------------------------------------- */

/* Every touch target -- not just nav links -- meets the 44px minimum
   (Design D5). Appearance matters too: these were previously sized but
   never styled, so a primary action looked identical to plain text. */
button,
input[type="submit"],
input[type="button"] {
  min-height: 44px;
  min-width: 44px;
  padding: 0.6rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
  filter: brightness(1.15);
}

button[hidden] {
  display: none;
}

input[type="text"],
input[type="number"],
input[type="search"],
textarea,
select {
  min-height: 44px;
  box-sizing: border-box;
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
}

label {
  display: inline-block;
  margin-right: 0.5rem;
  font-weight: 600;
}

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

/* Wrapping rather than overflowing: a 12-character part number next to a
   description must not push the page sideways on a 360px screen. */
form p {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* --- scanner ---------------------------------------------------------- */

video {
  width: 100%;
  max-width: 32rem;
  background: #000000;
  border-radius: var(--radius);
}

/* The single largest phone-usability defect this unit fixes (Design D5):
   #scanner-error previously had no styling at all, so a real error
   rendered as visually indistinguishable body text. Never display:none or
   visibility:hidden on it when empty -- a hidden live region can drop the
   screen-reader announcement when populated; :empty scopes the box away
   instead, so the DOM node and its role="alert"/aria-live="assertive"
   stay exactly as `scan.html`/`inventory/receipts/new.html`/`tickets/
   draft.html` already declare them. */
#scanner-error {
  border: 3px solid var(--error-line);
  background-color: var(--error-bg);
  color: var(--error-ink);
  font-weight: 700;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  border-radius: var(--radius);
}

#scanner-error:empty {
  border: 0;
  padding: 0;
  margin: 0;
}

/* --- wider than a phone ----------------------------------------------- */

@media (min-width: 40em) {
  #site-nav ul {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0 1rem;
  }

  #site-nav a {
    border-bottom: 3px solid transparent;
  }

  #site-nav a:hover,
  #site-nav a:focus-visible {
    border-bottom-color: var(--accent);
    background: transparent;
  }

  h1 {
    font-size: 2rem;
  }
}
