/* Reset mínimo */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg, video { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }

html {
  /* Evita scroll horizontal accidental y el reescalado de texto de iOS al rotar. */
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.5;
  min-height: 100vh;

  /* iPhone: sin scroll lateral, sin rebote/encadenado vertical (pull-to-refresh).
     overflow-x: clip (no hidden) para NO romper position:sticky de los sidebars;
     html ya corta el scroll horizontal global del documento. */
  overflow-x: clip;
  width: 100%;
  max-width: 100vw;
  overscroll-behavior-y: none;
  /* Quita el delay de 300ms del double-tap y desactiva double-tap-to-zoom. */
  touch-action: manipulation;
  /* Scroll suave con momentum en iOS. */
  -webkit-overflow-scrolling: touch;
}

/* Cinturón anti-overflow: nada debería desbordar el ancho del viewport. */
.container, .layout-wrapper, .layout-main-col, main { max-width: 100%; }

body.player-active { padding-bottom: var(--player-h); }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; margin: 0 0 var(--space-4); }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }

a { color: var(--color-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-primary-hover); }

:focus-visible { outline: 2px solid var(--color-focus-ring); outline-offset: 2px; border-radius: var(--radius-sm); }

/* Layout */
.container { max-width: var(--container-max); margin: 0 auto; padding: 0 var(--space-4); }

/* Navbar */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--color-bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}
.site-header .nav {
  display: flex; align-items: center; gap: var(--space-6);
  height: 100%; max-width: var(--container-max);
  margin: 0 auto; padding: 0 var(--space-4);
}
.site-header .brand {
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg);
  background: var(--gradient-brand);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.site-header .nav-spacer { flex: 1; }
.site-header .nav a { color: var(--color-text); font-weight: 500; }
.site-header .nav a:hover { color: var(--color-primary-hover); }
/* Legacy .nav-saldo (mantenido por compatibilidad si algo lo referencia) */
.site-header .nav-saldo {
  padding: 6px 12px; min-height: 32px;
  background: var(--color-surface-2); border: 1px solid var(--color-border);
  border-radius: var(--radius-full); font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
  text-decoration: none; font-family: var(--font-mono);
}
.site-header .nav-saldo small { color: var(--color-text-muted); font-weight: 400; }

/* Nav-pill: cápsula con icono + valor + unidad. Usado para Biblioteca y Saldo. */
.site-header .nav-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; min-height: 36px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text); text-decoration: none;
  font-size: var(--fs-sm); font-weight: 500;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}
.site-header .nav-pill:hover {
  border-color: var(--color-primary-hover);
  color: var(--color-primary-hover);
  background: color-mix(in srgb, var(--color-primary) 8%, var(--color-surface-2));
}
.site-header .nav-pill > svg { flex-shrink: 0; }
.site-header .nav-pill .mono { font-family: var(--font-mono); font-weight: 600; }
.site-header .nav-pill small {
  color: var(--color-text-muted); font-weight: 400; font-size: var(--fs-xs);
  margin-left: 2px;
}
/* En móvil, pills compactas: solo icono + número (la etiqueta se oculta para no saturar). */
@media (max-width: 991.98px) {
  .site-header .nav-pill { padding: 4px 9px; min-height: 32px; gap: 4px; }
  .site-header .nav-pill small { display: none; }
}

/* ── Navbar público (deslogueado) ─────────────────────────────────────── */
/* Links de sección con subrayado degradado animado al hover. */
.site-header .nav-links { display: inline-flex; align-items: center; gap: var(--space-5); }
.site-header .nav-links a {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--color-text-muted); font-weight: 500;
  padding: 4px 0;
  transition: color var(--transition-fast);
}
.site-header .nav-links a svg {
  flex-shrink: 0; color: var(--color-text-muted);
  transition: color var(--transition-fast), transform var(--transition-fast);
}
.site-header .nav-links a:hover svg {
  color: var(--color-primary-hover); transform: translateY(-1px);
}
.site-header .nav-links a::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -3px; height: 2px;
  background: var(--gradient-brand); border-radius: 2px;
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--transition-fast);
}
.site-header .nav-links a:hover { color: var(--color-text); }
.site-header .nav-links a:hover::after { transform: scaleX(1); }

