/* ==========================================================================
   FACEBMI — Core Stylesheet
   Futuristic AI scanner / cyber-interface theme
   ========================================================================== */
/* Style.css */
/* ---------------------------------------------------------------------- 
   1. DESIGN TOKENS (CSS Custom Properties)
   ---------------------------------------------------------------------- */
#particle-canvas,
.bg-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none !important; /* Pass all scroll/touch inputs through */
  z-index: 0;
}
html {
  /* Do NOT set height: 100% or height: 100vh here */
  overflow-x: hidden;
  overflow-y: auto;
}
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  /* CRITICAL: Ensure body default allows vertical scrolling */
  overflow-y: auto; 
  position: relative;
}
:root {
  /* Colors — deep navy base + neon blue accent */
  --color-bg:            #060a16;
  --color-bg-alt:        #0a1120;
  --color-surface:       rgba(13, 22, 43, 0.55);
  --color-border:        rgba(66, 153, 255, 0.35);

  --color-accent:        #2f8fff;
  --color-accent-2:      #57a8ff;
  --color-accent-strong: #0d6efd;
  --color-accent-glow:   rgba(47, 143, 255, 0.55);

  --color-text-primary:   #eaf2ff;
  --color-text-secondary: #7fa3d1;
  --color-text-muted:     #45577a;
  --color-text-on-accent: #f3f8ff;
  --color-warn:           #ffb020;

  /* Typography */
  --font-display: 'Orbitron', sans-serif;
  --font-body:    'Inter', sans-serif;

  --tracking-wide: 0.08em;
  --tracking-wider: 0.16em;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 28px;
  --radius-pill: 999px;

  /* Shadows / glow */
  --shadow-glow-sm: 0 0 18px var(--color-accent-glow);
  --shadow-glow-md: 0 0 36px var(--color-accent-glow);
  --shadow-glow-lg: 0 0 64px rgba(47, 143, 255, 0.45);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast:   0.2s var(--ease-out);
  --transition-medium: 0.45s var(--ease-out);
  --transition-slow:   0.8s var(--ease-out);

  /* Layout */
  --header-height: 88px;
  --footer-height: 56px;
  --content-max: 640px;
}

/* ---------------------------------------------------------------------- 
   2. RESET / BASE
   ---------------------------------------------------------------------- */
* { box-sizing: border-box; }

html {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-weight: 400;
  overflow-x: hidden;
  overflow-y: auto; /* FIX: Guarantees vertical scrolling */
  min-height: 100vh;
  position: relative;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------------------------------------------------------------------- 
   3. BACKGROUND LAYERS (canvas + radial glow)
   ---------------------------------------------------------------------- */
#particle-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none; /* FIX: Prevents canvas from intercepting mouse scroll */
  display: block;
}

.bg-glow {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(900px, 90vw);
  height: min(900px, 90vw);
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(47, 143, 255, 0.16) 0%, rgba(47, 143, 255, 0.05) 45%, rgba(6, 10, 22, 0) 72%);
  z-index: 0;
  pointer-events: none; /* FIX: Prevents radial glow from blocking pointer/scroll */
}

/* ---------------------------------------------------------------------- 
   4. SITE SHELL — shared header, footer, and per-page containers
   Header and footer markup is identical on every page (index, about,
   how-it-works, support) so the whole site reads as one application.
   ---------------------------------------------------------------------- */

/* Style Flask video feed to fill the frame */
.flask-feed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

/* Keep HUD overlays above the video feed */
.scanner-overlay,
.camera-placeholder,
.camera-error-panel {
  z-index: 2;
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--header-height);
  background: rgba(6, 10, 22, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(66, 153, 255, 0.15);
}

.site-header-inner {
  max-width: 1400px;
  height: 100%;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.1rem, 1.6vw, 1.4rem);
  letter-spacing: var(--tracking-wider);
  color: var(--color-text-primary);
}

.logo-accent {
  color: var(--color-accent-2);
}

.site-footer {
  position: relative;
  z-index: 1;
  height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-footer p {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-muted);
  text-align: center;
  padding: 0 20px;
}

/* Home page: the scanner experience sits between the fixed header and
   the static footer, always vertically centered. */
.app-container {
  position: relative;
  z-index: 1;
  padding-top: var(--header-height);
}

.screen {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-height) - var(--footer-height));
  padding: 32px clamp(20px, 5vw, 64px);
  text-align: center;
}

.screen.active {
  display: flex;
}

.screen-content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
}

/* ---------------------------------------------------------------------- 
   5. LANDING SCREEN
   ---------------------------------------------------------------------- */
.landing-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
}

.status-text {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(0.85rem, 1.6vw, 1.15rem);
  letter-spacing: var(--tracking-wider);
  color: var(--color-accent-2);
  text-shadow: 0 0 18px rgba(87, 168, 255, 0.45);
}

