/* Emila Live — Party Mode UI */
:root {
  --bg: #0a0a0f;
  --surface: #151520;
  --accent: #c084fc;       /* Purple glow */
  --accent-warm: #fb7185;  /* Rose for speaking */
  --accent-think: #60a5fa; /* Blue for thinking */
  --text: #f1f5f9;
  --text-dim: #64748b;
  --glow: 0 0 40px rgba(192, 132, 252, 0.3);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 40px 20px;
  position: relative;
}

/* Avatar */
#avatar-container {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  overflow: hidden;
  margin-bottom: 20px;
}

#avatar-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

#avatar-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow: var(--glow);
  transition: all 0.5s ease;
  pointer-events: none;
}

/* State-based ring colors */
.state-listening #avatar-ring {
  border-color: var(--accent);
  box-shadow: 0 0 30px rgba(192, 132, 252, 0.2);
}

.state-wake-word #avatar-ring {
  border-color: #fbbf24;
  box-shadow: 0 0 60px rgba(251, 191, 36, 0.4);
  animation: pulse 0.5s ease infinite;
}

.state-thinking #avatar-ring {
  border-color: var(--accent-think);
  box-shadow: 0 0 50px rgba(96, 165, 250, 0.4);
  animation: spin-glow 2s linear infinite;
}

.state-speaking #avatar-ring {
  border-color: var(--accent-warm);
  box-shadow: 0 0 60px rgba(251, 113, 133, 0.4);
  animation: pulse 1s ease infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

@keyframes spin-glow {
  0% { border-color: var(--accent-think); }
  33% { border-color: var(--accent); }
  66% { border-color: var(--accent-warm); }
  100% { border-color: var(--accent-think); }
}

/* Name */
#name-label {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text);
  margin-bottom: 8px;
}

/* State indicator */
#state-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 30px;
  opacity: 0.7;
}

#state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  transition: background 0.3s;
}

.state-listening #state-dot { background: var(--accent); }
.state-wake-word #state-dot { background: #fbbf24; }
.state-thinking #state-dot { background: var(--accent-think); animation: pulse 0.5s ease infinite; }
.state-speaking #state-dot { background: var(--accent-warm); animation: pulse 1s ease infinite; }

#state-text {
  font-size: 14px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Transcript */
#transcript-area {
  width: 100%;
  max-width: 600px;
  min-height: 40px;
  text-align: center;
  margin-bottom: 20px;
}

#room-transcript {
  font-size: 13px;
  color: var(--text-dim);
  opacity: 0.5;
  max-height: 40px;
  overflow: hidden;
  transition: opacity 0.3s;
}

#active-transcript {
  font-size: 18px;
  color: var(--text);
  font-weight: 500;
  min-height: 28px;
  transition: opacity 0.3s;
}

/* Response */
#response-area {
  width: 100%;
  max-width: 600px;
  text-align: center;
  min-height: 60px;
  margin-bottom: 20px;
}

#response-text {
  font-size: 20px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.5s ease;
}

#response-text.visible {
  opacity: 1;
}

/* Waveform */
#waveform {
  width: 300px;
  height: 50px;
  opacity: 0.6;
  margin-bottom: 30px;
}

/* Camera preview */
#camera-preview {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 100px;
  height: 75px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.1);
  opacity: 0.6;
  transition: opacity 0.3s;
}

#camera-preview:hover {
  opacity: 1;
}

/* Controls */
#controls {
  display: flex;
  gap: 16px;
  align-items: center;
}

#btn-start {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 30px;
  padding: 16px 40px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 0 30px rgba(192, 132, 252, 0.3);
}

#btn-start:hover {
  transform: scale(1.05);
  box-shadow: 0 0 50px rgba(192, 132, 252, 0.5);
}

#btn-start.hidden { display: none; }

#btn-mute {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.2s;
}

#btn-mute.muted {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
}

#btn-send {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.2s;
}

#btn-send:active {
  background: rgba(192, 132, 252, 0.3);
  border-color: var(--accent);
}

#btn-text {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 20px;
  cursor: pointer;
  position: absolute;
  bottom: 20px;
  left: 20px;
}

/* Text input fallback */
#text-input-area {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  width: 90%;
  max-width: 500px;
}

#text-input-area input {
  flex: 1;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

#text-input-area input:focus {
  border-color: var(--accent);
}

#text-input-area button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 16px;
  cursor: pointer;
}

/* Connection status */
#connection-status {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.5;
}

/* Responsive — iPad landscape */
@media (min-width: 768px) {
  #avatar-container {
    width: 260px;
    height: 260px;
  }
  #name-label { font-size: 36px; }
  #active-transcript { font-size: 22px; }
  #response-text { font-size: 24px; }
  #camera-preview { width: 140px; height: 105px; }
}

/* Responsive — iPad portrait */
@media (min-width: 768px) and (orientation: portrait) {
  #avatar-container {
    width: 300px;
    height: 300px;
    margin-bottom: 30px;
  }
}

/* Fullscreen immersion — hide Safari chrome */
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); }
}
