/* ============================================================
   Site capture: a phone screen used with gloves, in sunlight,
   one hand free. Big targets, strong contrast, one job per step.
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body.cap {
  min-height: 100vh; min-height: 100dvh;
  background: var(--bg-secondary); color: var(--text-primary);
  font: 15px/1.45 var(--font-body); -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cap-top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--text-primary); color: var(--bg-primary);
}
.cap-top__back { display: grid; place-items: center; width: 36px; height: 36px; margin-left: -8px; border-radius: 50%; color: inherit; }
.cap-top__title { font-weight: 600; font-size: 16px; }
.cap-top__proj { margin-left: auto; font: 500 11px/1 var(--font-mono); opacity: 0.6; }

.cap-main { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; }
.cap-loading { padding: 40px 0; text-align: center; color: var(--text-tertiary); }
.cap-step { display: flex; flex-direction: column; gap: 14px; animation: cap-in 0.25s ease-out both; }
.cap-h { margin: 6px 0 0; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.cap-sub { margin: 8px 0 -4px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary); }

/* step 1 */
.cap-scanbtn {
  display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 64px; padding: 16px;
  border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-ink); cursor: pointer;
  font-size: 17px; font-weight: 600; box-shadow: 0 6px 18px rgba(232, 93, 45, 0.28);
}
.cap-scanbtn:active { transform: scale(0.99); }
.cap-or { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 12px; color: var(--text-tertiary); }
.cap-or::before, .cap-or::after { content: ""; flex: 1; height: 1px; background: var(--border-strong); }
.cap-search {
  width: 100%; min-height: 52px; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--border-strong); background: var(--bg-card); font-size: 16px;
}
.cap-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cap-empty { padding: 12px 4px; color: var(--text-tertiary); font-size: 14px; }
.cap-item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; width: 100%; min-height: 58px;
  padding: 10px 14px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-card);
  text-align: left; cursor: pointer;
}
.cap-item:active { background: var(--bg-tertiary); }
.cap-item__id { font: 600 14px/1 var(--font-mono); }
.cap-item__name { display: flex; flex-direction: column; min-width: 0; font-size: 14px; }
.cap-item__name small { font-size: 12px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cap-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--status-idle); }
.cap-dot--signed { background: var(--status-ok); }
.cap-dot--in_progress { background: var(--status-progress); }
.cap-dot--blocked { background: var(--status-blocked); }
.cap-dot--waived_with_risk { background: #6366F1; }

/* step 2 and 3 */
.cap-asset {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 14px 16px;
  border-radius: 14px; background: var(--bg-card); border: 1px solid var(--border-color);
}
.cap-asset__id { font: 600 22px/1.1 var(--font-mono); letter-spacing: -0.01em; }
.cap-asset__name { grid-column: 1; font-weight: 600; }
.cap-asset__where { grid-column: 1; font-size: 13px; color: var(--text-secondary); }
.cap-asset .cap-link { grid-column: 2; grid-row: 1; align-self: start; }
.cap-link { background: none; border: 0; padding: 6px 0; color: var(--accent); font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center; }

.cap-gates { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.cap-gate {
  position: relative; min-height: 46px; padding: 0; border-radius: 9px; cursor: pointer;
  border: 1.5px solid var(--border-strong); background: var(--bg-card); font: 600 12px/1 var(--font-mono);
}
.cap-gate::after { content: ""; position: absolute; left: 50%; bottom: 6px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--status-idle); }
.cap-gate--signed::after { background: var(--status-ok); }
.cap-gate--in_progress::after { background: var(--status-progress); }
.cap-gate--blocked::after { background: var(--status-blocked); }
.cap-gate--waived_with_risk::after { background: #6366F1; }
.cap-gate.is-on { border-color: var(--text-primary); background: var(--text-primary); color: var(--bg-primary); }
.cap-gatename { margin: -4px 0 0; font-size: 14px; color: var(--text-secondary); }
.cap-gatename b { color: var(--text-primary); }

.cap-camera {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 132px; border-radius: 16px; cursor: pointer; text-align: center;
  border: 2px dashed var(--border-strong); background: var(--bg-card); color: var(--text-primary);
  font-size: 16px; font-weight: 600; transition: border-color 0.15s, background 0.15s;
}
.cap-camera:active { background: var(--accent-wash); border-color: var(--accent); }
.cap-camera svg { color: var(--accent); }
.cap-camera input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.cap-camera:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.cap-shots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cap-shots:empty { display: none; }
.cap-shot { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg-tertiary); display: grid; place-items: center; font-size: 11px; color: var(--text-tertiary); animation: cap-in 0.2s ease-out both; }
.cap-shot img { width: 100%; height: 100%; object-fit: cover; }
.cap-shot.is-busy span { animation: cap-pulse 1s ease-in-out infinite alternate; }
.cap-shot.is-bad { outline: 2px solid var(--status-blocked); }
.cap-shot__x {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,0.6); color: #fff; font-size: 18px; line-height: 1; cursor: pointer;
}

