/* my-gui voice input (js/voice.js): a small microphone at the end of the field's label row (under the field
   when it has no label), and what is being heard under the field. Spec: docs/spec.md 17. */

.m-voice { display: flex; align-items: center; gap: 10px; min-width: 0; }
.m-voice-btn {
  position: relative;
  order: 2;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--m-r-sm);
  background: transparent;
  color: var(--m-text-3);
  cursor: pointer;
}
.m-voice-btn .m-i { width: 14px; height: 14px; }
.m-voice-btn:hover { color: var(--m-text); background: rgba(var(--m-ink), .06); }
.m-voice-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--m-ring); }
.m-voice-btn:disabled { opacity: .45; cursor: not-allowed; }
.m-voice-btn[aria-pressed="true"] { color: var(--m-accent); background: rgba(var(--m-accent-rgb), .14); }

/* on the label row: the bar itself takes no room, the status line appears only when it says something */
.m-voice-host { position: relative; }
.m-voice-host > :first-child { padding-inline-end: 32px; }
.m-voice--label { display: contents; }
.m-voice--label .m-voice-btn { position: absolute; inset-block-start: -5px; inset-inline-end: 0; }
.m-voice--label .m-voice-status:empty { position: absolute; width: 1px; height: 1px; overflow: hidden; }
.m-voice.is-listening .m-voice-btn .m-i { animation: m-voice-pulse 1.4s ease-in-out infinite; }
@keyframes m-voice-pulse { 50% { opacity: .35; } }
.m-voice-status { flex: 1 1 0%; min-width: 0; color: var(--m-text-3); font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.m-voice.is-error .m-voice-status { color: var(--m-warn-text); }
textarea[data-m-voice][hidden] ~ .m-voice--label > *, input[data-m-voice][hidden] + .m-voice--label > * { display: none; }
textarea[data-m-voice][hidden] ~ .m-voice, input[data-m-voice][hidden] + .m-voice { display: none; }

/* a finger gets a 44px target around the small icon */
@media (pointer: coarse) {
  .m-voice-btn::before { content: ""; position: absolute; inset: -10px; }
}

@media (prefers-reduced-motion: reduce) {
  .m-voice.is-listening .m-voice-btn .m-i { animation: none; }
}

@media (forced-colors: active) {
  .m-voice-btn[aria-pressed="true"] { forced-color-adjust: none; color: HighlightText; background: Highlight; }
}

@media print {
  .m-voice { display: none; }
}
