/*
 * mic-fx.css — "Noise cancellation" (mic-fx.js, bead onfiremobile-pg2u5).
 * Load after devices.css / device-test.css:
 *   <link rel="stylesheet" href="/mic-fx.css?v=1">
 *
 * Three places: the mic popover (devices.js), the phone sheet (⋮ → Noise
 * cancellation) and, compact, the device-test.js microphone step. Colours
 * are theme tokens only (tests/theme-tokens.test.js).
 */

/* ---- Panel ------------------------------------------------------------- */
.mfx-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--call-border, #3c4043);
}

.mfx-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px 4px;
}

.mfx-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-hi);
}

/* ---- Mode picker: one pill, three segments ------------------------------ */
.mfx-seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--call-border, #3c4043);
  border-radius: 999px;
  background: var(--fg-a04);
}

.mfx-opt {
  display: inline-flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 150ms var(--call-ease, ease-out), color 150ms var(--call-ease, ease-out),
    box-shadow 150ms var(--call-ease, ease-out);
}

.mfx-opt:hover:not(:disabled):not([aria-checked="true"]) {
  background: var(--fg-a06);
  color: var(--text-hi);
}

.mfx-opt[aria-checked="true"] {
  background: var(--call-accent-soft, rgba(255, 107, 31, 0.16));
  box-shadow: inset 0 0 0 1px var(--call-accent, #FF6B1F);
  color: var(--call-accent-text, #ffb38a);
}

.mfx-opt:disabled {
  cursor: default;
  opacity: 0.6;
}

.mfx-opt:focus-visible,
.mfx-cmp-opt:focus-visible,
.mfx-adv-toggle:focus-visible,
.mfx-switch:focus-visible,
.mfx-btn:focus-visible,
.mfx-link:focus-visible,
.mfx-sheet-close:focus-visible {
  outline: 2px solid var(--call-focus, #ff7f3d);
  outline-offset: 2px;
}

.mfx-opt-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.mfx-badge {
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--accent-a18);
  color: var(--call-accent-text, #ffb38a);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 16px;
}

.mfx-desc {
  min-height: 2.8em; /* two lines: switching modes doesn't move what's below */
  margin: 8px 4px 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-dim);
}

.mfx-note {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--warning-a14);
  color: var(--warning-text);
  font-size: 12px;
  line-height: 1.4;
}

.mfx-note[hidden],
.mfx-adv[hidden],
.mfx-row[hidden],
.mfx-adv-body[hidden],
.mfx-chip[hidden],
.mfx-meter[hidden],
.mfx-cmp[hidden],
.mfx-link[hidden] {
  display: none;
}

/* ---- Advanced ---------------------------------------------------------- */
.mfx-adv {
  margin-top: 6px;
}

.mfx-adv-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 10px 0 4px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 150ms var(--call-ease, ease-out), background-color 150ms var(--call-ease, ease-out);
}

.mfx-adv-toggle:hover {
  color: var(--text-hi);
  background: var(--fg-a04);
}

.mfx-adv-toggle svg {
  transition: transform 180ms var(--call-ease, ease-out);
}

.mfx-adv-toggle[aria-expanded="true"] svg {
  transform: rotate(90deg);
}

.mfx-adv-body {
  padding: 2px 0 4px;
}

.mfx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 8px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 150ms var(--call-ease, ease-out);
}

.mfx-row:hover:not(.mfx-row-disabled) {
  background: var(--fg-a04);
}

.mfx-row-disabled {
  cursor: default;
}

.mfx-row-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mfx-row-label {
  font-size: 13px;
  color: var(--text-hi);
}

.mfx-row-hint {
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-dim);
}

.mfx-row-disabled .mfx-row-label {
  color: var(--text-dim);
}

.mfx-switch {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--switch-off);
  cursor: pointer;
  transition: background-color 150ms var(--call-ease, ease-out);
}

.mfx-switch[aria-checked="true"] {
  background: var(--call-accent, #FF6B1F);
}

.mfx-switch:disabled {
  cursor: default;
  opacity: 0.5;
}

.mfx-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--switch-knob);
  box-shadow: 0 1px 2px var(--shadow-a30);
  transition: transform 180ms var(--call-ease, ease-out);
}

.mfx-switch[aria-checked="true"] .mfx-switch-knob {
  transform: translateX(16px);
}

/* ---- Test -------------------------------------------------------------- */
.mfx-test {
  margin-top: 10px;
  padding: 12px;
  border-radius: 16px;
  background: var(--fg-a04);
}

.mfx-test-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 22px;
  margin-bottom: 8px;
}

.mfx-test-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
}

.mfx-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 8px;
  border-radius: 999px;
  background: var(--danger-a14);
  color: var(--danger-text);
  font-size: 12px;
  white-space: nowrap;
}

.mfx-test-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.mfx-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px 0 12px;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 150ms var(--call-ease, ease-out), transform 120ms var(--call-ease, ease-out);
}