/* Par de acciones de cuenta: "Iniciar sesión" ghost + "Crear cuenta" degradado. */
.site-header .nav-auth { display: inline-flex; align-items: center; gap: var(--space-3); }
.site-header .nav-login {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 36px; padding: 0 var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  color: var(--color-text); font-weight: 600; font-size: var(--fs-sm);
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
.site-header .nav-login svg { flex-shrink: 0; }
.site-header .nav-login:hover {
  border-color: var(--color-primary-hover);
  color: var(--color-primary-hover);
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}
.site-header .nav-cta { min-height: 36px; padding: 0 var(--space-4); gap: 7px; }
.site-header .nav-cta svg { flex-shrink: 0; }

/* ── Navbar flotante glassmorphism (solo deslogueado) ─────────────────── */
/* El header pasa a ser un contenedor transparente con aire; el .nav interior
   se convierte en una píldora de cristal flotante con bordes redondeados. */
.site-header.site-header--floating {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-bottom: 0;
  height: auto;
  padding: var(--space-3) var(--space-4);
}
.site-header--floating .nav {
  position: relative; /* contexto para el panel desplegable móvil */
  height: var(--header-h);
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-5);
  border-radius: var(--radius-full);
  /* Cristal: capa translúcida + desenfoque y saturación del fondo. */
  background: color-mix(in srgb, var(--color-surface) 60%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  /* Borde sutil + brillo superior interno = efecto vidrio. */
  border: 1px solid color-mix(in srgb, #fff 12%, transparent);
  box-shadow:
    0 10px 30px -10px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
}
/* Fallback sin backdrop-filter: subir opacidad para mantener legibilidad. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-header--floating .nav {
    background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  }
}
/* Móvil: menos aire, el cristal sigue flotando con margen lateral. */
@media (max-width: 991.98px) {
  .site-header.site-header--floating { padding: var(--space-2) var(--space-3); }
  .site-header--floating .nav { padding: 0 var(--space-4); }
}

/* ── Primitivas de estilo (rediseño underground / Spotify) ────────────── */
/* Aurora: malla de luz difusa + grano sutil. Una sola clase, sin markup extra. */
.fx-aurora { position: relative; isolation: isolate; }
.fx-aurora::before {
  content: ""; position: absolute; inset: -30% -10% auto -10%;
  height: clamp(420px, 62vh, 760px); z-index: -2; pointer-events: none;
  background:
    radial-gradient(38% 50% at 18% 16%, rgba(139, 92, 246, 0.40), transparent 70%),
    radial-gradient(34% 44% at 82% 6%,  rgba(59, 130, 246, 0.30), transparent 70%),
    radial-gradient(42% 52% at 62% 42%, rgba(255, 61, 154, 0.22), transparent 70%);
  filter: blur(46px) saturate(125%);
  animation: fxAuroraDrift 22s ease-in-out infinite alternate;
}
.fx-aurora::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes fxAuroraDrift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(0, -26px, 0) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) { .fx-aurora::before { animation: none; } }

/* Acento hype + utilidades de glow/badge. */
.text-hype { color: var(--color-hype); }
.glow-brand { box-shadow: var(--glow-brand); }
.badge-hype {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: var(--radius-full);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--color-text);
  background: color-mix(in srgb, var(--color-hype) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-hype) 45%, transparent);
}
.badge-hype .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-hype); box-shadow: var(--glow-hype);
}
/* Refuerzo opcional del CTA primario con glow de marca. */
.btn-primary-gradient.glow-brand:hover { box-shadow: var(--glow-brand); }

/* ── Theme toggle (claro / oscuro) ────────────────────────────────────── */
/* Transición suave del cambio de tema (respeta prefers-reduced-motion vía tokens.css). */
body { transition: background-color var(--transition-fast), color var(--transition-fast); }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex-shrink: 0;
  border: 0; background: transparent; color: var(--color-text);
  border-radius: var(--radius-md); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.theme-toggle:hover {
  color: var(--color-primary-hover);
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}
.theme-toggle:focus-visible { outline: 2px solid var(--color-focus-ring); outline-offset: 2px; }
.theme-toggle svg { flex-shrink: 0; }
.theme-toggle-label { display: none; }
/* Icono según el tema activo: en oscuro mostramos el sol (ir a claro); en claro, la luna. */
.theme-toggle .theme-ic-moon { display: none; }
[data-theme="light"] .theme-toggle .theme-ic-sun { display: none; }
[data-theme="light"] .theme-toggle .theme-ic-moon { display: inline-flex; }

