/* ─────────────────────────────────────────────
   Wavecrate — Design tokens
   Palette: deep obsidian bg, off-white text,
   electric lime accent (unexpected for music UIs
   that usually reach for purple/teal).
   Type: Space Grotesk (warmth) + Space Mono (data).
───────────────────────────────────────────── */
:root {
  --c-bg:        #0d0e10;
  --c-surface:   #141518;
  --c-surface-2: #1e2025;
  --c-border:    #2a2c32;
  --c-text:      #e8e9eb;
  --c-muted:     #767a84;
  --c-accent:    #c8f135;   /* electric lime */
  --c-accent-dk: #a8cc22;
  --c-danger:    #ff5c5c;

  --font-sans: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'Space Mono', 'Courier New', monospace;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --transition: 180ms ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100dvh;
}

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── Layout containers ── */
.header-inner,
.search-inner { max-width: 900px; margin: 0 auto; padding: 0 24px; }
#main-content  { max-width: 960px; margin: 0 auto; padding: 0 24px 80px; }

/* ─────────────────────────────────────────────
   HEADER
───────────────────────────────────────────── */
.site-header {
  padding: 36px 0 28px;
  border-bottom: 1px solid var(--c-border);
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.logo-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: var(--c-accent);
  color: var(--c-bg);
  font-size: 13px;
  border-radius: 6px;
  font-weight: 700;
  line-height: 1;
}
.logo-text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.tagline {
  color: var(--c-muted);
  font-size: 13px;
  font-weight: 400;
}

/* ─────────────────────────────────────────────
   SEARCH SECTION
───────────────────────────────────────────── */
.search-section {
  padding: 28px 0;
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--c-bg);
  backdrop-filter: blur(12px);
}
.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.input-wrap { flex: 1; }
.genre-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  color: var(--c-text);
  font-family: var(--font-mono);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.genre-input::placeholder { color: var(--c-muted); }
.genre-input:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-accent) 18%, transparent);
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.result-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--c-muted);
  min-height: 18px;
}

/* ─────────────────────────────────────────────
   BUTTONS
───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-search {
  background: var(--c-accent);
  color: var(--c-bg);
  min-width: 96px;
  justify-content: center;
}
.btn-search:hover { background: var(--c-accent-dk); }

.btn-batch {
  background: var(--c-surface-2);
  color: var(--c-text);
  border: 1px solid var(--c-border);
}
.btn-batch:hover:not(:disabled) {
  border-color: var(--c-accent);
  color: var(--c-accent);
}
.btn-batch:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--c-border);
  color: var(--c-muted);
  margin-top: 12px;
}
.btn-ghost:hover { border-color: var(--c-text); color: var(--c-text); }

.btn-dl {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  font-size: 12px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  width: 100%;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition);
}
.btn-dl:hover {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: var(--c-bg);
}

/* ─────────────────────────────────────────────
   EMPTY / LOADING / ERROR STATES
───────────────────────────────────────────── */
.empty-state,
.loading-state,
.error-state,
.no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
  color: var(--c-muted);
  gap: 12px;
}

.empty-art svg { width: 120px; opacity: 0.6; margin-bottom: 8px; }
.empty-headline { font-size: 17px; font-weight: 600; color: var(--c-text); }
.empty-sub { font-size: 13px; }

/* Waveform animation */
.waveform {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 40px;
  margin-bottom: 16px;
}
.waveform span {
  display: block;
  width: 5px;
  background: var(--c-accent);
  border-radius: 3px;
  animation: wave 1.1s ease-in-out infinite;
}
.waveform span:nth-child(1) { animation-delay: 0.0s; height: 14px; }
.waveform span:nth-child(2) { animation-delay: 0.1s; height: 28px; }
.waveform span:nth-child(3) { animation-delay: 0.2s; height: 38px; }
.waveform span:nth-child(4) { animation-delay: 0.3s; height: 22px; }
.waveform span:nth-child(5) { animation-delay: 0.4s; height: 34px; }
.waveform span:nth-child(6) { animation-delay: 0.3s; height: 18px; }
.waveform span:nth-child(7) { animation-delay: 0.2s; height: 30px; }
.waveform span:nth-child(8) { animation-delay: 0.1s; height: 12px; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.4); opacity: 0.5; }
  50%       { transform: scaleY(1);   opacity: 1;   }
}

.error-icon { font-size: 32px; color: var(--c-danger); }
.error-message { color: var(--c-text); font-weight: 500; }
.no-results-sub { font-size: 13px; }
.no-results-sub em { color: var(--c-accent); font-style: normal; }

/* ─────────────────────────────────────────────
   RESULTS GRID
───────────────────────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 18px;
  padding-top: 32px;
}

/* ── Track card ── */
.track-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition), transform var(--transition);
  animation: card-in 320ms ease both;
}
.track-card:hover {
  border-color: color-mix(in srgb, var(--c-accent) 50%, transparent);
  transform: translateY(-2px);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-image-wrap {
  position: relative;
  aspect-ratio: 1;
  background: var(--c-surface-2);
  overflow: hidden;
}
.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 300ms ease;
}
.track-card:hover .card-image { transform: scale(1.04); }

.card-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity var(--transition);
}
.track-card:hover .card-overlay { opacity: 1; }

.btn-play {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  background: var(--c-accent);
  color: var(--c-bg);
  border-radius: 50%;
  font-size: 16px;
  padding-left: 3px; /* optical nudge */
  transition: transform var(--transition);
}
.btn-play:hover { transform: scale(1.1); }

.card-body {
  padding: 12px 14px 8px;
  flex: 1;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.card-artist {
  font-size: 12px;
  color: var(--c-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-footer {
  padding: 0 10px 12px;
}

/* ─────────────────────────────────────────────
   TOAST
───────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  font-size: 13px;
  font-family: var(--font-mono);
  padding: 10px 20px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease, transform 250ms ease;
  white-space: nowrap;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────── */
@media (max-width: 600px) {
  .site-header { padding: 24px 0 18px; }
  .header-inner, .search-inner, #main-content { padding-inline: 16px; }

  .search-row { flex-direction: column; }
  .btn-search { width: 100%; }

  .action-row { flex-direction: column-reverse; align-items: flex-start; gap: 8px; }
  .btn-batch  { width: 100%; justify-content: center; }

  .results-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .waveform span { animation: none; height: 24px !important; }
  .track-card, .card-image, .toast { transition: none; }
}
