/* ============================================
   Portal Music — Stylesheet
   ============================================ */

/* --- Theme Variables --- */
:root {
  --bg: #080818;
  --surface: #0f0f2a;
  --card: #161630;
  --card-hover: #1e1e42;
  --accent: #7c3aed;
  --accent-2: #2563eb;
  --accent-light: #a855f7;
  --accent-glow: rgba(124, 58, 237, 0.25);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: rgba(124, 58, 237, 0.2);
  --nav-bg: rgba(8, 8, 24, 0.96);
  --player-bg: #0d0d22;
  --chip-bg: rgba(124, 58, 237, 0.12);
  --chip-hover: rgba(124, 58, 237, 0.28);
  --heart: #ef4444;
  --fav-banner-bg: rgba(239, 68, 68, 0.08);
  --fav-banner-border: rgba(239, 68, 68, 0.3);
}

[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #f1f5f9;
  --card: #ffffff;
  --card-hover: #f1f5f9;
  --accent: #7c3aed;
  --accent-2: #2563eb;
  --accent-light: #8b5cf6;
  --accent-glow: rgba(124, 58, 237, 0.1);
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --nav-bg: rgba(255, 255, 255, 0.96);
  --player-bg: #1e293b;
  --chip-bg: #f3f0ff;
  --chip-hover: #ede9fe;
  --fav-banner-bg: rgba(239, 68, 68, 0.06);
  --fav-banner-border: rgba(239, 68, 68, 0.25);
}

[data-theme="sepia"] {
  --bg: #f5ece0;
  --surface: #ede0cc;
  --card: #f9f2e7;
  --card-hover: #ede0cc;
  --accent: #9a3b1c;
  --accent-2: #7a5c2e;
  --accent-light: #b54c28;
  --accent-glow: rgba(154, 59, 28, 0.15);
  --text: #2d1b0e;
  --text-muted: #6b4c35;
  --border: #d4b896;
  --nav-bg: rgba(245, 236, 224, 0.96);
  --player-bg: #2d1b0e;
  --chip-bg: rgba(154, 59, 28, 0.08);
  --chip-hover: rgba(154, 59, 28, 0.18);
  --fav-banner-bg: rgba(154, 59, 28, 0.08);
  --fav-banner-border: rgba(154, 59, 28, 0.3);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 100px;
  transition: background 0.3s, color 0.3s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-light); }
img { max-width: 100%; display: block; }

/* --- Favorites Banner --- */
.fav-banner {
  background: var(--fav-banner-bg);
  border-bottom: 1px solid var(--fav-banner-border);
  padding: 8px 5%;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  z-index: 99;
}

.fav-banner-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0 4px;
  line-height: 1;
  margin-left: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.fav-banner-dismiss:hover { opacity: 1; }

/* --- Header --- */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 5%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
  gap: 16px;
}

.logo {
  font-size: 1.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}
.nav-links a:hover { background: var(--chip-bg); color: var(--text); }
.nav-links a.active { color: var(--accent); }

.theme-btns {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.theme-btn {
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 9px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.82rem;
  transition: all 0.2s;
  line-height: 1;
}
.theme-btn:hover, .theme-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* --- Container --- */
.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

/* --- Hero / Search Section --- */
.hero {
  text-align: center;
  padding: 4rem 0 2.5rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 1rem;
  color: var(--text);
}

.hero h1 span {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.search-bar-wrap {
  position: relative;
  max-width: 620px;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
  opacity: 0.5;
}

.search-input {
  width: 100%;
  padding: 15px 120px 15px 50px;
  border-radius: 50px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.search-input::placeholder { color: var(--text-muted); }

.search-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 10px 22px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.search-btn:hover { background: var(--accent-light); }
.search-btn:active { transform: translateY(-50%) scale(0.97); }

/* --- Section Headers --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2.5rem 0 1.25rem;
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-header a, .section-header button {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s;
  padding: 0;
  font-family: inherit;
}
.section-header a:hover, .section-header button:hover { color: var(--accent); }

/* --- Genre Grid --- */
.genre-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 1rem;
}

.genre-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.22s;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.genre-card:hover {
  background: var(--card-hover);
  border-color: var(--accent);
  box-shadow: 0 4px 22px var(--accent-glow);
  transform: translateY(-2px);
  color: var(--text);
}

.genre-icon { font-size: 1.8rem; line-height: 1; }
.genre-name { font-weight: 700; font-size: 0.9rem; }
.genre-count { font-size: 0.72rem; color: var(--text-muted); }

/* --- Chips Row --- */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 50px;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.18s;
  white-space: nowrap;
  font-family: inherit;
}
.chip:hover, .chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* --- Music Cards --- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.music-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.22s;
  position: relative;
}
.music-card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 28px var(--accent-glow);
  transform: translateY(-2px);
}

.music-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.music-card-art {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.fav-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  color: var(--text-muted);
  transition: color 0.18s, transform 0.1s;
  line-height: 1;
}
.fav-btn:hover { color: var(--heart); }
.fav-btn.active { color: var(--heart); }
.fav-btn:active { transform: scale(1.35); }

.music-card h3 {
  font-size: 0.975rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 2px;
}

