/*
 * Plumber Sky Eye. Palette from Colorbond roof colours, the trade's own words:
 * Zincalume sheet (page), Monument (ink), Deep Ocean (actions), Manor Red (seen), Cottage Green (clear),
 * Night Sky (dark scheme). Contrast is set for a phone in glare: strong edges, no pale greys.
 */
:root {
  --bg: #dde2e3;
  --surface: #ffffff;
  --ink: #1d1f21;
  --muted: #4b5459;
  --line: #b4bcbf;
  --edge: #6b767b;
  --accent: #1d4e6e;
  --accent-ink: #ffffff;
  --danger: #8e2a1e;
  --warn: #7a5a10;
  --ok: #2a5d3e;
  --chip-seen: #8e2a1e;
  --chip-seen-ink: #ffffff;
  --chip-check: #7a5a10;
  --chip-ok: #2a5d3e;
  --bg-deep: #1d1f21;
  --sheet-hi: #dfe4e5;
  --sheet-lo: #a9b3b6;
  --pad: 1rem;
  --reach: 4.5rem;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Native controls, scrollbars and the file picker follow the phone's light or dark setting. */
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191b;
    --surface: #232629;
    --ink: #eceeee;
    --muted: #a9b2b6;
    --line: #3d4448;
    --edge: #7d888d;
    --accent: #7fb8da;
    --accent-ink: #0d1a22;
    --danger: #f1a79d;
    --warn: #e3c36f;
    --ok: #8fcaa3;
    --chip-seen: #f1a79d;
    --chip-seen-ink: #3a0f0a;
    --chip-check: #e3c36f;
    --chip-ok: #8fcaa3;
    --sheet-hi: #3c4448;
    --sheet-lo: #23282b;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  font-weight: 450;
  line-height: 1.45;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}
/* No sideways drift on a phone (Walter's iPhone, 2026-12-03): a double tap no longer zooms the page, and anything a
   little too wide is clipped rather than letting the page pan right. Pinch zoom still works. */
html { touch-action: manipulation; }
body { overflow-x: clip; }
body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); }
h1, h2, h3 {
  font-weight: 800;
  font-stretch: 76%;
  letter-spacing: 0;
  line-height: 1.1;
  margin: 0 0 0.5rem;
}
h1 { font-size: 2.35rem; margin-top: 1.25rem; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--muted); font-size: 0.95rem; }
.center { text-align: center; }

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

.app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 var(--pad) calc(var(--reach) + 1rem);
}

