/* ============================================================
   DJ VISUALIZER — MAIN STYLESHEET
   Design language: professional VJ software / club aesthetic
   Inspired by Resolume, TouchDesigner
   ============================================================ */

/* ------------------------------------------------------------
   BASE RESET & GLOBAL
   ------------------------------------------------------------ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #000;
  overflow: hidden;
  font-family: 'Share Tech Mono', monospace;
}

/* ------------------------------------------------------------
   VISUALIZER CANVAS CONTAINER
   ------------------------------------------------------------ */
#viz-container {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* ------------------------------------------------------------
   UI OVERLAY
   ------------------------------------------------------------ */
#ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.6s ease;
}

#ui * {
  pointer-events: all;
}

/* Auto-hide: JS adds .fade-out after 4s of no interaction */
#ui.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* body.ui-hidden hides the overlay (alternative CSS-driven hide) */
body.ui-hidden #ui {
  opacity: 0;
  transition: opacity 0.6s ease;
}

/* Children remain clickable regardless of overlay opacity */
body.ui-hidden #ui * {
  pointer-events: all;
}

/* ------------------------------------------------------------
   BRAND — top-left
   ------------------------------------------------------------ */
#brand {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
}

#brand-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.9);
  text-transform: uppercase;
  white-space: nowrap;
}

#brand-icon {
  width: 28px;
  height: 28px;
  color: rgba(0, 210, 255, 0.9);
  flex-shrink: 0;
}

/* SVG inherits currentColor */
#brand-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

/* ------------------------------------------------------------
   TOP CONTROLS — top-right
   ------------------------------------------------------------ */
#top-controls {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
}

/* ------------------------------------------------------------
   BUTTONS — general
   ------------------------------------------------------------ */
button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(0, 210, 255, 0.4);
  color: rgba(0, 210, 255, 0.9);
}

button:focus-visible {
  outline: 1px solid rgba(0, 210, 255, 0.5);
  outline-offset: 2px;
}

/* ------------------------------------------------------------
   MIC BUTTON
   ------------------------------------------------------------ */
@keyframes micPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

#btn-mic {
  padding: 0.5rem 1rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
}

#btn-mic.active {
  background: rgba(0, 210, 255, 0.15);
  border-color: rgba(0, 210, 255, 0.6);
  color: rgba(0, 210, 255, 1);
  box-shadow: 0 0 20px rgba(0, 210, 255, 0.3);
  animation: micPulse 1.2s ease-in-out infinite;
}

/* ------------------------------------------------------------
   FULLSCREEN BUTTON
   ------------------------------------------------------------ */
#btn-fullscreen {
  width: 40px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* ------------------------------------------------------------
   BOTTOM BAR
   ------------------------------------------------------------ */
#bottom-bar {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1.5rem;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.75rem 1.5rem;
  white-space: nowrap;
}

/* Subtle separator between groups */
#bottom-bar > * + * {
  position: relative;
}

/* ------------------------------------------------------------
   SCENE TABS
   ------------------------------------------------------------ */
#scene-tabs {
  display: flex;
  flex-direction: row;
  gap: 0.35rem;
}

.scene-tab {
  padding: 0.4rem 0.9rem;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  border-radius: 4px;
  text-transform: uppercase;
}

.scene-tab.active {
  background: rgba(0, 210, 255, 0.2);
  border-color: rgba(0, 210, 255, 0.5);
  color: rgba(0, 210, 255, 1);
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.2);
}

/* ------------------------------------------------------------
   TAP TEMPO
   ------------------------------------------------------------ */
@keyframes tapRipple {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(3);
    opacity: 0;
  }
}

#tap-tempo {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
}

#btn-tap {
  padding: 0.4rem 1rem;
  position: relative;
  overflow: hidden;
}

/* Ripple element injected by JS: <span class="tap-ripple"> */
#btn-tap .tap-ripple {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(0, 210, 255, 0.25);
  pointer-events: none;
  animation: tapRipple 0.4s ease-out forwards;
  transform-origin: center;
}

#bpm-display {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  color: rgba(0, 210, 255, 0.8);
  min-width: 70px;
  text-align: left;
  letter-spacing: 0.05em;
}

/* ------------------------------------------------------------
   STATUS DOT
   ------------------------------------------------------------ */
@keyframes dotPulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 8px #00d2ff;
  }
  50% {
    opacity: 0.4;
    box-shadow: 0 0 3px #00d2ff;
  }
}

#status-dot {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
}

#status-dot .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}

#status-dot.listening .dot {
  background: #00d2ff;
  box-shadow: 0 0 8px #00d2ff;
  animation: dotPulse 1.6s ease-in-out infinite;
}

/* ------------------------------------------------------------
   OBS MODE — transparent background, no UI
   ------------------------------------------------------------ */
body.obs-mode #ui {
  display: none;
}

body.obs-mode {
  background: transparent !important;
}

body.obs-mode #viz-container canvas {
  background: transparent !important;
}

/* ------------------------------------------------------------
   RESPONSIVE — 768px and below
   ------------------------------------------------------------ */
@media (max-width: 768px) {
  /* Hide brand text; keep icon */
  #brand-text {
    display: none;
  }

  /* Bottom bar wraps on small screens */
  #bottom-bar {
    flex-wrap: wrap;
    justify-content: center;
    padding: 0.5rem 1rem;
    gap: 0.75rem;
    bottom: 1rem;
    max-width: calc(100vw - 2rem);
  }

  /* Smaller scene tab labels */
  .scene-tab {
    font-size: 0.55rem;
    padding: 0.35rem 0.65rem;
  }
}

