/* ============================================
   AIR DRAW — Premium Stylesheet
   ============================================ */

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

:root {
  --bg-primary: #050811;
  --bg-secondary: #0d1117;
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-shadow: rgba(0, 0, 0, 0.5);
  --accent: #7c3aed;
  --accent-2: #4cc9f0;
  --text-primary: #f0f4ff;
  --text-secondary: rgba(240, 244, 255, 0.55);
  --draw-color: #ffffff;
  --panel-blur: 12px;
  --radius-lg: 24px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Animated background blobs ── */
.bg-blobs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  animation: blobFloat 12s ease-in-out infinite alternate;
}

.blob-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #7c3aed, #4c1d95);
  top: -200px; left: -150px;
  animation-delay: 0s;
  will-change: transform;
}

.blob-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #0ea5e9, #0284c7);
  bottom: -150px; right: -100px;
  animation-delay: -4s;
}

.blob-3 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #ec4899, #be185d);
  top: 40%; left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -8s;
}

@keyframes blobFloat {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, 30px) scale(1.08); }
}

/* ── App Container ── */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 960px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* ── Header ── */
.header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 2rem;
  animation: waveHand 2.5s ease-in-out infinite;
}

@keyframes waveHand {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(25deg); }
  40% { transform: rotate(-10deg); }
  60% { transform: rotate(20deg); }
  80% { transform: rotate(-5deg); }
}

.logo-text {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #e0e7ff, #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-accent {
  background: linear-gradient(135deg, #818cf8, #4cc9f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

/* ── Canvas Wrapper ── */
.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 860px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1.5px solid var(--glass-border);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.03),
    0 30px 80px rgba(0, 0, 0, 0.7),
    0 0 60px rgba(124, 58, 237, 0.15);
  background: #000;
}

#webcam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror for natural drawing */
  display: block;
}

#drawCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* No CSS mirror — JS coords handle alignment with mirrored video */
}

#landmarkCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* No CSS mirror — JS coords handle alignment with mirrored video */
}

/* ── Finger cursor ── */
.finger-cursor {
  position: absolute;
  width: 36px;
  height: 36px;
  pointer-events: none;
  display: none;
  z-index: 10;
  will-change: transform;
  transform: translate(-50%, -50%);
}

.cursor-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2.5px solid var(--draw-color, #fff);
  opacity: 0.75;
  /* removed animation for perf */
}

.cursor-dot {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--draw-color, #fff);
  box-shadow: 0 0 10px var(--draw-color, #fff);
}

@keyframes cursorPulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 0.4; }
}

/* ── Status Overlay ── */
.status-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(5, 8, 17, 0.92);
  backdrop-filter: blur(8px);
  z-index: 20;
  transition: opacity 0.6s ease;
}

.status-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.status-icon {
  font-size: 3rem;
  animation: bounce 1.5s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.status-title {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #e0e7ff, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.status-msg {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: #818cf8;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Hand Badge ── */
.hand-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(10, 14, 30, 0.75);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
}

.hand-badge.detected {
  border-color: rgba(6, 214, 160, 0.5);
  color: #06d6a0;
}

.hand-badge-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #555;
  transition: var(--transition);
}

.hand-badge.detected .hand-badge-dot {
  background: #06d6a0;
  box-shadow: 0 0 8px #06d6a0;
  animation: pulseDot 1.5s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 6px #06d6a0; }
  50% { box-shadow: 0 0 18px #06d6a0; }
}

/* ── Mode Badge ── */
.mode-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(10, 14, 30, 0.75);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ── Controls Panel ── */
.controls-panel {
  width: 100%;
  max-width: 860px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--panel-blur));
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px 28px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-section.actions {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.control-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── Color Palette ── */
.color-palette {
  display: flex;
  gap: 8px;
  align-items: center;
}

.color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  background: var(--c);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.color-btn:hover {
  transform: scale(1.2);
  box-shadow: 0 0 18px var(--c), 0 0 35px var(--c);
}

.color-btn.active {
  border-color: #fff;
  transform: scale(1.25);
  box-shadow: 0 0 22px var(--c), 0 0 45px var(--c), 0 0 0 3px rgba(255,255,255,0.2);
}

/* ── Brush Size Slider ── */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 160px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.15);
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #818cf8, #4cc9f0);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(129, 140, 248, 0.5);
  transition: transform 0.2s;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

