/* Kodria K-id, Travelex-style onboarding layout re-skinned with the Kodria brand. */
:root {
  /* Kodria brand */
  --navy: #162532;
  --navy-h: #0d1822;
  --green: #05fd88;
  --green-d: #04b966;
  --green-h: #04d973;
  --blue: #5e86ff;
  --gray: #d9d9d9;

  --navy-soft: rgba(22, 37, 50, 0.08);
  --green-soft: rgba(5, 253, 136, 0.16);
  --blue-soft: rgba(94, 134, 255, 0.14);
  --error: #e5484d;
  --error-soft: #fdecea;

  /* Surfaces / text */
  --bg-page: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d2d5de;
  --text-strong: var(--navy);
  --text-default: #1f1f2e;
  --text-muted: rgba(22, 37, 50, 0.62);
  --text-soft: rgba(22, 37, 50, 0.4);

  --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --app-frame: 780px;
  --radius-md: 10px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 16px; line-height: 1.5; }
body {
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--text-default);
  background: var(--bg-page);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
h1 { margin: 0; font-weight: 800; line-height: 1.2; color: var(--text-strong); }
p { margin: 0; color: var(--text-muted); }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

/* App frame: centered column with vertical rails */
.app-frame {
  max-width: var(--app-frame);
  margin: 0 auto;
  height: 100dvh;          /* fixed to the viewport so the bottom button never moves */
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
@media (max-width: 540px) { .app-frame { border-left: 0; border-right: 0; } }

/* Header: back | logo | gear */
.page-header {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  height: 64px;
  padding: 10px 20px;
}
@media (min-width: 768px) { .page-header { height: 88px; padding: 0 60px; } }
.page-header__back, .page-header__gear {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius-md);
  color: var(--text-strong); background: transparent; border: 0;
}
.page-header__back { justify-self: start; }
.page-header__gear { justify-self: end; }
.page-header__back:hover, .page-header__gear:hover { background: #f4f6f8; }
.page-header__logo { height: 30px; max-width: 150px; object-fit: contain; justify-self: center; }
@media (min-width: 768px) { .page-header__logo { height: 36px; } }

/* Stepper */
.page-stepper { flex-shrink: 0; padding: 8px 20px 0; }
@media (min-width: 768px) { .page-stepper { padding: 16px 60px 0; } }
.stepper { width: 100%; }
.stepper__bar { display: flex; gap: 4px; width: 100%; }
.stepper__seg { flex: 1; height: 4px; background: var(--border); border-radius: 2px; }
.stepper__bar[data-step="1"] .stepper__seg:nth-child(-n+1),
.stepper__bar[data-step="2"] .stepper__seg:nth-child(-n+2),
.stepper__bar[data-step="3"] .stepper__seg:nth-child(-n+3),
.stepper__bar[data-step="4"] .stepper__seg:nth-child(-n+4) { background: var(--green); }

/* Page flow */
.page-flow { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.screen { display: none; flex: 1; flex-direction: column; min-height: 0; }
.screen.active { display: flex; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-top { flex-shrink: 0; padding: 24px 24px 0; }
@media (min-width: 768px) { .page-top { padding: 36px 60px 0; } }
.page-title { font-size: 26px; font-weight: 800; color: var(--text-strong); line-height: 1.18; margin: 0 0 8px; }
@media (min-width: 768px) { .page-title { font-size: 32px; } }
.page-subtitle { font-size: 14px; color: var(--text-muted); font-weight: 600; line-height: 1.45; }
@media (min-width: 768px) { .page-subtitle { font-size: 16px; } }
.center { text-align: center; }

.page-fields {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 0 24px; margin: 16px 0 12px;
  display: flex; flex-direction: column; gap: 12px;
}
@media (min-width: 768px) { .page-fields { padding: 0 60px; margin: 24px 0 16px; } }
.page-fields--centered { align-items: center; justify-content: center; text-align: center; }

.page-bottom { flex-shrink: 0; padding: 8px 24px max(20px, env(safe-area-inset-bottom)); }
@media (min-width: 768px) { .page-bottom { padding: 8px 60px 40px; } }

/* Buttons */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 0 24px; border-radius: 14px; border: 1px solid transparent;
  font-size: 16px; font-weight: 700; line-height: 1; height: 56px; width: 100%;
  transition: background-color .12s, border-color .12s, transform .12s, opacity .12s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--green); color: var(--navy); }
.btn--primary:hover:not(:disabled) { background: var(--green-h); }
.btn--secondary { background: var(--bg-page); color: var(--text-strong); border-color: var(--border-strong); }
.btn--secondary:hover:not(:disabled) { background: #f4f6f8; }
.btn--danger { background: var(--error); color: #fff; }
.btn--danger:hover:not(:disabled) { background: #c93b40; }
.btn__chevron { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--text-muted); letter-spacing: .2px; }
.field__hint { font-size: 13px; color: var(--text-muted); }
.input {
  width: 100%; padding: 0 16px; border: 1.5px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-page); font-size: 16px; font-weight: 600; height: 56px; color: var(--text-strong);
  transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 4px var(--blue-soft); }
.input::placeholder { color: var(--text-soft); font-weight: 400; }
.warn { color: #b06a00; font-size: 12.5px; background: #fff7e6; padding: 11px 13px; border-radius: 10px; }

/* Home menu */
.menu { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.menu-item {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  transition: border-color .15s, transform .05s;
}
.menu-item:hover { border-color: var(--navy); }
.menu-item:active { transform: scale(.99); }
.menu-item.danger:hover { border-color: var(--error); }
.mi-ic {
  width: 44px; height: 44px; flex: 0 0 44px; display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
}
.mi-ic svg { width: 22px; height: 22px; }
.mi-txt { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.mi-txt b { font-size: 15px; color: var(--navy); }
.mi-txt small { font-size: 12.5px; color: var(--text-muted); }
.mi-arrow { font-size: 22px; color: var(--gray); }

/* Selfie oval (Travelex geometry, Kodria green ring) */
.selfie-circle {
  width: min(74vw, 290px); aspect-ratio: 3 / 4; border-radius: 50%;
  margin: 12px auto; background: var(--navy); border: 4px solid var(--green);
  position: relative; flex-shrink: 0;
}
.selfie-circle::before {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
  border: 3px dashed var(--green); opacity: .45;
}
.selfie-circle video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  border-radius: 50%; transform: scaleX(-1);
}
.selfie-off {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #9fb0c4; font-size: 13px; text-align: center; padding: 0 20px;
}
.face-guide {
  position: absolute; inset: 0; z-index: 1; border-radius: 50%; overflow: hidden;
  pointer-events: none; opacity: 1; transition: opacity .45s ease;
}
.face-guide svg { width: 100%; height: 100%; display: block; }
.face-guide.hide { opacity: 0; }

.countdown {
  position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(22, 37, 50, .45);
  color: #fff; font-size: 120px; font-weight: 800; line-height: 1;
  animation: pop .3s ease;
}
@keyframes pop { from { transform: scale(.6); opacity: .2; } to { transform: scale(1); opacity: 1; } }

/* Capture quality feedback (DetectFaces gate) - overlays the oval top */
.capture-fb {
  position: absolute; left: 50%; top: 9%; transform: translate(-50%, 0);
  z-index: 3; display: flex; flex-direction: column; gap: 3px; align-items: center;
  width: max-content; max-width: 86%; padding: 8px 14px;
  background: rgba(22, 37, 50, .82); border-radius: 12px; backdrop-filter: blur(2px);
  animation: fbIn .25s ease;
}
.capture-fb span { font-size: 12.5px; font-weight: 700; color: #fff; text-align: center; line-height: 1.3; }
@keyframes fbIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Prepare-for-selfie step */
.prep-examples { display: flex; gap: 18px; justify-content: center; margin: 4px 0 20px; }
.prep-ex { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.prep-oval {
  width: 108px; aspect-ratio: 3 / 4; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.prep-oval svg { width: 72%; height: 72%; }
.prep-oval.ok { background: var(--green-soft); border: 3px solid var(--green); }
.prep-oval.bad { background: #f1f3f5; border: 2px dashed var(--border-strong); }
.prep-ex figcaption { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.prep-ex.ok figcaption { color: var(--green-d); }

.prep-tips { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 13px; }
.prep-tips li { display: flex; align-items: center; gap: 12px; font-size: 14.5px; color: var(--navy); font-weight: 600; }
.prep-tips .num {
  width: 26px; height: 26px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--green-soft); color: var(--green-d); font-size: 13px; font-weight: 800;
}

/* Manual capture "shutter" ball, overlays the oval rim, shown after 10s */
.shutter {
  position: absolute; left: 50%; bottom: -30px; transform: translateX(-50%);
  z-index: 5; width: 62px; height: 62px;
  border-radius: 50%; background: var(--green); border: 4px solid #fff; cursor: pointer;
  box-shadow: 0 6px 18px rgba(5, 253, 136, .45), 0 0 0 2px var(--green);
  animation: shutterIn .3s ease, shutterPulse 1.8s ease-in-out .3s infinite;
}
.shutter:active { transform: translateX(-50%) scale(.93); }
@keyframes shutterIn {
  from { opacity: 0; transform: translateX(-50%) scale(.5); }
  to   { opacity: 1; transform: translateX(-50%) scale(1); }
}
@keyframes shutterPulse {
  0%, 100% { box-shadow: 0 6px 18px rgba(5, 253, 136, .45), 0 0 0 2px var(--green); }
  50% { box-shadow: 0 6px 18px rgba(5, 253, 136, .45), 0 0 0 9px rgba(5, 253, 136, .22); }
}

.illus { margin: 24px 0; color: var(--text-soft); }
.illus svg { width: 72px; height: 72px; }
.illus--danger { color: var(--error); }

/* Result */
.result-wrap { align-items: center; text-align: center; }
.result-icon {
  width: 76px; height: 76px; flex-shrink: 0; margin: 16px auto 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--green-soft); color: var(--green-d);
}
.result-icon svg { width: 38px; height: 38px; }
.result-icon.fail { background: var(--error-soft); color: var(--error); }
.result-icon.info { background: var(--blue-soft); color: var(--blue); }
.result-thumb {
  width: 110px; height: 138px; object-fit: cover; border-radius: 14px; margin: 6px auto 18px;
  transform: scaleX(-1); border: 1px solid var(--border); box-shadow: 0 6px 18px rgba(22,37,50,.1);
}

/* Side-by-side compare: enrolled (left) vs just-captured (right) */
.compare { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 8px auto 20px; }
.cmp { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.cmp img {
  width: 118px; height: 148px; flex-shrink: 0; object-fit: cover; border-radius: 14px;
  border: 1px solid var(--border); box-shadow: 0 6px 18px rgba(22,37,50,.1);
  transform: scaleX(-1); background: var(--navy);
}
.cmp figcaption { font-size: 12px; font-weight: 700; color: var(--text-muted); letter-spacing: .3px; }
.cmp-arrow { color: var(--green-d); flex: 0 0 auto; }
@media (max-width: 380px) { .cmp img { width: 100px; height: 126px; } }
.score { width: 100%; max-width: 420px; margin: 6px auto 18px; }
.score-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.score-top span { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.score-top b { font-size: 22px; color: var(--navy); font-variant-numeric: tabular-nums; }
.score-bar { height: 10px; background: #eef0f3; border-radius: 6px; overflow: hidden; }
.score-fill { height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--blue), var(--green)); transition: width .6s ease; }
.score.fail .score-fill { background: var(--error); }
.details { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 420px; margin: 0 auto 14px; }
.detail-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 13px 15px; background: #fafbfc; border: 1px solid var(--border); border-radius: 12px;
}
.detail-row .k { font-size: 13px; color: var(--text-muted); }
.detail-row .v {
  font-size: 14px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums;
  text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%;
}
.detail-row .v.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.json-toggle { display: block; margin: 0 auto 4px; background: none; border: none; color: var(--blue); font-size: 13px; font-weight: 700; padding: 6px; }
.json { width: 100%; max-width: 420px; margin: 8px auto 0; background: #0f1722; color: #c7d4e3; border-radius: 12px; padding: 14px; font-size: 12px; overflow-x: auto; max-height: 180px; text-align: left; }

.hidden { display: none !important; }
