/* ══════════════════════════════════════════════
   GestureBoard — styles.css
   Design: Refined dark minimal. Single warm accent.
   Fonts: DM Mono (data) + DM Sans (UI) + Bebas Neue (display)
   ══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300&family=DM+Sans:wght@300;400;500&display=swap');

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

/* ─── Design Tokens ─── */
:root {
  /* Surface */
  --bg:        #0e0e0e;
  --surface:   #161616;
  --surface-2: #1e1e1e;

  /* Borders */
  --border:    rgba(255, 255, 255, 0.06);
  --border-md: rgba(255, 255, 255, 0.10);

  /* Text */
  --text:      #e6e2dc;
  --text-2:    #8a857e;
  --text-3:    #4a4642;

  /* Accent — warm amber, used sparingly */
  --accent:      #e8a04a;
  --accent-dim:  rgba(232, 160, 74, 0.10);
  --accent-line: rgba(232, 160, 74, 0.30);

  /* State colours — desaturated, functional only */
  --draw:  #c8b97a;   /* warm straw  */
  --erase: #b07070;   /* muted rose  */
  --pan:   #7a90a8;   /* cool slate  */

  /* Typography */
  --mono:    'DM Mono', monospace;
  --sans:    'DM Sans', sans-serif;
  --display: 'Bebas Neue', sans-serif;

  /* Elevation */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.7);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}


/* ══════════════════════════════════════════════
   CANVAS
   ══════════════════════════════════════════════ */
#mainCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: none;
  z-index: 1;
}


/* ══════════════════════════════════════════════
   CAMERA PANEL
   ══════════════════════════════════════════════ */
#camWrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 20;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-md);
  box-shadow: var(--shadow-lg);
  transition: opacity 0.4s ease, border-color 0.4s ease;
  background: #000;
}

#camWrap:hover {
  opacity: 0.72;
  border-color: var(--border);
}

#camWrap video {
  display: block;
  width: 200px;
  height: 150px;
  object-fit: cover;
  transform: scaleX(-1);
}

#camCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 200px;
  height: 150px;
  transform: scaleX(-1);
  pointer-events: none;
}

/* Thin live indicator — bottom edge of camera panel */
.cam-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  animation: livebar 2s ease-in-out infinite;
  font-size: 0;
}

.cam-eye {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  border: 1px solid var(--border-md);
  background: rgba(14,14,14,0.7);
  color: var(--text-2);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  opacity: 0;  /* hidden until hover */
}

#camWrap:hover .cam-eye {
  opacity: 1;
}

.cam-eye:hover {
  background: var(--surface-2);
  color: var(--text);
}

.cam-eye--off {
  color: var(--text-3);
  opacity: 1 !important;  /* stay visible when video is hidden as a reminder */
}

@keyframes livebar {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}


/* ══════════════════════════════════════════════
   HUD — LEFT PANEL
   ══════════════════════════════════════════════ */
#hudLeft {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 20;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hud-brand {
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: 0.2em;
  color: var(--text);
  line-height: 1;
}

.hud-brand span {
  color: var(--text-3);
}

.hud-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 4px;
  min-width: 186px;
  box-shadow: var(--shadow-sm);
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  gap: 16px;
}

.hud-row + .hud-row {
  border-top: 1px solid var(--border);
}

.hud-k {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 300;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
}

.hud-v {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 400;
  color: var(--text-2);
  letter-spacing: 0.3px;
}

.hud-v.c-cyan    { color: var(--accent); }
.hud-v.c-yellow  { color: var(--draw); }
.hud-v.c-magenta { color: var(--erase); }
.hud-v.c-purple  { color: var(--pan); }


/* ─── Mode Badge ─── */
#modeBadge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-3);
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  width: fit-content;
}

#modeBadge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
  transition: background 0.2s ease;
}

#modeBadge.mode-draw {
  color: var(--draw);
  border-color: rgba(200, 185, 122, 0.18);
  background: rgba(200, 185, 122, 0.04);
}
#modeBadge.mode-draw::before { background: var(--draw); }

#modeBadge.mode-erase {
  color: var(--erase);
  border-color: rgba(176, 112, 112, 0.18);
  background: rgba(176, 112, 112, 0.04);
}
#modeBadge.mode-erase::before { background: var(--erase); }

#modeBadge.mode-pan {
  color: var(--pan);
  border-color: rgba(122, 144, 168, 0.18);
  background: rgba(122, 144, 168, 0.04);
}
#modeBadge.mode-pan::before { background: var(--pan); }


/* ══════════════════════════════════════════════
   GESTURE LEGEND — RIGHT PANEL
   ══════════════════════════════════════════════ */
#legend {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 20;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 4px;
  min-width: 196px;
  box-shadow: var(--shadow-sm);
}

.legend-head {
  font-family: var(--mono);
  font-size: 7.5px;
  font-weight: 500;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}

.legend-row + .legend-row {
  border-top: 1px solid var(--border);
}

.legend-emo {
  font-size: 12px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.8;
}

.legend-text {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 300;
  letter-spacing: 0.3px;
  color: var(--text-3);
  line-height: 1.6;
}

.legend-text strong {
  font-weight: 500;
  color: var(--text-2);
  display: block;
  letter-spacing: 1px;
  font-size: 7.5px;
  text-transform: uppercase;
  margin-bottom: 0px;
}


/* ══════════════════════════════════════════════
   GESTURE FLASH OVERLAY
   ══════════════════════════════════════════════ */
#gFlash {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 30;
  transform: translate(-50%, -50%) translateY(8px);
  font-family: var(--display);
  font-size: 52px;
  letter-spacing: 8px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  color: var(--text);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

#gFlash.show {
  opacity: 0.85;
  transform: translate(-50%, -50%) translateY(0);
}


/* ══════════════════════════════════════════════
   STATUS BAR — BOTTOM LEFT
   ══════════════════════════════════════════════ */
#statusBar {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 20;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 300;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-3);
}

.s-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}

.s-dot.on {
  background: var(--accent);
  animation: pulse-dot 2.5s ease-in-out infinite;
}

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


/* ══════════════════════════════════════════════
   WATCHDOG WARNING
   ══════════════════════════════════════════════ */
#watchdogWarn {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 40;
  transform: translate(-50%, -50%);
  background: var(--surface-2);
  border: 1px solid var(--border-md);
  padding: 14px 28px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 2px;
  color: var(--erase);
  text-align: center;
  box-shadow: var(--shadow-md);
  display: none;
}

#watchdogWarn.visible { display: block; }


/* ══════════════════════════════════════════════
   LOADING SCREEN
   ══════════════════════════════════════════════ */
#loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.ld-title {
  font-family: var(--display);
  font-size: 56px;
  letter-spacing: 0.22em;
  color: var(--text);
  line-height: 1;
}

.ld-sub {
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 300;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: -4px;
}

.ld-track {
  width: 220px;
  height: 1px;
  background: var(--border-md);
  overflow: hidden;
  margin-top: 10px;
}

.ld-fill {
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.ld-msg {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 300;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
  min-height: 14px;
}


/* ══════════════════════════════════════════════
   BOTTOM TOOLBAR
   ══════════════════════════════════════════════ */
#toolbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 2px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px;
  border-radius: 5px;
  box-shadow: var(--shadow-md);
}

.tb-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 3px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.tb-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tb-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.tb-btn.danger:hover {
  background: rgba(176, 112, 112, 0.08);
  color: var(--erase);
}

.tb-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 3px;
  flex-shrink: 0;
}

.tb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}