/* ========================================================================
   Voice Recorder Component — Wovenkeep GM-Tool
   Design tokens: --bg, --surface, --surface2, --text, --muted, --red, --green
   Waveform colour: #d4a843 (Wovenkeep-Gold)
   ======================================================================== */

/* ---- container ---- */
.voice-recorder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--surface2);
}

/* ---- error message ---- */
.voice-recorder__error {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: rgba(192, 57, 43, 0.15);
  color: var(--red, #c0392b);
  font-size: 0.85rem;
  text-align: center;
}

/* ---- waveform canvas ---- */
.voice-recorder__canvas {
  width: 280px;
  height: 60px;
  border-radius: 8px;
  background: var(--bg, #0d0d14);
}

/* ---- timer ---- */
.voice-recorder__timer {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  color: var(--text, #d4d4d8);
  letter-spacing: 0.05em;
}

/* ---- actions row ---- */
.voice-recorder__actions {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- main mic button ---- */
.voice-recorder__btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--surface2, #252547);
  background: var(--surface2, #252547);
  color: var(--text, #d4d4d8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.voice-recorder__btn:hover {
  border-color: #d4a843;
  box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.2);
}

.voice-recorder__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- recording state (red pulse) ---- */
.voice-recorder__btn--recording {
  background: var(--red, #c0392b);
  border-color: var(--red, #c0392b);
  color: #fff;
  animation: vr-pulse 1.4s ease-in-out infinite;
}

.voice-recorder__btn--recording:hover {
  border-color: var(--red, #c0392b);
  box-shadow: 0 0 0 6px rgba(192, 57, 43, 0.25);
}

@keyframes vr-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.5); }
  70%  { box-shadow: 0 0 0 12px rgba(192, 57, 43, 0); }
  100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0); }
}

/* ---- hint text (e.g. auto-stop message) ---- */
.voice-recorder__hint {
  font-size: 0.8rem;
  color: var(--muted, #71717a);
  text-align: center;
}

/* ---- playback controls ---- */
.voice-recorder__playback {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.voice-recorder__audio {
  width: 100%;
  max-width: 300px;
  height: 36px;
  border-radius: 8px;
}

/* Style the native audio element for dark theme where possible */
.voice-recorder__audio::-webkit-media-controls-panel {
  background: var(--surface2, #252547);
}

.voice-recorder__re-record {
  font-size: 0.85rem;
}

/* ---- state-based visibility ---- */
.voice-recorder[data-state="idle"] .voice-recorder__canvas {
  opacity: 0.4;
}

.voice-recorder[data-state="recording"] .voice-recorder__canvas {
  opacity: 1;
}

.voice-recorder[data-state="recording"] .voice-recorder__timer {
  color: var(--red, #c0392b);
}

.voice-recorder[data-state="recorded"] .voice-recorder__canvas {
  opacity: 0.3;
}