.mfx-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.mfx-btn-primary {
  background: var(--call-accent, #FF6B1F);
  color: var(--call-accent-ink, #1a1a1a);
}

.mfx-btn-primary:hover:not(:disabled) {
  background: var(--call-accent-hover, #ff7f3d);
}

.mfx-btn-primary.mfx-btn-rec {
  background: var(--call-danger, #ea4335);
  color: var(--on-fill);
}

.mfx-btn-primary.mfx-btn-rec:hover {
  background: var(--call-danger-hover, #d93025);
}

.mfx-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.mfx-meter {
  display: flex;
  flex: 1 1 80px;
  align-items: center;
  gap: 3px;
  height: 16px;
  min-width: 0;
}

.mfx-meter-seg {
  flex: 1 1 0;
  max-width: 10px;
  height: 6px;
  border-radius: 999px;
  background: var(--meter-off);
  transition: height 80ms linear, background-color 80ms linear;
}

.mfx-meter-seg.on {
  height: 14px;
  background: var(--call-accent, #FF6B1F);
}

/* Original / Strong (AI) on the same take */
.mfx-cmp {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--call-border, #3c4043);
  border-radius: 999px;
}

.mfx-cmp-opt {
  height: 30px;
  padding: 0 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms var(--call-ease, ease-out), color 150ms var(--call-ease, ease-out);
}

.mfx-cmp-opt:hover:not(:disabled):not([aria-checked="true"]) {
  background: var(--fg-a06);
  color: var(--text-hi);
}

.mfx-cmp-opt[aria-checked="true"] {
  background: var(--call-accent-soft, rgba(255, 107, 31, 0.16));
  color: var(--call-accent-text, #ffb38a);
}

.mfx-cmp-opt:disabled {
  cursor: default;
  opacity: 0.5;
}

.mfx-link {
  height: 30px;
  margin-left: auto;
  padding: 0 8px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--call-accent-text, #ffb38a);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.mfx-link:hover {
  background: var(--fg-a04);
}

.mfx-test-status {
  margin: 8px 2px 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-dim);
}

.mfx-test-status.mfx-test-err {
  color: var(--danger-text);
}

/* ---- Wizard (device-test.js microphone step) ----------------------------- */
.mfx-picker.dt-fx {
  margin-top: 16px;
}

.mfx-compact .mfx-head {
  margin: 0 0 6px 4px;
}

.mfx-compact .mfx-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-dim);
}

.mfx-compact .mfx-desc {
  min-height: 0;
}

/* ---- ⋮ menu item: phones only (desktop has the mic chevron) -------------- */
.more-menu-item.mfx-menu-item {
  display: none;
}

@media (max-width: 599px) and (pointer: coarse) {
  .more-menu-item.mfx-menu-item {
    display: flex;
  }
}

/* ---- Sheet ------------------------------------------------------------- */
.mfx-sheet-root {
  position: fixed;
  inset: 0;
  z-index: 1060; /* the device-test wizard's layer */
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--scrim-a60);
  color-scheme: var(--color-scheme);
  opacity: 0;
  transition: opacity 200ms var(--call-ease, ease-out);
}

.mfx-sheet-root.mfx-in {
  opacity: 1;
}

.mfx-sheet {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
  padding: 6px 16px calc(20px + env(safe-area-inset-bottom));
  border: 1px solid var(--call-border, #3c4043);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  background: var(--call-menu, #28292a);
  box-shadow: 0 -12px 40px var(--shadow-a45);
  color: var(--text-hi);
  font-size: 14px;
  text-align: left;
  transform: translateY(24px);
  transition: transform 260ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

.mfx-sheet-root.mfx-in .mfx-sheet {
  transform: none;
}

.mfx-sheet-head {
  position: relative;
  z-index: 1; /* above the panel's title row, which slides up beside it */
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 36px;
}

.mfx-sheet-grab {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 999px;
  background: var(--fg-a20);
}

.mfx-sheet-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-icon);
  cursor: pointer;
}

.mfx-sheet-close:hover {
  background: var(--fg-a06);
}

.mfx-sheet .mfx-panel {
  margin-top: -22px; /* the title sits beside the close button */
  padding-top: 0;
  border-top: none;
}

.mfx-sheet .mfx-head {
  min-height: 36px;
  margin-bottom: 12px;
}

.mfx-sheet .mfx-title {
  font-size: 18px;
  font-weight: 600;
}

.mfx-sheet .mfx-opt {
  height: 40px;
}

/* Wider than a phone: a centred dialog rather than a bottom sheet. */
@media (min-width: 600px) {
  .mfx-sheet-root {
    align-items: center;
    padding: 16px;
  }

  .mfx-sheet {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--call-border, #3c4043);
    border-radius: 24px;
  }

  .mfx-sheet-grab {
    display: none;
  }
}

/* ---- Narrow ------------------------------------------------------------ */
@media (max-width: 599px) {
  .mfx-opt {
    padding: 0 6px;
    font-size: 13px;
  }

  .mfx-link {
    margin-left: 0;
  }
}

/* ---- Reduced motion ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .mfx-opt,
  .mfx-cmp-opt,
  .mfx-switch,
  .mfx-switch-knob,
  .mfx-adv-toggle svg,
  .mfx-btn,
  .mfx-meter-seg,
  .mfx-sheet-root,
  .mfx-sheet {
    transition: none;
  }
}
