/* Sound Reactive Type */

:root {
  --font-body:    'Space Grotesk', system-ui, sans-serif;
  --font-display: 'Unbounded', system-ui, sans-serif;
  --glow: rgba(139, 92, 246, 0.25);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--slate);
  color: var(--cloud);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── SKIP + HEADER ───────────────────────────────────────── */

.skip-link {
  position: absolute; top: -4rem; left: 1rem;
  background: var(--violet); color: var(--cloud);
  padding: 0.5rem 1rem; border-radius: 0 0 0.5rem 0.5rem;
  font-size: 0.875rem; text-decoration: none; z-index: 200;
  transition: top 0.15s;
}
.skip-link:focus { top: 0; }

.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--slate-raised);
  gap: 1rem;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 0.6rem; font-size: 0.8rem; }
.back-link { color: var(--violet-muted); text-decoration: none; transition: color 0.15s; }
.back-link:hover { color: var(--cloud); }
.brand-sep { color: var(--slate-raised); }
.brand-name { color: var(--violet-bright); font-weight: 600; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--slate-raised);
  color: var(--violet-muted);
  padding: 0.4rem 0.85rem;
  border-radius: 0.5rem;
  font: 500 0.78rem var(--font-body);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover { border-color: var(--violet); color: var(--cloud); }
.btn-ghost.active { border-color: var(--cyan); color: var(--cyan); }

/* ── MAIN LAYOUT ─────────────────────────────────────────── */

.main-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

/* ── STAGE ───────────────────────────────────────────────── */

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Ambient background pulse driven by JS */
.bg-pulse {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 60%, rgba(139,92,246,0) 0%, transparent 100%);
  pointer-events: none;
  transition: opacity 0.1s;
}

#canvas-wrap {
  position: relative;
  z-index: 1;
}

#canvas-wrap canvas {
  display: block;
}

/* ── CONTROLS BAR ────────────────────────────────────────── */

.controls-bar {
  background: var(--slate-panel);
  border-top: 1px solid var(--slate-raised);
  padding: 1rem 2rem;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.controls-inner {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.ctrl-group { display: flex; flex-direction: column; gap: 0.3rem; }

.ctrl-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--violet-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.val-badge { color: var(--violet-bright); font-weight: 500; font-size: 0.7rem; }

.text-input {
  background: var(--slate-raised);
  border: 1px solid var(--slate-raised);
  color: var(--cloud);
  font: 500 0.875rem var(--font-body);
  padding: 0.45rem 0.75rem;
  border-radius: 0.5rem;
  width: 140px;
  transition: border-color 0.15s;
  letter-spacing: 0.05em;
}
.text-input:hover { border-color: var(--violet-deep); }
.text-input:focus { outline: 2px solid var(--cyan); outline-offset: 2px; border-color: transparent; }

.ctrl-range {
  -webkit-appearance: none; appearance: none;
  width: 120px; height: 0.3rem;
  background: var(--slate-raised);
  border-radius: 999px; cursor: pointer;
}
.ctrl-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 0.9rem; height: 0.9rem; border-radius: 50%;
  background: var(--violet); border: 2px solid var(--cloud);
}
.ctrl-range::-moz-range-thumb {
  width: 0.9rem; height: 0.9rem; border-radius: 50%;
  background: var(--violet); border: 2px solid var(--cloud);
}

/* Mic button */
.mic-group { gap: 0.4rem; }

.btn-mic {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--slate-raised);
  border: 1px solid var(--violet-deep);
  color: var(--violet-bright);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font: 600 0.82rem var(--font-body);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-mic:hover { background: var(--violet-deep); color: var(--cloud); }
.btn-mic.active {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--violet);
  color: var(--cloud);
  animation: mic-pulse 1.4s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0); }
}

.mic-status {
  font-size: 0.65rem;
  color: var(--violet-muted);
  font-style: italic;
}
.mic-status.active { color: var(--cyan); font-style: normal; }

/* Demo mode toggle */
.demo-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.demo-checkbox {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.demo-track {
  display: block;
  width: 32px; height: 18px;
  background: var(--slate-raised);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.demo-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--violet-muted);
  transition: transform 0.2s, background 0.2s;
}
.demo-checkbox:checked + .demo-track { background: var(--violet); }
.demo-checkbox:checked + .demo-track::after {
  transform: translateX(14px);
  background: var(--cloud);
}
.demo-checkbox:focus-visible + .demo-track {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* ── FOOTER ──────────────────────────────────────────────── */

.site-footer {
  padding: 1rem 2rem;
  border-top: 1px solid var(--slate-raised);
  font-size: 0.75rem;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
.site-footer a { color: var(--violet-muted); text-decoration: none; transition: color 0.15s; }
.site-footer a:hover { color: var(--cloud); }

/* ── RESPONSIVE ──────────────────────────────────────────── */

@media (max-width: 700px) {
  .controls-inner { gap: 1rem; }
  .site-header, .controls-bar { padding: 0.9rem 1.25rem; }
  body { overflow: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .btn-mic.active { animation: none; }
}
