/* ═══════════════════════════════════════════════════════════════════════
   css/22 — In-app QR scanner (ui/qr-scanner.js)
   ─────────────────────────────────────────────────────────────────────
   Full-screen live-camera sheet. The stage is ALWAYS dark (it shows the
   camera feed) so its chrome is light in both themes; the status/error
   panel uses theme tokens so it adapts. Class ends in "-overlay" so
   ui/modal-stack.js owns the z-index; sits below the impersonation banner
   via top:var(--banner-h) (§6). Reuses .ah-spinner from css/01.
   ═══════════════════════════════════════════════════════════════════════ */

.qr-scanner-overlay {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  top: var(--banner-h, 0);
  z-index: 9000;
  background: #000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.qr-scanner-overlay.is-open { opacity: 1; }

/* Prevent the page behind from scrolling / rubber-banding while open. */
body.qr-scanner-open { overflow: hidden; }

/* ── Stage (camera feed + viewfinder) ─────────────────────────────────── */
.qr-scanner-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  overflow: hidden;
}
.qr-scanner-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: block;
}

.qr-scanner-frame {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(68vw, 280px);
  height: min(68vw, 280px);
  pointer-events: none;
}
.qr-scanner-frame i {
  position: absolute;
  width: 34px; height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.92);
}
.qr-scanner-frame i:nth-child(1) { top: 0;    left: 0;  border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.qr-scanner-frame i:nth-child(2) { top: 0;    right: 0; border-left: 0;  border-bottom: 0; border-top-right-radius: 14px; }
.qr-scanner-frame i:nth-child(3) { bottom: 0; left: 0;  border-right: 0; border-top: 0;    border-bottom-left-radius: 14px; }
.qr-scanner-frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0;  border-top: 0;    border-bottom-right-radius: 14px; }

.qr-scanner-hint {
  position: absolute;
  left: 50%;
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 24px));
  transform: translateX(-50%);
  max-width: min(86vw, 420px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.66);
  color: #fff;
  font-family: var(--font-body, 'Manrope', system-ui, sans-serif);
  font-size: var(--text-sm, 0.875rem);
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
.qr-scanner-hint.is-show { opacity: 1; }

/* ── Top bar (over the feed) ───────────────────────────────────────────── */
.qr-scanner-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 18px max(14px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.62) 0%, rgba(0, 0, 0, 0) 100%);
  pointer-events: none;
}
.qr-scanner-titles { min-width: 0; pointer-events: none; }
.qr-scanner-title {
  color: #fff;
  font-family: var(--font-display, 'Bricolage Grotesque', system-ui, sans-serif);
  font-size: var(--text-lg, 1.125rem);
  font-weight: 700;
  line-height: 1.2;
}
.qr-scanner-sub {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.82);
  font-family: var(--font-body, 'Manrope', system-ui, sans-serif);
  font-size: var(--text-xs, 0.75rem);
  font-weight: 500;
  line-height: 1.3;
}
.qr-scanner-close {
  flex: none;
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, transform 0.08s;
}
.qr-scanner-close:hover { background: rgba(0, 0, 0, 0.6); }
.qr-scanner-close:active { transform: scale(0.94); }
.qr-scanner-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.qr-scanner-close svg { width: 20px; height: 20px; }

/* ── Status / error panel (theme-aware; covers the stage) ─────────────── */
.qr-scanner-status {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px max(20px, env(safe-area-inset-left)) 32px max(20px, env(safe-area-inset-right));
  text-align: center;
  background: var(--bg-base);
  color: var(--text-primary);
}
.qr-scanner-status[hidden] { display: none; }   /* §6: author display:flex beats [hidden] */
.qr-scanner-spin { width: 30px; height: 30px; }
.qr-scanner-status-title {
  font-family: var(--font-display, 'Bricolage Grotesque', system-ui, sans-serif);
  font-size: var(--text-lg, 1.125rem);
  font-weight: 700;
}
.qr-scanner-status-body {
  max-width: 320px;
  color: var(--text-secondary);
  font-family: var(--font-body, 'Manrope', system-ui, sans-serif);
  font-size: var(--text-sm, 0.875rem);
  line-height: 1.45;
}
.qr-scanner-status-btn {
  margin-top: 6px;
  padding: 11px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-body, 'Manrope', system-ui, sans-serif);
  font-size: var(--text-sm, 0.875rem);
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.12s;
}
.qr-scanner-status-btn:hover { background: var(--bg-surface); }
.qr-scanner-status-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
