/* ============================================================================
   mic.css — Buddy (V9) microphone tester: mascot, hero, test card, segmented
   meter, waveform, verdict bubble, vibe tiles, tip card, score card, modal.
   Tokens only; no literal hex (enforced). Accent flows via var(--ac) / --ac-soft
   set by the body.k-* class — and is NEVER transitioned (snap), per spec §3.
   ============================================================================ */

/* --- Hero ------------------------------------------------------------------ */
.hero-buddy {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding-block: var(--space-6) var(--space-5);
}
.hero-text {
  flex: 1;
}
.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--indigo);
  background: var(--indigo-soft);
  border: 2px solid var(--line);
  box-shadow: var(--sticker-sm);
  border-radius: var(--r-pill);
  padding: var(--space-1) var(--space-3);
  margin-bottom: var(--space-3);
}
.hero-buddy h1 {
  font-size: var(--fs-hero);
  letter-spacing: -0.02em;
}
.hero-buddy h1 .accent {
  color: var(--indigo);
}
.hero-sub {
  margin-top: var(--space-3);
  color: var(--ink-soft);
  max-width: 52ch;
}

/* --- Mascot (§5) — pure CSS face, color reacts to state -------------------- */
.mascot {
  position: relative;
  width: 120px;
  height: 120px;
  flex: none;
  border-radius: 34px;
  background: var(--ac); /* snaps — no transition */
  border: 3px solid var(--line);
  box-shadow: var(--sticker-lg);
  animation: bobf 3s ease-in-out infinite;
}
@keyframes bobf {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}
.mascot .eye {
  position: absolute;
  top: 40px;
  width: 18px;
  height: 22px;
  border-radius: 50%;
  background: var(--line);
  transition: height var(--dur-base) var(--ease), top var(--dur-base) var(--ease);
}
.mascot .eye-l {
  left: 32px;
}
.mascot .eye-r {
  right: 32px;
}
.mascot .blush {
  position: absolute;
  top: 60px;
  width: 20px;
  height: 12px;
  border-radius: 50%;
  background: color-mix(in srgb, white 36%, transparent);
}
.mascot .blush-l {
  left: 18px;
}
.mascot .blush-r {
  right: 18px;
}
.mascot .mouth {
  position: absolute;
  left: 50%;
  top: 70px;
  transform: translateX(-50%);
  width: 46px;
  height: 24px;
  border: 0 solid var(--line);
  border-bottom-width: 5px;
  border-radius: 0 0 44px 44px;
  transition: border-width var(--dur-base) var(--ease),
    width var(--dur-base) var(--ease), height var(--dur-base) var(--ease),
    border-radius var(--dur-base) var(--ease), top var(--dur-base) var(--ease);
}
/* face variants */
.mascot.face-worried .mouth {
  top: 82px;
  height: 18px;
  border-bottom-width: 0;
  border-top-width: 5px;
  border-radius: 44px 44px 0 0;
}
.mascot.face-flat .mouth {
  top: 80px;
  width: 34px;
  height: 0;
  border-bottom-width: 5px;
  border-radius: 6px;
}
.mascot.face-sleepy .mouth {
  top: 76px;
  width: 26px;
  height: 13px;
  border-bottom-width: 5px;
}
.mascot.face-sleepy .eye {
  height: 5px;
  top: 50px;
  border-radius: 5px;
}
.mascot .wave {
  position: absolute;
  top: -14px;
  right: -10px;
  font-size: 28px;
  display: none;
  transform-origin: 70% 70%;
}
.mascot.face-happy .wave {
  display: block;
  animation: wavef 1s ease-in-out 2;
}
@keyframes wavef {
  0%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(18deg);
  }
  75% {
    transform: rotate(-12deg);
  }
}
.mascot.cheer {
  animation: cheer 0.65s var(--ease);
}
@keyframes cheer {
  0%,
  100% {
    transform: translateY(0) rotate(0);
  }
  30% {
    transform: translateY(-20px) scale(1.06) rotate(-4deg);
  }
  60% {
    transform: translateY(0) scale(1) rotate(3deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .mascot {
    animation: none;
  }
  .mascot.cheer {
    animation: none;
  }
  .mascot .wave {
    animation: none;
  }
  .mascot .eye,
  .mascot .mouth {
    transition: none;
  }
}

/* --- Main grid ------------------------------------------------------------- */
.tool {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: var(--space-5);
  padding-bottom: var(--space-7);
  align-items: start;
}
@media (max-width: 860px) {
  .tool {
    grid-template-columns: 1fr;
  }
  .hero-buddy {
    flex-direction: column;
    text-align: center;
  }
  .hero-sub {
    margin-inline: auto;
  }
}

/* --- Test card ------------------------------------------------------------- */
.test-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.device-tag {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--ink-dim);
}

/* dB readout (§6.2) */
.db-readout {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.db-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-num);
  line-height: 0.82;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ac); /* snaps */
}
.db-unit {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink-dim);
}
.db-cap {
  margin-left: auto;
  align-self: flex-end;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* segmented meter (§6.3) */
.meter {
  display: flex;
  gap: 5px;
  height: 26px;
}
.seg {
  flex: 1;
  border-radius: 7px;
  border: 2px solid var(--line);
  background: var(--surface);
  transition: transform 0.12s var(--ease); /* transform only — bg snaps */
}
.seg.on {
  background: var(--ac);
  transform: scaleY(1.12);
}
@media (prefers-reduced-motion: reduce) {
  .seg {
    transition: none;
  }
  .seg.on {
    transform: none;
  }
}

/* waveform (§6.4) */
.wavebox {
  height: 92px;
  border: 2px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--sticker-sm);
  overflow: hidden;
}
.wavebox canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* verdict bubble (§6.5) */
.verdict {
  position: relative;
  background: var(--ac-soft); /* snaps */
  border: 3px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sticker);
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-4);
  margin-top: var(--space-2);
}
.verdict::before {
  content: "";
  position: absolute;
  top: -13px;
  left: 34px;
  width: 22px;
  height: 22px;
  background: var(--ac-soft);
  border-left: 3px solid var(--line);
  border-top: 3px solid var(--line);
  transform: rotate(45deg);
  border-top-left-radius: 6px;
}
.verdict-head-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.verdict-icon-chip {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 11px;
  background: var(--canvas);
  border: 2px solid var(--line);
  color: var(--ac);
}
.verdict-icon-chip .icon {
  width: 20px;
  height: 20px;
}
.verdict-head {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--ink);
}
.verdict-detail {
  margin-top: var(--space-2);
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.verdict-action {
  margin-top: var(--space-3);
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.verdict-action .btn {
  min-height: 38px;
  font-size: 0.85rem;
  padding: 0 var(--space-4);
}
.verdict-action ol {
  margin: var(--space-1) 0 0 var(--space-4);
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* action buttons (§6.6) */
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.action-row .btn {
  flex: 1 1 auto;
}
.btn.stop {
  background: var(--canvas);
  color: var(--ink);
}
@media (max-width: 600px) {
  .action-row .btn {
    flex-basis: 100%;
  }
}

/* inline recorder */
.recorder {
  display: none;
  align-items: center;
  gap: var(--space-3);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--sticker-sm);
  padding: var(--space-2) var(--space-3);
}
.recorder[data-show="true"] {
  display: flex;
}
.recorder audio {
  width: 100%;
  height: 38px;
}

/* --- Side column ----------------------------------------------------------- */
.side {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.side-head {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
}
.side-sub {
  font-size: 0.82rem;
  color: var(--ink-dim);
  margin-top: 2px;
  margin-bottom: var(--space-3);
}

/* score card (folded-in quality score) */
.score-card {
  background: var(--canvas);
  border: 3px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sticker-lg);
  padding: var(--space-4) var(--space-5);
}
.score-top {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.score-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.6rem;
  line-height: 0.9;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ac);
}
.score-max {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink-dim);
}
.score-grade {
  margin-left: auto;
  align-self: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: var(--ac-soft);
  border: 2px solid var(--line);
  border-radius: var(--r-pill);
  padding: 2px var(--space-3);
}
.score-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: var(--space-1);
}
.score-best {
  margin-top: var(--space-2);
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.score-card[data-show="false"] .score-best {
  display: none;
}

/* vibe-check tiles (§7) */
.vibe-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.vtile {
  border: 2px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: var(--sticker-sm);
  padding: var(--space-3) var(--space-4);
  transition: transform var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}
.vtile:hover {
  transform: translate(-1px, -1px);
  box-shadow: var(--sticker);
}
.vtile-noise {
  background: var(--teal-soft);
}
.vtile-clip {
  background: var(--amber-soft);
}
.vtile-channels {
  background: var(--sky-soft);
}
.vtile-rate {
  background: var(--lime-soft);
}
.vtile-label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.vtile-label .icon {
  width: 14px;
  height: 14px;
}
.vtile-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--ink);
  margin-top: 2px;
}
.vtile-sub {
  font-size: 0.76rem;
  color: var(--ink-soft);
}
@media (prefers-reduced-motion: reduce) {
  .vtile:hover {
    transform: none;
  }
}

