/* FORTIFIED Photo Capture — mobile-first styles.
   Target: iOS 17+ Safari and Android 11+ Chrome, one hand, on a roof.
   Every interactive target is >= 48px tall. No framework, no build step. */

:root {
  --brand: #0f3d5c;
  --brand-light: #e8f1f7;
  --brand-dark: #0a2b42;
  --accent: #c8791a;
  --ok: #1c7c3c;
  --warn: #8a5a00;
  --err: #a3231d;
  --line: #d4dbe1;
  --ink: #16212b;
  --muted: #5d6b77;
  --bg: #f4f6f8;
  --card: #ffffff;
  --tap: 48px;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

.cap-loading { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- header ---------- */
.cap-header {
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
}
.cap-header-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  max-width: 720px;
  margin: 0 auto;
}
.cap-back-link {
  color: #fff;
  text-decoration: none;
  font-size: 26px;
  line-height: 1;
  padding: 6px 10px 6px 0;
}
.cap-logo { width: 34px; height: 34px; border-radius: 4px; object-fit: contain; background: #fff; }
.cap-header-title { flex: 1; min-width: 0; }
.cap-header-title h1 { font-size: 17px; margin: 0; display: flex; align-items: center; gap: 8px; }
.cap-header-title p { font-size: 12px; margin: 2px 0 0; opacity: .82; }

/* ---------- layout ---------- */
.cap-root { max-width: 720px; margin: 0 auto; padding: 14px 14px 120px; }
.cap-card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(16, 33, 43, .1);
}
.cap-card h2 { font-size: 18px; margin: 0 0 6px; }
.cap-card h3 { font-size: 15px; margin: 18px 0 8px; color: var(--brand); }
.cap-lead { color: var(--muted); font-size: 14px; margin: 0 0 14px; line-height: 1.45; }
.cap-muted { color: var(--muted); font-size: 13px; line-height: 1.45; }
.cap-ok { color: var(--ok); }
.cap-warn { color: var(--warn); }
.cap-err { color: var(--err); }

.cap-failed-list {
  margin: 8px 0 0 0;
  padding: 0 0 0 18px;
  color: #6b4a12;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}
.cap-failed-list li { margin: 0 0 4px 0; }

.cap-alert {
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 12px;
  border: 1px solid;
}
.cap-alert.error { background: #fdf1f0; border-color: #f0c4c1; color: var(--err); }
.cap-alert.warn { background: #fff8e8; border-color: #f0dcae; color: var(--warn); }
.cap-alert.info { background: var(--brand-light); border-color: #c3d9e7; color: var(--brand-dark); }

/* ---------- buttons ---------- */
.cap-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 18px;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}
.cap-btn:active { background: var(--brand-dark); }
.cap-btn:disabled { background: #9aabb6; cursor: not-allowed; }
.cap-btn.secondary { background: transparent; color: var(--brand); border: 2px solid var(--brand); }
.cap-btn.secondary:active { background: var(--brand-light); }
.cap-btn.ghost { background: transparent; color: var(--muted); border: none; text-decoration: underline; min-height: 40px; }
.cap-btn.danger { background: transparent; color: var(--err); border: 2px solid var(--err); }
.cap-btn-row { display: flex; gap: 10px; }
.cap-btn-row .cap-btn { flex: 1; }

/* ---------- sticky action bar ---------- */
.cap-sticky {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .97);
  border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}
.cap-sticky-note { font-size: 12px; color: var(--muted); text-align: center; margin: 0 0 8px; }

/* ---------- chips (quick questions) ---------- */
.cap-q { margin-bottom: 20px; }
.cap-q-label { display: block; font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.cap-q-hint { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.cap-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cap-chip {
  min-height: var(--tap);
  padding: 11px 16px;
  border-radius: 24px;
  border: 2px solid var(--line);
  background: #fff;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
}
.cap-chip.selected { border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }
.cap-chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- photo step ---------- */
.cap-step-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.cap-step-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cap-progress {
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0 16px;
}
.cap-progress-fill { height: 100%; background: var(--brand); transition: width .25s ease; }
.cap-instruction { font-size: 15px; line-height: 1.5; margin: 0 0 4px; }

/* ---------- upload progress (2026-11-04, John: "something more immediate to see") ---------- */
.cap-upload-progress {
  position: relative;
  height: 14px;
  background: var(--line);
  border-radius: 7px;
  overflow: hidden;
  margin: 14px 0 6px;
}
.cap-upload-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--brand);
  transition: width .25s ease;
}
/* Indeterminate: the phases where the exact percentage is unknown
   (waiting for GPS, opening the project). The bar slides so the screen
   reads as alive. */
.cap-upload-progress.pulse .cap-upload-progress-fill {
  width: 38%;
  transition: none;
  animation: cap-upload-slide 1.2s ease-in-out infinite;
}
@keyframes cap-upload-slide {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(280%); }
}
.cap-upload-note { font-size: 13px; font-variant-numeric: tabular-nums; }
/* The "does not apply" state plus its Undo button. */
.cap-skip-block { display: flex; flex-direction: column; gap: 10px; }
.cap-skip-block .cap-warn { margin: 0; }

/* ---------- photo guide copy (what to shoot / must be in frame / mistake) ---------- */
.cap-guide {
  background: var(--brand-light);
  border: 1px solid #c3d9e7;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 12px;
}
.cap-guide-title {
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--brand-dark);
  margin: 0 0 4px;
}
.cap-guide-what { font-size: 15px; line-height: 1.5; margin: 0 0 10px; }
.cap-guide-chips-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 5px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.cap-guide-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.cap-guide-chip {
  display: inline-block;
  background: #fff;
  border: 1px solid #a9c6da;
  color: var(--brand-dark);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .03em;
}
.cap-guide-mistake {
  display: flex;
  gap: 8px;
  align-items: baseline;
  border-top: 1px solid #c3d9e7;
  padding-top: 9px;
  font-size: 14px;
  line-height: 1.45;
}
.cap-guide-mistake-label {
  flex: 0 0 auto;
  background: #fdf1f0;
  color: var(--err);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* ---------- the five photo rules ---------- */
.cap-rules { margin: 0 0 4px; padding-left: 20px; }
.cap-rules li { font-size: 14px; line-height: 1.5; margin-bottom: 7px; }
.cap-rules strong { color: var(--brand-dark); }

/* ---------- spec sheet upload ---------- */
.cap-doc-card { margin-top: 4px; }
.cap-doc-grid { display: flex; flex-direction: column; gap: 12px; }
.cap-doc-zone {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fbfcfd;
}
.cap-doc-label { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.cap-doc-stub { font-size: 13px; margin: 0 0 8px; }
.cap-doc-input { display: block; width: 100%; min-height: var(--tap); font-size: 13px; }
.cap-doc-list { list-style: none; margin: 8px 0 0; padding: 0; }
.cap-doc-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  padding: 3px 0;
}
.cap-doc-remove {
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  font-family: inherit;
  color: var(--err);
  cursor: pointer;
}
.cap-min-note { font-size: 13px; color: var(--muted); margin: 0 0 14px; }

.cap-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch;
}
.cap-thumb {
  flex: 0 0 84px;
  width: 84px;
  height: 84px;
  border-radius: 8px;
  object-fit: cover;
  background: #e4eaee;
  border: 1px solid var(--line);
}
.cap-thumb-empty {
  flex: 0 0 84px;
  width: 84px;
  height: 84px;
  border-radius: 8px;
  border: 2px dashed var(--line);
  display: flex; align-items: center; justify-content: center;
  color: #a9b6bf; font-size: 22px;
}
.cap-thumb-wrap { position: relative; }
.cap-thumb-del {
  position: absolute;
  top: -6px; right: -6px;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--err);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

/* ---------- fields ---------- */
.cap-field { margin-bottom: 14px; min-width: 0; }
.cap-field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.cap-field .cap-req { color: var(--err); }
.cap-field input,
.cap-field select,
.cap-field textarea {
  width: 100%;
  /* 2026-11-03 per John: the roof install date picker rendered WIDER than
     the box behind it. min-width:0 lets the field shrink inside a grid
     track instead of forcing the track open. */
  min-width: 0;
  max-width: 100%;
  min-height: var(--tap);
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px; /* 16px stops iOS Safari from zooming on focus */
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
.cap-field input:focus, .cap-field select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.cap-field .cap-field-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.cap-field input.cap-invalid, .cap-field select.cap-invalid { border-color: var(--err); background: #fffafa; }
.cap-field-err { color: var(--err); font-size: 12px; margin-top: 4px; }
.cap-grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
@media (max-width: 420px) { .cap-grid-2 { grid-template-columns: 1fr; } }

/* ---------- review ---------- */
.cap-review-step {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.cap-review-step:last-child { border-bottom: none; }
.cap-review-count { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.cap-review-count.short { color: var(--err); }
.cap-total { font-size: 15px; font-weight: 700; margin: 10px 0 0; }

/* ---------- done ---------- */
.cap-done-box {
  background: #eaf6ee;
  border: 1px solid #b9dfc7;
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  margin-bottom: 14px;
}
.cap-done-box h2 { margin: 0 0 6px; color: var(--ok); }
.cap-folder-link {
  display: inline-block;
  margin-top: 10px;
  padding: 12px 18px;
  min-height: var(--tap);
  background: var(--brand);
  color: #fff;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
}
.cap-kv { font-size: 14px; color: var(--muted); margin: 3px 0; }
.cap-kv code { font-size: 13px; background: #eef2f5; padding: 2px 5px; border-radius: 4px; }

/* Sticky bottom action bar (created by capture.js at render time). */
.cap-sticky {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line, #d7dee4);
  box-shadow: 0 -2px 10px rgba(16, 33, 43, 0.08);
}
.cap-sticky-note {
  margin: 0;
  font-size: 13px;
  color: var(--muted, #5d6b77);
  text-align: center;
}
.cap-sticky-note.cap-err { color: #b3261e; font-weight: 600; }
.cap-btn-row { display: flex; gap: 10px; }
.cap-btn-row .cap-btn { flex: 1 1 0; }
.cap-btn.secondary {
  background: #eef2f5;
  color: var(--brand, #0f3d5c);
  border: 1px solid #cfd8de;
}
.cap-btn[disabled] { opacity: 0.5; }

/* Live status line during upload. */
#cap-phase { font-weight: 600; color: var(--brand, #0f3d5c); }

/* Reference example photo for the current step. */
.cap-example {
  margin: 10px 0 12px;
  border: 1px solid var(--line, #d7dee4);
  border-radius: 10px;
  overflow: hidden;
  background: #f6f8fa;
}
.cap-example-img {
  display: block;
  width: 100%;
  /* 2026-11-04 per John: "on both of the second photos, you zoomed in on
     them. Please unzoom on both and just have the full image rather than it
     being zoomed in." The old rule was a FIXED 210px height with
     object-fit:cover, so every portrait photo was scaled up and had its
     sides cut off - the app was cropping the picture no matter how good
     the source file was. height:auto + contain shows the WHOLE photo;
     tap it to enlarge. */
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
  background: #e7ecf0;
}
.cap-example-cap {
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #5d6b77);
  background: #fff;
  border-top: 1px solid var(--line, #d7dee4);
}
.cap-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 18, 24, 0.88);
}
.cap-lightbox-img {
  max-width: 100%;
  max-height: 86vh;
  border-radius: 8px;
  background: #111;
}
.cap-lightbox-close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 12px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  color: #10212b;
  font-size: 26px;
  line-height: 44px;
}
