/* =========================================================
   face-scan.css — 3D Face Scan page
   GHOSTFRAME Design System
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gf-lime:   #E2E2E2;
  --gf-cyan:   #00DCFF;
  --gf-amber:  #FFA500;
  --gf-bg:     #0a0a0a;
  --gf-border: rgba(255,255,255,0.10);
  --gf-muted:  rgba(255,255,255,0.45);
  --gf-font:   'Inter', 'Helvetica Neue', system-ui, sans-serif;
}


/* ── GHOSTFRAME shared color tokens (synced with design-system.css) ── */
:root {
  --gf-bg:           #0a0a0a;
  --gf-surface:      #111111;
  --gf-surface-2:    #1a1a1a;
  --gf-border:       rgba(255,255,255,0.10);
  --gf-border-solid: #2a2a2a;
  --gf-text:         #e2e2e2;
  --gf-text-dim:     #888888;
  --gf-accent:       #E2E2E2;
  --gf-amber:        #FFA500;
  --gf-danger:       #ff4444;
  --gf-success:      #4ade80;
  --gf-radius:       12px;
  --gf-radius-sm:    8px;
  --gf-radius-lg:    20px;
}

html, body {
  height: 100%;
  background: var(--gf-bg);
  color: var(--gf-text);
  font-family: var(--gf-font);
  overflow: hidden;
}

.hidden { display: none !important; }

/* ── Top bar ────────────────────────────────────────────── */
.gf-top-bar {
  position: fixed;
  top: 0; left: 0; right: 0; height: 52px;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gf-border);
}
.gf-top-bar__back {
  display: flex; align-items: center; gap: 6px;
  color: var(--gf-muted); text-decoration: none;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.10em; text-transform: uppercase;
  transition: color 0.2s; min-height: 44px;
}
.gf-top-bar__back:hover { color: var(--gf-text); }
.gf-top-bar__title {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase;
}

/* ── Camera viewport ─────────────────────────────────────── */
.camera-wrap {
  position: fixed;
  inset: 52px 0 0 0;
  background: var(--gf-bg);
  display: flex; align-items: center; justify-content: center;
}
#videoEl  { display: none; }   /* hidden — canvas renders frames */
#canvasEl {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain; display: block;
}

/* ── Quality badge (camera overlay) ─────────────────────── */
.quality-badge {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 50;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0,0,0,0.65);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--gf-muted);
  transition: color 0.3s, border-color 0.3s, background 0.3s;
  pointer-events: none;
}
.quality-badge.poor   { color: var(--gf-danger); border-color: rgba(255,85,85,0.35); }
.quality-badge.ok     { color: var(--gf-amber); border-color: rgba(255,160,0,0.40); }
.quality-badge.good   { color: var(--gf-lime);  border-color: rgba(212,255,0,0.40);
                         background: rgba(212,255,0,0.08); }

/* ── Init overlay ───────────────────────────────────────── */
.overlay-init {
  position: fixed; inset: 52px 0 0 0;
  z-index: 150;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.85); gap: 14px;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.overlay-init.visible { opacity: 1; pointer-events: auto; }
.init-spinner {
  width: 32px; height: 32px;
  border: 3px solid rgba(255,255,255,0.12);
  border-top-color: var(--gf-lime);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.init-text {
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--gf-muted);
}

/* ── Phase panel ─────────────────────────────────────────── */
.phase-panel {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 100;
  background: rgba(10,10,20,0.88);
  backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  border-top: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 -4px 40px rgba(0,0,0,0.5);
  padding: 20px 24px max(32px, env(safe-area-inset-bottom, 32px));
  display: flex; flex-direction: column; gap: 14px;
  max-height: 65vh; overflow-y: auto;
}

/* ── Phase common ───────────────────────────────────────── */
.phase-header {
  display: flex; align-items: center; gap: 10px;
}
.phase-badge {
  font-size: 9px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px; padding: 3px 8px; flex-shrink: 0;
  color: var(--gf-muted);
}
.phase-title  { font-size: 15px; font-weight: 700; letter-spacing: 0.04em; }
.phase-instr  { font-size: 13px; line-height: 1.55; color: var(--gf-muted); }
.phase-instr strong { color: var(--gf-text); }