/* The header is a length of corrugated roofing sheet: tall on the home screen, a slim strip elsewhere. */
.brand {
  margin: 0 calc(var(--pad) * -1);
  padding: 0.5rem var(--pad);
  min-height: 4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
  background:
    repeating-linear-gradient(90deg, var(--sheet-lo) 0, var(--sheet-hi) 7px, var(--sheet-lo) 14px);
  border-bottom: 3px solid var(--ink);
}
.brand .name {
  font-size: 1.5rem;
  font-weight: 850;
  font-stretch: 72%;
  line-height: 1;
  margin: 0;
}
.brand .tag { display: none; margin: 0.4rem 0 0; font-size: 1rem; font-weight: 600; color: var(--ink); }
.app:has(#screen-home.on) .brand { align-items: flex-end; padding-top: 2.25rem; padding-bottom: 1.1rem; }
.app:has(#screen-home.on) .brand .name { font-size: 3rem; }
.app:has(#screen-home.on) .brand .tag { display: block; }

.home-btn {
  flex: none;
  min-height: 44px;
  min-width: 44px;
  padding: 0 1rem;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 6px;
  cursor: pointer;
}
.home-btn.hidden { display: none; }

.screen { display: none; }
.screen.on { display: block; animation: rise 180ms ease-out; }
@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.panel {
  background: var(--surface);
  padding: 1rem;
  margin: 0.75rem 0;
}
label {
  display: block;
  font-weight: 700;
  margin: 0.85rem 0 0.35rem;
}
input, select, textarea {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
  padding: 0.65rem 0.75rem;
  border: 2px solid var(--edge);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 2px var(--accent); }
textarea { min-height: 88px; resize: vertical; }

.btn, button.btn, a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 48px;
  min-width: 44px;
  padding: 0.7rem 1rem;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.btn-row .btn { flex: 1 1 140px; }
.btn-stack { flex-direction: column; }
.btn-stack .btn { flex: 0 0 auto; }

.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 0.6rem var(--pad) calc(0.6rem + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 3px solid var(--ink);
  display: none;
  z-index: 20;
}
.dock.on { display: block; }
.dock .inner { max-width: 720px; margin: 0 auto; }

.build-line { color: var(--muted); font-size: 0.8rem; margin-top: 1.25rem; font-variant-numeric: tabular-nums; }

/* New version ready: at the top, clear of the dock at the bottom. */
.update {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  top: max(12px, env(safe-area-inset-top)); width: min(640px, calc(100% - 24px));
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 10px 12px 10px 16px; border-radius: 8px; font-size: 0.95rem;
  background: var(--bg-deep); color: #fff; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.update button {
  flex: none; min-height: 44px; min-width: 44px; padding: 0 1rem; font: inherit; font-weight: 750;
  border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-ink); cursor: pointer;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.photo-cell {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--line);
}
.photo-cell img { width: 100%; height: 100%; object-fit: cover; }
.photo-cell .badge {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0.3rem 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(20, 22, 24, 0.84);
  color: #fff;
}
.err {
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  border-left: 5px solid var(--danger);
  color: var(--ink);
  font-weight: 600;
  padding: 0.75rem;
  margin: 0.75rem 0;
}
.warn-box {
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
  border-left: 5px solid var(--warn);
  padding: 0.75rem;
  margin: 0.75rem 0;
}

/* Status is told by wording and shape as well as colour: Seen is solid, To check is outlined, clear is a thin line. */
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.1rem 0.55rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 750;
  border: 2px solid transparent;
}
.chip.seen { background: var(--chip-seen); color: var(--chip-seen-ink); }
.chip.to_check { background: transparent; color: var(--chip-check); border-color: var(--chip-check); }
.chip.not_seen { background: transparent; color: var(--chip-ok); border-color: color-mix(in srgb, var(--chip-ok) 55%, transparent); }
.chip.not_checked { background: transparent; color: var(--muted); border-color: var(--line); }
.chip.advice { background: transparent; color: var(--muted); border-color: var(--line); }

.issue-card {
  border-top: 1px solid var(--line);
  padding: 0.85rem 0;
}
.issue-card:first-child { border-top: 0; }
.issue-head { display: flex; gap: 0.5rem; align-items: flex-start; justify-content: space-between; }
.issue-head h3 { font-size: 1.2rem; margin: 0; flex: 1; }

.finding-card {
  border: 2px solid var(--line);
  padding: 0.75rem;
  margin: 0.6rem 0;
  background: var(--surface);
}
.finding-card .row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }
.finding-card .row-actions .btn { flex: 1 1 90px; }
/* Keep / Drop: both plain until one is chosen; the chosen one fills, and the card says what happens to the item. */
.btn.choice.keep { border-color: var(--ok); color: var(--ok); }
.btn.choice.drop { border-color: var(--danger); color: var(--danger); }
.btn.choice.keep[aria-pressed="true"] { background: var(--ok); color: var(--surface); box-shadow: inset 0 0 0 2px rgb(0 0 0 / 0.25); }
.btn.choice.drop[aria-pressed="true"] { background: var(--danger); color: var(--surface); box-shadow: inset 0 0 0 2px rgb(0 0 0 / 0.25); }
.finding-card.saving .btn.choice:disabled { opacity: 1; cursor: progress; }
.decision-note { margin: 0.4rem 0 0; font-weight: 700; color: var(--muted); }
.finding-card.keep { border-color: var(--ok); border-left-width: 8px; }
.finding-card.keep .decision-note { color: var(--ok); }
.finding-card.drop { border-color: var(--line); border-style: dashed; background: var(--bg); }
.finding-card.drop .decision-note { color: var(--danger); }
.finding-card.drop > p:not(.decision-note),
.finding-card.drop .ev-row,
.finding-card.drop label,
.finding-card.drop input { opacity: 0.6; }
.finding-card.drop > p:not(.decision-note) { text-decoration: line-through; }
.review-progress { font-weight: 700; margin: 0.5rem 0; }
.review-progress.done { color: var(--ok); }

.list-jobs button {
  width: 100%;
  text-align: left;
  min-height: 48px;
  margin: 0.35rem 0;
  padding: 0.75rem;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.footer-note {
  margin-top: auto;
  padding: 1.5rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem var(--pad);
  border-bottom: 2px solid var(--ink);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.bar { flex-wrap: wrap; }
.bar .actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-left: auto; }

.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 100px;
}

