/* EMBER voice widget — floating, accessible voice controls (read aloud + ask).
   Standalone-safe: theme variables fall back to the EMBER dark palette. */
:root {
  --bg: #0e1116; --panel: #161b22; --panel2: #1c232d; --line: #2a323d;
  --ink: #e7edf3; --muted: #93a1b0; --brand: #ff7a18; --brand2: #7ec9ff;
  --good: #3fb950; --bad: #f85149; --partial: #d29922;
}

.ember-voice {
  position: fixed;
  right: 112px;       /* sit to the LEFT of the corner Ember flame (#em-fab), not under it */
  bottom: 26px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 28px);
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  color: var(--ink);
  font: 13px/1.4 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

/* The corner flame (#em-fab) is the mascot; the pill's own mascot is redundant and
   was the wasted space — hide it so the pill is just the compact controls. */
.ember-voice .ev-mascot { display: none; }

.ember-voice .ev-btn {
  position: relative;
  width: 40px;
  height: 40px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  color: var(--ink);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.ember-voice .ev-btn:hover { border-color: var(--brand2); color: var(--brand2); }
.ember-voice .ev-btn:focus-visible {
  outline: 2px solid var(--brand2);
  outline-offset: 2px;
}
.ember-voice .ev-btn svg { display: block; }

/* Active states reflect speaking (speaker) / listening (mic). */
.ember-voice.speaking .ev-speak,
.ember-voice.listening .ev-mic {
  color: #160a04;
  background: var(--brand);
  border-color: var(--brand);
}
.ember-voice.listening .ev-mic {
  color: var(--bg);
  background: var(--brand2);
  border-color: var(--brand2);
}

/* Pulse ring shown only while the relevant button is active. */
.ev-pulse {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0;
  pointer-events: none;
}
.ember-voice.speaking .ev-speak .ev-pulse,
.ember-voice.listening .ev-mic .ev-pulse {
  opacity: .7;
  animation: ev-ring 1.4s ease-out infinite;
}

@keyframes ev-ring {
  0% { transform: scale(.85); opacity: .7; }
  70% { transform: scale(1.4); opacity: 0; }
  100% { transform: scale(1.4); opacity: 0; }
}

.ember-voice .ev-status {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.ember-voice.speaking .ev-status,
.ember-voice.listening .ev-status { color: var(--ink); }
.ember-voice .ev-status:empty { display: none; }

/* Mobile: keep it compact, drop the long status text, stay left of the flame. */
@media (max-width: 560px) {
  .ember-voice { right: 104px; bottom: 20px; gap: 6px; padding: 5px 7px; }
  .ember-voice .ev-btn { width: 38px; height: 38px; }
  .ember-voice .ev-status { display: none; }
}

/* Respect reduced-motion: no pulsing, just a steady highlight. */
@media (prefers-reduced-motion: reduce) {
  .ember-voice .ev-pulse { animation: none !important; }
  .ember-voice.speaking .ev-speak .ev-pulse,
  .ember-voice.listening .ev-mic .ev-pulse { opacity: .55; transform: none; }
  .ember-voice .ev-btn { transition: none; }
}

/* High-contrast / forced colors safety. */
@media (forced-colors: active) {
  .ember-voice { border: 1px solid CanvasText; }
  .ember-voice .ev-btn { border: 1px solid CanvasText; }
}
