/* =============================================
   Horkos Identity Verification — horkos.css
   Mobile-first, WCAG AA, dark mode support
   ============================================= */

/* ── 1. Design tokens ──────────────────────── */
:root {
  /* Color palette — light */
  --bg:            #fafafa;
  --surface:       #ffffff;
  --surface-raised:#f4f5f8;
  --text-primary:  #0e0f12;
  --text-muted:    #5a6072;
  --border:        #e6e8ee;
  --accent:        #d97706;
  --accent-dark:   #b45309;
  --accent-subtle: color-mix(in srgb, #d97706 10%, transparent);
  --ok:            #10b981;
  --warn:          #f59e0b;
  --bad:           #ef4444;
  --info:          #3b82f6;

  /* Typography — system stack only */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --fs-h1:   1.75rem; --lh-h1:   1.2;
  --fs-h2:   1.25rem; --lh-h2:   1.3;
  --fs-body: 1rem;    --lh-body: 1.5;
  --fs-sm:   .875rem; --lh-sm:   1.4;
  --fs-xs:   .75rem;  --lh-xs:   1.4;

  /* Spacing scale */
  --s4:  4px;  --s8:  8px;  --s12: 12px; --s16: 16px;
  --s20: 20px; --s24: 24px; --s32: 32px; --s40: 40px;
  --s48: 48px; --s64: 64px;

  /* Radii */
  --r-sm: 8px;  --r-md: 12px; --r-lg: 16px; --r-xl: 24px;
  --r-full: 9999px;

  /* Layout */
  --content-max: 480px;
  --screen-gap: 28px;
  --t: 180ms ease;
}

/* Desktop bump */
@media (min-width: 768px) {
  :root { --fs-h1: 2.25rem; }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0e0f12;
    --surface:       #161821;
    --surface-raised:#1c1e2a;
    --text-primary:  #e8eaef;
    --text-muted:    #8a8f99;
    --border:        #232633;
    --accent-subtle: color-mix(in srgb, #d97706 14%, transparent);
  }
}

/* ── 2. Reset ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-primary);
  background: var(--bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; }
button { cursor: pointer; font: inherit; border: none; background: none; }
a { color: inherit; }
ul { list-style: none; }
[hidden] { display: none !important; }

/* ── 3. App shell ──────────────────────────── */
.hk-app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.hk-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s16) var(--s20);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.hk-logo {
  font-size: var(--fs-sm);
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text-primary);
  user-select: none;
}
.hk-logo-accent { color: var(--accent); }

.hk-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--s32) var(--s20) var(--s48);
}

.hk-content {
  width: 100%;
  max-width: var(--content-max);
  display: flex;
  flex-direction: column;
  gap: var(--screen-gap);
}

.hk-footer {
  padding: var(--s16) var(--s20);
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  line-height: var(--lh-xs);
}
.hk-footer-main,
.hk-footer-links,
.hk-footer-copy {
  max-width: var(--content-max);
  margin: 0 auto;
}
.hk-footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--s8) var(--s16);
  margin-top: var(--s8);
}
.hk-footer-links a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.hk-footer-links a:hover { color: var(--text-primary); }
.hk-footer-copy { margin-top: var(--s8); }

/* ── 4. Progress indicator ─────────────────── */
.hk-progress {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--s12) var(--s20);
}
.hk-progress-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--s12);
}
.hk-progress progress {
  flex: 1;
  height: 4px;
  border: none;
  border-radius: var(--r-full);
  background: var(--border);
  -webkit-appearance: none;
  appearance: none;
}
.hk-progress progress::-webkit-progress-bar  { background: var(--border); border-radius: var(--r-full); }
.hk-progress progress::-webkit-progress-value { background: var(--accent); border-radius: var(--r-full); transition: width 400ms ease; }
.hk-progress progress::-moz-progress-bar  { background: var(--accent); border-radius: var(--r-full); }
.hk-progress-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 52px;
  text-align: right;
}

/* ── 5. Typography helpers ─────────────────── */
.hk-h1    { font-size: var(--fs-h1); line-height: var(--lh-h1); font-weight: 700; text-wrap: pretty; }
.hk-h2    { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: 600; text-wrap: pretty; }
.hk-body  { font-size: var(--fs-body); line-height: var(--lh-body); }
.hk-small { font-size: var(--fs-sm);   line-height: var(--lh-sm); }
.hk-tiny  { font-size: var(--fs-xs);   line-height: var(--lh-xs); }
.text-muted   { color: var(--text-muted); }
.text-center  { text-align: center; }

