/* ==========================================================================
   estilos.css — Layout y componentes
   Usa los tokens definidos en variables.css.
   Secciones: base · cabecera · búsqueda · resultados · tarjetas · descargas · perfil de canal · pie
   ========================================================================== */

/* ---- Base ---- */
* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding-inline: 20px;
  padding-block: 0;
}

/* ---- Cabecera ---- */
header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.head-inner { padding-block: 18px; display: flex; flex-direction: column; gap: 16px; }
.brand { display: flex; align-items: center; gap: 11px; cursor: pointer; }
.logo { width: 38px; height: 38px; border-radius: 10px; flex: none; background: var(--accent); color: #fff; display: grid; place-items: center; }
.logo svg { width: 20px; height: 20px; }
.brand h1 { font-family: var(--display); font-weight: 600; font-size: 1.5rem; margin: 0; letter-spacing: -.01em; }
.brand p { margin: 0; font-size: .8rem; color: var(--muted); }

/* ---- Búsqueda ---- */
.search-row { display: flex; gap: 10px; flex-wrap: wrap; }
.search-box { flex: 1 1 280px; min-width: 0; position: relative; display: flex; align-items: center; margin: 0; }
.search-box svg { position: absolute; left: 15px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search-box input { width: 100%; padding: 13px 16px 13px 44px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--fg); font-size: 1rem; font-family: inherit; }
.search-box input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
button.go { flex: none; padding: 13px 24px; border: none; border-radius: 11px; background: var(--accent); color: #fff; font-weight: 600; font-size: .95rem; font-family: inherit; cursor: pointer; transition: filter .15s; }
button.go:hover { filter: brightness(1.07); }

/* ---- Área principal / estados ---- */
main { padding-block: 26px 48px; }
.status-msg { text-align: center; color: var(--muted); padding: 60px 20px; }
.status-msg .big { font-family: var(--display); font-size: 1.3rem; color: var(--fg); margin-bottom: 6px; }
.meta-line { font-size: .82rem; color: var(--muted); margin-bottom: 16px; }

/* ---- Cuadrícula de resultados ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }

/* ---- Tarjeta de canción ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.thumb { position: relative; aspect-ratio: 16/9; background: var(--line); max-width: 100%; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dur { position: absolute; bottom: 7px; right: 7px; background: rgba(0, 0, 0, .82); color: #fff; font-size: .74rem; font-weight: 600; padding: 3px 8px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.card-body { padding: 13px 14px 15px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title { font-weight: 600; font-size: .92rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chan-link { font-size: .8rem; font-weight: 500; color: var(--fg); background: none; border: none; padding: 0; font-family: inherit; cursor: pointer; text-align: left; }
.chan-link:hover { color: var(--accent); text-decoration: underline; }
.stats { display: flex; gap: 12px; font-size: .76rem; color: var(--muted); margin-top: auto; font-variant-numeric: tabular-nums; }
.stats span { display: inline-flex; align-items: center; gap: 4px; }
.stats svg { width: 13px; height: 13px; }
.open-btn { margin-top: 10px; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 9px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .83rem; text-decoration: none; transition: background .15s; }
.open-btn:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 12%); }
.open-btn svg { width: 15px; height: 15px; }

/* ---- Botón de descarga en la tarjeta ---- */
.download-btn { width: 100%; border: 0; font-family: inherit; cursor: pointer; background: var(--accent); color: #fff; min-height: 44px; margin-top: 0; }
.download-btn:hover { background: var(--accent); filter: brightness(1.06); }
button:disabled { cursor: wait; opacity: .65; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---- Sección de descargas ---- */
.downloads { margin-bottom: 24px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.downloads h2 { margin: 0 0 6px; font: 600 1.2rem var(--display); }
.download-help { margin: 0 0 12px; font-size: .8rem; color: var(--muted); }
.download-list { display: grid; gap: 12px; }
.download-item { padding-top: 12px; border-top: 1px solid var(--line); }
.download-title { font-weight: 600; overflow-wrap: anywhere; }
.download-message { font-size: .82rem; color: var(--muted); margin: 5px 0; }
.download-item[data-state="error"] .download-message { color: var(--accent); }
.download-item[data-state="processing"] .download-message::before,
.download-item[data-state="queued"] .download-message::before { content: ''; display: inline-block; width: 11px; height: 11px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; margin-right: 8px; vertical-align: -2px; animation: spin .7s linear infinite; }
.download-item .open-btn { display: inline-flex; min-height: 44px; padding-inline: 16px; }
@media (prefers-reduced-motion: reduce) { .download-item .download-message::before { animation: none; } }

/* ---- Perfil del canal ---- */
.back { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; color: var(--muted); font-family: inherit; font-size: .85rem; cursor: pointer; padding: 0; margin-bottom: 18px; }
.back:hover { color: var(--accent); }
.back svg { width: 15px; height: 15px; }
.profile { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 26px; }
.avatar { width: 84px; height: 84px; border-radius: 50%; flex: none; object-fit: cover; background: var(--line); }
.profile-info { flex: 1 1 200px; min-width: 0; }
.profile-info h2 { font-family: var(--display); font-size: 1.5rem; margin: 0 0 4px; font-weight: 600; }
.profile-stats { display: flex; gap: 18px; flex-wrap: wrap; font-size: .83rem; color: var(--muted); margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.profile-stats b { color: var(--fg); font-weight: 600; }
.profile-desc { font-size: .83rem; color: var(--muted); line-height: 1.55; max-width: 60ch; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.profile-open { display: inline-flex; align-items: center; gap: 7px; margin-top: 12px; padding: 9px 16px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 600; font-size: .82rem; text-decoration: none; }
.profile-open svg { width: 14px; height: 14px; }

/* ---- Errores y pie ---- */
.err { background: var(--accent-soft); color: var(--accent); border-radius: 11px; padding: 14px 16px; font-size: .86rem; margin-bottom: 18px; }
footer { text-align: center; font-size: .74rem; color: var(--muted); padding: 24px 20px 40px; line-height: 1.6; }

/* ---- Spinner y «cargar más» ---- */
.spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto 14px; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.load-more { display: block; margin: 26px auto 0; padding: 12px 28px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--fg); font-family: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; }
.load-more:hover { border-color: var(--accent); color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .card { transition: none; } }
