/* ==========================================================
   AIPA · IB Vauth demo
   Palette: near-black navy base, teal-cyan signal accent
   (matches IB Vault's own brand color), amber for caution.
   System font stack — no webfont loading for a demo this small.
   ========================================================== */

:root {
  --bg: #0F1923;
  --bg-raised: #16233F;
  --bg-card: #142031;
  --line: #26344A;
  --line-soft: #1D2A3D;
  --text: #E7ECEF;
  --text-dim: #8A96A3;
  --text-faint: #5A6474;
  --signal: #1B8A94;
  --signal-bright: #2FBFC9;
  --amber: #FF8800;
  --red: #E8534B;
  --green: #5BBA6F;
  --radius: 10px;
  --radius-lg: 16px;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

.scene {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(circle at 50% 0%, rgba(27, 138, 148, 0.10), transparent 55%),
    var(--bg);
}

/* ---------- header ---------- */
.scene-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 4px rgba(27, 138, 148, 0.18);
}

.brand-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* ---------- card ---------- */
.card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
}

.step-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.step-copy {
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0 0 20px;
}

.step-note {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: 14px;
  line-height: 1.5;
}

.step-error {
  font-size: 13px;
  color: var(--red);
  background: rgba(232, 83, 75, 0.1);
  border: 1px solid rgba(232, 83, 75, 0.3);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 14px;
  line-height: 1.4;
}

.back-link {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 12.5px;
  font-family: var(--font-ui);
  cursor: pointer;
  padding: 0;
  margin-bottom: 14px;
  display: inline-block;
}
.back-link:hover { color: var(--text-dim); }
.back-link:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; border-radius: 4px; }

/* ---------- form fields ---------- */
.field {
  display: block;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field-hint {
  display: block;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 5px;
}

input[type="email"],
input[type="password"] {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: 14.5px;
  color: var(--text);
  font-family: var(--font-ui);
  transition: border-color 0.15s ease;
}
input[type="email"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px rgba(27, 138, 148, 0.18);
}
input::placeholder { color: var(--text-faint); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 11px 18px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
  width: 100%;
}
.btn:active { transform: scale(0.99); }
.btn:focus-visible { outline: 2px solid var(--signal-bright); outline-offset: 2px; }

.btn-primary {
  background: var(--signal);
  color: #04211F;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

.btn-secondary {
  background: transparent;
  color: var(--signal-bright);
  border-color: var(--signal);
  margin-bottom: 10px;
}
.btn-secondary:hover { background: rgba(27, 138, 148, 0.1); }

.btn-ghost {
  background: transparent;
  color: var(--text-faint);
  border-color: var(--line);
}
.btn-ghost:hover { color: var(--text-dim); border-color: var(--text-faint); }

.btn-small {
  width: auto;
  padding: 7px 12px;
  font-size: 12.5px;
}

/* ---------- dashboard: session bar ---------- */
.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
}

.session-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 3px;
}

.session-value {
  font-size: 14.5px;
  font-weight: 600;
  word-break: break-all;
}

/* ---------- token panel ---------- */
.token-panel {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 20px;
}

.token-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
}
.pill-l1 {
  background: rgba(27, 138, 148, 0.18);
  color: var(--signal-bright);
}

.token-expiry {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.token-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  word-break: break-all;
  line-height: 1.5;
  max-height: 60px;
  overflow-y: auto;
}

/* ---------- divider ---------- */
.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 16px;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-soft);
}
.divider span {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  white-space: nowrap;
}

/* ---------- face section ---------- */
.face-status .step-copy { margin-bottom: 14px; }

.face-camera-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--line);
}

#face-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror, feels natural */
}

#face-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
}

.face-camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 25, 35, 0.75);
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  padding: 20px;
}

/* Scanning state: don't cover the video (person needs to see themselves
   to frame their face) — instead show a small pulsing badge so it's
   unmistakable that detection is actively running, not frozen. */
.face-camera-overlay-scanning {
  inset: auto;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(27, 138, 148, 0.92);
  color: #04211F;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.03em;
  padding: 7px 14px;
  border-radius: 999px;
  animation: scan-pulse 1.1s ease-in-out infinite;
}

/* Captured state: a brief, solid (non-pulsing) confirmation badge —
   deliberately held for a moment so the "found your face, now
   processing" step is visible rather than instant. */
.face-camera-overlay-captured {
  inset: auto;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(91, 186, 111, 0.95);
  color: #072B0F;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.03em;
  padding: 7px 14px;
  border-radius: 999px;
}

@keyframes scan-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
  .face-camera-overlay-scanning { animation: none; }
}

.face-result {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.face-result-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}

.face-score {
  font-family: var(--font-mono);
  font-weight: 700;
}

.face-score-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
}

.face-score-fill {
  height: 100%;
  width: 0%;
  background: var(--signal);
  transition: width 0.4s ease, background 0.4s ease;
}

/* ---------- sanctum (locked) ---------- */
.sanctum-locked {
  background: repeating-linear-gradient(
    135deg,
    var(--bg-raised),
    var(--bg-raised) 10px,
    var(--line-soft) 10px,
    var(--line-soft) 11px
  );
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.sanctum-locked .step-copy { margin: 0; }

/* ---------- footer ---------- */
.scene-footer {
  margin-top: 24px;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  text-align: center;
}

/* ---------- responsive ---------- */
@media (max-width: 480px) {
  .card { padding: 26px 20px; }
  .scene { padding: 20px 14px; }
}

@media (min-width: 900px) {
  .card { max-width: 460px; }
}
