/* =======================================================
   Rhapsody Choir – CORE THEME (Single Source of Truth)
======================================================= */

/* -------------------------------------------------------
   Base layout
-------------------------------------------------------- */

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  margin: 0;
  background: #faf6f2; /* ? warm neutral (Christmas clarity, now core) */
  color: #111;
}

header {
  background: #4b4fa3;
  color: #fff;
  padding: 1rem;
  text-align: center;
  font-size: 1.5rem;
}

nav {
  background: #eee;
  padding: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}

nav a {
  text-decoration: none;
  color: #333;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  background: #e0e0f5;
  border-radius: 999px;
}

/* -------------------------------------------------------
   Content container
-------------------------------------------------------- */

.container {
  padding: 1rem;
  max-width: 900px;
  margin: auto;
}

/* -------------------------------------------------------
   Song groups (accordion panels)
-------------------------------------------------------- */

details {
  background: rgba(255,255,255,0.92);
  border-radius: 16px;
  padding: 0.9rem;
  margin: 0.9rem 0;

  box-shadow:
    0 0 0 1px rgba(76,80,198,0.12),
    0 10px 34px rgba(76,80,198,0.18);
}

details summary {
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 600;
}

details[open] summary {
  margin-bottom: 0.5rem;
}

/* -------------------------------------------------------
   Filter bar
-------------------------------------------------------- */

.filter-bar {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin: 1rem auto 1.2rem;
  flex-wrap: wrap;
  width: 100%;
}

.filter-bar .segment {
  display: inline-flex;
  background: #e3e6ff;
  border-radius: 999px;
  padding: 0.3rem;
}

.filter-bar .segment button {
  border: none;
  background: #e8e9fb;
  color: #3b3f8f;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}

.filter-bar .segment button.active {
  background: #4c50c6;
  color: #fff;
}

.filter-bar .controls {
  display: flex;
  gap: 0.4rem;
}

.filter-bar .controls button {
  border: none;
  background: #4b4fa3;
  color: #fff;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}

.filter-bar .controls button:hover {
  background: #363a82;
}

/* -------------------------------------------------------
   Track rows (CORE clarity + glow)
-------------------------------------------------------- */

.track-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  margin-bottom: 6px;
  border-radius: 14px;

  background: #ffffff;
  line-height: 1.2;

  box-shadow:
    0 4px 12px rgba(0,0,0,0.05),
    0 0 0 1px rgba(0,0,0,0.04);

  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.track-row:hover {
  background: #f5f7ff;
}

/* Dimmed when another track plays */
.track-row.dimmed {
  opacity: 0.45;
}

/* ACTIVE / PLAYING — Christmas-style clarity, purple tone */
.track-row.playing {
  opacity: 1;
  background: #ffffff;

  box-shadow:
    0 0 0 3px rgba(76, 80, 198, 0.45),
    0 0 34px rgba(76, 80, 198, 0.55),
    0 18px 46px rgba(76, 80, 198, 0.45);

  position: relative;
  z-index: 2;
}


/* -------------------------------------------------------
   Track title
-------------------------------------------------------- */

.track-title {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: #f1f3f6;
  border: 1px solid #d7dbe2;
  font-size: 0.8rem;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
}

.track-title.is-empty {
  display: none;
}

.track-row .part-badge {
  margin-right: 6px;
}

/* -------------------------------------------------------
   Part badges
-------------------------------------------------------- */

.part-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;

  border: 1px solid rgba(0,0,0,0.15);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
}

/* Voice colours unchanged */
.part-badge.tenor    { background: #e2f1ff; color: #194c8c; }
.part-badge.lead     { background: #ffe5ec; color: #a03155; }
.part-badge.baritone { background: #e6f5e9; color: #245b3a; }
.part-badge.bass     { background: #fff7d9; color: #735600; }
.part-badge.allparts { background: #eee6ff; color: #4c3585; }
.part-badge.fullmix  { background: #eae7ff; color: #3f2f82; }
.part-badge.track,
.part-badge.nopart   { background: #eceff4; color: #394150; }

/* -------------------------------------------------------
   Audio + download
-------------------------------------------------------- */

.track-row audio {
  min-width: 260px;
  height: 32px;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  background: #4b5cff;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(75,92,255,0.35);
}

.download-btn:hover {
  background: #3b4ae0;
}

/* -------------------------------------------------------
   Now Playing bar (core)
-------------------------------------------------------- */

#now-playing {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: #4b4fa3;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 999px;
  display: none;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 999;
}

#now-playing.visible {
  display: flex;
}

#now-playing button {
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
}

/* -------------------------------------------------------
   Scroll to top
-------------------------------------------------------- */

#scroll-top {
  position: fixed;
  right: 16px;
  bottom: 80px;
  border: none;
  background: #4b4fa3;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
}

/* =======================================================
   CHRISTMAS THEME (Overlay Only)
======================================================= */

body.christmas-theme {
  background: #fdf7f2;
}

body.christmas-theme header {
  background: linear-gradient(90deg, #b30000, #e04040);
}

body.christmas-theme nav a {
  background: #ffe9e9;
  color: #900;
  border: 1px solid #ffbcbc;
}

body.christmas-theme details {
  border: 1px solid #ffd7d7;
  box-shadow: 0 6px 18px rgba(255,0,0,0.18);
}

body.christmas-theme #now-playing {
  background: #b30000;
}

body.christmas-theme {
  --xmas-main: #b30000;
  --xmas-accent: #e04040;
  --xmas-soft: #fff0f0;
  --xmas-glow: rgba(227, 64, 64, 0.55);
}

/* Filter bar */
body.christmas-theme .filter-bar .segment {
  background: #ffe3e3;
}

body.christmas-theme .filter-bar .segment button {
  background: #ffecec;
  color: #8a0000;
}

body.christmas-theme .filter-bar .segment button.active {
  background: var(--xmas-main);
  color: #fff;
}

/* Expand / Collapse buttons */
body.christmas-theme .filter-bar .controls button {
  background: var(--xmas-main);
}

body.christmas-theme .filter-bar .controls button:hover {
  background: #8f0000;
}

body.christmas-theme .track-row:hover {
  background: #fff6f6;
}

/* Christmas playing track — STRONG glow */
body.christmas-theme .track-row.playing {
  background: #fff;
  box-shadow:
    0 0 0 3px rgba(227, 64, 64, 0.6),
    0 0 32px rgba(227, 64, 64, 0.65),
    0 16px 40px rgba(227, 64, 64, 0.45);
}

body.christmas-theme .download-btn {
  background: var(--xmas-main);
  box-shadow: 0 4px 14px rgba(227,64,64,0.6);
}

body.christmas-theme .download-btn:hover {
  background: #8f0000;
}

body.christmas-theme .part-badge {
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.5),
    0 0 0 1px rgba(227,64,64,0.25);
}

.track-row.playing::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 18px;
  background: radial-gradient(
    circle,
    rgba(76,80,198,0.25),
    transparent 70%
  );
  z-index: -1;
}

body.christmas-theme .track-row.playing::after {
  background: radial-gradient(
    circle,
    rgba(227,64,64,0.35),
    transparent 70%
  );
}

#now-playing .np-repeat.active {
  background: rgba(255,255,255,0.35);
}

#now-playing .np-repeat {
  font-weight: 600;
  padding: 0.25rem 0.6rem;
}