/* ── 6. Buttons ────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s8);
  min-height: 48px;
  padding: 0 var(--s24);
  width: 100%;
  border-radius: var(--r-md);
  font-size: var(--fs-body);
  font-weight: 600;
  text-decoration: none;
  border: 2px solid transparent;
  transition: background var(--t), color var(--t), border-color var(--t), opacity var(--t), transform 80ms ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}
.btn:active:not(:disabled) { transform: scale(.98); }

/* Primary */
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }

/* Secondary */
.btn-secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-secondary:hover:not(:disabled) { background: var(--accent-subtle); }

/* Ghost (smaller, auto-width) */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
  width: auto;
}
.btn-ghost:hover:not(:disabled) { border-color: var(--text-muted); color: var(--text-primary); }

/* Inline text link */
.btn-link {
  background: none;
  color: var(--accent);
  min-height: auto;
  padding: 0;
  width: auto;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-link:hover { text-decoration: none; }

/* Loading state */
.btn[aria-busy="true"] {
  pointer-events: none;
  cursor: wait;
}

/* ── 7. Spinner ────────────────────────────── */
.spinner {
  display: inline-block;
  flex-shrink: 0;
  width: 18px; height: 18px;
  border: 2.5px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}
.spinner-lg {
  width: 36px; height: 36px;
  border-width: 3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 8. Step hero icon ─────────────────────── */
.hk-icon-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px; height: 80px;
  border-radius: var(--r-xl);
  background: var(--accent-subtle);
  color: var(--accent);
  margin: 0 auto;
}

/* Result icons */
.hk-icon-result {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px; height: 96px;
  border-radius: 50%;
  margin: 0 auto;
}
.hk-icon-result--ok   { background: color-mix(in srgb, var(--ok)   12%, var(--surface)); color: var(--ok); }
.hk-icon-result--bad  { background: color-mix(in srgb, var(--bad)  12%, var(--surface)); color: var(--bad); }
.hk-icon-result--warn { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); color: var(--warn); }
.hk-icon-result--info { background: color-mix(in srgb, var(--info) 12%, var(--surface)); color: var(--info); }

/* ── 9. Step list (landing) ────────────────── */
.hk-step-list { display: flex; flex-direction: column; gap: var(--s8); }
.hk-step-item {
  display: flex;
  align-items: center;
  gap: var(--s12);
  padding: var(--s12) var(--s16);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.hk-step-item-icon {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  background: var(--accent-subtle);
  color: var(--accent);
}
.hk-step-item-label { font-size: var(--fs-sm); font-weight: 500; flex: 1; }
.hk-step-item-num   { font-size: var(--fs-xs); color: var(--text-muted); }

/* ── 10. Privacy / info hints ──────────────── */
.hk-hint {
  display: flex;
  align-items: flex-start;
  gap: var(--s8);
  padding: var(--s12);
  background: color-mix(in srgb, var(--info) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--info) 22%, var(--border));
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: var(--lh-sm);
}
.hk-hint svg { flex-shrink: 0; margin-top: 1px; color: var(--info); }

/* ── 11. Inline error banner ───────────────── */
.hk-error-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--s8);
  padding: var(--s12);
  background: color-mix(in srgb, var(--bad) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--bad) 25%, var(--border));
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  line-height: var(--lh-sm);
}
.hk-error-banner svg { flex-shrink: 0; margin-top: 1px; color: var(--bad); }

/* ── 12. Form controls ─────────────────────── */
.hk-field { display: flex; flex-direction: column; gap: var(--s8); }
.hk-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-primary); }
.hk-sublabel { font-size: var(--fs-xs); color: var(--text-muted); margin-top: -4px; }

.hk-select, .hk-input {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--s16);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: var(--fs-body);
  color: var(--text-primary);
  transition: border-color var(--t), box-shadow var(--t);
  -webkit-appearance: none;
  appearance: none;
}
.hk-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 7L11 1' stroke='%235a6072' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s16) center;
  padding-right: 40px;
}
.hk-select:focus, .hk-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.hk-input::placeholder { color: var(--text-muted); }