/* ------------------------------------------------------------
   SCENE TOAST — brief scene name flash on switch
   ------------------------------------------------------------ */
#scene-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Orbitron', sans-serif;
  font-size: 3rem;
  font-weight: 300;
  letter-spacing: 0.4em;
  color: rgba(0, 210, 255, 0.0);
  pointer-events: none;
  z-index: 20;
  transition: color 0.15s ease, opacity 0.5s ease;
  opacity: 0;
  text-shadow: 0 0 40px rgba(0, 210, 255, 0.6);
  white-space: nowrap;
}

#scene-toast.show {
  opacity: 1;
  color: rgba(0, 210, 255, 0.85);
  animation: toastFade 1.2s ease forwards;
}

@keyframes toastFade {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1);   }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.05); }
}

/* ------------------------------------------------------------
   LYRICS OVERLAY — floating detected words + transcript line
   ------------------------------------------------------------ */

/* Individual mood-trigger words — float up and fade out */
#lyric-overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  overflow: hidden;
}

.lyric-word {
  position: absolute;
  font-family: 'Orbitron', sans-serif;
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  pointer-events: none;
  animation: lyricFloat 3.5s ease-out forwards;
  text-shadow: 0 0 20px currentColor, 0 0 60px currentColor;
  opacity: 0;
  white-space: nowrap;
}

@keyframes lyricFloat {
  0%   { opacity: 0; transform: translateY(20px) scale(0.8); filter: blur(4px); }
  15%  { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
  60%  { opacity: 0.8; }
  100% { opacity: 0; transform: translateY(-80px) scale(1.1); filter: blur(2px); }
}

/* Full transcript line — bottom of screen, subtle */
#lyric-line {
  position: fixed;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  pointer-events: none;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.35);
  text-align: center;
  max-width: 80vw;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: color 0.3s, opacity 0.5s;
  opacity: 0;
}

#lyric-line.visible {
  opacity: 1;
}

#lyric-line.interim {
  color: rgba(255, 255, 255, 0.2);
  font-style: italic;
}

/* Lyrics button styling */
#btn-lyrics {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
}

#btn-lyrics svg {
  width: 16px;
  height: 16px;
}

#btn-lyrics.active {
  background: rgba(170, 68, 255, 0.15);
  border-color: rgba(170, 68, 255, 0.6);
  color: rgba(170, 68, 255, 1);
  box-shadow: 0 0 20px rgba(170, 68, 255, 0.3);
}

/* Mood flash — brief fullscreen color wash on mood change */
#mood-flash {
  position: fixed;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease-in;
  mix-blend-mode: screen;
}

#mood-flash.active {
  opacity: 1;
  animation: moodFlashFade 1.2s ease-out forwards;
}

@keyframes moodFlashFade {
  0%   { opacity: 0.4; }
  100% { opacity: 0; }
}

/* ------------------------------------------------------------
   LYRICS CAPTURE PANEL — slide-up overlay showing real-time lyrics
   ------------------------------------------------------------ */
.lyrics-panel {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: min(600px, 90vw);
  max-height: 50vh;
  z-index: 30;
  background: rgba(8, 8, 20, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 210, 255, 0.15);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: all;
}

.lyrics-panel.open {
  transform: translateX(-50%) translateY(0);
}

.lyrics-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lyrics-panel-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  color: rgba(0, 210, 255, 0.8);
}

.lyrics-panel-actions {
  display: flex;
  gap: 0.5rem;
}

.lyrics-panel-actions button {
  padding: 0.25rem 0.6rem;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  border-radius: 4px;
}

.lyrics-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.2rem;
  scroll-behavior: smooth;
}

.lyrics-panel-content::-webkit-scrollbar {
  width: 4px;
}

.lyrics-panel-content::-webkit-scrollbar-thumb {
  background: rgba(0, 210, 255, 0.3);
  border-radius: 2px;
}

.lyrics-empty {
  color: rgba(255, 255, 255, 0.2);
  font-size: 0.75rem;
  text-align: center;
  padding: 2rem 0;
  letter-spacing: 0.05em;
}

.lyric-captured-line {
  padding: 0.35rem 0;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.03em;
  line-height: 1.5;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  animation: lyricLineIn 0.3s ease-out;
}

.lyric-captured-line .lyric-timestamp {
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.2);
  margin-right: 0.6rem;
  font-family: 'Share Tech Mono', monospace;
}

.lyric-captured-line .lyric-mood-tag {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.5rem;
  letter-spacing: 0.1em;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

@keyframes lyricLineIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lyrics-interim {
  padding: 0.5rem 1.2rem 0.8rem;
  font-size: 0.75rem;
  color: rgba(0, 210, 255, 0.4);
  font-style: italic;
  min-height: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  letter-spacing: 0.03em;
}

/* Mood tag colors */
.lyric-mood-tag.fire    { background: rgba(255,68,0,0.2); color: #ff4400; }
.lyric-mood-tag.dark    { background: rgba(68,136,255,0.2); color: #4488ff; }
.lyric-mood-tag.love    { background: rgba(255,102,170,0.2); color: #ff66aa; }
.lyric-mood-tag.euphoria { background: rgba(170,68,255,0.2); color: #aa44ff; }
.lyric-mood-tag.speed   { background: rgba(0,255,136,0.2); color: #00ff88; }
.lyric-mood-tag.water   { background: rgba(0,187,255,0.2); color: #00bbff; }
