/* inspectorjay inspector app. Built for gloves, sunlight and one thumb:
   big tap targets (56px+), high contrast, one primary action at the bottom. */
:root {
  --fg: #111111;
  --muted: #4a4f55;
  --bg: #ffffff;
  --panel: #f1f3f5;
  --line: #858a91; /* 3.5:1 on white: card and field edges must be visible (WCAG 1.4.11) */
  --accent: #0b4f8a;
  --accent-fg: #ffffff;
  --pass: #136f2c;
  --fail: #b3261e;
  --warn-bg: #fff3c4;
  --warn-fg: #5c4400;
  --field: #ffffff;
  --field-line: #6b7178;
  --late-bg: #fdf0ee;
  --here-bg: #e8f0f8;
  --na: #5f656b;
  --na-line: #8a9096;
  --na-solid: #4a4f55;
  --on-solid: #ffffff;
  --toast-bg: #111111;
  --toast-fg: #ffffff;
  --tap: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
/* Follows the device's setting. Same contrast rules as above. */
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #eceef0;
    --muted: #b0b5bb;
    --bg: #121417;
    --panel: #1e2125;
    --line: #7d848c;
    --accent: #8ab4f8;
    --accent-fg: #0d1b2e;
    --pass: #7fcf96;
    --fail: #f28b82;
    --warn-bg: #3a2f0b;
    --warn-fg: #f3c969;
    --field: #1e2125;
    --field-line: #8a9199;
    --late-bg: #3b1816;
    --here-bg: #1a2736;
    --na: #a9afb7;
    --na-line: #8a9096;
    --na-solid: #a9afb7;
    --on-solid: #111111;
    --toast-bg: #eceef0;
    --toast-fg: #111111;
  }
}
:root { color-scheme: light dark; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font: 19px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; color: var(--fg); background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
.hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

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

/* Top bar: title and the sync indicator, always visible. */
.bar {
  position: sticky; top: 0; z-index: 2; background: var(--bg);
  padding: calc(env(safe-area-inset-top, 0px) + .5rem) 1rem .5rem;
  border-bottom: 2px solid var(--line);
}
.bar h1 { font-size: 1.25rem; margin: .1rem 0 .2rem; overflow-wrap: anywhere; }
.bar .bar-link {
  position: absolute; right: 1rem; top: calc(env(safe-area-inset-top, 0px) + .5rem);
  min-height: 44px; padding: .25rem .9rem; border: 2px solid var(--accent); border-radius: 10px;
  background: var(--bg); color: var(--accent); font-weight: 700;
}
.bar:has(.bar-link) h1 { padding-right: 6.5rem; }
.sync { font-size: .9rem; font-weight: 600; color: var(--pass); }
.sync::before { content: "● "; }
.sync.waiting { color: var(--warn-fg); }
.sync-link { min-height: 0; padding: 0; color: inherit; font-weight: 700; }
.rejected { border: 2px solid var(--line); border-radius: 12px; padding: .25rem 1rem 1rem; margin: 0 0 1rem; }
.rejected .preview { max-height: 30vh; }
.check-row { display: flex; gap: .75rem; align-items: center; min-height: var(--tap); margin: 0; font-weight: 600; border-bottom: 1px solid var(--line); }
.check-row input { width: 28px; height: 28px; min-height: 0; flex: none; }
fieldset.roles { border: 0; padding: 0; margin: 0 0 .5rem; }
fieldset.roles legend { font-weight: 700; margin: 1rem 0 .4rem; padding: 0; }
/* The pad and saved signatures stay white: the ink is dark. */
canvas.pad { display: block; width: 100%; height: 200px; border: 2px dashed var(--field-line); border-radius: 10px; background: #ffffff; touch-action: none; }
.signatures { display: grid; gap: .6rem; }
.signature { margin: 0; padding: .5rem; border: 2px solid var(--line); border-radius: 10px; }
.signature img { display: block; width: 100%; max-height: 90px; object-fit: contain; background: #ffffff; border-radius: 6px; }
.signature figcaption { font-size: .9rem; color: var(--muted); }
.visit { display: flex; gap: .5rem; align-items: stretch; }
.visit .card { flex: 1; }
.visit.late .card { border-color: var(--fail); background: var(--late-bg); }
.visit.done .card { opacity: .7; }
.visit .done-btn { margin-bottom: .6rem; min-width: 5rem; }
.quick { margin: 0 0 .5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
.grid-2 .span-2 { grid-column: 1 / -1; }
.rows { display: flex; flex-direction: column; gap: .5rem; }
.row-line { display: flex; gap: .4rem; align-items: center; }
.row-line input, .row-line select { min-width: 0; padding: .5rem; font-size: 1rem; }
.row-line .w-l { flex: 3; }
.row-line .w-m { flex: 2; }
.row-line .w-s { flex: 1; }
.row-line .remove { flex: none; min-width: 44px; font-size: 1.1rem; text-decoration: none; }
select { font: inherit; font-size: 1rem; min-height: var(--tap); border: 2px solid var(--field-line); border-radius: 10px; background: var(--field); color: var(--fg); }
.row-buttons { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

.back {
  min-height: 44px; padding: .25rem 0; margin: 0 0 .1rem; border: 0; background: none;
  color: var(--accent); font: inherit; font-weight: 600; font-size: 1.05rem; cursor: pointer;
}

.content { flex: 1; padding: 1rem 1rem calc(var(--tap) + 2.5rem + var(--safe-bottom)); }

/* The one primary action, always in the same place. */
.action {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: .75rem 1rem calc(.75rem + var(--safe-bottom));
  background: var(--bg); border-top: 2px solid var(--line);
}
button { font: inherit; cursor: pointer; }
button.primary {
  display: block; width: 100%; min-height: var(--tap); padding: .7rem 1rem;
  border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-fg);
  font-size: 1.2rem; font-weight: 700;
}
button.primary:active { filter: brightness(.85); }
button.secondary {
  min-height: var(--tap); padding: .6rem 1.1rem; border: 2px solid var(--accent); border-radius: 12px;
  background: var(--bg); color: var(--accent); font-weight: 700;
}
button.wide { display: block; width: 100%; margin: 1rem 0; font-size: 1.1rem; }
button.link { border: 0; background: none; color: var(--accent); text-decoration: underline; padding: .5rem 0; min-height: 44px; }

label { display: block; font-weight: 700; margin: 1rem 0 .4rem; }
input, textarea {
  font: inherit; font-size: 1.1rem; width: 100%; padding: .75rem; min-height: var(--tap);
  border: 2px solid var(--field-line); border-radius: 10px; background: var(--field); color: var(--fg);
}
input:focus, textarea:focus { outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea { resize: vertical; }
.hint { color: var(--muted); font-size: .95rem; margin: .4rem 0; }
.error { color: var(--fail); font-weight: 600; min-height: 1px; }
.error:empty { display: none; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.label { font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 1rem 0 .4rem; }
.chosen { font-size: 1.25rem; font-weight: 700; margin: 0 0 .6rem; }
.chosen.small { font-size: 1rem; }
.banner { background: var(--warn-bg); color: var(--warn-fg); padding: .75rem 1rem; border-radius: 10px; margin: 0 0 1rem; }
.banner p { margin: .35rem 0 .6rem; }
.signed-in { margin-top: 2rem; color: var(--muted); font-size: .95rem; }

/* Big tappable cards for projects. */
.card {
  display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; width: 100%;
  min-height: 64px; margin: 0 0 .6rem; padding: .7rem 1rem; text-align: left;
  border: 2px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--fg);
}
.card .name { font-weight: 700; font-size: 1.1rem; }
.card .sub { color: var(--muted); font-size: .9rem; }
.card.here { border-color: var(--accent); background: var(--here-bg); }
.card.selected { border-color: var(--accent); border-width: 3px; background: var(--here-bg); }
.card.quiet { border-style: dashed; }
.card.attention { border-color: var(--warn-fg); background: var(--warn-bg); }
.photos figure.tappable { cursor: pointer; }
p.note { white-space: pre-wrap; }
.card:active { background: var(--panel); }

.preview { display: block; width: 100%; max-height: 45vh; object-fit: contain; background: #000; border-radius: 10px; }

/* Checklist */
h2 { font-size: 1.15rem; margin: 1.25rem 0 .6rem; }
.items { display: flex; flex-direction: column; gap: .5rem; }
.item {
  display: grid; grid-template-columns: 1fr auto; gap: .25rem .75rem; align-items: start;
  width: 100%; min-height: var(--tap); padding: .7rem .9rem; text-align: left;
  border: 2px solid var(--line); border-left-width: 8px; border-radius: 10px; background: var(--bg); color: var(--fg);
}
.item .text { font-weight: 600; }
.item .note, .item .waiting { grid-column: 1 / -1; font-size: .9rem; color: var(--muted); }
.item.st-fail { border-left-color: var(--fail); }
.item.st-pass, .item.st-fixed { border-left-color: var(--pass); }
.item.st-na { border-left-color: var(--na-line); }
.tag { display: inline-block; margin-left: .4rem; font-size: .75rem; font-weight: 700; padding: 0 .4rem; border-radius: 4px; background: var(--warn-bg); color: var(--warn-fg); vertical-align: middle; }
.pill { font-size: .85rem; font-weight: 700; padding: .1rem .55rem; border-radius: 999px; border: 2px solid currentColor; white-space: nowrap; }
.pill.st-open { color: var(--muted); }
.pill.st-pass, .pill.st-fixed { color: var(--pass); }
.pill.st-fail { color: var(--fail); }
.pill.st-na { color: var(--na); }
.waiting { color: var(--warn-fg) !important; font-weight: 600; }
.item .due { grid-column: 1 / -1; font-size: .9rem; font-weight: 600; color: var(--muted); }
.item .due.late { color: var(--fail); }
.item.overdue { background: var(--late-bg); }
input[type=date] { max-width: 14rem; }

/* Item sheet: full-screen, over the project. */
.sheet { position: fixed; inset: 0; z-index: 10; background: var(--bg); overflow-y: auto; }
.sheet-body { padding: calc(env(safe-area-inset-top, 0px) + .75rem) 1rem calc(var(--tap) + 3rem + var(--safe-bottom)); }
.sheet h2 { font-size: 1.3rem; margin: .5rem 0; }
.statuses { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: 1rem 0; }
.status {
  min-height: 64px; border: 3px solid var(--line); border-radius: 12px; background: var(--bg);
  font-size: 1.2rem; font-weight: 800; color: var(--fg);
}
.status.st-pass.selected, .status.st-fixed.selected { background: var(--pass); border-color: var(--pass); color: var(--on-solid); }
.status.st-fail.selected { background: var(--fail); border-color: var(--fail); color: var(--on-solid); }
.status.st-na.selected { background: var(--na-solid); border-color: var(--na-solid); color: var(--on-solid); }

/* Photos */
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.photos figure { margin: 0; }
.photos img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--panel); }
.photos figcaption { font-size: .8rem; color: var(--muted); margin-top: .2rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.photos figcaption .waiting { display: block; }

/* Item history, newest first. */
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: .6rem 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; }
.history .what { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; font-weight: 600; }
.history .who { font-weight: 400; color: var(--muted); font-size: .95rem; }
.history .note { margin: .3rem 0 0; white-space: pre-wrap; }
.history .when { margin: .2rem 0 0; color: var(--muted); font-size: .85rem; }

/* Confirmation toast, just above the bottom button so it never covers the
   sync status. */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tap) + 2.25rem + var(--safe-bottom));
  transform: translate(-50%, 1rem); opacity: 0; pointer-events: none;
  width: max-content; max-width: calc(100vw - 2rem); text-align: center;
  z-index: 20; padding: .6rem 1.4rem; border-radius: 24px; background: var(--toast-bg); color: var(--toast-fg); font-weight: 700;
  transition: transform .2s ease, opacity .2s ease;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

/* Screen headings take focus when a screen opens; no ring for that. */
h1:focus, .sheet h2:focus { outline: none; }
.row-head { font-size: .8rem; font-weight: 700; color: var(--muted); }
.row-head span { padding: 0 .5rem; }

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