/* Variante fila (dentro del menú hamburguesa móvil): ancho completo con etiqueta. */
.theme-toggle.theme-toggle--row {
  width: 100%; height: auto; justify-content: flex-start; gap: 10px;
  min-height: 44px; padding: 10px 12px;
  color: var(--color-text); font-weight: 500; font-size: var(--fs-base);
}
.theme-toggle.theme-toggle--row .theme-toggle-label { display: inline; }
.theme-toggle.theme-toggle--row:hover { background: var(--color-surface-2); }
.theme-toggle.theme-toggle--row svg { color: var(--color-text-muted); }
.theme-toggle.theme-toggle--row:hover svg { color: var(--color-primary-hover); }

/* Cluster derecho del header público (toggle + avatar) cuando hay sesión. */
.site-header .nav-right { display: inline-flex; align-items: center; gap: var(--space-2); margin-left: auto; }
.site-header .nav-right .nav-avatar { margin-left: 0; }

/* Acciones del topbar admin móvil (toggle + hamburguesa). */
.admin-topbar-actions { display: inline-flex; align-items: center; gap: var(--space-2); }

/* ── Menú hamburguesa (móvil, navbar deslogueado) ─────────────────────── */
.nav-hamburger {
  display: none; /* visible solo en móvil (ver media query) */
  align-items: center; justify-content: center;
  width: 44px; height: 44px; margin-left: auto; flex-shrink: 0;
  border: 0; background: transparent; color: var(--color-text);
  border-radius: var(--radius-md); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-hamburger:hover { color: var(--color-primary-hover); }
.nav-hamburger:focus-visible { outline: 2px solid var(--color-focus-ring); outline-offset: 2px; }
.nav-hamburger .hb-close { display: none; }
.nav-hamburger.is-open .hb-open { display: none; }
.nav-hamburger.is-open .hb-close { display: block; }

/* Panel desplegable, mismo lenguaje glass que el pill. */
.nav-mobile-menu {
  display: none;
  position: absolute; top: calc(100% + var(--space-2)); left: 0; right: 0;
  flex-direction: column; gap: 2px;
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--color-surface) 78%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid color-mix(in srgb, #fff 12%, transparent);
  box-shadow:
    0 16px 40px -12px rgba(0, 0, 0, 0.60),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .nav-mobile-menu { background: color-mix(in srgb, var(--color-surface) 96%, transparent); }
}
.nav-mobile-menu.is-open { display: flex; animation: navMenuIn 160ms ease; }
@keyframes navMenuIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .nav-mobile-menu.is-open { animation: none; }
}
.nav-mobile-menu a {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--color-text); font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-mobile-menu a svg { flex-shrink: 0; color: var(--color-text-muted); }
.nav-mobile-menu a:hover { background: var(--color-surface-2); }
.nav-mobile-menu a:hover svg { color: var(--color-primary-hover); }
.nav-mobile-menu-auth {
  display: flex; flex-direction: column; gap: var(--space-2);
  margin-top: var(--space-2); padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}
.nav-mobile-menu-auth .nav-login,
.nav-mobile-menu-auth .nav-cta { justify-content: center; }

@media (max-width: 991.98px) { .nav-hamburger { display: inline-flex; } }
@media (min-width: 992px) {
  .nav-hamburger { display: none !important; }
  .nav-mobile-menu { display: none !important; }
}

.btn-primary-gradient {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 var(--space-6);
  background: var(--gradient-brand); color: var(--color-on-primary);
  border: 0; border-radius: var(--radius-md);
  font-weight: 600; transition: background var(--transition), box-shadow var(--transition);
  text-decoration: none;
}
.btn-primary-gradient:hover { background: var(--gradient-brand-strong); box-shadow: var(--shadow-glow); color: var(--color-on-primary); }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 var(--space-6);
  background: var(--color-surface-2); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  font-weight: 500; text-decoration: none;
}