/* Scan button */
.btn-scan {
  position: relative;
  border: none;
  border-radius: var(--radius-md);
  padding: 20px 64px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: var(--tracking-wider);
  color: var(--color-text-on-accent);
  background: linear-gradient(135deg, #3aa0ff 0%, #1f6fe0 100%);
  box-shadow: var(--shadow-glow-md), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  overflow: hidden;
}

.btn-scan .btn-scan-label {
  position: relative;
  z-index: 1;
}

.btn-scan-glow {
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 60%);
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.btn-scan:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: var(--shadow-glow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-scan:hover .btn-scan-glow {
  opacity: 1;
}

.btn-scan:active {
  transform: translateY(0) scale(0.97);
}

.btn-scan:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ---------------------------------------------------------------------- 
   6. SCANNER SCREEN
   ---------------------------------------------------------------------- */
.scanner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.scanner-card {
  position: relative;
  width: min(340px, 78vw);
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background:
    radial-gradient(circle at 1px 1px, rgba(87, 168, 255, 0.28) 1px, transparent 1.6px) 0 0 / 22px 22px,
    var(--color-surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-glow-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Countdown timer badge overlay */
.scan-timer-badge {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 3;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(0, 240, 255, 0.4);      
  color: #00f0ff;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.9rem;
  padding: 4px 10px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

.webcam-feed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror, like a selfie camera */
  opacity: 0;
  transition: opacity var(--transition-medium);
}

.webcam-feed.is-visible {
  opacity: 1;
}

.camera-placeholder {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--color-accent-2);
  font-family: var(--font-body);
  font-size: 0.75rem;
  letter-spacing: var(--tracking-wide);
  transition: opacity var(--transition-medium);
}

.camera-placeholder.is-hidden {
  opacity: 0;
}

.placeholder-icon {
  width: 46px;
  height: 46px;
  border: 2px solid var(--color-accent);
  border-radius: 50%;
  padding: 8px;
  filter: drop-shadow(0 0 10px var(--color-accent-glow));
}

/* Scanner HUD overlay */
.scanner-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-accent-2);
  filter: drop-shadow(0 0 6px var(--color-accent-glow));
}
.corner-tl { top: 14px; left: 14px; border-right: none; border-bottom: none; border-radius: 4px 0 0 0; }
.corner-tr { top: 14px; right: 14px; border-left: none; border-bottom: none; border-radius: 0 4px 0 0; }
.corner-bl { bottom: 14px; left: 14px; border-right: none; border-top: none; border-radius: 0 0 0 4px; }
.corner-br { bottom: 14px; right: 14px; border-left: none; border-top: none; border-radius: 0 0 4px 0; }

.center-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border: 1.5px solid rgba(87, 168, 255, 0.55);
  border-radius: 50%;
}

.scan-line {
  position: absolute;
  left: 6%;
  width: 88%;
  height: 2px;
  top: 0;
  background: linear-gradient(90deg, rgba(87, 168, 255, 0) 0%, #7cc3ff 50%, rgba(87, 168, 255, 0) 100%);
  box-shadow: 0 0 14px 2px rgba(124, 195, 255, 0.8);
  opacity: 0;
}

.scanner-card.is-scanning .scan-line {
  animation: scanLineMove 2.2s ease-in-out infinite;
}

/* Camera permission error — replaces the feed inside the same card shell */
.camera-error-panel {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 30px 26px;
  text-align: center;
  background: rgba(8, 13, 26, 0.94);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity var(--transition-medium);
}

.camera-error-panel.d-none {
  display: none;
}

.camera-error-icon {
  font-size: 1.9rem;
  line-height: 1;
  color: var(--color-warn);
  filter: drop-shadow(0 0 10px rgba(255, 176, 32, 0.45));
}

.camera-error-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-primary);
}

.camera-error-message {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--color-text-secondary);
  max-width: 250px;
}

.btn-camera-retry {
  margin-top: 4px;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 10px 30px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: var(--tracking-wide);
  color: var(--color-accent-2);
  transition: box-shadow var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.btn-camera-retry:hover {
  box-shadow: var(--shadow-glow-sm);
  background: rgba(47, 143, 255, 0.08);
}

.btn-camera-retry:active {
  transform: translateY(0) scale(0.97);
}

.scanning-text {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(0.8rem, 1.4vw, 1rem);
  letter-spacing: var(--tracking-wider);
  color: var(--color-accent-2);
  text-shadow: 0 0 16px rgba(87, 168, 255, 0.4);
  min-height: 1.4em;
  opacity: 1;
  transition: opacity var(--transition-medium);
}

.scanning-text.is-hidden {
  opacity: 0;
}

/* ---------------------------------------------------------------------- 
   7. RESULT SCREEN
   ---------------------------------------------------------------------- */
.result-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.result-card {
  position: relative;
  width: min(320px, 80vw);
  padding: 44px 32px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background-color: var(--color-accent-strong);
  background-image:
    linear-gradient(135deg, #3aa0ff 0%, #1971e8 100%),
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 100% 100%, 26px 26px, 26px 26px;
  box-shadow: var(--shadow-glow-lg);
}

.result-label {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: var(--tracking-wider);
  color: rgba(255, 255, 255, 0.85);
}

.result-category {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 4vw, 2rem);
  color: #ffffff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

/* Retry button */
.btn-retry {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 14px 30px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: var(--tracking-wider);
  color: var(--color-accent-2);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast), background var(--transition-fast);
}

.retry-icon {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-medium);
}

.btn-retry:hover {
  box-shadow: var(--shadow-glow-sm);
  background: rgba(47, 143, 255, 0.08);
  transform: translateY(-2px);
}

.btn-retry:hover .retry-icon {
  transform: rotate(-180deg);
}

.btn-retry:active {
  transform: translateY(0) scale(0.97);
}