.artist-name {
  font-size: 0.8rem;
  color: var(--accent-light);
  font-weight: 500;
  margin-bottom: 6px;
}

.meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.badge {
  padding: 2px 9px;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--chip-bg);
  color: var(--accent-light);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.subgenre {
  background: rgba(37, 99, 235, 0.08);
  color: #60a5fa;
  border-color: rgba(37, 99, 235, 0.18);
}

.tags {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

.btn-play {
  flex: 1;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: inherit;
}
.btn-play:hover { background: var(--accent-light); }
.btn-play.playing { background: var(--accent-2); }

.btn-dl {
  background: var(--chip-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
}
.btn-dl:hover {
  background: var(--chip-hover);
  border-color: var(--accent);
  color: var(--text);
}

/* --- Artist Cards --- */
.artists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.artist-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.22s;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  display: block;
}
.artist-card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 32px var(--accent-glow);
  transform: translateY(-3px);
  color: var(--text);
}

.artist-card-img {
  width: 100%;
  height: 190px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  overflow: hidden;
}
.artist-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.artist-card-info { padding: 1.2rem; }
.artist-card-info h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: 4px; }
.artist-genre-tag { font-size: 0.8rem; color: var(--accent-light); margin-bottom: 8px; font-weight: 500; }
.artist-card-info p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.55; }

/* --- Ad Slots --- */
.ad-slot {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 12px;
  min-height: 90px;
  display: block;
  margin: 1.5rem 0;
  overflow: hidden;
  text-align: center;
}
/* The adsbygoogle ins element */
.ad-slot ins.adsbygoogle {
  display: block !important;
  border-radius: 12px;
  overflow: hidden;
}
/* Fallback label shown when no ad renders */
.ad-slot .ad-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.ad-slot.tall { min-height: 280px; }
.ad-slot.tall .ad-label { min-height: 280px; }

/* --- Player Bar --- */
#player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--player-bg);
  border-top: 1px solid var(--accent);
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.5);
  padding: 10px 5%;
  display: none;
  align-items: center;
  gap: 14px;
}
#player-bar.visible { display: flex; }

.player-art {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.player-info { min-width: 0; flex: 1; }
.player-title {
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: white;
}
.player-artist { font-size: 0.75rem; color: rgba(255, 255, 255, 0.55); }

.player-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.player-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: white;
  font-size: 1.1rem;
  padding: 7px;
  border-radius: 50%;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  line-height: 1;
}
.player-btn:hover { background: rgba(255, 255, 255, 0.1); }

#play-pause-btn {
  background: var(--accent);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1rem;
  justify-content: center;
}
#play-pause-btn:hover { background: var(--accent-light); }

.player-progress {
  flex: 2;
  min-width: 100px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-track {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  width: 0%;
  pointer-events: none;
  transition: width 0.1s linear;
}

.player-time {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  min-width: 80px;
  text-align: right;
}

.player-fav {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.4);
  transition: color 0.2s;
  padding: 4px;
  flex-shrink: 0;
}
.player-fav:hover, .player-fav.active { color: var(--heart); }

/* --- Browse Page --- */
.browse-header { padding: 2rem 0 0.5rem; }
.browse-header h1 { font-size: 2rem; font-weight: 900; letter-spacing: -0.02em; }
.browse-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

.subgenre-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

/* --- Search Page --- */
.search-page-wrap { padding: 2rem 0 1rem; }
.search-results-info { color: var(--text-muted); font-size: 0.9rem; margin: 0.5rem 0 1.5rem; }

/* --- Empty / No Results --- */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 1rem; }

/* --- Download Page --- */
.download-wrap {
  max-width: 560px;
  margin: 5rem auto;
  text-align: center;
  padding: 0 5%;
}
.download-wrap h1 { font-size: 1.8rem; font-weight: 900; }
.download-wrap .dl-subtitle { color: var(--text-muted); margin-top: 6px; font-size: 0.95rem; }

.countdown-ring {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--chip-bg);
  border: 3px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--accent);
  margin: 2rem auto;
}

.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
  font-family: inherit;
}
.dl-btn:hover { background: var(--accent-light); color: white; }

/* --- License Page --- */
.license-wrap { max-width: 820px; margin: 4rem auto; padding: 0 5%; }
.license-wrap h1 { font-size: 2rem; font-weight: 900; margin-bottom: 2rem; }
.license-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.license-section h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.75rem; }
.license-section ul { padding-left: 1.25rem; line-height: 2.1; }
.license-section p { line-height: 1.7; }
.license-section code {
  display: block;
  margin-top: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: 8px;
  font-size: 0.88rem;
  border: 1px solid var(--border);
}

/* --- Favorites Section --- */
.favs-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 1rem 0;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  header { padding: 0 4%; gap: 10px; }
  .container { width: 94%; }
  .genre-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
  .artists-grid { grid-template-columns: 1fr 1fr; }
  .player-progress { display: none; }
  .nav-links a { display: none; }
  .search-input { padding: 13px 115px 13px 45px; }
}

@media (max-width: 540px) {
  .grid { grid-template-columns: 1fr; }
  .artists-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.9rem; }
  .genre-grid { grid-template-columns: repeat(3, 1fr); }
  .browse-header h1 { font-size: 1.6rem; }
}
