/* ==============================
   V3 DESIGN TOKENS & BASE
   Warm & Grounded — unified across all pages
   ============================== */
:root {
  /* Brand — Music Disciple */
  --md-green: #2d5f3f;
  --md-green-light: #3a7a52;
  --md-green-dim: rgba(45, 95, 63, 0.08);
  --md-gold: #9e7f1f;
  --md-gold-light: #d4a84b;
  --md-gold-dim: rgba(184, 146, 45, 0.08);
  --md-gold-glow: rgba(184, 146, 45, 0.12);
  --md-gold-border: rgba(184, 146, 45, 0.25);

  /* Legacy brand aliases (used by some components) */
  --green-500: #2d5f3f;
  --green-600: #1a4a2e;
  --green-700: #14532d;
  --gold-400: #d4a84b;
  --gold-100: #fef3c7;

  /* Semantic — Verdict Tiers */
  --tier-listen: #10b981;
  --tier-discern: #06b6d4;
  --tier-caution: #d97706;
  --tier-avoid: #ef4444;
  --md-emerald: #10b981;
  --md-discern: #06b6d4;
  --md-caution: #d97706;
  --md-avoid: #ef4444;
  --md-emerald-dim: rgba(16, 185, 129, 0.08);
  --md-discern-dim: rgba(6, 182, 212, 0.08);
  --md-caution-dim: rgba(217, 119, 6, 0.08);
  --md-avoid-dim: rgba(239, 68, 68, 0.08);

  /* Surfaces — Warm cream palette */
  --md-bg: #faf6f0;
  --md-surface: #ece4d6;
  --md-surface-raised: #fff9f0;
  --md-surface-hover: #ebe4d8;

  /* Legacy surface aliases (for components not yet migrated) */
  --bg-primary: #faf6f0;
  --bg-surface: #ece4d6;
  --bg-surface-raised: #fff9f0;
  --bg-surface-hover: #ebe4d8;

  /* Text — Warm brown */
  --md-text: #2c2417;
  --md-text-secondary: #6b5d4f;
  --md-text-muted: #7a6c5c;

  /* Legacy text aliases */
  --text-primary: #2c2417;
  --text-secondary: #6b5d4f;
  --text-tertiary: #7a6c5c;

  /* Borders — Warm */
  --md-border: rgba(44, 36, 23, 0.08);
  --md-border-mid: rgba(44, 36, 23, 0.14);

  /* Legacy border aliases */
  --border-subtle: rgba(44, 36, 23, 0.08);
  --border-default: rgba(44, 36, 23, 0.14);
  --border-strong: rgba(44, 36, 23, 0.24);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --md-radius-sm: 10px;
  --md-radius-md: 14px;
  --md-radius-lg: 16px;
  --md-radius-xl: 20px;
  --md-radius-pill: 50px;

  /* Shadows */
  --md-shadow-sm: 0 1px 3px rgba(44, 36, 23, 0.06);
  --md-shadow-md: 0 4px 16px rgba(44, 36, 23, 0.08);
  --md-shadow-lg: 0 8px 40px rgba(44, 36, 23, 0.1);

  /* Footer */
  --md-footer-bg: #1e3328;
  --md-footer-text: rgba(237, 232, 223, 0.6);
  --md-footer-text-hover: rgba(237, 232, 223, 0.9);
  --md-footer-text-dim: rgba(237, 232, 223, 0.4);

  /* Fluid typography scale (mobile 375px → desktop 1440px+)
     Uses clamp() so sizes adapt to viewport without breakpoints.
     At 1440p 27": body ≈ 20px, headings scale proportionally. */
  --fs-xs:    clamp(0.8125rem, 0.78rem + 0.15vw, 0.9375rem);     /* ~13px → 15px */
  --fs-sm:    clamp(0.9375rem, 0.89rem + 0.2vw, 1.0625rem);      /* ~15px → 17px */
  --fs-base:  clamp(1.0625rem, 1rem + 0.3vw, 1.25rem);           /* ~17px → 20px */
  --fs-md:    clamp(1.125rem, 1.05rem + 0.35vw, 1.375rem);       /* ~18px → 22px */
  --fs-lg:    clamp(1.375rem, 1.27rem + 0.5vw, 1.6875rem);       /* ~22px → 27px */
  --fs-xl:    clamp(1.625rem, 1.48rem + 0.7vw, 2.125rem);        /* ~26px → 34px */
  --fs-2xl:   clamp(2rem, 1.8rem + 1vw, 2.75rem);                /* ~32px → 44px */
  --fs-3xl:   clamp(2.5rem, 2.2rem + 1.3vw, 3.5rem);             /* ~40px → 56px */

  /* Fluid spacing */
  --space-xs:  clamp(0.25rem, 0.2rem + 0.25vw, 0.5rem);
  --space-sm:  clamp(0.5rem, 0.4rem + 0.5vw, 1rem);
  --space-md:  clamp(1rem, 0.8rem + 1vw, 2rem);
  --space-lg:  clamp(1.5rem, 1.2rem + 1.5vw, 3rem);
  --space-xl:  clamp(2rem, 1.6rem + 2vw, 4rem);

  /* Dynamic album color (overridden per-page via inline style) */
  --album-hue: 220;
  --album-color: hsl(var(--album-hue), 60%, 50%);
  --album-color-muted: hsl(var(--album-hue), 20%, 90%);
  --album-glow: hsl(var(--album-hue), 60%, 50%, 0.08);
}

