/* © 2024-2026 Mehdi TMIMI — Vivace Music (vivace-music.org) */
/* Library Section Styles — /library/ */

/* ═══════════════════════════════════════════
   CSS VARIABLES (inherits from main.css)
   ═══════════════════════════════════════════ */

:root {
  --lib-accent: #7c3aed;
  --lib-accent-light: #8b5cf6;
  --lib-accent-glow: rgba(124, 58, 237, 0.2);
  --lib-gradient: linear-gradient(135deg, #8b5cf6, #ec4899);
  --lib-surface: #f8f9fc;
  --lib-surface-elevated: #ffffff;
  --lib-surface-card: #ffffff;
  --lib-text: #1a1a2e;
  --lib-text-secondary: #4a5568;
  --lib-text-muted: #9ca3af;
  --lib-border: rgba(0, 0, 0, 0.08);
  --lib-radius: 16px;
  --lib-radius-sm: 10px;
  --lib-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Override main.css section fade-in (no IntersectionObserver on this page) */
section {
  opacity: 1 !important;
  transform: none !important;
}

[data-theme="dark"] {
  --lib-accent: #8b5cf6;
  --lib-accent-light: #a78bfa;
  --lib-accent-glow: rgba(139, 92, 246, 0.3);
  --lib-surface: #0e0f17;
  --lib-surface-elevated: #1a1b2e;
  --lib-surface-card: #161729;
  --lib-text: #e8e8f0;
  --lib-text-secondary: #9ca3b0;
  --lib-text-muted: #6b7280;
  --lib-border: rgba(139, 92, 246, 0.15);
}


/* ═══════════════════════════════════════════
   HERO SECTION
   ═══════════════════════════════════════════ */

.library-hero {
  position: relative;
  padding: 140px 24px 60px;
  text-align: center;
  background: var(--lib-surface);
  overflow: hidden;
}

.library-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(139, 92, 246, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 30%, rgba(236, 72, 153, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 90%, rgba(59, 130, 246, 0.06) 0%, transparent 40%);
  pointer-events: none;
}

.hero-bg-notes {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.hero-bg-notes span {
  position: absolute;
  font-size: 2rem;
  opacity: 0.06;
  animation: float-note 12s infinite ease-in-out;
  color: var(--lib-accent);
}

.hero-bg-notes span:nth-child(1) { left: 8%; top: 20%; animation-delay: 0s; font-size: 2.5rem; }
.hero-bg-notes span:nth-child(2) { left: 25%; top: 60%; animation-delay: 2s; font-size: 1.8rem; }
.hero-bg-notes span:nth-child(3) { left: 50%; top: 15%; animation-delay: 4s; font-size: 3rem; }
.hero-bg-notes span:nth-child(4) { left: 70%; top: 55%; animation-delay: 1s; font-size: 2.2rem; }
.hero-bg-notes span:nth-child(5) { left: 88%; top: 25%; animation-delay: 3s; font-size: 1.6rem; }
.hero-bg-notes span:nth-child(6) { left: 40%; top: 75%; animation-delay: 5s; font-size: 2rem; }

@keyframes float-note {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.06; }
  25% { transform: translateY(-20px) rotate(10deg); opacity: 0.1; }
  50% { transform: translateY(-8px) rotate(-5deg); opacity: 0.04; }
  75% { transform: translateY(-25px) rotate(8deg); opacity: 0.08; }
}

.hero-content {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  z-index: 1;
}

.library-hero h1 {
  font-family: 'Poppins', sans-serif;
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 700;
  color: var(--lib-text);
  margin: 0 0 16px;
  line-height: 1.2;
}

.hero-icon {
  display: inline-block;
  font-size: 0.85em;
  margin-right: 8px;
}

.hero-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  color: var(--lib-text-secondary);
  margin: 0 0 32px;
  line-height: 1.6;
}

.hero-subtitle strong {
  color: var(--lib-accent-light);
}


/* ═══════════════════════════════════════════
   SEARCH BAR
   ═══════════════════════════════════════════ */

.library-search {
  position: relative;
  max-width: 560px;
  margin: 0 auto 28px;
}

.library-search .search-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--lib-text-muted);
  font-size: 1rem;
  pointer-events: none;
  transition: color var(--lib-transition);
}

.library-search input {
  width: 100%;
  padding: 16px 48px 16px 52px;
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  color: var(--lib-text);
  background: var(--lib-surface-elevated);
  border: 2px solid var(--lib-border);
  border-radius: 50px;
  outline: none;
  transition: all var(--lib-transition);
  -webkit-appearance: none;
}

.library-search input::placeholder {
  color: var(--lib-text-muted);
}

.library-search input:focus {
  border-color: var(--lib-accent);
  box-shadow: 0 0 0 4px var(--lib-accent-glow), 0 8px 32px rgba(0, 0, 0, 0.15);
}

