/**
 * EMMA Voice Assistant - Futuristic Circular Design
 * Inspired by Figma prototype with dark glass aesthetic
 */

/* =============================================================================
   EMMA ORB - Main Circular Button
   ============================================================================= */

#emma-orb {
  /* Positioning */
  position: fixed;
  bottom: 32px;
  left: 32px;
  z-index: 9999;

  /* Size - Comfortable circular button */
  width: 140px;
  height: 140px;

  /* Remove default button styles */
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  outline: none;

  /* Interaction */
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#emma-orb:hover {
  transform: scale(1.02);
}

#emma-orb:active {
  transform: scale(0.98);
}

/* Deep Shadow Layers for 3D Depth */
#emma-orb::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  filter: blur(40px);
  transform: translateY(12px);
  z-index: -2;
}

#emma-orb::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  filter: blur(20px);
  transform: translateY(8px);
  z-index: -1;
}

/* =============================================================================
   EMMA CONTAINER - Main circular body
   ============================================================================= */

.emma-container {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
}

/* Outer Shell - Dark Glass Effect */
.emma-shell {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg,
    rgba(31, 41, 55, 0.95) 0%,
    rgba(0, 0, 0, 0.98) 50%,
    rgba(0, 0, 0, 1) 100%
  );
  border-radius: 50%;
}

/* Subtle Inner Bevel */
.emma-bevel {
  position: absolute;
  inset: 3px;
  background: linear-gradient(135deg,
    rgba(31, 41, 55, 0.4) 0%,
    rgba(0, 0, 0, 1) 50%,
    rgba(0, 0, 0, 1) 100%
  );
  border-radius: 50%;
}

/* Glowing Edge Ring - Changes based on state */
.emma-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(6, 182, 212, 0.2);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.1);
  transition: all 0.3s ease;
}

/* Listening State - Green */
#emma-orb.listening .emma-ring {
  border: 2px solid rgba(74, 222, 128, 0.7);
  box-shadow:
    0 0 20px rgba(74, 222, 128, 0.5),
    inset 0 0 20px rgba(74, 222, 128, 0.2);
  animation: pulse-green 2s ease-in-out infinite;
}

/* Speaking State - Cyan */
#emma-orb.speaking .emma-ring {
  border: 2px solid rgba(34, 211, 238, 0.7);
  box-shadow:
    0 0 20px rgba(34, 211, 238, 0.5),
    inset 0 0 20px rgba(34, 211, 238, 0.2);
  animation: pulse-cyan 2s ease-in-out infinite;
}

/* Glossy Top Reflection */
.emma-gloss {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 0.08) 0%,
    transparent 40%,
    transparent 100%
  );
  border-radius: 50%;
  pointer-events: none;
}

/* =============================================================================
   EMMA CONTENT - Label and Visualizer
   ============================================================================= */

.emma-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* EMMA Label Container */
.emma-label-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 12px;
  min-height: 36px;
}

/* EMMA Label Text */
.emma-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgb(107, 114, 128); /* Gray for standby */
  transition: color 0.3s ease;
}

#emma-orb:hover .emma-label {
  color: rgba(34, 211, 238, 0.8);
}

#emma-orb.listening .emma-label {
  color: rgb(134, 239, 172); /* Green */
}

#emma-orb.speaking .emma-label {
  color: rgb(103, 232, 249); /* Cyan */
}

/* Status Text */
.emma-status {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgb(55, 65, 81);
  margin-top: 4px;
  transition: all 0.3s ease;
}

#emma-orb:hover .emma-status {
  color: rgba(6, 182, 212, 0.4);
}

#emma-orb.listening .emma-status {
  color: rgba(74, 222, 128, 0.6);
}

#emma-orb.speaking .emma-status {
  color: rgba(34, 211, 238, 0.6);
  animation: pulse-text 1.8s ease-in-out infinite;
}

/* =============================================================================
   VOICE VISUALIZER - Animated Bars
   ============================================================================= */

.emma-visualizer {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 50px;
  margin-top: 8px;
}

.emma-bar {
  width: 2px;
  background: linear-gradient(to top,
    rgb(31, 41, 55),
    rgb(55, 65, 81),
    rgb(75, 85, 99)
  );
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* Listening State - Green Bars */
#emma-orb.listening .emma-bar {
  background: linear-gradient(to top,
    rgb(22, 163, 74),
    rgb(74, 222, 128),
    rgb(134, 239, 172)
  );
}

/* Speaking State - Cyan Bars with Animation */
#emma-orb.speaking .emma-bar {
  background: linear-gradient(to top,
    rgb(8, 145, 178),
    rgb(34, 211, 238),
    rgb(103, 232, 249)
  );
}

/* Listening state - subtle pulse */
#emma-orb.listening .emma-bar {
  animation: bar-pulse-subtle 2s ease-in-out infinite;
}

/* Speaking state - NO animation (uses real-time audio visualization) */
#emma-orb.speaking .emma-bar {
  animation: none;
}

