/* ==========================================================================
   ASCII GLITCH AUDIO DECK - Spotify Edition (Vercel/Linear Dark Aesthetic)
   ========================================================================== */

:root {
  --bg-primary: #09090b;
  --bg-surface: #121215;
  --bg-surface-glass: rgba(18, 18, 21, 0.75);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text-primary: #f4f4f5;
  --text-muted: #71717a;
  --accent: #ffffff;
  --accent-glow: rgba(255, 255, 255, 0.25);
  --accent-rgb: 255, 255, 255;
  --spotify-green: #1db954;
  --danger: #ef4444;
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Geist Mono', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 9999px;
  --dock-height: 64px;
}

/* Themes */
body[data-theme="monochrome"] {
  --accent: #ffffff;
  --accent-glow: rgba(255, 255, 255, 0.3);
  --accent-rgb: 255, 255, 255;
}

body[data-theme="amber"] {
  --accent: #f59e0b;
  --accent-glow: rgba(245, 158, 11, 0.4);
  --accent-rgb: 245, 158, 11;
  --bg-primary: #080602;
}

body[data-theme="emerald"] {
  --accent: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.4);
  --accent-rgb: 16, 185, 129;
  --bg-primary: #020804;
}

body[data-theme="coral"] {
  --accent: #f43f5e;
  --accent-glow: rgba(244, 63, 94, 0.4);
  --accent-rgb: 244, 63, 94;
  --bg-primary: #0a0204;
}

/* Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}

/* CRT & Glitch VFX Overlays */
.crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.3) 50%);
  background-size: 100% 3px;
  opacity: 0.35;
}

.glitch-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 51;
  box-shadow: inset 0 0 100px rgba(0,0,0,0.85);
  transition: box-shadow 0.1s ease;
}

body.glitching .glitch-vignette {
  box-shadow: inset 0 0 140px var(--accent-glow);
  filter: contrast(150%) hue-rotate(90deg);
  animation: chromatic-shift 0.15s infinite;
}

@keyframes chromatic-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  50% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, -2px); }
  100% { transform: translate(0, 0); }
}

/* Header */
.deck-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 40;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-glass);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulse-glow 2s infinite ease-in-out;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.brand-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-primary);
}

.version-tag {
  font-size: 10px;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  padding: 1px 5px;
  border-radius: 4px;
}

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

.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.spotify-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #666;
}

.spotify-dot.online {
  background: var(--spotify-green);
  box-shadow: 0 0 8px var(--spotify-green);
}

/* Viewport Canvas */
.viewport-container {
  position: absolute;
  inset: 0;
  top: 48px;
  bottom: var(--dock-height);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  overflow: hidden;
}

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

.canvas-watermark {
  position: absolute;
  bottom: 16px;
  left: 20px;
  pointer-events: none;
  font-family: var(--font-mono);
  opacity: 0.7;
}

.wm-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wm-artist {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.spotify-embed-box {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 320px;
  z-index: 30;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 24px rgba(0,0,0,0.6);
}

/* Floating Bento Dock */
.deck-dock {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 1020px;
  height: var(--dock-height);
  z-index: 45;
}

.dock-inner {
  height: 100%;
  background: var(--bg-surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  gap: 10px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
}

.dock-section {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Buttons */
button, .dock-btn {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

button:hover, .dock-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-strong);
}

button:active, .dock-btn:active {
  transform: scale(0.97);
}

.dock-action-btn.primary {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #000;
  border: none;
  box-shadow: 0 0 15px var(--accent-glow);
}

.dock-action-btn.primary:hover {
  transform: scale(1.05);
}

.spotify-action-btn {
  background: rgba(29, 185, 84, 0.12);
  border: 1px solid rgba(29, 185, 84, 0.3);
  color: #fff;
}

.spotify-action-btn:hover {
  background: var(--spotify-green);
  color: #000;
  box-shadow: 0 0 15px rgba(29, 185, 84, 0.4);
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
}

.icon-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-subtle);
}

.dock-btn.secondary {
  color: var(--text-muted);
  font-size: 11px;
  padding: 5px 9px;
}

.dock-btn.glitch-btn {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.1em;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--border-strong);
  color: var(--accent);
}

.dock-btn.glitch-btn:hover {
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 15px var(--accent-glow);
}

/* Mode Tabs */
.mode-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  gap: 2px;
}

.mode-tab {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.mode-tab.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* Slider */
.slider-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.slider-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
}

.custom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 65px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
}

.slider-val {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  min-width: 26px;
  text-align: right;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-subtabs {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.4);
  padding: 3px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.subtab {
  flex: 1;
  font-size: 11px;
  padding: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: 4px;
}

.subtab.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.input-group {
  margin-bottom: 16px;
}

.input-label {
  display: block;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input-group input, .input-wrapper input {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
}

.input-group input:focus, .input-wrapper input:focus {
  border-color: var(--spotify-green);
}

.auth-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.spotify-btn {
  background: var(--spotify-green);
  color: #000;
  font-weight: 600;
  padding: 8px 16px;
}

.help-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.help-box a {
  color: var(--spotify-green);
  text-decoration: none;
}

.help-box code {
  display: block;
  background: rgba(0,0,0,0.5);
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--text-primary);
  margin-top: 4px;
  word-break: break-all;
}

.hidden {
  display: none !important;
}

/* Mobile */
@media (max-width: 768px) {
  .deck-header {
    padding: 0 12px;
  }
  .version-tag, #bpm-badge {
    display: none;
  }
  .deck-dock {
    width: 100%;
    bottom: 0;
    border-radius: 0;
  }
  .dock-inner {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 6px 8px;
    gap: 4px;
  }
  .btn-text, .slider-group {
    display: none;
  }
  .mode-tab {
    padding: 4px 6px;
    font-size: 10px;
  }
  .canvas-watermark {
    bottom: calc(var(--dock-height) + 12px);
    left: 12px;
  }
  .wm-title {
    max-width: 220px;
  }
}