.btn-google {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  width: 100%; min-height: 46px;
  background: var(--color-surface-2); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  font-weight: 600; text-decoration: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.btn-google:hover { background: var(--color-surface); border-color: color-mix(in srgb, var(--color-primary) 40%, var(--color-border)); color: var(--color-text); }

/* Auth card (compartido por las vistas de cuenta) — cristal + halo aurora */
.auth-card {
  position: relative; isolation: isolate;
  max-width: 440px; margin: var(--space-10) auto;
  background: color-mix(in srgb, var(--color-surface) 72%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(140%); backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: var(--space-8);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.6);
}
.auth-card::before {
  content: ""; position: absolute; z-index: -1; inset: -45% -25% 45% -25%;
  background:
    radial-gradient(50% 60% at 50% 0%, rgba(139, 92, 246, 0.35), transparent 70%),
    radial-gradient(40% 50% at 82% 8%, rgba(255, 61, 154, 0.18), transparent 70%);
  filter: blur(42px); pointer-events: none;
}
.auth-card button[type="submit"], .auth-card .btn-primary-gradient { width: 100%; }
.auth-title {
  font-family: var(--font-display); font-size: var(--fs-2xl); letter-spacing: -0.01em;
  margin-bottom: var(--space-2);
}
.auth-subtitle { color: var(--color-text-muted); margin-bottom: var(--space-6); }
.auth-foot { margin-top: var(--space-6); color: var(--color-text-muted); font-size: var(--fs-sm); text-align: center; }
.auth-foot a { color: var(--color-primary-hover); }
.auth-divider { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-6) 0; color: var(--color-text-muted); font-size: var(--fs-sm); }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--color-border); }

.form-field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.form-field label { font-size: var(--fs-sm); color: var(--color-text-muted); }
.form-field input,
.form-field textarea {
  min-height: 46px;
  background: color-mix(in srgb, var(--color-bg) 60%, transparent); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  padding: 12px var(--space-3); font: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-field input:hover, .form-field textarea:hover { border-color: color-mix(in srgb, var(--color-primary) 30%, var(--color-border)); }
.form-field input:focus, .form-field textarea:focus {
  border-color: var(--color-focus-ring); outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-focus-ring) 25%, transparent);
}

/* Cabecera de cuenta (display) — global; las page-CSS no la sobreescriben. */
.cuenta-head h1 {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 1.3rem + 2.4vw, 2.75rem); letter-spacing: -0.02em;
  margin: 0 0 var(--space-2);
}

.alert { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); margin-bottom: var(--space-4); font-size: var(--fs-sm); }
.alert-info    { background: color-mix(in srgb, var(--color-info)    20%, transparent); color: var(--color-text); border: 1px solid var(--color-info); }
.alert-success { background: color-mix(in srgb, var(--color-success) 20%, transparent); color: var(--color-text); border: 1px solid var(--color-success); }
.alert-danger  { background: color-mix(in srgb, var(--color-danger)  20%, transparent); color: var(--color-text); border: 1px solid var(--color-danger); }

.text-danger { color: var(--color-danger); font-size: var(--fs-sm); }

/* ── Beat card (compartido por home, catálogo, relacionados) ────────────── */
/* Grid más densa que la versión original: en móvil 2 cols (no 1), en desktop
   hasta 6 cols. Las cards quedan más pequeñas y se ven más beats a la vez. */
.beat-grid {
  display: grid; gap: var(--space-3);
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 480px)  { .beat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 768px)  { .beat-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1100px) { .beat-grid { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 1400px) { .beat-grid { grid-template-columns: repeat(6, 1fr); } }

.beat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition-fast);
}
.beat-card:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--color-primary) 40%, var(--color-border));
}

/* Wrap del cover: contenedor relativo para badges + side-buttons */
.beat-card-cover-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--color-surface-2);
  overflow: hidden;
}
.beat-card-cover {
  display: block;
  width: 100%; height: 100%;
}
.beat-card-cover img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform var(--transition);
  will-change: transform;
}
.beat-card:hover .beat-card-cover img { transform: scale(1.04); }
.beat-card-cover-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; color: var(--color-text-muted);
}

/* Stack de badges en la esquina superior-izquierda */
.beat-card-badges {
  position: absolute; top: var(--space-2); left: var(--space-2);
  display: flex; flex-direction: column; gap: 4px;
  align-items: flex-start;
  z-index: 2;
  pointer-events: none;
}
.beat-card-badge {
  background: var(--gradient-brand); color: var(--color-on-primary);
  font-size: var(--fs-xs); font-weight: 600;
  padding: 2px 8px; border-radius: var(--radius-full);
  letter-spacing: 0.03em;
}
.beat-card-badge-nuevo {
  background: var(--color-success); color: white;
}