/* Stagger animation delays for wave effect */
.emma-bar:nth-child(1) { animation-delay: 0s; }
.emma-bar:nth-child(2) { animation-delay: 0.04s; }
.emma-bar:nth-child(3) { animation-delay: 0.08s; }
.emma-bar:nth-child(4) { animation-delay: 0.12s; }
.emma-bar:nth-child(5) { animation-delay: 0.16s; }
.emma-bar:nth-child(6) { animation-delay: 0.2s; }
.emma-bar:nth-child(7) { animation-delay: 0.24s; }
.emma-bar:nth-child(8) { animation-delay: 0.28s; }
.emma-bar:nth-child(9) { animation-delay: 0.32s; }
.emma-bar:nth-child(10) { animation-delay: 0.36s; }
.emma-bar:nth-child(11) { animation-delay: 0.32s; }
.emma-bar:nth-child(12) { animation-delay: 0.28s; }
.emma-bar:nth-child(13) { animation-delay: 0.24s; }
.emma-bar:nth-child(14) { animation-delay: 0.2s; }
.emma-bar:nth-child(15) { animation-delay: 0.16s; }
.emma-bar:nth-child(16) { animation-delay: 0.12s; }
.emma-bar:nth-child(17) { animation-delay: 0.08s; }
.emma-bar:nth-child(18) { animation-delay: 0.04s; }

/* =============================================================================
   CIRCULAR ACCENT RING
   ============================================================================= */

.emma-accent-ring {
  position: absolute;
  inset: 48px;
  border-radius: 50%;
  border: 1px solid rgba(100, 116, 139, 0.1);
  opacity: 0.3;
  transition: all 0.3s ease;
}

#emma-orb.listening .emma-accent-ring {
  border-color: rgba(74, 222, 128, 0.2);
  animation: ring-pulse 2.5s ease-in-out infinite;
}

#emma-orb.speaking .emma-accent-ring {
  border-color: rgba(34, 211, 238, 0.2);
  animation: ring-pulse 2.5s ease-in-out infinite;
}

/* =============================================================================
   EMMA PANEL - Status text display (keep existing panel)
   ============================================================================= */

#emma-panel {
  /* Positioning - appears above the orb */
  position: fixed;
  bottom: 190px;
  left: 32px;
  z-index: 9998;

  /* Size constraints */
  max-width: 320px;
  min-width: 200px;
  padding: 12px 16px;

  /* Appearance */
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(20, 184, 166, 0.3);
  border-radius: 12px;

  /* Subtle glow */
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.3),
    0 0 15px rgba(20, 184, 166, 0.15);

  /* Typography */
  color: #f1f5f9;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;

  /* Initially hidden */
  display: none;

  /* Animation */
  animation: emma-panel-fadein 0.3s ease-out;
}

@keyframes emma-panel-fadein {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */

@keyframes pulse-green {
  0%, 100% {
    box-shadow:
      0 0 20px rgba(74, 222, 128, 0.5),
      inset 0 0 20px rgba(74, 222, 128, 0.2);
  }
  50% {
    box-shadow:
      0 0 40px rgba(74, 222, 128, 0.8),
      inset 0 0 30px rgba(74, 222, 128, 0.3);
  }
}

@keyframes pulse-cyan {
  0%, 100% {
    box-shadow:
      0 0 20px rgba(34, 211, 238, 0.5),
      inset 0 0 20px rgba(34, 211, 238, 0.2);
  }
  50% {
    box-shadow:
      0 0 40px rgba(34, 211, 238, 0.8),
      inset 0 0 30px rgba(34, 211, 238, 0.3);
  }
}

@keyframes pulse-text {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.9; }
}

@keyframes bar-pulse-subtle {
  0%, 100% {
    transform: scaleY(0.9);
    opacity: 0.8;
  }
  50% {
    transform: scaleY(1.1);
    opacity: 1;
  }
}

@keyframes ring-pulse {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.05);
  }
}

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

@media (max-width: 768px) {
  #emma-orb {
    width: 140px;
    height: 140px;
    bottom: 24px;
    left: 24px;
  }

  #emma-panel {
    bottom: 180px;
    left: 24px;
    max-width: 260px;
    font-size: 12px;
  }

  .emma-label {
    font-size: 11px;
  }

  .emma-status {
    font-size: 8px;
  }

  .emma-visualizer {
    height: 40px;
  }
}

@media (max-width: 480px) {
  #emma-orb {
    width: 120px;
    height: 120px;
    bottom: 16px;
    left: 16px;
  }

  #emma-panel {
    bottom: 150px;
    left: 16px;
    max-width: 220px;
    padding: 10px 14px;
    font-size: 11px;
  }
}

/* =============================================================================
   ACCESSIBILITY - Screen reader only content
   ============================================================================= */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* =============================================================================
   PRINT - Hide EMMA in print layouts
   ============================================================================= */

@media print {
  #emma-orb,
  #emma-panel {
    display: none !important;
  }
}