.cap-covers { margin: 0; padding: 12px 14px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-card); }
.cap-covers legend { padding: 0 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary); }
.cap-check { display: flex; align-items: center; gap: 12px; min-height: 40px; font-size: 15px; cursor: pointer; }
.cap-check input { width: 22px; height: 22px; accent-color: var(--accent); }

.cap-field { display: flex; flex-direction: column; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary); }
.cap-field textarea {
  min-height: 72px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--border-strong);
  background: var(--bg-card); font-size: 16px; letter-spacing: 0; text-transform: none; resize: vertical;
}
.cap-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: rgba(220,38,38,0.08); color: var(--status-blocked); font-size: 14px; }
.cap-save {
  min-height: 56px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--text-primary); color: var(--bg-primary); font-size: 17px; font-weight: 600;
}
.cap-save:disabled { opacity: 0.35; cursor: not-allowed; }
.cap-ghost { min-height: 52px; border-radius: 14px; border: 1.5px solid var(--border-strong); background: var(--bg-card); font-size: 16px; font-weight: 600; cursor: pointer; }

/* step 4 */
.cap-done { align-items: stretch; text-align: center; padding-top: 24px; }
.cap-done__mark { align-self: center; display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--status-ok); color: #fff; animation: cap-pop 0.4s cubic-bezier(.3,1.5,.5,1) both; }
.cap-done__text { margin: 0 0 10px; color: var(--text-secondary); }
.cap-done__text b { color: var(--text-primary); font-family: var(--font-mono); font-weight: 600; }

/* scanner */
.cap-scan { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.cap-scan[hidden] { display: none; }
.cap-scan video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cap-scan__frame { position: relative; width: min(68vw, 280px); aspect-ratio: 1; border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,0.5); border: 3px solid #fff; }
.cap-scan__frame::after { content: ""; position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: cap-sweep 1.6s ease-in-out infinite alternate; }
.cap-scan__hint { position: relative; margin: 24px 0 0; color: #fff; font-weight: 500; }
.cap-scan__close { position: absolute; bottom: calc(28px + env(safe-area-inset-bottom)); min-width: 140px; min-height: 50px; border-radius: 999px; border: 0; background: #fff; color: #111; font-weight: 600; font-size: 16px; }

.cap-toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 60;
  padding: 14px 16px; border-radius: 12px; background: var(--text-primary); color: var(--bg-primary); font-size: 14px;
  transform: translateY(140%); transition: transform 0.25s ease;
}
.cap-toast.is-on { transform: none; }

@keyframes cap-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes cap-pop { from { transform: scale(0.3); } to { transform: scale(1); } }
@keyframes cap-pulse { from { opacity: 0.4; } to { opacity: 1; } }
@keyframes cap-sweep { from { top: 18%; } to { top: 82%; } }
@media (prefers-reduced-motion: reduce) {
  .cap-step, .cap-shot, .cap-done__mark, .cap-scan__frame::after { animation: none; }
  .cap-toast { transition: none; }
}
