@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-void:        #05080B;
  --panel-glass:    rgba(13, 20, 26, 0.74);
  --grid-line:      #1F3B4D;
  --signal:         #3DDC97;
  --signal-dim:     #1F6B4E;
  --alert:          #FF8A3D;
  --text-hi:        #E8F1F2;
  --text-mid:       #9FB4BD;
  --text-dim:       #5A6F78;
  --font-data:      'JetBrains Mono', ui-monospace, monospace;
  --font-ui:        'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: var(--font-ui);
  color: var(--text-hi);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

/*
 * IMPORTANTE (MindAR): a biblioteca injeta o <video> da câmera como filho
 * direto do <body> e, por padrão, coloca z-index: -2. Se o <body> tiver um
 * background opaco, esse vídeo fica literalmente atrás do fundo da página e
 * a tela parece preta mesmo com a câmera funcionando.
 *
 * Mantemos o fallback escuro no <html>, deixamos o <body> transparente e
 * colocamos explicitamente vídeo -> cena AR -> HUD em camadas previsíveis.
 */
html {
  background: var(--bg-void);
}

body {
  background: transparent;
}

body > video {
  z-index: 0 !important;
  pointer-events: none;
  background: transparent !important;
}

a-scene {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  background: transparent !important;
}

.a-canvas {
  background: transparent !important;
}

/* ---------- Overlay de UI (fora da cena AR) ---------- */

#hud-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(5,8,11,0.85) 0%, rgba(5,8,11,0) 100%);
}

#hud-top .brand {
  font-family: var(--font-data);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--text-mid);
  display: flex;
  align-items: center;
  gap: 8px;
}

#hud-top .brand .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 8px var(--signal);
  animation: pulse-dot 2s ease-in-out infinite;
}

#hud-top .clock {
  font-family: var(--font-data);
  font-size: 12px;
  color: var(--text-dim);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------- Tela de scan (antes de achar o marcador) ---------- */

#scan-state {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#scan-state.hidden {
  opacity: 0;
  pointer-events: none;
}

.scan-frame {
  position: relative;
  width: 220px;
  height: 220px;
}

.scan-frame .corner {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 2px solid var(--signal);
  opacity: 0.85;
}
.scan-frame .corner.tl { top: 0; left: 0; border-right: none; border-bottom: none; }
.scan-frame .corner.tr { top: 0; right: 0; border-left: none; border-bottom: none; }
.scan-frame .corner.bl { bottom: 0; left: 0; border-right: none; border-top: none; }
.scan-frame .corner.br { bottom: 0; right: 0; border-left: none; border-top: none; }

.scan-frame .sweep {
  position: absolute;
  left: 4px; right: 4px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--signal), transparent);
  animation: sweep 2.2s ease-in-out infinite;
}

@keyframes sweep {
  0%   { top: 6%; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: 94%; opacity: 0; }
}

#scan-state .label {
  font-family: var(--font-data);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--text-mid);
  text-transform: uppercase;
}

#scan-state .sublabel {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-dim);
  max-width: 260px;
  text-align: center;
}

/* ---------- Botão de instalar PWA ---------- */

#install-btn {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 25;
  font-family: var(--font-data);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-hi);
  background: var(--panel-glass);
  border: 1px solid var(--grid-line);
  padding: 10px 14px;
  border-radius: 4px;
  backdrop-filter: blur(6px);
  display: none;
}

#install-btn.visible { display: block; }

/* ---------- Estado de erro (AR.js não carregou / câmera falhou) ---------- */

#error-state {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
  background: var(--bg-void);
}

#error-state.visible { display: flex; }

#error-state .icon {
  font-family: var(--font-data);
  font-size: 34px;
  color: var(--alert);
}

#error-state .title {
  font-family: var(--font-data);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-hi);
}

#error-state .detail {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text-mid);
  max-width: 320px;
  line-height: 1.5;
}

#error-state .retry {
  margin-top: 10px;
  font-family: var(--font-data);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-hi);
  background: var(--panel-glass);
  border: 1px solid var(--grid-line);
  padding: 10px 18px;
  border-radius: 4px;
}

/* ---------- Badge de status/debug (temporário, ajuda a diagnosticar) ---------- */

.debug-badge {
  position: fixed;
  bottom: 18px;
  left: 18px;
  z-index: 25;
  font-family: var(--font-data);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--text-mid);
  background: var(--panel-glass);
  border: 1px solid var(--grid-line);
  padding: 6px 10px;
  border-radius: 4px;
  backdrop-filter: blur(6px);
  max-width: 60vw;
}
