/* ==========================================================================
   Variables & Paleta Obsidian + Sky Blue
   ========================================================================== */
:root {
  --ink: #f5f6f8;
  --muted: #8e939e;
  --night: #090a0c;          /* Negro obsidiana profundo */
  --panel: #111317;          /* Superficie obsidiana pulida */
  --panel-hover: #171a20;    /* Efecto hover */
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);

  --sky-blue: #38bdf8;       /* Azul cielo vibrante */
  --ice-blue: #7dd3fc;       /* Azul pálido / escarcha */
  --deep-blue: #0284c7;      /* Azul marino */
  --navy-glow: rgba(56, 189, 248, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--night);
  font-family: "Space Grotesk", sans-serif;
  background-image:
    radial-gradient(circle at 85% 8%, rgba(56, 189, 248, 0.07), transparent 30rem),
    radial-gradient(circle at 15% 35%, rgba(2, 132, 199, 0.05), transparent 26rem),
    linear-gradient(180deg, #0c0d10 0%, #07080a 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100% - 48px));
  margin: auto;
}

/* Cabecera */
.topbar {
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.06em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: #040914;
  background: linear-gradient(135deg, var(--ice-blue), var(--sky-blue));
  transform: rotate(-8deg);
  font-size: 15px;
  font-weight: 700;
  border-radius: 4px;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
}

nav {
  display: flex;
  align-items: center;
  gap: 30px;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s ease;
}

nav a:hover,
nav a.active {
  color: var(--ice-blue);
}

.nav-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.02);
  padding: 11px 18px;
  font-size: 13px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.nav-button:hover {
  border-color: var(--sky-blue);
  color: var(--ice-blue);
  background: rgba(56, 189, 248, 0.05);
}

/* Hero & Buscador */
.hero {
  padding: 90px 0 60px;
  max-width: 850px;
}

.eyebrow {
  color: var(--ice-blue);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  max-width: 800px;
  margin: 17px 0 23px;
  font-size: clamp(48px, 7.5vw, 92px);
  line-height: 0.94;
  letter-spacing: -0.085em;
  font-weight: 600;
}

h1 em {
  color: var(--sky-blue);
  font-style: normal;
}

.hero-copy {
  max-width: 520px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.search-box {
  position: relative;
  max-width: 760px;
  margin-top: 36px;
}

.search-box input {
  width: 100%;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 19px 150px 19px 22px;
  outline: none;
  font-size: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
  border-color: var(--sky-blue);
  box-shadow: 0 0 0 3px var(--navy-glow), 0 8px 30px rgba(0, 0, 0, 0.6);
}

.search-box input::placeholder {
  color: #555861;
}

.search-box button {
  position: absolute;
  right: 8px;
  top: 8px;
  bottom: 8px;
  padding: 0 24px;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--sky-blue), var(--deep-blue));
  color: #040914;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.3);
  transition: all 0.2s ease;
}

.search-box button:hover {
  background: linear-gradient(135deg, #56c8fa, #0284c7);
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.45);
}

.search-icon {
  position: absolute;
  left: -30px;
  bottom: -28px;
  color: var(--sky-blue);
  font-family: "DM Mono", monospace;
  font-size: 20px;
  transform: rotate(-13deg);
}

/* Filtros de Género */
.genre-row {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin: 4px 0 65px;
}

.genre {
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.015);
  font-size: 12px;
  transition: all 0.2s ease;
}

.genre:hover,
.genre.selected {
  border-color: var(--sky-blue);
  color: var(--ice-blue);
  background: rgba(56, 189, 248, 0.09);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.12);
}

/* Resultados */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.result-count {
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 11px;
}

.results {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  margin-top: 1px;
  background: var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.track {
  min-height: 125px;
  display: flex;
  align-items: center;
  gap: 19px;
  padding: 18px 22px;
  background: #0d0e12;
  transition: background-color 0.2s ease;
}

.track:hover {
  background: var(--panel-hover);
}

/* Carátulas (Soporta imagen de la API y respaldo) */
.cover {
  position: relative;
  width: 80px;
  height: 80px;
  flex: 0 0 80px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: #181b22;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.cover-image {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}

.cover-fallback {
  color: var(--ice-blue);
  font-size: 24px;
  font-weight: 700;
  z-index: 1;
}

.track-info {
  min-width: 0;
  flex: 1;
}

.track-title {
  margin: 0 0 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 500;
}

.artist {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta {
  display: flex;
  gap: 11px;
  color: #656975;
  font-family: "DM Mono", monospace;
  font-size: 11px;
}

.play {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
}

.play:hover,
.play.playing {
  color: #040914;
  background: var(--sky-blue);
  border-color: var(--sky-blue);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.5);
}

/* Estados Vacíos y Spinner de Carga */
.empty {
  grid-column: 1 / -1;
  padding: 65px 20px;
  text-align: center;
  color: var(--muted);
  background: #0d0e12;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--sky-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.sub-error {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: #555861;
}

/* Footer */
footer {
  display: flex;
  justify-content: space-between;
  margin-top: 85px;
  padding: 24px 0 36px;
  border-top: 1px solid var(--line);
  color: #656975;
  font-family: "DM Mono", monospace;
  font-size: 10px;
}

.status {
  color: var(--sky-blue);
}

/* Responsive */
@media (max-width: 700px) {
  .shell { width: min(100% - 30px, 560px); }
  .topbar { height: 72px; }
  nav { gap: 0; }
  nav a { display: none; }
  .hero { padding: 65px 0 45px; }
  h1 { font-size: clamp(52px, 16vw, 78px); }
  .search-box input { padding-right: 110px; }
  .search-box button { padding: 0 16px; }
  .search-icon { display: none; }
  .genre-row { margin-bottom: 48px; }
  .results { grid-template-columns: 1fr; }
  .track { min-height: 115px; padding: 14px; }
  .cover { width: 68px; height: 68px; flex-basis: 68px; }
  footer { gap: 20px; flex-direction: column; }
}