/* tip card (§7.12) */
.tip-card {
  background: linear-gradient(135deg, var(--indigo-soft), var(--pink-soft));
  border: 2px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sticker);
  padding: var(--space-4);
  display: flex;
  gap: var(--space-3);
}
.tip-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  background: var(--canvas);
  border: 2px solid var(--line);
  color: var(--indigo);
  animation: wobble 4s ease-in-out infinite;
}
.tip-icon .icon {
  width: 20px;
  height: 20px;
}
@keyframes wobble {
  0%,
  100% {
    transform: rotate(-6deg);
  }
  50% {
    transform: rotate(6deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .tip-icon {
    animation: none;
  }
}
.tip-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--ink);
}
.tip-body {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 2px;
}

/* controls block */
.controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.processing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.processing-pill {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* guide links (footer of card) */
.guide-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}
.guide-links .label {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.85rem;
}
.guide-links a {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.85rem;
}

/* --- Headphones modal (§8) ------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: color-mix(in srgb, var(--ink) 45%, transparent);
}
.modal-backdrop[data-show="true"] {
  display: flex;
}
.modal {
  background: var(--canvas);
  border: 3px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sticker-lg);
  padding: var(--space-5);
  max-width: 380px;
  width: 100%;
  text-align: center;
  animation: modal-pop var(--dur-base) var(--ease);
}
@keyframes modal-pop {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.modal-emoji {
  font-size: 40px;
}
.modal h2 {
  margin: var(--space-2) 0;
}
.modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-4);
}
@media (prefers-reduced-motion: reduce) {
  .modal {
    animation: none;
  }
}

/* spinner (requesting) */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid color-mix(in srgb, var(--ac-contrast) 40%, transparent);
  border-top-color: var(--ac-contrast);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}