/* ── Action Buttons ── */
.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--glass-border);
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(10px);
}

.action-btn:hover {
  background: rgba(255,255,255,0.12);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.action-btn:active {
  transform: translateY(0);
}

.pause-btn:hover { border-color: #ffd166; color: #ffd166; }
.clear-btn:hover { border-color: #ff4d6d; color: #ff4d6d; }
.save-btn:hover { border-color: #4cc9f0; color: #4cc9f0; }

.pause-btn.paused {
  border-color: #06d6a0;
  color: #06d6a0;
  background: rgba(6, 214, 160, 0.08);
}

.btn-icon {
  font-size: 1rem;
}

/* ── Instructions ── */
.instructions {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.instruction-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 100px;
  padding: 8px 16px;
}

.inst-icon {
  font-size: 1.1rem;
}

/* ══════════════════════════════════════════
   RESPONSIVE — Tablet (max 768px)
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
  .app-container {
    padding: 16px 14px;
    gap: 14px;
  }

  .logo-text { font-size: 2rem; }
  .tagline   { font-size: 0.9rem; }

  /* Canvas keeps 16:9 but fills width */
  .canvas-wrapper {
    border-radius: 16px;
  }

  /* Controls stack into 2-column grid */
  .controls-panel {
    padding: 16px 18px;
    gap: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .control-section.actions {
    grid-column: 1 / -1;   /* full width row */
    margin-left: 0;
    justify-content: center;
    flex-wrap: wrap;
  }

  .slider { width: 100%; }

  /* Instructions: 2 per row */
  .instructions { gap: 10px; }
  .instruction-item { font-size: 0.78rem; padding: 7px 12px; }

  /* Badges smaller */
  .hand-badge, .mode-badge { font-size: 0.74rem; padding: 5px 10px; }
}

/* ══════════════════════════════════════════
   RESPONSIVE — Mobile (max 480px)
   ══════════════════════════════════════════ */
@media (max-width: 480px) {
  body { align-items: flex-start; }

  .app-container {
    padding: 12px 10px;
    gap: 12px;
  }

  .logo-icon  { font-size: 1.5rem; }
  .logo-text  { font-size: 1.5rem; }
  .tagline    { font-size: 0.8rem; display: none; }

  /* Full-screen feel for canvas */
  .canvas-wrapper {
    border-radius: 12px;
    /* taller on portrait phones */
    aspect-ratio: 4 / 3;
  }

  /* Controls: single column */
  .controls-panel {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 12px;
  }

  .control-section.actions {
    grid-column: 1;
    gap: 8px;
  }

  /* Smaller action buttons on mobile */
  .action-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
    flex: 1;
    justify-content: center;
  }

  /* Color palette wraps */
  .color-palette { flex-wrap: wrap; gap: 10px; }
  .color-btn { width: 28px; height: 28px; }

  /* Brush slider full width */
  .slider { width: 100%; }

  /* Instructions: stack vertically */
  .instructions {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .instruction-item {
    width: 100%;
    max-width: 300px;
    justify-content: center;
    font-size: 0.8rem;
  }

  /* Hide status overlay text on tiny screens */
  .status-msg { display: none; }

  /* Smaller badges */
  .hand-badge, .mode-badge {
    font-size: 0.7rem;
    padding: 4px 8px;
    gap: 5px;
  }
  .hand-badge-dot { width: 6px; height: 6px; }
}

/* ══════════════════════════════════════════
   RESPONSIVE — Large screens (min 1200px)
   ══════════════════════════════════════════ */
@media (min-width: 1200px) {
  .app-container { max-width: 1100px; }
  .canvas-wrapper { max-width: 1000px; }
  .controls-panel { max-width: 1000px; }
}

