/*
 * Beat microphone-avatar: Nightshift, a streaming desk where a visitor's voice comes out
 * of Pip (web/landing/sections/microphone-avatar.html). Linked in the page head by
 * lib/landing.ts while the beat is enabled; the shells' sheets it builds on are linked
 * by the page itself, once each and before every section sheet. Every class here starts
 * with the beat id and every rule is scoped by [data-beat]: the frame's variant
 * (microphone-avatar-nightshift) is styled here and nowhere else.
 *
 * Layout: the copy above, the desk below at the full width. Inside the desk, the broadcast
 * preview (Pip) on the left and the input column on the right (the line to read, the
 * microphone's state and level, the countdown and the buffered output), the small timeline
 * across both. Narrow: the preview at the full width, then the input column, the timeline
 * and the controls under it.
 */

[data-beat="microphone-avatar"] .use-case-mount { margin-top: clamp(24px, 4vh, 40px); }

/* ── The desk's layout ─────────────────────────────────────────────────── */

[data-beat="microphone-avatar"] .demo-frame-body { grid-template-areas: "stage" "main" "aside"; }

@container demo-frame (min-width: 640px) {
  [data-beat="microphone-avatar"] .demo-frame-body {
    grid-template-columns: minmax(0, 1.25fr) minmax(250px, 1fr);
    grid-template-areas:
      "stage main"
      "aside aside";
    align-items: stretch;
  }
}

[data-beat="microphone-avatar"] .demo-frame-slot[data-slot="main"] {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
}

/* ── The broadcast preview ─────────────────────────────────────────────── */

[data-beat="microphone-avatar"] .microphone-avatar-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  padding: 10px 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0e0b14;
}

[data-beat="microphone-avatar"] .microphone-avatar-preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  color: var(--muted);
}

/* The tally: dark at rest, lit while Pip's voice is playing. */
[data-beat="microphone-avatar"] .microphone-avatar-tally {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--line);
  transition: background .12s, box-shadow .12s;
}

[data-beat="microphone-avatar"] .microphone-avatar-tally[data-on] {
  background: #ff5d5d;
  box-shadow: 0 0 0 3px color-mix(in srgb, #ff5d5d 25%, transparent);
}

[data-beat="microphone-avatar"] .microphone-avatar-cam {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-beat="microphone-avatar"] .microphone-avatar-timecode {
  margin-left: auto;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

[data-beat="microphone-avatar"] .microphone-avatar-stage {
  align-self: center;
  max-width: 360px;
  box-shadow: none;
}

/* ── The input column ──────────────────────────────────────────────────── */

[data-beat="microphone-avatar"] .microphone-avatar-line { margin: 0; }

[data-beat="microphone-avatar"] .microphone-avatar-line-label,
[data-beat="microphone-avatar"] .microphone-avatar-readout dt {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

[data-beat="microphone-avatar"] .microphone-avatar-line-text {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: clamp(20px, 2.4vw, 25px);
  line-height: 1.35;
  font-weight: 500;
  color: var(--text);
}

[data-beat="microphone-avatar"] .microphone-avatar-input {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 55%, var(--panel));
}

[data-beat="microphone-avatar"] .microphone-avatar-mic {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
}

[data-beat="microphone-avatar"] .microphone-avatar-dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--muted);
}

[data-beat="microphone-avatar"] .microphone-avatar-mic[data-state="asking"] .microphone-avatar-dot { background: #f2c26b; box-shadow: none; }
[data-beat="microphone-avatar"] .microphone-avatar-mic[data-state="live"] .microphone-avatar-dot,
[data-beat="microphone-avatar"] .microphone-avatar-mic[data-state="sample"] .microphone-avatar-dot { background: #ff5d5d; box-shadow: none; }

/* The slim input meter: its fill is the level, -60 to 0 dBFS. */
[data-beat="microphone-avatar"] .microphone-avatar-meter {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--ink);
}

[data-beat="microphone-avatar"] .microphone-avatar-meter i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  transform: scaleX(var(--level, 0));
  transform-origin: left center;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0 70%, #f2c26b 85%, #ff5d5d);
  background-size: 100% 100%;
  transition: transform .06s linear;
}

[data-beat="microphone-avatar"] .microphone-avatar-readouts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin: 2px 0 0;
}

[data-beat="microphone-avatar"] .microphone-avatar-readout {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  gap: 2px;
  min-width: 0;
}

[data-beat="microphone-avatar"] .microphone-avatar-readout dt {
  font-size: 10.5px;
  letter-spacing: .08em;
  line-height: 1.35;
}

[data-beat="microphone-avatar"] .microphone-avatar-readout dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 22px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

/* ── The timeline and the controls ─────────────────────────────────────── */

[data-beat="microphone-avatar"] .demo-frame-slot[data-slot="aside"] {
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 55%, var(--panel));
}

[data-beat="microphone-avatar"] .microphone-avatar-headphones {
  font-size: 12.5px;
  color: var(--muted);
}

[data-beat="microphone-avatar"] .microphone-avatar-headphones[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  [data-beat="microphone-avatar"] .microphone-avatar-meter i,
  [data-beat="microphone-avatar"] .microphone-avatar-tally { transition: none; }
}
