/* ===================================================================
   /microphone-test - the studio microphone.

   --lvl (0..1) is written by Microphone.js from the RMS of the live
   input, so the grille glow and the rings follow what the microphone
   actually hears. Scoped under .mc.
   =================================================================== */

.mc {
    --mc-accent: #3d8bff;
    --mc-accent-2: #22d3ee;
    --mc-ok: #34f5a6;
    --mc-warn: #ffb547;
    --mc-bad: #ff5f6d;
    --mc-ink: #10162b;
    --mc-muted: #5b6275;
    --mc-line: #e4e7ef;
    --lvl: 0;

    margin: 18px auto 24px;
    padding: 0; /* WebsiteTemplate gives every <section> 60px */
    max-width: 1040px;
    border-radius: 28px;
    background: #fff;
    border: 1px solid var(--mc-line);
    box-shadow: 0 30px 60px -32px rgb(16 22 43 / 45%);
    overflow: hidden;
    text-align: left;
    font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--mc-ink);
}

.mc *, .mc *::before, .mc *::after { box-sizing: border-box; }
.mc button, .mc select { font: inherit; }
.mc svg { display: block; }
.mc [hidden] { display: none !important; }

.mc-visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- top bar ---------- */

.mc-topbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
    padding: 12px 20px;
    background: linear-gradient(180deg, #151b33, #10162b);
    color: #cdd5ee;
}
.mc-detected { display: flex; align-items: center; gap: 8px; margin: 0; font-size: .9rem; font-weight: 500; min-width: 0; }
.mc-detected svg { width: 18px; height: 18px; color: var(--mc-accent-2); flex: none; }
.mc-picker { flex: 0 1 340px; min-width: 0; }
.mc-select {
    width: 100%; min-height: 38px; padding: 0 36px 0 14px; border-radius: 999px;
    border: 1px solid rgb(255 255 255 / 14%); background-color: rgb(255 255 255 / 8%); color: #eef2ff;
    font-size: .85rem; font-weight: 600; cursor: pointer;
    -webkit-appearance: none; appearance: none; text-overflow: ellipsis;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23aeb8d6' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
.mc-select option { color: var(--mc-ink); }
.mc-select:disabled { opacity: .55; cursor: default; }
.mc-select:focus-visible { outline: 3px solid var(--mc-accent-2); outline-offset: 2px; }

/* ---------- stage ---------- */

.mc-stage {
    position: relative;
    display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: clamp(20px, 4vw, 48px); align-items: center;
    padding: clamp(24px, 4vw, 44px) clamp(14px, 4vw, 44px);
    background:
        radial-gradient(45% 70% at 18% 60%, rgb(34 211 238 / calc(.06 + var(--lvl) * .22)), transparent 70%),
        radial-gradient(60% 60% at 60% 120%, rgb(61 139 255 / 24%), transparent 70%),
        linear-gradient(180deg, #10162b 0%, #1a2142 100%);
    isolation: isolate;
}

.mc-mic-col { display: flex; flex-direction: column; align-items: center; gap: 18px; min-width: 0; }

.mc-mic { position: relative; width: min(100%, 190px); }
.mc-mic-art {
    position: relative; width: 100%; height: auto; z-index: 1;
    filter: drop-shadow(0 24px 24px rgb(0 0 0 / 45%));
    transform: translateY(calc(var(--lvl) * -3px));
}
.mc-grille-glow { opacity: calc(var(--lvl) * .95); }
.mc-led { fill: #3a4163; transition: fill .2s ease; }
.mc.is-live .mc-led { fill: var(--mc-bad); filter: drop-shadow(0 0 4px var(--mc-bad)); }

.mc-halo {
    position: absolute; left: 50%; top: 29%; width: 150%; aspect-ratio: 1; transform: translate(-50%, -50%) scale(calc(.7 + var(--lvl) * .5));
    border-radius: 50%; pointer-events: none;
    background: radial-gradient(circle, rgb(34 211 238 / calc(var(--lvl) * .55)), transparent 62%);
}
.mc-rings { position: absolute; left: 50%; top: 29%; width: 0; height: 0; pointer-events: none; }
.mc-rings i {
    position: absolute; width: 190px; height: 190px; margin: -95px 0 0 -95px; border-radius: 50%;
    border: 2px solid var(--mc-accent-2); opacity: 0; transform: scale(.5);
}
.mc.is-sounding .mc-rings i { animation: mc-ring 1.6s cubic-bezier(.2, .6, .3, 1) infinite; }
.mc.is-sounding .mc-rings i:nth-child(2) { animation-delay: .53s; }
.mc.is-sounding .mc-rings i:nth-child(3) { animation-delay: 1.06s; }
@keyframes mc-ring { 0% { opacity: calc(.1 + var(--lvl) * .8); transform: scale(.5); } 100% { opacity: 0; transform: scale(1.5); } }

.mc-start {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 52px; padding: 0 26px; border: 0; border-radius: 999px; cursor: pointer;
    color: #fff; font-weight: 700; font-size: 1rem; white-space: nowrap;
    background: radial-gradient(circle at 30% 20%, #6aa9ff, var(--mc-accent) 55%, #2254c9);
    box-shadow: 0 14px 30px -10px rgb(61 139 255 / 75%), inset 0 -3px 8px rgb(0 0 0 / 22%), inset 0 2px 6px rgb(255 255 255 / 25%);
    transition: transform .15s ease, background .2s ease;
}
.mc-start svg { width: 20px; height: 20px; }
.mc-start:hover { transform: translateY(-2px); }
.mc-start:active { transform: scale(.96); }
.mc-start:disabled { opacity: .6; cursor: progress; transform: none; }
.mc-start:focus-visible { outline: 3px solid var(--mc-accent-2); outline-offset: 4px; }
.mc-i-stop { display: none; }
.mc.is-live .mc-start { background: radial-gradient(circle at 30% 20%, #ff8a95, #e5485a 55%, #b3263a); box-shadow: 0 14px 30px -10px rgb(229 72 90 / 70%), inset 0 -3px 8px rgb(0 0 0 / 22%); }
.mc.is-live .mc-i-stop { display: block; }
.mc.is-live .mc-i-start { display: none; }

.mc-error {
    width: 100%; padding: 12px 14px; border-radius: 14px;
    background: rgb(255 95 109 / 12%); border: 1px solid rgb(255 95 109 / 35%); color: #ffd6da; font-size: .85rem; line-height: 1.45;
}
.mc-error strong { display: block; color: #fff; margin-bottom: 4px; }
.mc-error ul { margin: 0; padding-left: 1.1em; }

/* readout */
.mc-readout-col { min-width: 0; color: #dfe5f7; }
.mc-db { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.mc-db-value { font-size: clamp(2.6rem, 6vw, 3.8rem); font-weight: 800; line-height: 1; color: #fff; font-variant-numeric: tabular-nums; letter-spacing: -.02em; min-width: 3.2ch; }
.mc-db-unit { font-size: .9rem; font-weight: 700; color: #aeb8d6; letter-spacing: .04em; }
.mc-db-unit small { font-size: .7rem; opacity: .75; }
.mc-clip {
    margin-left: auto; align-self: center; padding: 4px 10px; border-radius: 8px;
    font-size: .75rem; font-weight: 800; letter-spacing: .1em;
    background: rgb(255 255 255 / 7%); color: #5a6280; transition: background-color .1s ease, color .1s ease, box-shadow .1s ease;
}
.mc.is-clipping .mc-clip { background: var(--mc-bad); color: #fff; box-shadow: 0 0 16px rgb(255 95 109 / 70%); }

.mc-meter {
    position: relative; height: 26px; margin: 16px 0 26px; border-radius: 8px;
    background:
        repeating-linear-gradient(90deg, transparent 0 calc(2.5% - 2px), rgb(16 22 43 / 90%) calc(2.5% - 2px) 2.5%),
        rgb(255 255 255 / 7%);
}
.mc-meter-fill {
    position: absolute; inset: 0; border-radius: inherit;
    background:
        repeating-linear-gradient(90deg, transparent 0 calc(2.5% - 2px), #10162b calc(2.5% - 2px) 2.5%),
        linear-gradient(90deg, #34f5a6 0%, #22d3ee 55%, #ffb547 80%, #ff5f6d 95%);
    clip-path: inset(0 calc(100% - var(--mc-fill, 0%)) 0 0 round 8px);
}
.mc-meter-peak {
    position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; border-radius: 2px;
    left: var(--mc-peak, 0%); background: #fff; box-shadow: 0 0 8px rgb(255 255 255 / 80%);
    opacity: 0; transition: opacity .2s ease;
}
.mc.is-live .mc-meter-peak { opacity: 1; }
.mc-meter-ticks { position: absolute; left: 0; right: 0; top: 100%; height: 18px; }
.mc-meter-ticks i { position: absolute; top: 4px; transform: translateX(-50%); font-style: normal; font-size: .68rem; font-weight: 600; color: #7d87a8; font-variant-numeric: tabular-nums; }
.mc-meter-ticks i:first-child { transform: none; }
.mc-meter-ticks i:last-child { transform: translateX(-100%); }

.mc-peak-line { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 14px; font-size: .82rem; color: #aeb8d6; }
.mc-peak-line b { color: #fff; font-variant-numeric: tabular-nums; }

.mc-scopes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mc-scope { margin: 0; min-width: 0; }
.mc-scope canvas { display: block; width: 100%; height: 118px; border-radius: 14px; background: rgb(5 8 18 / 70%); border: 1px solid rgb(255 255 255 / 8%); }
.mc-scope figcaption { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #7d87a8; }
.mc-scope figcaption span { text-transform: none; letter-spacing: 0; font-weight: 600; }

/* ---------- panel ---------- */

.mc-panel { padding: 22px clamp(16px, 4vw, 36px) 26px; }

.mc-status {
    margin: 0; padding: 12px 16px; border-radius: 14px;
    background: #f4f7ff; border: 1px solid #dce6fb; font-weight: 600; color: #1d3a7a;
}
.mc[data-state="error"] .mc-status { background: #fff4f5; border-color: #f8d0d5; color: #9b1c2c; }

.mc-label { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mc-muted); }

.mc-cards { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 14px; margin-top: 16px; }
.mc-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 16px 18px; border-radius: 18px; background: #f6f8fc; border: 1px solid var(--mc-line); }

.mc-noise { display: flex; align-items: baseline; gap: 8px; }
.mc-big { font-size: 1.9rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.mc-noise-unit { font-size: .8rem; font-weight: 600; color: var(--mc-muted); }
.mc-verdict { font-size: .88rem; color: var(--mc-muted); line-height: 1.4; }
.mc-verdict.is-good { color: #127a4c; font-weight: 600; }
.mc-verdict.is-warn { color: #b26a00; font-weight: 600; }
.mc-verdict.is-bad { color: #b3263a; font-weight: 600; }
.mc-noise-bar { position: relative; display: block; height: 8px; margin-top: 4px; border-radius: 999px; background: linear-gradient(90deg, #34f5a6, #22d3ee 40%, #ffb547 70%, #ff5f6d); }
.mc-noise-bar span { position: absolute; top: -4px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: #fff; border: 3px solid var(--mc-ink); left: var(--mc-noise, 0%); opacity: 0; transition: left .6s ease, opacity .3s ease; }
.mc-noise-bar.is-set span { opacity: 1; }

.mc-rec-row { display: flex; align-items: center; gap: 14px; }
.mc-rec {
    position: relative; flex: none; width: 60px; height: 60px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
    background: #fff; box-shadow: 0 6px 16px -8px rgb(16 22 43 / 45%);
    transition: transform .12s ease, opacity .2s ease;
}
.mc-rec svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.mc-rec-track { fill: none; stroke: #e3e7f1; stroke-width: 3; }
.mc-rec-progress { fill: none; stroke: var(--mc-bad); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 100.53; stroke-dashoffset: calc(100.53 * (1 - var(--mc-rec, 0))); }
.mc-rec-dot { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: var(--mc-bad); transition: border-radius .2s ease, transform .2s ease; }
.mc.is-recording .mc-rec-dot { border-radius: 5px; transform: scale(.85); animation: mc-recpulse 1s ease-in-out infinite; }
@keyframes mc-recpulse { 50% { opacity: .6; } }
.mc-rec:hover:not(:disabled) { transform: scale(1.05); }
.mc-rec:active:not(:disabled) { transform: scale(.94); }
.mc-rec:disabled { opacity: .45; cursor: default; }
.mc-rec-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.mc-rec-info strong { font-size: 1rem; }
.mc-rec-info span { font-size: .84rem; color: var(--mc-muted); line-height: 1.35; }

.mc-play {
    flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--mc-line); background: #fff; color: var(--mc-ink); font-weight: 700; font-size: .9rem;
    box-shadow: 0 4px 10px -6px rgb(16 22 43 / 40%); transition: transform .12s ease, opacity .2s ease, background-color .15s ease;
}
.mc-play svg { width: 16px; height: 16px; }
.mc-play .mc-i-pause { display: none; }
.mc-play[aria-pressed="true"] { background: var(--mc-ink); color: #fff; }
.mc-play[aria-pressed="true"] .mc-i-pause { display: block; }
.mc-play[aria-pressed="true"] .mc-i-play { display: none; }
.mc-play:hover:not(:disabled) { background: #f4f7ff; }
.mc-play[aria-pressed="true"]:hover { background: #1d2440; }
.mc-play:active:not(:disabled) { transform: scale(.95); }
.mc-play:disabled { opacity: .45; cursor: default; }
.mc-rec:focus-visible, .mc-play:focus-visible, .mc-switch:focus-visible, .mc .mc-download:focus-visible { outline: 3px solid var(--mc-accent); outline-offset: 2px; }

.mc-playbars { display: flex; align-items: center; gap: 3px; height: 34px; margin-top: 2px; }
.mc-playbars i { flex: 1; height: 100%; border-radius: 3px; background: linear-gradient(180deg, var(--mc-accent-2), var(--mc-accent)); transform: scaleY(.08); transform-origin: center; opacity: .35; transition: transform .06s linear, opacity .2s ease; }
.mc.is-playing .mc-playbars i { opacity: 1; }
.mc .mc-download { align-self: flex-start; font-size: .84rem; font-weight: 700; color: var(--mc-accent); text-decoration: none; }
.mc .mc-download:hover { text-decoration: underline; }

.mc-processing { margin-top: 14px; padding: 16px 18px; border-radius: 18px; border: 1px solid var(--mc-line); }
.mc-processing-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
.mc-processing-note { font-size: .8rem; color: var(--mc-muted); }
.mc-switches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.mc-switch {
    display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 10px; align-items: center;
    min-height: 60px; padding: 10px 12px; border-radius: 14px; cursor: pointer; text-align: left;
    border: 1px solid var(--mc-line); background: #f6f8fc; color: var(--mc-ink);
    transition: background-color .15s ease, border-color .15s ease;
}
.mc-switch:hover { border-color: #c9d6f2; }
.mc-switch:disabled { cursor: progress; opacity: .7; }
.mc-switch-track { grid-row: 1 / 3; position: relative; width: 40px; height: 24px; border-radius: 999px; background: #c9cfdf; transition: background-color .2s ease; }
.mc-switch-track span { position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: transform .2s cubic-bezier(.3, 1.4, .5, 1); }
.mc-switch[aria-pressed="true"] .mc-switch-track { background: var(--mc-accent); }
.mc-switch[aria-pressed="true"] .mc-switch-track span { transform: translateX(16px); }
.mc-switch-name { font-size: .88rem; font-weight: 700; }
.mc-switch-applied { justify-self: start; margin-top: 2px; padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; background: #e9ecf4; color: var(--mc-muted); }
.mc-switch-applied.is-on { background: #dff7ec; color: #127a4c; }
.mc-switch-applied.is-off { background: #eceef4; color: #5b6275; }
.mc-switch-applied.is-mismatch { background: #fff1db; color: #945800; }

.mc-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 12px 0 0; }
.mc-facts div { min-width: 0; }
.mc-facts dt { font-size: .75rem; font-weight: 600; color: var(--mc-muted); }
.mc-facts dd { margin: 0; font-weight: 700; font-size: .92rem; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.mc-note { margin: 16px 0 0; font-size: .88rem; color: var(--mc-muted); line-height: 1.55; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
    .mc-stage { grid-template-columns: 1fr; }
    .mc-mic-col { flex-direction: row; justify-content: center; flex-wrap: wrap; }
    .mc-mic { width: 130px; }
    .mc-cards { grid-template-columns: 1fr; }
    .mc-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 575.98px) {
    .mc { border-radius: 22px; margin-inline: -4px; }
    .mc-topbar { padding: 12px 14px; }
    .mc-picker { flex: 1 1 100%; }
    .mc-mic-col { flex-direction: column; gap: 12px; }
    .mc-mic { width: 110px; }
    .mc-scopes { grid-template-columns: 1fr; }
    .mc-scope canvas { height: 96px; }
    .mc-switches { grid-template-columns: 1fr; }
    .mc-rec-row { flex-wrap: wrap; }
    .mc-rec-info { flex-basis: calc(100% - 80px); }
    .mc-play { margin-left: 74px; }
}

@media (pointer: coarse) {
    .mc-select { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    .mc *, .mc *::before, .mc *::after { animation: none !important; transition: none !important; }
}
