/* © 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: 100px 24px 20px;
  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.6rem, 4vw, 2.5rem);
  font-weight: 700;
  color: var(--lib-text);
  margin: 0 0 10px;
  line-height: 1.2;
}

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

.hero-subtitle {
  font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  color: var(--lib-text-secondary);
  margin: 0 0 20px;
  line-height: 1.5;
}

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


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

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

.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);
}


/* ═══════════════════════════════════════════
   FILTER BAR (Compact dropdown system)
   ═══════════════════════════════════════════ */

.library-filters {
  position: sticky;
  top: 52px;
  z-index: 40;
  background: var(--lib-surface);
  border-bottom: 1px solid var(--lib-border);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  padding: 10px 24px;
}

[data-theme="dark"] .library-filters {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 720px;
  margin: 0 auto;
}

/* ── Dropdown Container ── */
.filter-dropdown {
  position: relative;
}

/* ── Trigger Button ── */
.filter-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.82rem;
  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 0.2s ease;
  white-space: nowrap;
  line-height: 1;
}

.filter-trigger:hover {
  border-color: var(--lib-accent-light);
  color: var(--lib-accent);
}

.filter-trigger[aria-expanded="true"] {
  border-color: var(--lib-accent);
  color: var(--lib-accent);
  background: rgba(139, 92, 246, 0.06);
  box-shadow: 0 0 0 3px var(--lib-accent-glow);
}

.filter-trigger[aria-expanded="true"] .filter-trigger__arrow {
  transform: rotate(180deg);
}

.filter-trigger__arrow {
  font-size: 0.6rem;
  opacity: 0.5;
  transition: transform 0.2s ease;
}

.filter-trigger__label {
  pointer-events: none;
}

/* ── Active filter badge ── */
.filter-trigger__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  background: var(--lib-gradient);
  border-radius: 50px;
  line-height: 1;
}

/* ── Dropdown Panel ── */
.filter-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  max-width: 360px;
  padding: 12px;
  background: var(--lib-surface-elevated);
  border: 1px solid var(--lib-border);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  z-index: 100;
  animation: filterPanelIn 0.15s ease;
}

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

.filter-dropdown.open .filter-panel {
  display: block;
}

@keyframes filterPanelIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.filter-panel__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Filter Chips (inside panels) ── */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--lib-text-secondary);
  background: var(--lib-surface);
  border: 1.5px solid var(--lib-border);
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

.filter-chip.active {
  background: var(--lib-gradient);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 2px 10px var(--lib-accent-glow);
}

.filter-chip.active:hover {
  box-shadow: 0 4px 16px var(--lib-accent-glow);
}

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

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

/* ── Difficulty color accents ── */
.difficulty-chip[data-difficulty="Beginner"] { border-left: 3px solid #22c55e; }
.difficulty-chip[data-difficulty="Beginner"] i { color: #22c55e; }
.difficulty-chip[data-difficulty="Easy"] { border-left: 3px solid #3b82f6; }
.difficulty-chip[data-difficulty="Easy"] i { color: #3b82f6; }
.difficulty-chip[data-difficulty="Intermediate"] { border-left: 3px solid #f59e0b; }
.difficulty-chip[data-difficulty="Intermediate"] i { color: #f59e0b; }
.difficulty-chip[data-difficulty="Hard"] { border-left: 3px solid #ef4444; }
.difficulty-chip[data-difficulty="Hard"] i { color: #ef4444; }

.difficulty-chip.active[data-difficulty="Beginner"] {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  box-shadow: 0 2px 10px rgba(34, 197, 94, 0.3);
  border-left-color: transparent;
}
.difficulty-chip.active[data-difficulty="Easy"] {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
  border-left-color: transparent;
}
.difficulty-chip.active[data-difficulty="Intermediate"] {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
  border-left-color: transparent;
}
.difficulty-chip.active[data-difficulty="Hard"] {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.3);
  border-left-color: transparent;
}


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

.library-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 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;
}


/* ═══════════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════════ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 36px 0 20px;
  flex-wrap: wrap;
}

.page-btn,
.page-btn-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--lib-border);
  border-radius: var(--lib-radius);
  background: var(--lib-surface-card);
  color: var(--lib-text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--lib-transition);
  user-select: none;
}

.page-btn:hover:not(:disabled),
.page-btn-nav:hover:not(:disabled) {
  background: var(--lib-accent);
  color: #fff;
  border-color: var(--lib-accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

.page-btn.active {
  background: var(--lib-accent);
  color: #fff;
  border-color: var(--lib-accent);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
  font-weight: 600;
}

.page-btn:disabled,
.page-btn-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-btn-nav {
  font-size: 1.2rem;
  font-weight: 700;
}

.page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 40px;
  color: var(--lib-text-muted);
  font-size: 1rem;
  letter-spacing: 2px;
}

.page-info {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 8px;
  color: var(--lib-text-muted);
  font-size: 0.82rem;
}


/* ═══════════════════════════════════════════
   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: 80px 16px 14px;
  }

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

  .song-card {
    padding: 20px;
  }

  /* Compact filter bar on mobile */
  .library-filters {
    padding: 8px 12px;
    top: 44px;
  }

  .filter-bar {
    gap: 6px;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

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

  .filter-trigger {
    padding: 7px 12px;
    font-size: 0.76rem;
    flex-shrink: 0;
  }

  .filter-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    max-width: 100%;
    width: 100%;
    border-radius: 20px 20px 0 0;
    padding: 20px 16px calc(env(safe-area-inset-bottom, 16px) + 16px);
    max-height: 50vh;
    overflow-y: auto;
    animation: filterPanelSlideUp 0.2s ease;
  }

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

  /* Backdrop overlay on mobile */
  .filter-dropdown.open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99;
  }

  .filter-panel__chips {
    gap: 8px;
  }

  .filter-chip {
    padding: 9px 16px;
    font-size: 0.82rem;
  }

  .hero-features {
    gap: 6px;
  }

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

  .pagination {
    gap: 4px;
    margin: 24px 0 16px;
  }

  .page-btn,
  .page-btn-nav {
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    font-size: 0.82rem;
  }

  .page-btn-nav {
    font-size: 1.1rem;
  }
}

@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);
  }
}