/* Marca "Comprado" en la esquina superior-derecha del cover */
.beat-card-owned {
  position: absolute; top: var(--space-2); right: var(--space-2);
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px 3px 6px;
  background: var(--color-success); color: white;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: 0.03em;
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.beat-card-owned-label { line-height: 1; }

/* En cards muy pequeñas (móvil 2-col) ocultamos el texto, solo check */
@media (max-width: 575px) {
  .beat-card-owned { padding: 4px; }
  .beat-card-owned-label { display: none; }
}

/* Botones en la esquina inferior derecha: play a la izquierda, comprar a la derecha */
.beat-card-side-buttons {
  position: absolute; bottom: var(--space-2); right: var(--space-2);
  display: flex; flex-direction: row; gap: var(--space-2);
  z-index: 2;
}
.bc-side-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--radius-full);
  background: rgba(10, 10, 15, 0.75);
  backdrop-filter: blur(8px);
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast), color var(--transition-fast);
}
.bc-side-btn:hover {
  background: var(--gradient-brand);
  color: var(--color-on-primary);
  transform: scale(1.08);
}
.bc-side-btn:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

/* Toggle de icono play/pause según .is-playing en la card */
.bc-side-play .bc-icon-pause { display: none; }
.beat-card.is-playing .bc-side-play .bc-icon-play { display: none; }
.beat-card.is-playing .bc-side-play .bc-icon-pause { display: inline; }

/* Cuando la card está sonando: el botón play queda en gradient + pulso */
.beat-card.is-playing .bc-side-play {
  background: var(--gradient-brand);
  color: var(--color-on-primary);
  animation: bc-pulse 1.6s ease-in-out infinite;
}
@keyframes bc-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0); }
}

/* Marca visible en la card cuando está reproduciendo */
.beat-card.is-playing {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-glow);
}