/* ── Quality bar (scanning phase) ───────────────────────── */
.quality-bar-wrap {
  display: flex; align-items: center; gap: 10px;
}
.quality-bar-track {
  flex: 1; height: 6px; border-radius: 999px;
  background: rgba(255,255,255,0.08); overflow: hidden;
}
.quality-bar-fill {
  height: 100%; border-radius: 999px;
  background: var(--gf-lime);
  transition: width 0.3s ease, background 0.3s;
  width: 0%;
}
.quality-bar-fill.poor   { background: var(--gf-danger); }
.quality-bar-fill.ok     { background: var(--gf-amber); }
.quality-bar-fill.good   { background: var(--gf-lime); }
.quality-pct {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; color: var(--gf-muted);
  min-width: 36px; text-align: right;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  width: 100%; padding: 16px; border-radius: 12px; border: none;
  background: var(--gf-lime); color: #000;
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.10em; text-transform: uppercase;
  cursor: pointer; transition: opacity 0.2s;
  touch-action: manipulation;
}
.btn-primary:disabled       { opacity: 0.30; cursor: default; }
.btn-primary:not(:disabled):active { opacity: 0.80; }

.btn-secondary {
  width: 100%; padding: 14px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.75);
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer; transition: background 0.2s;
  touch-action: manipulation;
}
.btn-secondary:active { background: rgba(255,255,255,0.12); }

.actions-col { display: flex; flex-direction: column; gap: 10px; }

/* ── Export button row ──────────────────────────────────── */
.export-row {
  display: flex; gap: 8px;
}
.btn-export {
  flex: 1; padding: 12px 6px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: var(--gf-text); font-size: 12px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer; transition: background 0.2s, border-color 0.2s;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.btn-export:hover  { background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.30); }
.btn-export:active { background: rgba(255,255,255,0.16); }
.btn-export.disabled { opacity: 0.35; cursor: default; pointer-events: none; }
.btn-export-ext  { font-size: 14px; font-weight: 800; }
.btn-export-desc { font-size: 9px; color: var(--gf-muted); font-weight: 600; }

/* ── Three.js preview container ─────────────────────────── */
.three-preview {
  width: 100%; height: 260px;
  border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  background: #0d0d18;
  position: relative;
}
.three-preview canvas { display: block; width: 100% !important; height: 100% !important; }
.three-hint {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: rgba(255,255,255,0.25);
  white-space: nowrap; pointer-events: none;
}

/* ── Scan quality instruction row ───────────────────────── */
.scan-tip {
  font-size: 11px; color: var(--gf-muted); text-align: center;
  letter-spacing: 0.04em; line-height: 1.5;
}
.scan-tip.good  { color: var(--gf-lime); }
.scan-tip.ok    { color: var(--gf-amber); }

/* ── Angle steps (3-angle guided scan) ──────────────────── */
.angle-steps {
  display: flex;
  gap: 8px;
  margin: 4px 0;
}
.angle-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  opacity: 0.35;
  transition: opacity 0.3s, border-color 0.3s;
}
.angle-step.active {
  opacity: 1;
  border-color: rgba(212,255,0,0.45);
}
.angle-step.done {
  opacity: 0.6;
  border-color: rgba(212,255,0,0.25);
}
.angle-step__icon {
  font-size: 18px;
  line-height: 1;
}
.angle-step__label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--gf-muted);
}
.angle-step.active .angle-step__label { color: var(--gf-lime); }

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .phase-panel {
    padding: 16px 16px max(24px, env(safe-area-inset-bottom, 24px));
    gap: 12px;
  }
  .phase-title { font-size: 14px; }
  .phase-instr { font-size: 12px; }
  .three-preview { height: 210px; }
  .export-row { gap: 6px; }
  .btn-export { padding: 10px 4px; font-size: 11px; }
  .btn-export-ext { font-size: 12px; }
  .btn-primary, .btn-secondary { padding: 14px; }
  .angle-step { padding: 8px 4px; }
  .angle-step__icon { font-size: 16px; }
}

@media (max-width: 360px) {
  /* 4 export buttons wrap into 2×2 on very small phones */
  .export-row { flex-wrap: wrap; }
  .btn-export { flex: 0 0 calc(50% - 3px); }
  .phase-title { font-size: 13px; }
}
