/* Mic Test — two-column tool (visual stage + parameter panel) and page-specific content.
   Shared explainer rows and the tool CTA card live in ../css/tool-pages.css. */

[hidden] {
  display: none !important;
}

/* ── Tool shell ── */
.mic-tool {
  background:
    radial-gradient(ellipse 70% 60% at 15% 0%, rgba(37, 99, 235, 0.16), transparent 70%),
    #05070a;
  padding: clamp(1.25rem, 3vw, 2.25rem) var(--page-pad-inline, 1.25rem) clamp(2rem, 5vw, 3.5rem);
}

.mic-tool__inner {
  max-width: 1280px;
  margin: 0 auto;
}

.mic-intro {
  display: grid;
  gap: 0.75rem 2.5rem;
  align-items: end;
  margin-bottom: clamp(1rem, 2.5vw, 1.5rem);
}

@media (min-width: 960px) {
  .mic-intro { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

.mic-intro__head { display: grid; gap: 0.5rem; }

.mic-intro__title {
  margin: 0;
  font-family: var(--font-display, "Sora", sans-serif);
  font-size: clamp(2rem, 4.4vw, 3.1rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: #f8fafc;
}

.mic-intro__title span {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.5em;
  letter-spacing: -0.01em;
  color: var(--accent-bright, #60a5fa);
}

.mic-intro__lead {
  margin: 0 0 0.75rem;
  color: #cbd5e1;
  font-size: 1rem;
  line-height: 1.6;
}

.mic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mic-chips li {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.mic-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 960px) {
  .mic-grid {
    grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr);
    align-items: stretch;
  }
}

/* ── Left: stage ── */
.mic-stage {
  position: relative;
  min-height: 420px;
  border-radius: 20px;
  overflow: hidden;
  background: #070b14;
  border: 1px solid rgba(96, 165, 250, 0.16);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

@media (min-width: 960px) {
  .mic-stage { min-height: 560px; }
}

.mic-hero {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: clamp(1.5rem, 4vw, 3rem);
}

.mic-hero__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 72% 40%;
}

.mic-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(5, 9, 18, 0.9) 0%, rgba(5, 9, 18, 0.7) 32%, rgba(5, 9, 18, 0.05) 62%, rgba(5, 9, 18, 0) 100%);
}

.mic-hero__copy {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.9rem;
  max-width: 19rem;
}

.mic-hero__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  color: #fff;
  background: rgba(59, 130, 246, 0.22);
  border: 1px solid rgba(96, 165, 250, 0.5);
  box-shadow: 0 0 0 10px rgba(59, 130, 246, 0.08), 0 0 40px rgba(59, 130, 246, 0.35);
}

