/* ═══════════════════════════════════════════════════
   SONORA — Sound Visualiser  |  Design System
   ═══════════════════════════════════════════════════ */

/* --- Reset & Base --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:        #0a0a0f;
  --bg-card:   rgba(255,255,255,0.04);
  --bg-card-h: rgba(255,255,255,0.07);
  --border:    rgba(255,255,255,0.06);
  --text:      #e2e8f0;
  --text-dim:  #64748b;
  --text-muted:#475569;
  --accent-1:  #a78bfa;
  --accent-2:  #6ee7b7;
  --glow:      rgba(167,139,250,0.15);
  --radius:    12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --topbar-h:  56px;
  --controls-h:72px;
  --font:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:      'JetBrains Mono', ui-monospace, monospace;
}

html, body {
  height: 100%; width: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* --- Landing Page --- */
.landing {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  overflow: hidden;
}

.landing-bg-rings {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 600px 600px at 50% 50%, rgba(167,139,250,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 900px 900px at 30% 60%, rgba(110,231,183,0.04) 0%, transparent 70%);
}

.landing::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 25% 25%, rgba(167,139,250,0.03) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(110,231,183,0.03) 0%, transparent 50%);
  animation: landingPulse 8s ease-in-out infinite alternate;
}

@keyframes landingPulse {
  0%   { opacity: 0.5; transform: scale(1); }
  100% { opacity: 1;   transform: scale(1.05); }
}

.landing-content {
  position: relative; z-index: 2;
  text-align: center;
  animation: fadeUp 1s ease-out;
}

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

.logo-mark {
  width: 80px; height: 80px;
  margin: 0 auto 28px;
  animation: logoSpin 20s linear infinite;
}

@keyframes logoSpin {
  to { transform: rotate(360deg); }
}

.landing-title {
  font-size: 48px;
  font-weight: 300;
  letter-spacing: 6px;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.landing-sub {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 48px;
}

.landing-actions {
  display: flex; gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-landing {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 28px;
  border: none; border-radius: 50px;
  font-family: var(--font);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.3px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #0a0a0f;
  box-shadow: 0 0 30px rgba(167,139,250,0.25);
}
.btn-primary:hover {
  box-shadow: 0 0 50px rgba(167,139,250,0.4);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.btn-secondary:hover {
  background: var(--bg-card-h);
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-2px);
}

.landing-hint {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* --- App Shell --- */
.app {
  display: flex; flex-direction: column;
  height: 100vh; width: 100vw;
}

/* --- Top Bar --- */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: rgba(10,10,15,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  flex-shrink: 0;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.transport {
  display: flex; align-items: center; gap: 8px;
}

.transport-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.transport-btn:hover {
  background: var(--bg-card-h);
  color: var(--text);
  border-color: rgba(255,255,255,0.1);
}

.play-btn {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border: none;
  color: #0a0a0f;
}
.play-btn:hover {
  box-shadow: 0 0 20px var(--glow);
  transform: scale(1.05);
}

.track-info {
  margin-left: 12px;
  display: flex; flex-direction: column;
}
.track-name {
  font-size: 13px; font-weight: 500;
  color: var(--text);
}
.track-time {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-dim);
}

.icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}
.icon-btn:hover {
  background: var(--bg-card);
  color: var(--text);
}

/* --- Canvas Area --- */
.canvas-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

#canvas {
  width: 100%; height: 100%;
  display: block;
}

/* --- Info Panel (floating) --- */
.info-panel {
  position: absolute;
  top: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  z-index: 5;
}

.info-card {
  padding: 12px 16px;
  background: rgba(10,10,15,0.7);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 140px;
  transition: all 0.3s;
}

.info-label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.info-value {
  display: block;
  font-size: 22px;
  font-weight: 300;
  font-family: var(--mono);
  color: var(--text);
  line-height: 1.2;
}

.info-detail {
  display: block;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-dim);
  margin-top: 2px;
}

.note-card .info-value {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 28px;
  font-weight: 400;
}

.amp-bar-wrap {
  width: 100%; height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  margin: 6px 0 4px;
  overflow: hidden;
}

.amp-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  border-radius: 2px;
  transition: width 0.08s linear;
}

/* --- Controls Bar --- */
.controls-bar {
  min-height: var(--controls-h);
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px;
  background: rgba(10,10,15,0.9);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  z-index: 10;
  scrollbar-width: none;
}
.controls-bar::-webkit-scrollbar { display: none; }

.control-group {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}

.ctrl-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Viz Switcher */
.viz-switcher {
  display: flex; gap: 4px;
}

.viz-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.viz-btn:hover {
  background: var(--bg-card-h);
  color: var(--text);
}
.viz-btn.active {
  background: rgba(167,139,250,0.12);
  border-color: rgba(167,139,250,0.3);
  color: var(--accent-1);
}

/* Theme Dots */
.theme-switcher {
  display: flex; gap: 6px;
}

.theme-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}
.theme-dot:hover { transform: scale(1.2); }
.theme-dot.active {
  border-color: rgba(255,255,255,0.5);
  box-shadow: 0 0 10px rgba(255,255,255,0.15);
}

/* Slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100px; height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border-radius: 50%;
  border: none;
  box-shadow: 0 0 8px var(--glow);
  cursor: pointer;
  transition: transform 0.15s;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* Select */
.select {
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  outline: none;
}
.select:focus { border-color: rgba(167,139,250,0.4); }

/* --- Spotify Button --- */
.btn-spotify svg { flex-shrink: 0; }