/* ── BeatCard: elevación underground / Spotify ────────────────────────── */
.beat-card {
  background: color-mix(in srgb, var(--color-surface) 86%, transparent);
}
.beat-card:hover {
  transform: translateY(-6px);
  border-color: color-mix(in srgb, var(--color-primary) 55%, var(--color-border));
  box-shadow: 0 16px 36px -14px rgba(0, 0, 0, 0.6), var(--glow-brand);
}
/* Degradado inferior sobre la portada: hace destacar botones y da profundidad. */
.beat-card-cover-wrap::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 58%;
  background: linear-gradient(to top, rgba(8, 8, 12, 0.72), transparent);
  opacity: 0.6; pointer-events: none; z-index: 1;
  transition: opacity var(--transition-fast);
}
.beat-card:hover .beat-card-cover-wrap::after { opacity: 0.92; }
/* Botón play protagonista: gradiente + glow siempre; crece al hover. */
.bc-side-btn { width: 40px; height: 40px; }
.bc-side-play {
  background: var(--gradient-brand);
  color: var(--color-on-primary);
  box-shadow: var(--glow-brand);
}
.bc-side-play:hover { transform: scale(1.12); }
.bc-side-buy {
  background: color-mix(in srgb, var(--color-bg) 68%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
/* Badge "Nuevo" en neón hype. */
.beat-card-badge-nuevo {
  background: var(--color-hype); color: #fff;
  box-shadow: var(--glow-hype);
}
.beat-card-title { font-weight: 600; letter-spacing: -0.01em; }

.beat-card-body {
  padding: var(--space-3);
  display: flex; flex-direction: column; gap: var(--space-1); flex: 1;
}
.beat-card-title {
  color: var(--color-text); font-weight: 600; line-height: 1.25;
  font-size: var(--fs-sm);
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden;
  text-decoration: none;
}
.beat-card-title:hover { color: var(--color-primary-hover); }
.beat-card-meta {
  margin: 0; color: var(--color-text-muted); font-size: var(--fs-xs);
  display: flex; gap: var(--space-1); align-items: center; flex-wrap: wrap;
}
.beat-card-meta .dot { opacity: .5; }
.beat-card-meta .mono { font-family: var(--font-mono); }

.beat-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto; padding-top: var(--space-2);
}
.beat-card-precio {
  font-family: var(--font-mono); font-weight: 600; font-size: var(--fs-base);
  background: var(--gradient-brand);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.beat-card-precio small { font-size: var(--fs-xs); color: var(--color-text-muted); -webkit-text-fill-color: var(--color-text-muted); }
.beat-card-excl {
  display: inline-block; margin-left: 4px;
  font-size: var(--fs-xs); font-weight: 700;
  padding: 1px 6px; border-radius: var(--radius-full);
  background: var(--gradient-brand); color: var(--color-on-primary) !important;
  -webkit-text-fill-color: var(--color-on-primary);
  letter-spacing: .05em;
}
/* .beat-card-actions / .beat-card-play / .beat-card-comprar quitados
   (rediseño catálogo): el play vive ahora como overlay sobre la portada
   y la card entera es el link al detalle. */

/* Cookie banner (privacy-first) */
.cookie-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  background: var(--color-surface-2);
  border-top: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
}
.cookie-banner-inner {
  max-width: var(--container-max); margin: 0 auto;
  padding: var(--space-4);
  display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap;
}
.cookie-banner p {
  margin: 0; color: var(--color-text-muted); font-size: var(--fs-sm); flex: 1; min-width: 280px;
}
.cookie-banner p a { color: var(--color-primary-hover); }
.cookie-banner-actions {
  display: flex; gap: var(--space-2); flex-wrap: wrap;
}
.cookie-banner button { min-height: 40px; padding: 0 var(--space-4); font-size: var(--fs-sm); }

/* ── Nav móvil vs desktop ─────────────────────────────────────────────── */
/* En móvil: oculta items desktop (la navegación va por bottom-nav). */
.nav-desktop-only { display: none !important; }

/* Avatar en el header móvil — esquina superior derecha */
.nav-mobile-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  margin-left: auto;
  border-radius: var(--radius-full);
  background: var(--gradient-brand);
  color: var(--color-on-primary);
  text-decoration: none;
  font-weight: 700; font-family: var(--font-display);
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  flex-shrink: 0;
}
.nav-mobile-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nav-mobile-avatar:hover { transform: scale(1.06); box-shadow: var(--shadow-glow); color: var(--color-on-primary); }
.nav-mobile-avatar:focus-visible { outline: 2px solid var(--color-focus-ring); outline-offset: 2px; }

/* Avatar de acceso al perfil (autenticado), arriba a la derecha. Visible en móvil y desktop. */
.site-header .nav-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; margin-left: auto; flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--gradient-brand);
  color: var(--color-on-primary);
  text-decoration: none;
  font-weight: 700; font-family: var(--font-display);
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.site-header .nav-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.site-header .nav-avatar:hover { transform: scale(1.06); box-shadow: var(--shadow-glow); color: var(--color-on-primary); }
.site-header .nav-avatar:focus-visible { outline: 2px solid var(--color-focus-ring); outline-offset: 2px; }

@media (min-width: 992px) {
  .nav-desktop-only { display: inline-flex !important; }
  .nav-mobile-avatar { display: none !important; }
  .site-header .nav-spacer { flex: 1; }
}
@media (max-width: 991.98px) {
  /* En móvil: brand a la izquierda, avatar a la derecha (margin-left:auto). */
  .site-header .nav-spacer { display: none; }
  .site-header .nav { gap: var(--space-3); }
}