/* ==============================
   SKIP LINK (accessibility)
   ============================== */
.v2-skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-sm);
  z-index: 9999;
  padding: var(--space-xs) var(--space-md);
  background: var(--md-green);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  opacity: 0;
  transition: top 0.2s, opacity 0.2s;
}

.v2-skip-link:focus {
  top: var(--space-sm);
  opacity: 1;
  outline: 2px solid var(--md-green);
  outline-offset: 2px;
}

/* ==============================
   RESET / BASE
   ============================== */
.v2-layout * { box-sizing: border-box; }

/* Override Bootstrap's white body background */
body:has(.v2-layout) {
  background: var(--md-bg);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

.v2-layout {
  font-family: 'Source Sans 3', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: var(--fs-base);
  background: var(--md-bg);
  color: var(--md-text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  width: 100%;
}

/* ==============================
   TYPOGRAPHY
   ============================== */
.v2-heading {
  font-family: 'Lora', Georgia, serif;
}

.v2-layout h1, .v2-layout h2, .v2-layout h3 {
  font-family: 'Lora', Georgia, serif;
  line-height: 1.2;
}

.v2-layout h1 { font-size: var(--fs-2xl); }
.v2-layout h2 { font-size: var(--fs-xl); }
.v2-layout h3 { font-size: var(--fs-lg); }

.v2-layout a {
  color: var(--md-green);
  text-decoration: none;
  transition: color 0.15s;
}

.v2-layout a:hover {
  color: var(--md-green-light);
}

/* ==============================
   LAYOUT: main content area
   ============================== */
.v2-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.v2-main {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xl) clamp(24px, 3vw, 56px);
  display: flex;
  justify-content: center;
}

.v2-main-inner {
  width: 100%;
  max-width: 1400px;
}

.v2-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 clamp(16px, 2vw, 32px);
}

/* ==============================
   PAGE HEADER
   ============================== */
.v2-page-header {
  margin-bottom: var(--space-lg);
}

.v2-page-title {
  font-family: 'Lora', Georgia, serif;
  font-size: var(--fs-2xl);
  color: var(--md-text);
  margin-bottom: var(--space-xs);
}

.v2-page-subtitle {
  color: var(--md-text-secondary);
  font-size: var(--fs-base);
}

/* ==============================
   SECTION HEADERS
   ============================== */
.v2-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.v2-section-header--line {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--md-text-muted);
}

.v2-section-header--line::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--md-border-mid);
}

.v2-section-title {
  font-size: var(--fs-lg);
  font-weight: 700;
}

.v2-section-action {
  font-size: var(--fs-sm);
  color: var(--md-text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.v2-section-action:hover {
  color: var(--md-text);
}

/* ==============================
   FLASH MESSAGES (v2 styled)
   ============================== */
.v2-flash {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  font-size: var(--fs-sm);
  border: 1px solid var(--md-border);
  background: var(--md-surface-raised);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.v2-flash--success { border-left: 3px solid var(--tier-listen); }
.v2-flash--error { border-left: 3px solid var(--tier-avoid); }
.v2-flash--warning { border-left: 3px solid var(--tier-caution); }
.v2-flash--info { border-left: 3px solid var(--tier-discern); }

.v2-flash-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--md-text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: var(--fs-base);
}

/* ==============================
   TOPNAV (for song detail / non-sidebar pages)
   ============================== */
.v2-topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) clamp(16px, 2vw, 32px);
  border-bottom: 1px solid var(--md-border);
}

.v2-topnav-brand {
  font-family: 'Lora', Georgia, serif;
  font-size: var(--fs-md);
  color: var(--md-green);
  text-decoration: none;
}

.v2-topnav-back {
  color: var(--md-text-secondary);
  text-decoration: none;
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  transition: color 0.2s;
}

.v2-topnav-back:hover {
  color: var(--md-text);
}

/* ==============================
   AUTHENTICATED TOP NAV (V3)
   ============================== */
