/* Light-first design per vendor research: white canvas, one card per screen,
   pill buttons, big title + 16px body. Primary #3773F5 (Onfido), success #00BFB2
   (Innovatrics). Dark chrome only on the camera screen. */
:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --ink: #16202b;
  --muted: #5f6b7a;
  --line: #e4e8ee;
  --primary: #3773f5;
  --primary-press: #2a5fd4;
  --success: #00bfb2;
  --amber: #f59e0b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  font-size: 16px;
  line-height: 1.5;
}

#topbar {
  padding: calc(env(safe-area-inset-top) + 14px) 20px 0;
  max-width: 480px; margin: 0 auto;
}
.brand { font-size: 15px; font-weight: 700; letter-spacing: -.2px; display: flex; align-items: center; gap: 7px; }
.brand-mark {
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 800;
  border-radius: 7px; padding: 3px 6px; letter-spacing: .5px;
}
.brand-sub { color: var(--muted); font-weight: 500; }
.progress-track { height: 3px; background: var(--line); border-radius: 99px; margin-top: 14px; overflow: hidden; }
#progress-fill { height: 100%; width: 0%; background: var(--primary); border-radius: 99px; transition: width .45s cubic-bezier(.4,0,.2,1); }

#app { max-width: 480px; margin: 0 auto; padding: 20px 20px calc(env(safe-area-inset-bottom) + 28px); }