.mic-start-btn {
  padding: 1rem 1.9rem;
  border: none;
  border-radius: 999px;
  background: var(--accent, #3b82f6);
  color: #fff;
  font-family: var(--font-display, "Sora", sans-serif);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 30px var(--glow, rgba(37, 99, 235, 0.35));
  transition: background 0.15s;
}

.mic-start-btn:hover { background: var(--accent-bright, #60a5fa); }

.mic-start-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mic-note {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #94a3b8;
}

.mic-privacy {
  margin: 0;
  font-size: 0.8125rem;
  color: #64748b;
}

.mic-hero .mic-note { color: #cbd5e1; }
.mic-hero .mic-privacy { color: #94a3b8; }

@media (max-width: 959px) {
  .mic-hero { align-items: flex-end; }
  .mic-hero__img { object-position: 78% 30%; }
  .mic-hero::after {
    background: linear-gradient(180deg, rgba(5, 9, 18, 0) 20%, rgba(5, 9, 18, 0.75) 55%, rgba(5, 9, 18, 0.96) 100%);
  }
  .mic-hero__copy { max-width: none; }
  .mic-hero__icon { display: none; }
}

/* Error panels sit over the stage */
/* In normal flow so a long fix list grows the stage instead of scrolling inside it */
.mic-error {
  position: relative;
  z-index: 2;
  min-height: inherit;
  height: 100%;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  background: radial-gradient(ellipse at 30% 0%, rgba(127, 29, 29, 0.35), transparent 60%), #070b14;
  color: #e2e8f0;
  font-size: 0.9375rem;
  line-height: 1.55;
}

.mic-error > * { max-width: 560px; }

.mic-error h2 {
  margin: 0 0 0.6rem;
  font-family: var(--font-display, "Sora", sans-serif);
  font-size: 1.2rem;
  color: #fca5a5;
}

.mic-error p,
.mic-error ol { margin: 0 0 0.85rem; }
.mic-error ol { padding-inline-start: 1.25rem; }
.mic-error li { margin-bottom: 0.4rem; }

.mic-error .btn-download {
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.75rem 1.5rem;
}

/* Live view */
.mic-live {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  height: 100%;
  padding: clamp(1.1rem, 3vw, 1.75rem);
  background: radial-gradient(ellipse at 50% 0%, rgba(37, 99, 235, 0.12), transparent 65%);
}

.mic-live__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.mic-guidance {
  flex: 1 1 18rem;
  margin: 0;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  font-family: var(--font-display, "Sora", sans-serif);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.35;
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
}

.mic-guidance--good { background: rgba(34, 197, 94, 0.14); color: #86efac; }
.mic-guidance--quiet { background: rgba(234, 179, 8, 0.14); color: #fde68a; }
.mic-guidance--loud { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }

.mic-wave {
  position: relative;
  flex: 1 1 auto;
  min-height: 150px;
  border-radius: 14px;
  background:
    repeating-linear-gradient(90deg, rgba(148, 163, 184, 0.05) 0 1px, transparent 1px 48px),
    rgba(2, 6, 23, 0.6);
  border: 1px solid rgba(96, 165, 250, 0.12);
  overflow: hidden;
}

.mic-wave__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.mic-meter,
.mic-meter__scale,
.mic-zones__meter {
  direction: ltr;
}

.mic-meter {
  position: relative;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(96, 165, 250, 0.18);
  overflow: hidden;
}

/* Segment lines over the fill give the meter an LED-bar look */
.mic-meter::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 9px, rgba(7, 11, 20, 0.75) 9px 11px);
  pointer-events: none;
}

.mic-meter__zone {
  position: absolute;
  top: 0;
  bottom: 0;
  /* -35 dBFS to -12 dBFS on a -60..0 scale */
  left: 41.667%;
  width: 38.333%;
  background: rgba(34, 197, 94, 0.1);
  border-inline: 1px dashed rgba(34, 197, 94, 0.45);
}

.mic-meter__zone::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 100%;
  width: 52.17%; /* the remaining 20% of the scale, relative to the zone */
  background: rgba(239, 68, 68, 0.08);
}

.mic-meter__fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: #64748b;
  transition: width 60ms linear;
}

.mic-meter__fill.is-good { background: linear-gradient(90deg, #15803d, #22c55e); }
.mic-meter__fill.is-loud { background: linear-gradient(90deg, #15803d, #22c55e 60%, #ef4444); }

.mic-meter__peak {
  position: absolute;
  z-index: 1;
  top: 3px;
  bottom: 3px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: #f8fafc;
  box-shadow: 0 0 8px rgba(248, 250, 252, 0.7);
}

.mic-meter__scale {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}

.mic-clip {
  margin: 0.6rem 0 0;
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  background: #b91c1c;
  color: #fff;
  font-weight: 700;
  font-size: 0.875rem;
}

.mic-rec {
  padding-top: 1rem;
  border-top: 1px solid rgba(96, 165, 250, 0.1);
}

.mic-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.mic-rec-status {
  font-size: 0.9375rem;
  color: #cbd5e1;
  font-variant-numeric: tabular-nums;
}

.mic-player {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
}

.mic-download {
  display: inline-block;
  margin-top: 0.6rem;
  text-decoration: none;
}

/* ── Shared small controls ── */
.calc-label {
  display: block;
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.ghost-btn {
  padding: 0.5rem 1rem;
  border: 1px solid rgba(96, 165, 250, 0.35);
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: #bfdbfe;
  font-family: var(--font-display, "Sora", sans-serif);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ghost-btn:hover {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(96, 165, 250, 0.6);
}

.ghost-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost-btn.is-recording {
  background: #b91c1c;
  border-color: #ef4444;
  color: #fff;
}

.mic-rec__btn::before {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-inline-end: 0.45rem;
  border-radius: 50%;
  background: #ef4444;
  vertical-align: 0.05em;
}

.mic-rec__btn.is-recording::before {
  border-radius: 2px;
  background: #fff;
}

/* ── Right: parameter panel ── */
.mic-panel {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: clamp(1.1rem, 2.5vw, 1.5rem);
  border-radius: 20px;
  background: linear-gradient(180deg, #0f1a30 0%, #0b1324 100%);
  border: 1px solid rgba(96, 165, 250, 0.16);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.mic-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(96, 165, 250, 0.1);
}

.mic-panel__title {
  margin: 0;
  font-family: var(--font-display, "Sora", sans-serif);
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: #f1f5f9;
}

.mic-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.06);
}

.mic-status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
}

.mic-panel[data-state="starting"] .mic-status__dot { background: #facc15; }
.mic-panel[data-state="live"] .mic-status__dot { background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2); }
.mic-panel[data-state="recording"] .mic-status__dot { background: #ef4444; box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.25); }
.mic-panel[data-state="error"] .mic-status__dot { background: #f87171; }
.mic-panel[data-state="live"] .mic-status { color: #86efac; }
.mic-panel[data-state="recording"] .mic-status { color: #fca5a5; }
.mic-panel[data-state="error"] .mic-status { color: #fca5a5; }

.mic-select {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.55rem 0.75rem;
  background: #0a1122;
  border: 1px solid rgba(96, 165, 250, 0.22);
  border-radius: 10px;
  color: #e2e8f0;
  font: inherit;
  font-size: 0.9375rem;
}

.mic-select:disabled { opacity: 0.6; }

.mic-device-label {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: #cbd5e1;
  overflow-wrap: anywhere;
}

.mic-device-label strong {
  color: #64748b;
  font-weight: 600;
}

/* Empty values show a dash until the microphone starts. */
#micDeviceLabel:empty::before,
.mic-stat dd:empty::before,
.mic-toggle__applied:empty::before,
.mic-noise__result:empty::before {
  content: "—";
  color: #475569;
}

.mic-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin: 0;
}

.mic-stat {
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(96, 165, 250, 0.1);
}

.mic-stat dt {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #64748b;
}

.mic-stat dd {
  margin: 0.15rem 0 0;
  font-family: var(--font-display, "Sora", sans-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: #f1f5f9;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mic-panel__group .mic-note { margin-top: 0.5rem; font-size: 0.8125rem; }

.mic-noise {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
}

.mic-noise .calc-label { margin-bottom: 0.4rem; }

.mic-noise__result {
  margin: 0 0 0.6rem;
  font-size: 0.9375rem;
  color: #cbd5e1;
  font-variant-numeric: tabular-nums;
}

.mic-noise__result.is-quiet { color: #86efac; }
.mic-noise__result.is-some { color: #fde68a; }
.mic-noise__result.is-noisy { color: #fca5a5; }

.mic-noise__btn { width: 100%; }

.mic-toggles {
  display: grid;
  gap: 0.35rem;
}

.mic-toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.65rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.9375rem;
  color: #e2e8f0;
  cursor: pointer;
}

.mic-toggle input {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  position: relative;
  width: 2.1rem;
  height: 1.2rem;
  margin: 0;
  border-radius: 999px;
  background: #334155;
  cursor: pointer;
  transition: background 0.15s;
}

.mic-toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.2rem - 4px);
  height: calc(1.2rem - 4px);
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.mic-toggle input:checked { background: var(--accent, #3b82f6); }
.mic-toggle input:checked::after { transform: translateX(0.9rem); }
.mic-toggle input:focus-visible { outline: 2px solid var(--accent-bright, #60a5fa); outline-offset: 2px; }
.mic-toggle input:disabled { opacity: 0.5; }

.mic-toggle__name { flex: 1 1 auto; }

.mic-toggle__applied {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #94a3b8;
  white-space: nowrap;
}

/* ── Explainer: steps strip ── */
.mic-steps {
  display: grid;
  gap: 0.75rem;
  margin: clamp(1.5rem, 4vw, 2.5rem) 0 0;
  padding: 0;
  list-style: none;
  counter-reset: micstep;
}

@media (min-width: 720px) {
  .mic-steps { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
}

.mic-steps li {
  position: relative;
  padding: 1.1rem 1.1rem 1.1rem 3.3rem;
  border-radius: 16px;
  background: rgba(17, 26, 46, 0.7);
  border: 1px solid rgba(96, 165, 250, 0.12);
  color: #cbd5e1;
  font-size: 0.9375rem;
  line-height: 1.55;
  counter-increment: micstep;
}

.mic-steps li::before {
  content: counter(micstep);
  position: absolute;
  left: 1rem;
  top: 1.05rem;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  font-family: var(--font-display, "Sora", sans-serif);
  font-size: 0.8125rem;
  font-weight: 700;
}

.mic-steps strong {
  display: block;
  color: #f1f5f9;
}

/* ── Explainer: level-zone visual ── */
.mic-zones { margin: 0; }

.mic-zones__card {
  padding: clamp(1.25rem, 3vw, 2rem);
  border-radius: 18px;
  background: radial-gradient(ellipse at 50% 0%, rgba(37, 99, 235, 0.16), transparent 65%), #0b1324;
  border: 1px solid rgba(96, 165, 250, 0.16);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.mic-zones__title {
  margin: 0 0 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #94a3b8;
}

.mic-zones__meter {
  position: relative;
  display: flex;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(96, 165, 250, 0.18);
}

.mic-zones__band.is-quiet { width: 41.667%; background: rgba(234, 179, 8, 0.1); }
.mic-zones__band.is-good { width: 38.333%; background: rgba(34, 197, 94, 0.12); border-inline: 1px dashed rgba(34, 197, 94, 0.5); }
.mic-zones__band.is-loud { width: 20%; background: rgba(239, 68, 68, 0.14); }

.mic-zones__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 63%;
  background: linear-gradient(90deg, #15803d, #22c55e);
}

.mic-zones__peak {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 74%;
  width: 3px;
  border-radius: 2px;
  background: #f8fafc;
  box-shadow: 0 0 8px rgba(248, 250, 252, 0.7);
}

.mic-zones__meter::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 9px, rgba(11, 19, 36, 0.8) 9px 11px);
}

.mic-zones__legend {
  display: grid;
  gap: 0.6rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}

.mic-zones__legend li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.1rem 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-inline-start: 3px solid #64748b;
  font-size: 0.875rem;
}

.mic-zones__legend li.is-quiet { border-color: #eab308; }
.mic-zones__legend li.is-good { border-color: #22c55e; }
.mic-zones__legend li.is-loud { border-color: #ef4444; }

.mic-zones__legend strong {
  grid-row: span 2;
  min-width: 5.5rem;
  color: #f1f5f9;
  font-family: var(--font-display, "Sora", sans-serif);
}

.mic-zones__legend span { color: #e2e8f0; }
.mic-zones__legend em { font-style: normal; color: #94a3b8; }

.mic-zones figcaption {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: #94a3b8;
  text-align: center;
}

/* ── Fixes card grid ── */
.mic-fixes {
  display: grid;
  gap: 0.9rem;
}

@media (min-width: 640px) {
  .mic-fixes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 3 system cards on the first row, the 4 browser cards on the second */
@media (min-width: 1000px) {
  .mic-fixes { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .mic-fix { grid-column: span 4; }
  .mic-fix:nth-child(n + 4) { grid-column: span 3; }
}

.mic-fix {
  padding: 1.2rem 1.25rem;
  border-radius: 16px;
  background: rgba(17, 26, 46, 0.7);
  border: 1px solid rgba(96, 165, 250, 0.12);
}

.mic-fix h3 {
  margin: 0 0 0.6rem;
  font-family: var(--font-display, "Sora", sans-serif);
  font-size: 1.05rem;
  color: #f1f5f9;
}

.mic-fix p {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.mic-fix p + p { margin-top: 0.6rem; }
.mic-fix strong { color: #f1f5f9; }

.tool-explain .tool-steps strong { color: #f1f5f9; }
.tool-row .tool-steps + p { margin-top: 1rem; }

@media (max-width: 560px) {
  .mic-stage { min-height: 400px; }
  .mic-start-btn { width: 100%; }
  .mic-hero__copy { width: 100%; align-items: stretch; text-align: center; }
  .mic-wave { min-height: 120px; }
}

/* Right-to-left pages (ar, he): mirror the photo scrim so the text side stays dark. */
[dir="rtl"] .mic-hero::after { transform: scaleX(-1); }