.v2-md-nav {
  display: flex; align-items: center;
  padding: var(--space-md) clamp(1.5rem, 3vw, 4rem);
  max-width: 1400px; margin: 0 auto;
  gap: var(--space-lg);
}
.v2-md-nav-brand {
  font-family: 'Lora', Georgia, serif;
  font-size: var(--fs-lg); font-weight: 500;
  color: var(--md-green);
  text-decoration: none; letter-spacing: -0.01em;
  display: inline-flex; align-items: center; gap: 0.4rem;
  margin-right: auto; /* Push links to the right */
}
.v2-md-nav-brand i {
  opacity: 0.6; color: var(--md-gold);
  font-size: 0.75em;
}
.v2-md-nav-links {
  display: flex; align-items: center; gap: var(--space-md);
}
.v2-md-nav-links > a {
  font-size: var(--fs-sm); color: var(--md-text-secondary);
  text-decoration: none; font-weight: 400;
  transition: color 0.2s;
}
.v2-md-nav-links > a:hover { color: var(--md-text); }
.v2-md-nav-links > a.active {
  color: var(--md-green); font-weight: 600;
}

/* Hamburger toggle — hidden on desktop */
.v2-md-nav-toggle {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--md-text); font-size: 1.25rem; padding: 0.25rem;
  line-height: 1;
}

/* Mobile-only links (Settings, Admin, Logout in hamburger) — hidden on desktop */
.v2-md-nav-mobile-only { display: none; }

/* Avatar dropdown wrapper */
.v2-md-nav-avatar-wrap {
  position: relative;
}
.v2-md-nav-avatar-btn {
  display: flex; align-items: center; gap: 0.35rem;
  background: none; border: none; cursor: pointer; padding: 0.25rem;
  border-radius: var(--md-radius-pill);
  transition: background 0.2s;
}
.v2-md-nav-avatar-btn:hover {
  background: var(--md-surface);
}
.v2-md-nav-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--md-green), #1a4a2e);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.75rem; font-weight: 600;
  overflow: hidden; flex-shrink: 0;
}
.v2-md-nav-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.v2-md-nav-caret {
  font-size: 0.6rem; color: var(--md-text-muted);
  transition: transform 0.2s;
}
.v2-md-nav-dropdown.open ~ .v2-md-nav-avatar-btn .v2-md-nav-caret,
.v2-md-nav-avatar-btn[aria-expanded="true"] .v2-md-nav-caret {
  transform: rotate(180deg);
}

/* Dropdown menu */
.v2-md-nav-dropdown {
  display: none;
  position: absolute; top: calc(100% + 0.5rem); right: 0;
  min-width: 200px;
  background: var(--md-surface-raised);
  border: 1px solid var(--md-border-mid);
  border-radius: var(--md-radius-lg);
  box-shadow: var(--md-shadow-md);
  z-index: 200;
  overflow: hidden;
}
.v2-md-nav-dropdown.open { display: block; }
.v2-md-nav-dropdown-header {
  padding: var(--space-sm) var(--space-md);
}
.v2-md-nav-dropdown-name {
  display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--md-text);
}
.v2-md-nav-dropdown-email {
  display: block; font-size: var(--fs-xs); color: var(--md-text-muted); margin-top: 2px;
}
.v2-md-nav-dropdown-divider {
  height: 1px; background: var(--md-border); margin: 0;
}
.v2-md-nav-dropdown-item {
  display: flex; align-items: center; gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--fs-sm); color: var(--md-text-secondary);
  text-decoration: none; transition: background 0.15s, color 0.15s;
}
.v2-md-nav-dropdown-item:hover {
  background: var(--md-surface); color: var(--md-text);
}
.v2-md-nav-dropdown-item i {
  width: 16px; text-align: center; font-size: var(--fs-xs); color: var(--md-text-muted);
}
.v2-md-nav-dropdown-logout:hover {
  color: var(--md-avoid);
}
.v2-md-nav-dropdown-logout:hover i {
  color: var(--md-avoid);
}

/* Mobile responsive */
@media (max-width: 767px) {
  .v2-md-nav { position: relative; }
  .v2-md-nav-toggle { display: block; order: 2; }
  .v2-md-nav-avatar-wrap { display: none; } /* Hide avatar dropdown on mobile */
  .v2-md-nav-mobile-only { display: contents; } /* Show mobile-only links */
  .v2-md-nav-links {
    display: none; flex-direction: column; gap: var(--space-sm);
    position: absolute; top: 100%; left: 0; right: 0;
    background: rgba(250, 246, 240, 0.98);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--md-border-mid);
    padding: var(--space-md) clamp(1.5rem, 3vw, 4rem);
    box-shadow: 0 4px 16px rgba(44, 36, 23, 0.08);
    z-index: 100;
  }
  .v2-md-nav-links.open { display: flex; }
  .v2-md-nav-links > a,
  .v2-md-nav-mobile-only a {
    display: block; font-size: var(--fs-base); padding: var(--space-xs) 0;
    color: var(--md-text-secondary); text-decoration: none;
  }
  .v2-md-nav-mobile-only .v2-md-nav-logout {
    color: var(--md-text-muted); margin-top: var(--space-xs);
    padding-top: var(--space-xs); border-top: 1px solid var(--md-border);
  }
}