.screen { display: none; }
.screen.active { display: block; animation: fadein .3s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.sheet {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 28px 22px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.sheet.center { text-align: center; }
h1 { font-size: 25px; font-weight: 750; letter-spacing: -.4px; margin-bottom: 8px; }
h2 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.sub { color: var(--muted); font-size: 15.5px; margin-bottom: 20px; }

.steps-list { list-style: none; display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.steps-list li { display: flex; gap: 14px; align-items: flex-start; }
.step-num {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: #eef3fe; color: var(--primary); font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 2px;
}
.steps-list b { display: block; font-size: 15.5px; }
.steps-list li > div > span { color: var(--muted); font-size: 13.5px; }

.consent { display: flex; gap: 12px; font-size: 13px; color: var(--muted); line-height: 1.5; cursor: pointer; margin-bottom: 20px; }
.consent input { width: 20px; height: 20px; flex: none; margin-top: 2px; accent-color: var(--primary); }
.consent b { color: var(--ink); }
.consent a { color: var(--primary); }

.btn {
  display: block; width: 100%; border: none; border-radius: 999px;
  padding: 16px; font-size: 16px; font-weight: 650; cursor: pointer;
  font-family: inherit; transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:not(:disabled):hover { background: var(--primary-press); }
.btn.primary:disabled { background: #cdd7e4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-row { display: flex; gap: 10px; margin-top: 18px; }
.btn-row .btn { margin: 0; }

#qr { display: flex; justify-content: center; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; width: fit-content; margin: 0 auto 16px; }

/* document type options */
.doc-options { display: flex; flex-direction: column; gap: 12px; }
.doc-option {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 16px;
  padding: 18px 16px; cursor: pointer; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.doc-option:hover, .doc-option:focus-visible { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(55,115,245,.12); }
.doc-ico { font-size: 28px; }
.doc-text b { display: block; font-size: 16px; color: var(--ink); }
.doc-text span { color: var(--muted); font-size: 13.5px; }
.doc-arrow { margin-left: auto; color: #b3bdc9; font-size: 26px; font-weight: 300; }

.tips-list { list-style: none; display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.tips-list li { display: flex; gap: 11px; font-size: 15px; color: var(--ink); }
.tips-list li::before { content: "✓"; color: var(--success); font-weight: 800; flex: none; }

/* ======== capture (the one dark screen) ======== */
.screen.fullscreen { position: fixed; inset: 0; z-index: 30; background: #000; max-width: none; padding: 0; }
#cam-wrap { position: absolute; inset: 0; overflow: hidden; }
#video, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#video.mirror, #overlay.mirror { transform: scaleX(-1); }

#flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .1s; }
#flash.on { opacity: .85; }

#instruction-wrap {
  position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 128px);
  display: flex; justify-content: center; padding: 0 20px; z-index: 5;
}
.instruction {
  background: rgba(255,255,255,.96); color: var(--ink);
  font-size: 16.5px; font-weight: 650; border-radius: 999px;
  padding: 13px 24px; text-align: center; max-width: 94%;
  box-shadow: 0 4px 24px rgba(0,0,0,.25);
  transition: background .25s, color .25s, opacity .2s;
}
.instruction.hold { background: var(--ink); color: #fff; }
.instruction.success { background: var(--success); color: #fff; }

#turn-arrows { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.t-arrow {
  position: absolute; top: 38%; font-size: 58px; line-height: 1; color: #fff;
  text-shadow: 0 2px 14px rgba(0,0,0,.55); font-weight: 600;
}
.t-arrow.left { left: 4%; animation: nudgeL 1.15s ease-in-out infinite; }
.t-arrow.right { right: 4%; animation: nudgeR 1.15s ease-in-out infinite; }
.t-arrow.done { animation: none; opacity: 0; transition: opacity .35s; }
@keyframes nudgeL { 0%, 100% { transform: translateX(0); opacity: .45; } 50% { transform: translateX(-15px); opacity: 1; } }
@keyframes nudgeR { 0%, 100% { transform: translateX(0); opacity: .45; } 50% { transform: translateX(15px); opacity: 1; } }

#capture-bottom {
  position: absolute; bottom: calc(env(safe-area-inset-bottom) + 30px); left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; gap: 22px; z-index: 5;
}
.round-btn {
  width: 46px; height: 46px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.18); color: #fff; font-size: 17px; cursor: pointer;
  backdrop-filter: blur(8px);
}
.round-btn.on { background: var(--amber); }
.manual-btn {
  border: none; border-radius: 999px; padding: 13px 26px; cursor: pointer;
  background: rgba(255,255,255,.92); color: var(--ink); font-size: 15px; font-weight: 650;
  font-family: inherit; box-shadow: 0 4px 20px rgba(0,0,0,.3);
}

#debug-panel {
  position: absolute; top: calc(env(safe-area-inset-top) + 16px); left: 12px; z-index: 6;
  background: rgba(0,0,0,.65); color: #9fe3b8; font: 10.5px/1.5 ui-monospace, Menlo, monospace;
  padding: 8px 10px; border-radius: 8px; white-space: pre; pointer-events: none;
}

/* ======== preview ======== */
.preview-wrap { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 14px; background: #0c1116; }
#preview-img { width: 100%; display: block; }
.preview-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.preview-meta .m {
  font-size: 12px; color: var(--muted); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px;
}
.preview-meta .m b { color: var(--ink); }

.barcode-result { margin-top: 14px; background: #f0fbfa; border: 1px solid #b9ebe7; border-radius: 14px; padding: 14px 16px; }
.barcode-result.muted { background: var(--bg); border-color: var(--line); }
.barcode-result h3 { font-size: 13.5px; color: #0a8f86; margin-bottom: 8px; }
.barcode-result.muted h3 { color: var(--muted); }
.barcode-result table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.barcode-result td { padding: 3px 0; vertical-align: top; }
.barcode-result td:first-child { color: var(--muted); width: 42%; }
.barcode-result .fineprint { color: #8a97a5; font-size: 11.5px; margin-top: 8px; }

/* ======== done ======== */
.done-check {
  width: 64px; height: 64px; border-radius: 50%; margin: 4px auto 16px;
  background: #e6f9f7; color: var(--success); font-size: 32px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  animation: pop .4s cubic-bezier(.2,1.6,.4,1);
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.done-gallery { display: flex; justify-content: center; gap: 10px; margin-bottom: 18px; }
.done-gallery figure { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); width: 30%; background: #0c1116; }
.done-gallery img { width: 100%; aspect-ratio: 3/2.1; object-fit: cover; display: block; }
.done-gallery figcaption { font-size: 11px; color: var(--muted); padding: 5px 0; background: var(--bg); }
.done-stats { display: flex; justify-content: center; gap: 10px; margin-bottom: 18px; }
.done-stats .stat { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; min-width: 88px; }
.done-stats .stat b { display: block; font-size: 19px; color: var(--ink); }
.done-stats .stat span { font-size: 11.5px; color: var(--muted); }

.next-steps { text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 13px 16px; margin-top: 4px; }
.next-steps summary { font-size: 13.5px; font-weight: 650; color: var(--muted); cursor: pointer; }
.next-steps ul { list-style: none; margin-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.next-steps li { font-size: 13px; color: var(--muted); padding-left: 18px; position: relative; }
.next-steps li::before { content: "→"; position: absolute; left: 0; color: var(--primary); }