.library-search input:focus ~ .search-icon {
  color: var(--lib-accent);
}

.search-clear {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 50%;
  color: var(--lib-text-secondary);
  cursor: pointer;
  transition: all var(--lib-transition);
}

.search-clear:hover {
  background: rgba(139, 92, 246, 0.2);
  color: var(--lib-accent);
}


/* ═══════════════════════════════════════════
   FEATURE TAGS
   ═══════════════════════════════════════════ */

.hero-features {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.feature-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--lib-text-secondary);
  background: var(--lib-surface-elevated);
  border: 1px solid var(--lib-border);
  border-radius: 50px;
  white-space: nowrap;
}

.feature-tag i {
  color: var(--lib-accent-light);
  font-size: 0.8rem;
}


/* ═══════════════════════════════════════════
   FILTER CHIPS
   ═══════════════════════════════════════════ */

.library-filters {
  padding: 0 24px;
  margin-bottom: 8px;
  background: var(--lib-surface);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 0;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--lib-text-secondary);
  background: var(--lib-surface-elevated);
  border: 1.5px solid var(--lib-border);
  border-radius: 50px;
  cursor: pointer;
  transition: all var(--lib-transition);
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--lib-accent);
  color: var(--lib-accent);
  background: rgba(139, 92, 246, 0.08);
}

.filter-chip.active {
  background: var(--lib-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px var(--lib-accent-glow);
}

.filter-chip.active i {
  color: #fff;
}

.filter-chip i {
  font-size: 0.82rem;
}


/* ═══════════════════════════════════════════
   RESULTS INFO
   ═══════════════════════════════════════════ */

.library-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 80px;
  min-height: 60vh;
}

.results-info {
  font-family: 'Poppins', sans-serif;
  font-size: 0.9rem;
  color: var(--lib-text-muted);
  margin-bottom: 20px;
  padding-left: 4px;
}


/* ═══════════════════════════════════════════
   SONGS GRID
   ═══════════════════════════════════════════ */

.songs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.song-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--lib-surface-card);
  border: 1px solid var(--lib-border);
  border-radius: var(--lib-radius);
  text-decoration: none;
  color: inherit;
  transition: all var(--lib-transition);
  animation: fadeInUp 0.5s ease both;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.song-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--lib-gradient);
  opacity: 0;
  transition: opacity var(--lib-transition);
}

.song-card:hover {
  border-color: var(--lib-accent);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(139, 92, 246, 0.1);
}

.song-card:hover::before {
  opacity: 1;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.card-icon {
  font-size: 1.6rem;
}

.difficulty-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 50px;
  letter-spacing: 0.02em;
}

.badge-beginner {
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-medium {
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-hard {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.card-title {
  font-family: 'Poppins', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--lib-text);
  margin: 0 0 12px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  flex: 1;
  align-items: center;
  align-content: flex-start;
}

.song-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1;
  color: var(--lib-accent-light);
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 50px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--lib-border);
}

.play-label {
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--lib-accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

.play-label i {
  font-size: 1rem;
}

.card-arrow {
  color: var(--lib-text-muted);
  transition: all var(--lib-transition);
}

.song-card:hover .card-arrow {
  color: var(--lib-accent);
  transform: translateX(4px);
}


/* ═══════════════════════════════════════════
   NO RESULTS
   ═══════════════════════════════════════════ */

.no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: var(--lib-text-muted);
}

.no-results i {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.3;
}

.no-results h3 {
  font-family: 'Poppins', sans-serif;
  font-size: 1.3rem;
  color: var(--lib-text-secondary);
  margin: 0 0 8px;
}

.no-results p {
  font-size: 0.95rem;
}


/* ═══════════════════════════════════════════
   DARK THEME OVERRIDES
   ═══════════════════════════════════════════ */

[data-theme="dark"] .library-hero {
  background: var(--lib-surface);
}

[data-theme="dark"] .song-card:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(139, 92, 246, 0.3);
}

[data-theme="dark"] .badge-beginner {
  background: rgba(34, 197, 94, 0.15);
}

[data-theme="dark"] .badge-medium {
  background: rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .badge-hard {
  background: rgba(239, 68, 68, 0.15);
}


/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width: 768px) {
  .library-hero {
    padding: 120px 16px 40px;
  }

  .songs-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .song-card {
    padding: 20px;
  }

  .filter-row {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 12px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .filter-row::-webkit-scrollbar {
    display: none;
  }

  .filter-chip {
    flex-shrink: 0;
  }

  .hero-features {
    gap: 6px;
  }

  .feature-tag {
    font-size: 0.72rem;
    padding: 5px 10px;
  }
}

@media (max-width: 480px) {
  .library-search input {
    padding: 14px 44px 14px 46px;
    font-size: 0.9rem;
  }
}

@media (min-width: 1400px) {
  .songs-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
