/* Voice Capture — dictation control for the Quick Capture editor. */

/* Label row: sits beside the textarea label inside the editor form. */
.voice-capture-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.voice-capture-label-row .field-label {
  margin: 0;
}

.voice-capture {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

/* Mic toggle button: calm until listening. */
.voice-capture__mic {
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
}

.voice-capture__mic svg {
  width: 20px;
  height: 20px;
}

.voice-capture__mic:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.voice-capture__mic[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--gold) 60%, var(--border));
  background: color-mix(in srgb, var(--gold) 10%, var(--surface));
  color: var(--gold);
  animation: voice-capture-pulse 2.4s ease-in-out infinite;
}

@keyframes voice-capture-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 40%, transparent);
  }
  50% {
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--gold) 0%, transparent);
  }
}

/* Interim transcript: what the recognizer is hearing, before it's committed. */
.voice-capture__interim {
  margin: 0;
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-style: italic;
}

.voice-capture__interim[hidden] {
  display: none;
}

/* Cancel: visible only while listening; stops and discards interim text. */
.voice-capture__cancel {
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}

.voice-capture__cancel[hidden] {
  display: none;
}

.voice-capture__cancel:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Unsupported browsers (e.g. iOS Safari): a one-line note, never a dead button. */
.voice-capture__unsupported {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}

/* Night theme: keep the listening glow readable against dark surfaces. */
:root[data-theme="night"] .voice-capture__mic[aria-pressed="true"] {
  border-color: #c9a35f;
  background: rgb(201 163 95 / 0.14);
  color: #c9a35f;
}

:root[data-theme="night"] .voice-capture__interim {
  color: #b3a88f;
}

:root[data-theme="night"] .voice-capture__unsupported {
  color: #b3a88f;
}

/* Honest degradation: no motion when the user prefers reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .voice-capture__mic[aria-pressed="true"] {
    animation: none;
  }
}