.busy-dot::after {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-left: 0.35rem;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.hidden { display: none !important; }

/* Sky Eye: address-first check */
.small { font-size: 0.9rem; }
.sky3d-wrap { position: relative; }
/* Step 1: the house should fill this box (public/sky3d.js CENTRE_BOX = 0.7 of the view each way). */
.sky3d-box { position: absolute; left: 15%; top: 15%; width: 70%; height: 70%; border: 2px dashed #fff; outline: 1px solid rgba(0, 0, 0, 0.45); border-radius: 4px; pointer-events: none; }
.sky3d-step { font-weight: 700; margin: 0.5rem 0 0; }
.sky3d { width: 100%; aspect-ratio: 4 / 3; border-radius: 4px; overflow: hidden; background: #111315; touch-action: none; }
.sky3d .cesium-viewer-bottom { font-size: 10px; }
.lead-badge { display: inline-block; padding: 0.35rem 0.7rem; border-radius: 4px; font-weight: 750; margin: 0.25rem 0 0.5rem; }
.lead-badge.hot { background: color-mix(in srgb, var(--chip-seen) 16%, var(--surface)); color: var(--chip-seen); }
.lead-badge.warm, .lead-badge.knock { background: color-mix(in srgb, var(--chip-check) 16%, var(--surface)); color: var(--chip-check); }
.lead-badge.cool, .lead-badge.pending { background: color-mix(in srgb, var(--line) 55%, var(--surface)); color: var(--muted); }
.strength { font-size: 0.85rem; color: var(--muted); }
.photo-cell .vlabel { position: absolute; left: 4px; right: 4px; top: 4px; font-size: 11px; line-height: 1.2; background: rgba(0,0,0,0.6); color: #fff; padding: 2px 4px; border-radius: 3px; }

/* Address suggestions (as plan-29a) */
.addr-wrap { position: relative; }
.addr-suggest { list-style: none; margin: 0.25rem 0 0; padding: 0; border: 2px solid var(--edge); border-radius: 4px; background: var(--surface); overflow: hidden; }
.addr-suggest li { min-height: 48px; padding: 0.55rem 0.75rem; display: flex; flex-direction: column; justify-content: center; cursor: pointer; border-top: 1px solid var(--line); }
.addr-suggest li:first-child { border-top: 0; }
.addr-suggest li.on, .addr-suggest li:hover { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.addr-suggest .main { font-weight: 700; }
.addr-suggest .sub { font-size: 0.85rem; color: var(--muted); }

/* Read the roof: per-view readout (plumber only) */
.readout { margin-top: 0.6rem; border-left: 5px solid var(--accent); padding: 0.4rem 0.7rem; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.readout h3 { margin: 0 0 0.3rem; font-size: 1.1rem; }
.readout ul { list-style: none; margin: 0; padding: 0; }
.readout li { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.25rem 0; border-top: 1px solid var(--line); }
.readout li:first-child { border-top: 0; }
.readout .w-seen { color: var(--chip-seen); font-weight: 800; }
.readout .w-to_check { color: var(--chip-check); font-weight: 800; }
.readout .w-not_seen { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .screen.on { animation: none; }
  .busy-dot::after { animation: none; opacity: 1; }
  .btn:active { transform: none; }
}

/* Review: the views behind an item, best first; tap for full size. */
.ev-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.25rem; }
.ev-thumb { padding: 0; border: 2px solid var(--line); border-radius: 4px; background: none; width: 96px; height: 96px; overflow: hidden; cursor: zoom-in; }
.ev-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ev-thumb.off { opacity: 0.35; border-style: dashed; }
.ev-thumb:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.photo-view { width: min(100vw - 1rem, 900px); max-height: calc(100dvh - 1rem); padding: 0.75rem; border: 0; border-radius: 6px; }
.photo-view::backdrop { background: rgb(0 0 0 / 0.7); }
.photo-view img { width: 100%; max-height: 65dvh; object-fit: contain; display: block; background: #111; }
.pv-label { font-weight: 700; margin: 0.5rem 0 0.1rem; }

/* Whose name goes on the report, shown on the review screen with a Change button (44 px tap target). */
.report-by { margin: 0.25rem 0 0.75rem; }
.link-btn {
  background: none; border: 0; padding: 0 0.25rem; min-height: 44px; font: inherit; color: inherit;
  text-decoration: underline; cursor: pointer;
}

/* The "Report ready" screen's frame: the live 3D view, where the PDF's picture is made (decision 20). */
.hero-frame { width: 100%; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: #111315; margin: 0.5rem 0; }
.hero-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.btn[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }
