/* HIPERGRAPHICS · DS-0015 · COMMON COMPONENTS
   Canonical: packages/design-system/styles/hg-controls.css
   One visual control, two mechanisms: staff uses a CSS SVG because its button
   contains legacy emoji; public demo already injects one native SVG in demo-v5.js.
   NEVER draw a second pseudo-icon on a button that already has an SVG child. */

/* Consistent HiperGraphics selection, including staff and all public pages. */
::selection { background:var(--hg-yellow); color:var(--hg-ink); }
::-moz-selection { background:var(--hg-yellow); color:var(--hg-ink); }

.hg-voice-trigger {
  /* No position declaration here! Position belongs to the field wrapper. */
  display:inline-grid;
  place-items:center;
  box-sizing:border-box;
  flex:none;
  appearance:none;
  min-width:var(--hg-voice-size,44px);
  min-height:var(--hg-voice-size,44px);
  padding:0;
  border:1.5px solid var(--hg-ink);
  border-radius:0;
  background-color:var(--hg-yellow);
  color:var(--hg-ink);
  cursor:pointer;
  vertical-align:middle;
  line-height:1;
}
.hg-voice-trigger:hover:not(:disabled) { background-color:#ffe069; }
.hg-voice-trigger:focus-visible {
  outline:var(--hg-focus-width,3px) solid var(--hg-focus);
  outline-offset:2px;
}
.hg-voice-trigger:disabled { cursor:not-allowed; opacity:.5; }

/* Both field systems use the same geometric contract: mic overlays the input,
   never sits below it and never changes the field's document flow. */
.with-voice,
.v7-input-voice { position:relative; min-width:0; width:100%; }
.with-voice > input,
.with-voice > textarea { width:100%; padding-right:60px; }
.with-voice > .hg-voice-trigger {
  position:absolute;
  z-index:2;
  right:2px;
  top:1px;
  width:44px;
  height:44px;
  min-width:44px;
  min-height:44px;
  margin:0;
  font-size:0;         /* hide legacy emoji only in staff */
  color:transparent;   /* do not affect the external image */
}
.with-voice > .hg-voice-trigger::before {
  content:"";
  width:24px;
  height:24px;
  display:block;
  background:url("./hg-mic-hand.svg") center / contain no-repeat;
  pointer-events:none;
}
.with-voice > .hg-voice-trigger.active,
.with-voice > .hg-voice-trigger[aria-pressed="true"] {
  background-color:var(--hg-signal);
}
.with-voice > .hg-voice-trigger.active::before,
.with-voice > .hg-voice-trigger[aria-pressed="true"]::before {
  filter:brightness(0) invert(1);
}

/* The public demonstration dynamically moves its button into .v7-input-voice,
   then inserts its OWN SVG. Do not cover or replace that existing SVG. */
.v7-input-voice > .hg-voice-trigger::before { content:none !important; }
.v7-input-voice > .hg-voice-trigger { z-index:2; }
.v7-input-voice > .hg-voice-trigger svg {
  display:block;
  max-width:24px;
  max-height:24px;
  color:inherit;
  fill:none;
}
.v7-input-voice > .hg-voice-trigger[aria-pressed="true"] svg {
  fill:currentColor;
}
@media (prefers-reduced-motion:reduce) {
  .hg-voice-trigger { transition:none !important; }
}