#now-playing .np-repeat.active {
  background: rgba(255,255,255,0.35);
  font-weight: 600;
}

     #now-playing .np-repeat {
  transition: background 0.2s ease, font-weight 0.2s ease;
}

/* =========================================================
   MOBILE OPTIMISATION — Rhapsody Choir
   Applies to screens = 520px only
========================================================= */

@media (max-width: 520px) {

  /* -----------------------------------------------------
     Reserve space for Now Playing bar (prevents overlap)
  ----------------------------------------------------- */
  body {
    padding-bottom: 96px;
  }

  /* -----------------------------------------------------
     Track row layout (flat markup-safe)
     Row 1: badges + title | play
     Row 2: controls (when visible)
  ----------------------------------------------------- */
  .track-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "meta audio"
      "controls controls";
    gap: 10px;
    padding: 12px;
  }

  /* Badges + title treated as a visual group */
  /*.track-row .descriptor-badge,*/
  .track-row .track-title {
    grid-area: meta;
  }

  .track-row .track-title {
    display: inline-block;
    font-size: 0.9rem;
  }

  /* Audio play button */
  .track-row audio {
    grid-area: audio;
    min-width: 48px;
    min-height: 48px;
  }

  /* -----------------------------------------------------
     Secondary controls (hidden by default on mobile)
  ----------------------------------------------------- */
  .track-row input[type="range"],
  .track-row .download-btn {
    display: none;
    grid-column: 1 / -1;
  }

  /* Reveal controls only for active track */
  .track-row.is-playing input[type="range"],
  .track-row.is-playing .download-btn {
    display: block;
  }

  .track-row.is-playing input[type="range"] {
    height: 34px;
    margin-top: 6px;
  }

  .track-row.is-playing .download-btn {
    width: 100%;
    font-size: 0.95rem;
    padding: 10px 14px;
    opacity: 0.9;
    margin-top: 4px;
  }

  /* -----------------------------------------------------
     Touch targets (Apple HIG)
  ----------------------------------------------------- */
  .play-btn,
  .np-stop,
  .repeat-btn {
    min-width: 44px;
    min-height: 44px;
    border-radius: 12px;
  }

  /* -----------------------------------------------------
     Active track glow (stronger on mobile)
  ----------------------------------------------------- */
  .track-row.is-playing {
    box-shadow:
      0 0 0 2px rgba(120, 110, 255, 0.45),
      0 10px 24px rgba(120, 110, 255, 0.25);
  }

  /* -----------------------------------------------------
     Badge compaction
  ----------------------------------------------------- */
  .part-badge,
  .descriptor-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
  }

  /* -----------------------------------------------------
     Song cards / accordion spacing
  ----------------------------------------------------- */
  .song-card {
    margin-bottom: 16px;
  }

  .song-header {
    padding: 16px;
    font-size: 1.05rem;
  }

  /* -----------------------------------------------------
     Now Playing bar (mobile polish)
  ----------------------------------------------------- */
  #now-playing {
    position: fixed;
    bottom: 0;
    padding: 10px 12px;
    gap: 8px;
    font-size: 0.9rem;
  }

  #now-playing .np-track {
    line-height: 1.2;
  }

  #now-playing button {
    min-width: 40px;
    min-height: 40px;
  }
}


@media (max-width: 520px) {
  .track-row:not(.is-playing) .speed-slider,
  .track-row:not(.is-playing) .download-btn {
    display: none !important;
  }
}

@media (max-width: 520px) {
  .track-row {
    margin-bottom: 8px;
  }
}