/* ==============================
   RESPONSIVE
   ============================== */
@media (max-width: 768px) {
  .v2-main {
    padding: var(--space-md) 16px;
  }

  .v2-container {
    padding: 0 16px;
  }
}

/* ==============================
   GLOBAL SEARCH MODAL
   ============================== */
.v2-search-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(44, 36, 23, 0.5);
  z-index: 10000;
  justify-content: center;
  align-items: flex-start;
  padding-top: clamp(80px, 15vh, 160px);
}
.v2-search-overlay.open {
  display: flex;
}
.v2-search-modal {
  width: 100%;
  max-width: 600px;
  background: var(--md-surface-raised);
  border: 1px solid var(--md-border-mid);
  border-radius: var(--md-radius-xl);
  box-shadow: var(--md-shadow-lg);
  overflow: hidden;
  animation: v2-searchFadeIn 0.15s ease;
}
@keyframes v2-searchFadeIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Input row */
.v2-search-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-bottom: 1px solid var(--md-border);
}
.v2-search-input-icon {
  color: var(--md-text-muted);
  font-size: var(--fs-base);
  flex-shrink: 0;
}
.v2-search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--fs-base);
  color: var(--md-text);
}
.v2-search-input::placeholder {
  color: var(--md-text-muted);
}
.v2-search-kbd {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--fs-xs);
  color: var(--md-text-muted);
  background: var(--md-surface);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--md-border);
  flex-shrink: 0;
}

/* Results area */
.v2-search-results {
  max-height: 400px;
  overflow-y: auto;
  padding: var(--space-xs) 0;
}
.v2-search-hint {
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--md-text-muted);
}

/* Category header */
.v2-search-category {
  padding: var(--space-xs) var(--space-md);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--md-gold);
}
.v2-search-category:not(:first-child) {
  border-top: 1px solid var(--md-border);
  margin-top: var(--space-xs);
  padding-top: var(--space-sm);
}

/* Result row */
.v2-search-result {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background 0.1s;
}
.v2-search-result:hover {
  background: var(--md-surface);
}

/* Result artwork */
.v2-search-result-art {
  width: 36px; height: 36px;
  border-radius: 6px;
  background: var(--md-surface);
  flex-shrink: 0;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
}
.v2-search-result-art img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 6px;
}
.v2-search-result-art--circle {
  border-radius: 50%;
}
.v2-search-result-art--circle img {
  border-radius: 50%;
}
.v2-search-result-art-initial {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--md-green), #1a4a2e);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* Result text */
.v2-search-result-info {
  flex: 1;
  min-width: 0;
}
.v2-search-result-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--md-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v2-search-result-meta {
  font-size: var(--fs-xs);
  color: var(--md-text-muted);
}

/* Score badge in results */
.v2-search-result-score {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--md-radius-pill);
  flex-shrink: 0;
}

/* "See all" link */
.v2-search-see-all {
  display: block;
  padding: var(--space-xs) var(--space-md);
  font-size: var(--fs-xs);
  color: var(--md-green);
  text-decoration: none;
  font-weight: 500;
}
.v2-search-see-all:hover {
  text-decoration: underline;
}

/* Footer */
.v2-search-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--md-border);
  font-size: 0.65rem;
  color: var(--md-text-muted);
}
.v2-search-footer kbd {
  font-family: inherit;
  background: var(--md-surface);
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid var(--md-border);
  font-size: 0.6rem;
}
.v2-search-footer-shortcut {
  color: var(--md-green);
  font-weight: 500;
}

/* Nav search button */
.v2-md-nav-search-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #2c2417;
  font-size: 16px;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.v2-md-nav-search-btn i {
  color: inherit;
}
.v2-md-nav-search-btn:hover {
  color: #2d5f3f;
  background: #ece4d6;
}

/* Mobile responsive */
@media (max-width: 600px) {
  .v2-search-overlay {
    padding-top: 0;
    align-items: stretch;
  }
  .v2-search-modal {
    max-width: 100%;
    border-radius: 0;
    min-height: 100vh;
  }
}