/* ── Bottom nav (móvil) ───────────────────────────────────────────────── */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  display: flex; align-items: stretch;
  /* La altura SUMA el safe-area-inset (home indicator de iPhone) para que los
     iconos vivan en los 60px superiores y el indicador tenga su propio espacio. */
  height: calc(var(--bottom-nav-h, 60px) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--color-surface-2) 95%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--color-border);
}
.bottom-nav a {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  color: var(--color-text-muted);
  font-size: var(--fs-xs); font-weight: 500;
  text-decoration: none;
  padding: 6px 4px;
}
.bottom-nav a > span {
  max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bottom-nav a:hover { color: var(--color-text); }
.bottom-nav a.is-active {
  color: var(--color-primary-hover);
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}
.bottom-nav-admin {
  color: var(--color-primary-hover) !important;
}

/* ── Bottom-nav flotante glassmorphism (registrados no-staff) ──────────── */
/* Mismo lenguaje que el navbar superior de los no registrados: despegado de
   los bordes, esquinas redondeadas (píldora) y cristal con desenfoque. */
.bottom-nav.bottom-nav--floating {
  left: var(--space-3);
  right: var(--space-3);
  bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  height: var(--bottom-nav-h, 60px);
  padding-bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  border: 1px solid color-mix(in srgb, #fff 12%, transparent);
  border-radius: var(--radius-full);
  overflow: hidden; /* recorta el fondo activo a la píldora */
  background: color-mix(in srgb, var(--color-surface) 60%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  box-shadow:
    0 10px 30px -10px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .bottom-nav.bottom-nav--floating {
    background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  }
}

/* El contenido y el player deben librar la barra flotante (altura + aire).
   Solo en móvil: en desktop el bottom-nav está oculto y manda el reset existente. */
@media (max-width: 991.98px) {
  body.bottom-nav-floating.has-bottom-nav {
    padding-bottom: calc(var(--bottom-nav-h, 60px) + var(--space-6) + env(safe-area-inset-bottom, 0px));
  }
  body.bottom-nav-floating.has-bottom-nav.player-active {
    padding-bottom: calc(var(--bottom-nav-h, 60px) + var(--space-6) + var(--player-h) + env(safe-area-inset-bottom, 0px));
  }
  body.bottom-nav-floating.has-bottom-nav #player-flotante {
    bottom: calc(var(--bottom-nav-h, 60px) + var(--space-6) + env(safe-area-inset-bottom, 0px));
  }
}

/* Empuja el contenido y el player por encima de la bottom-nav (móvil). */
body.has-bottom-nav {
  padding-bottom: calc(var(--bottom-nav-h, 60px) + env(safe-area-inset-bottom, 0px));
}
body.has-bottom-nav.player-active {
  padding-bottom: calc(var(--bottom-nav-h, 60px) + var(--player-h) + env(safe-area-inset-bottom, 0px));
}
body.has-bottom-nav #player-flotante {
  bottom: calc(var(--bottom-nav-h, 60px) + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 992px) {
  /* Desktop: no hay bottom nav. */
  .bottom-nav { display: none; }
  body.has-bottom-nav { padding-bottom: 0; }
  body.has-bottom-nav.player-active { padding-bottom: var(--player-h); }
  body.has-bottom-nav #player-flotante { bottom: 0; }
}

/* ── Layout con sidebar (solo autenticados, desde lg) ─────────────────── */
.layout-wrapper { display: block; }
.layout-main { min-width: 0; }

/* Columna que agrupa main + footer dentro del wrapper. Con esto el footer
   vive en la misma columna del grid que el main → el sidebar sticky se mantiene
   visible aunque scrollees hasta el final de la página. */
.layout-main-col {
  display: flex; flex-direction: column;
  min-width: 0;
}

@media (min-width: 992px) {
  body.has-sidebar .layout-wrapper {
    display: grid;
    grid-template-columns: var(--sidebar-w, 240px) 1fr;
    align-items: start;
  }
  body.has-sidebar.sidebar-collapsed .layout-wrapper {
    grid-template-columns: var(--sidebar-w-collapsed, 64px) 1fr;
  }
}

/* ── Sidebar usuario ──────────────────────────────────────────────────── */
.sidebar-usuario {
  display: none;
}
@media (min-width: 992px) {
  body.has-sidebar .sidebar-usuario {
    display: flex; flex-direction: column;
    position: sticky; top: var(--header-h);
    height: calc(100vh - var(--header-h));
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: var(--space-4) var(--space-3);
    gap: var(--space-3);
    overflow-y: auto;
  }
}

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-2);
}
.sidebar-perfil {
  display: flex; align-items: center; gap: var(--space-3);
  min-width: 0; flex: 1;
}
.sidebar-avatar {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: var(--radius-full);
  background: var(--gradient-brand); color: var(--color-on-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-family: var(--font-display);
  overflow: hidden;
}
.sidebar-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.sidebar-perfil-info {
  display: flex; flex-direction: column; min-width: 0;
}
.sidebar-nombre {
  font-weight: 600; color: var(--color-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-saldo {
  font-size: var(--fs-sm); color: var(--color-text-muted);
}
.sidebar-saldo small { color: var(--color-text-muted); }

.sidebar-toggle {
  flex: 0 0 32px; width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--color-surface-2); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
}
.sidebar-toggle:hover { color: var(--color-primary-hover); border-color: var(--color-primary-hover); }

.sidebar-nav {
  display: flex; flex-direction: column; gap: 2px;
  margin-top: var(--space-2);
}
.sidebar-nav a {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px var(--space-3);
  color: var(--color-text);
  border-radius: var(--radius-md);
  font-weight: 500;
  white-space: nowrap; overflow: hidden;
}
.sidebar-nav a:hover { background: var(--color-surface-2); color: var(--color-primary-hover); }
.sidebar-nav a.is-active {
  background: color-mix(in srgb, var(--color-primary) 15%, transparent);
  color: var(--color-primary-hover);
  position: relative;
}
/* Marca lateral izquierda del item activo (gradient) */
.sidebar-nav a.is-active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  background: var(--gradient-brand);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.sidebar-nav a > svg { flex: 0 0 20px; }
.sidebar-nav a > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.sidebar-sep {
  border: 0; border-top: 1px solid var(--color-border);
  margin: var(--space-2) 0;
}

.sidebar-item-admin {
  background: color-mix(in srgb, var(--color-primary) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-primary) 30%, transparent);
}
.sidebar-item-admin:hover {
  background: color-mix(in srgb, var(--color-primary) 25%, transparent) !important;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}
.sidebar-logout {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%; padding: 10px var(--space-3);
  background: transparent; color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  font-weight: 500;
  white-space: nowrap; overflow: hidden;
}
.sidebar-logout:hover { color: var(--color-danger); border-color: var(--color-danger); }
.sidebar-logout > svg { flex: 0 0 20px; }

/* Estado colapsado: ocultar textos */
body.sidebar-collapsed .sidebar-perfil-info,
body.sidebar-collapsed .sidebar-nav a > span,
body.sidebar-collapsed .sidebar-logout > span {
  display: none;
}
body.sidebar-collapsed .sidebar-head { justify-content: center; flex-direction: column; }
body.sidebar-collapsed .sidebar-perfil { justify-content: center; }
body.sidebar-collapsed .sidebar-nav a,
body.sidebar-collapsed .sidebar-logout { justify-content: center; padding: 10px; }

/* ── Footer ──────────────────────────────────────────────────────── */
.site-footer {
  position: relative;
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  margin-top: var(--space-16);
  padding: var(--space-12) 0 var(--space-6);
}
/* Línea gradient sutil en el borde superior */
.site-footer::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: var(--gradient-brand);
  opacity: 0.6;
}
.site-footer-inner { display: flex; flex-direction: column; gap: var(--space-8); }