/* --- Spotify Setup Modal --- */
.spotify-setup {
  position: fixed; inset: 0; z-index: 150;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  animation: fadeUp 0.3s ease-out;
}

.spotify-setup-card {
  width: 420px; max-width: 90vw;
  padding: 32px;
  background: rgba(15,15,22,0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
}

.spotify-setup-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}

.spotify-setup-header h2 {
  font-size: 18px; font-weight: 400;
  letter-spacing: 0.5px;
}

.spotify-setup-desc {
  font-size: 13px; color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 20px;
}

.spotify-setup-field {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 20px;
}

.spotify-input {
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.spotify-input:focus {
  border-color: #1DB954;
  box-shadow: 0 0 0 2px rgba(29,185,84,0.15);
}
.spotify-input::placeholder { color: var(--text-muted); }

.spotify-setup-actions {
  display: flex; gap: 10px;
  margin-bottom: 16px;
}

.btn-spotify-connect {
  background: #1DB954;
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: 50px;
  font-family: var(--font);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-spotify-connect:hover {
  background: #1ed760;
  box-shadow: 0 0 20px rgba(29,185,84,0.3);
  transform: translateY(-1px);
}

.btn-sm { padding: 12px 20px !important; }

.spotify-setup-hint {
  font-size: 11px; color: var(--text-muted);
  line-height: 1.6;
}
.spotify-setup-hint a {
  color: #1DB954;
  text-decoration: none;
}
.spotify-setup-hint a:hover { text-decoration: underline; }
.spotify-setup-hint code {
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-dim);
  user-select: all;
}

/* --- Spotify Now Playing --- */
.spotify-now-playing {
  position: absolute;
  bottom: 20px; left: 20px;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: rgba(10,10,15,0.7);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 5;
  max-width: 320px;
  animation: fadeUp 0.4s ease-out;
}

.spotify-album-art {
  width: 44px; height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.spotify-track-info {
  display: flex; flex-direction: column;
  min-width: 0;
}

.spotify-track-name {
  font-size: 13px; font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spotify-artist-name {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spotify-badge {
  flex-shrink: 0;
  opacity: 0.6;
}

/* --- Spotify Status Message --- */
.spotify-status {
  position: absolute;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: rgba(10,10,15,0.75);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 50px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  white-space: nowrap;
  z-index: 5;
  animation: fadeUp 0.5s ease-out;
}

/* --- Layers Panel --- */
.layers-panel {
  position: absolute;
  top: 20px; left: 20px;
  width: 230px;
  background: rgba(10,10,15,0.8);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 5;
  transition: transform 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}
.layers-panel--closed {
  transform: translateX(-110%);
  opacity: 0;
  pointer-events: none;
}

.layers-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
}

.layers-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.layers-close {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}
.layers-close:hover { background: var(--bg-card); color: var(--text); }

.layers-list { padding: 6px 0; }

.layer-row {
  padding: 8px 14px;
  transition: background 0.15s;
}
.layer-row:hover { background: rgba(255,255,255,0.02); }

.layer-row > .layer-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  flex-shrink: 0;
}

.layer-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  vertical-align: middle;
}

.layer-range {
  display: block;
  font-size: 9px;
  font-family: var(--mono);
  color: var(--text-muted);
  margin: 2px 0 4px 16px;
  letter-spacing: 0.3px;
}

.layer-meter {
  display: block;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  margin: 4px 0 6px 0;
  background: rgba(255,255,255,0.04);
}

.layer-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.layer-gain {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.layer-gain::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px; height: 10px;
  background: var(--text-dim);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.layer-gain::-webkit-slider-thumb:hover {
  background: var(--text);
  transform: scale(1.2);
}

.layer-mute, .layer-solo {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.layer-mute:hover, .layer-solo:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}
.layer-mute.active {
  background: rgba(239,68,68,0.2);
  border-color: rgba(239,68,68,0.3);
  color: #ef4444;
}
.layer-solo.active {
  background: rgba(251,191,36,0.2);
  border-color: rgba(251,191,36,0.3);
  color: #fbbf24;
}

.ctrl-sep {
  width: 1px; height: 28px;
  background: var(--border);
  flex-shrink: 0;
  padding: 0; margin: 0;
}

@media (max-width: 768px) {
  .layers-panel {
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  }
  .layers-panel--closed {
    transform: translateY(110%);
  }
}

/* --- Keyboard Hint --- */
.keyboard-hint {
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: rgba(10,10,15,0.75);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 50px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
  animation: fadeUp 0.5s ease-out;
}

/* --- Drag Over State --- */
body.drag-over::after {
  content: 'Drop audio file';
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,10,15,0.9);
  border: 2px dashed rgba(167,139,250,0.4);
  color: var(--accent-1);
  font-size: 18px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 300;
}

/* --- Transitions --- */
.landing.fade-out {
  animation: fadeOutLanding 0.6s ease-out forwards;
}

@keyframes fadeOutLanding {
  to { opacity: 0; transform: scale(1.05); pointer-events: none; }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .landing-title { font-size: 32px; letter-spacing: 4px; }
  .landing-actions { flex-direction: column; align-items: center; }
  .info-panel { top: 12px; right: 12px; }
  .info-card { min-width: 110px; padding: 8px 12px; }
  .info-value { font-size: 18px; }
  .note-card .info-value { font-size: 22px; }
  .controls-bar { gap: 20px; padding: 0 16px; }
  .slider { width: 70px; }
}
