/* Wavelets Keyboard — shares the site design tokens from /theme.css (linked
   before this file) and mirrors the Wavelets/BPM component style (topbar,
   footer controls, About panel). Keyboard-specific bits: the full-width stage
   canvas and the "press ▶" box. Unlike Wavelets, the app column is NOT capped
   at 640px — the keyboard is meant to grow wide on desktop screens. */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; margin: 0; overscroll-behavior: none; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;    /* Safari/iOS honor only the prefixed one for double-tap selection */
  -webkit-touch-callout: none;  /* no long-press copy/… callout */
  overflow: hidden;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header — same treatment as Wavelets/BPM: small, uppercase, dim, spaced. */
.topbar {
  padding: env(safe-area-inset-top, 16px) 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.topbar h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* The canvas is sized to the keyboard's height by keyboard.js; the stage
   flex-centers it vertically (so portrait is never taller than landscape and the
   keyboard sits centered in the available space). */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
#kbd { display: block; width: 100%; touch-action: none; }

/* Auto-scroll toggle, in the room below the centered keyboard. */
.kbd-controls { display: flex; justify-content: center; align-items: center; gap: 8px; }
.toggle-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  padding: 6px 18px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}
.toggle-btn.active { color: var(--accent); border-color: var(--accent-dim); background: var(--bg-panel); }

/* Scrub bar (time review) — same as Wavelets. */
.scrub-bar {
  flex: 0 0 auto;
  padding: 0 16px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.scrub-track {
  position: relative;
  flex: 1;
  height: 28px;
  background: var(--bg-panel);
  border-radius: 999px;
  touch-action: none;
}
.scrub-thumb {
  position: absolute;
  top: 3px; bottom: 3px;
  left: 3px;
  width: 22px;
  border-radius: 999px;
  background: var(--accent);
}
.live-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.live-btn.active { border-color: var(--accent); color: var(--accent); }

.hint {
  flex: 0 0 auto;
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
  margin: 0;
  padding: 4px 12px;
  min-height: 1.3em;
}

/* "Press ▶ to start" box — shown centered over the idle keyboard, in the family
   panel style. Non-interactive so taps reach the real play button below. */
.press-start {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: auto;         /* the hint is itself a play button */
  cursor: pointer;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 22px;
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}
.press-start[hidden] { display: none; }
.press-start .ps-play { color: var(--accent); font-size: 1.05rem; }

/* Footer controls — identical to Wavelets. */
.controls {
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;              /* mic picker can wrap to its own line on a narrow phone */
  gap: 12px;
  flex: 0 0 auto;
}

/* Microphone picker — a circular icon button (matches reload/about) with an
   invisible native <select> laid over it, shown only when there's a choice. */
.mic-btn { position: relative; overflow: hidden; }
.mic-btn[hidden] { display: none; } /* .icon-btn sets display:flex, which outranks the UA [hidden] rule */
.mic-ico { width: 20px; height: 20px; display: block; }
.mic-select-overlay {
  position: absolute;
  inset: 0;
  opacity: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  font-size: 16px; /* keep iOS from zoom-on-focus */
}
.icon-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: var(--surface-active); color: var(--text); border-color: var(--accent-dim); }
.start-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  padding: 12px 40px;
  border-radius: 999px;
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
}
.start-btn.active { color: var(--accent); border-color: var(--accent-dim); }
.start-btn:active { background: var(--surface-active); color: var(--text); }

/* About overlay + panel — identical to Wavelets. */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
}
.overlay[hidden] { display: none; }
.about-panel {
  position: relative;
  background: var(--bg-panel);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}
.about-panel h2 { margin: 0 0 16px; font-size: 1.25rem; color: var(--text); }
.about-panel h3 { margin: 20px 0 6px; font-size: 0.95rem; color: var(--accent); }
.about-panel h3:first-of-type { margin-top: 0; }
.about-panel p { margin: 0 0 8px; font-size: 0.92rem; line-height: 1.55; color: var(--text-dim); }
.about-panel strong { color: var(--text); font-weight: 600; }
.about-panel a { color: var(--accent); }
.about-close {
  position: absolute;
  top: 12px; right: 12px;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.about-close:active { color: var(--text); }

/* First-load progress box — same look as Wavelets' #bpProgress. */
#bpProgress {
  position: fixed;
  left: 50%; top: 44%;
  transform: translateX(-50%);
  z-index: 60;
  width: min(80vw, 440px);
  background: rgba(18, 20, 26, 0.96);
  border: 1px solid rgba(94, 234, 212, 0.45);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
  text-align: center;
}
#bpProgress[hidden] { display: none; }
#bpProgressLabel { display: block; color: #e8eaf0; font-size: 15px; font-weight: 600; margin-bottom: 10px; }
#bpProgressTrack { height: 12px; background: rgba(255, 255, 255, 0.12); border-radius: 6px; overflow: hidden; }
#bpProgressFill { height: 100%; width: 0; background: #e879f9; border-radius: 6px; }