/* Grid principal: brand + 2 cols (en desktop 4 cols efectivos con brand 2x) */
.site-footer-grid {
  display: grid; gap: var(--space-8);
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .site-footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
  .site-footer-grid { grid-template-columns: 2fr 1fr 1fr; }
}

/* Bloque de marca */
.site-footer-brand { display: flex; flex-direction: column; gap: var(--space-3); max-width: 360px; }
.site-footer-logo {
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-xl);
  background: var(--gradient-brand);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-decoration: none;
  align-self: flex-start;
}
.site-footer-tagline { margin: 0; line-height: 1.5; color: var(--color-text-muted); }

/* Columnas de enlaces */
.site-footer-col { display: flex; flex-direction: column; gap: var(--space-2); }
.site-footer-title {
  font-family: var(--font-display);
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 var(--space-2);
}
.site-footer-col a {
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 2px 0;
  width: fit-content;
  transition: color var(--transition-fast);
}
.site-footer-col a:hover { color: var(--color-primary-hover); }

/* Barra inferior */
.site-footer-bottom {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted); font-size: var(--fs-xs);
}
.site-footer-bottom p { margin: 0; }
.site-footer-meta a {
  background: var(--gradient-brand);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-weight: 600; text-decoration: none;
  transition: opacity var(--transition-fast);
}
.site-footer-meta a:hover { opacity: 0.85; }

/* Variante compacta: solo barra inferior, sin las 3 columnas. Usada en todas
   las vistas excepto la home. */
.site-footer-compact {
  padding: var(--space-6) 0;
  margin-top: var(--space-8);
}
.site-footer-compact .site-footer-bottom {
  padding-top: 0;
  border-top: 0;
}