/* Segment control (doc type switcher) */
.hk-segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s4);
  padding: var(--s4);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.hk-segment-btn {
  padding: var(--s8) var(--s4);
  border-radius: calc(var(--r-sm) - 2px);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  transition: background var(--t), color var(--t);
  white-space: nowrap;
  min-height: 36px;
}
.hk-segment-btn:hover:not(.active) { color: var(--text-primary); }
.hk-segment-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.hk-segment-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ── 13. Camera capture area ───────────────── */
.capture-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--s12);
}
.capture-viewport {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  background: #111;
  aspect-ratio: 4/3;
}
.capture-viewport video {
  width: 100%; height: 100%;
  object-fit: cover;
}
.capture-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.capture-overlay svg { width: 100%; height: 100%; }
.capture-shutter {
  position: absolute;
  bottom: var(--s16);
  left: 50%;
  transform: translateX(-50%);
  width: 60px; height: 60px;
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  border: 3px solid rgba(255,255,255,.5);
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--t), background var(--t);
  z-index: 2;
}
.capture-shutter::after {
  content: '';
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--text-primary);
}
.capture-shutter:hover  { transform: translateX(-50%) scale(1.06); }
.capture-shutter:active { transform: translateX(-50%) scale(.95); }
.capture-shutter:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* File upload drop zone */
.capture-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s8);
  padding: var(--s32) var(--s20);
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
  min-height: 160px;
  position: relative;
}
.capture-dropzone:hover,
.capture-dropzone:focus-within { border-color: var(--accent); background: var(--accent-subtle); }
.capture-dropzone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.capture-dropzone-icon { color: var(--text-muted); }
.capture-dropzone-label { font-size: var(--fs-sm); font-weight: 500; }
.capture-dropzone-hint  { font-size: var(--fs-xs); color: var(--text-muted); }

/* Preview image */
.capture-preview {
  width: 100%;
  border-radius: var(--r-md);
  object-fit: contain;
  max-height: 260px;
  background: #111;
}

/* Action row below capture */
.capture-actions {
  display: flex;
  gap: var(--s8);
}
.capture-actions .btn { flex: 1; }

/* ── 14. Liveness stage ────────────────────── */
.liveness-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--s16);
}
.liveness-stage {
  position: relative;
  aspect-ratio: 3/4;
  max-height: 420px;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #111;
}
.liveness-stage video {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.face-ring {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -55%);
  width: 55%; aspect-ratio: 3/4;
  border: 2.5px solid rgba(255,255,255,.65);
  border-radius: 50% 50% 50% 50% / 58% 58% 42% 42%;
  pointer-events: none;
}
.challenge-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: var(--s20) var(--s16);
  background: linear-gradient(to top, rgba(0,0,0,.7) 0%, transparent 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s8);
}
.challenge-direction {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px; height: 72px;
}
.challenge-text {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.5);
  letter-spacing: .02em;
}
.challenge-countdown {
  font-size: 2.5rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
  text-shadow: 0 2px 12px rgba(0,0,0,.5);
}

/* Arrow animations */
@keyframes arrow-right { 0%,100%{transform:translateX(0)} 50%{transform:translateX(10px)} }
@keyframes arrow-left  { 0%,100%{transform:translateX(0)} 50%{transform:translateX(-10px)} }
.anim-right { animation: arrow-right .8s ease-in-out infinite; }
.anim-left  { animation: arrow-left  .8s ease-in-out infinite; }

/* Capture flash */
@keyframes flash {
  0%   { opacity: 0; }
  20%  { opacity: .6; }
  100% { opacity: 0; }
}
.capture-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  pointer-events: none;
  opacity: 0;
}
.capture-flash.active { animation: flash 400ms ease forwards; }

/* ── 15. Status cards ──────────────────────── */
.hk-status-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s20);
  padding: var(--s40) var(--s20);
  text-align: center;
}

/* ── 16. Reason card ───────────────────────── */
.hk-reason-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--s16);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: var(--lh-sm);
}
.hk-reason-card strong { color: var(--text-primary); display: block; margin-bottom: var(--s8); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; }

/* ── 17. Screen transitions ────────────────── */
.hk-screen {
  animation: fadeUp 260ms ease both;
}
.hk-screen > section,
.hk-content > section {
  display: flex;
  flex-direction: column;
  gap: var(--screen-gap);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 18. Divider ───────────────────────────── */
.hk-divider {
  display: flex;
  align-items: center;
  gap: var(--s8);
  color: var(--text-muted);
  font-size: var(--fs-xs);
}
.hk-divider::before, .hk-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── 19. Permission screen ─────────────────── */
.permission-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s24);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s16);
  text-align: center;
}

/* ── 20. Legal pages ───────────────────────── */
.hk-legal {
  display: flex;
  flex-direction: column;
  gap: var(--s16);
}
.hk-legal h1 {
  font-size: var(--fs-h1);
  line-height: var(--lh-h1);
  font-weight: 700;
}
.hk-legal h2 {
  margin-top: var(--s12);
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  font-weight: 650;
}
.hk-legal h3 {
  margin-top: var(--s8);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: 650;
}
.hk-legal p,
.hk-legal li {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
}
.hk-legal ul {
  display: flex;
  flex-direction: column;
  gap: var(--s8);
  padding-left: var(--s20);
  list-style: disc;
}
.hk-legal strong { color: var(--text-primary); }

/* ── 21. Accessibility ─────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
