/* ---------- SCROLLBAR STABILITY ---------- */
html{
  scrollbar-gutter: stable;
}

/* ---------- BACKGROUND ---------- */
body{
  margin:0;
  font-family:Segoe UI,Arial,sans-serif;
  background: linear-gradient(135deg,#5a2cff,#8a46ff 40%,#ffd84d 100%);
  background-attachment:fixed;
  color:white;
}

/* ---------- HEADER ---------- */
header{
  position:sticky;
  top:0;
  height:60px;
  background:rgba(20,0,40,0.65);
  backdrop-filter:blur(14px);
  border-bottom:1px solid rgba(255,255,255,0.25);
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:0 35px;
  z-index:9999;
  isolation:isolate;
}

h1,
.headerTitle{
  margin:0;
  font-size:20px;
  letter-spacing:1px;
}

/* ---------- HERO TITLE (big at top, transitions on scroll) ---------- */
.heroTitleWrap{
  padding: 48px 24px 56px;
  text-align: center;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.heroTitle{
  margin: 0;
  font-size: clamp(2.5rem, 10vw, 4.5rem);
  font-weight: 800;
  letter-spacing: 2px;
  line-height: 1.1;
  text-shadow:
    0 0 10px rgba(255,255,255,0.8),
    0 0 20px rgba(143,92,255,0.8),
    0 0 40px rgba(143,92,255,0.6),
    0 0 80px rgba(143,92,255,0.4),
    0 4px 24px rgba(0,0,0,0.4);
  animation: titleGlow 2.5s ease-in-out infinite;
}

@keyframes titleGlow{
  0%, 100%{
    text-shadow:
      0 0 10px rgba(255,255,255,0.8),
      0 0 20px rgba(143,92,255,0.8),
      0 0 40px rgba(143,92,255,0.6),
      0 0 80px rgba(143,92,255,0.4),
      0 4px 24px rgba(0,0,0,0.4);
  }
  50%{
    text-shadow:
      0 0 15px rgba(255,255,255,1),
      0 0 30px rgba(143,92,255,1),
      0 0 60px rgba(143,92,255,0.8),
      0 0 100px rgba(143,92,255,0.5),
      0 0 140px rgba(255,216,77,0.3),
      0 4px 24px rgba(0,0,0,0.4);
  }
}

.heroTagline{
  margin: 0.5em 0 0;
  font-size: clamp(1rem, 4vw, 1.5rem);
  font-weight: 500;
  letter-spacing: 1px;
  opacity: 0.9;
  text-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.heroSocial{
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 28px;
}

.socialBtn{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  transition: background 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}

.socialBtn:hover{
  background: rgba(255,255,255,0.35);
  border-color: rgba(255,255,255,0.5);
  transform: scale(1.08);
}

.socialIcon{
  width: 22px;
  height: 22px;
}

body.scrolled .heroTitleWrap{
  opacity: 0;
  transform: translateY(-20px) scale(0.97);
  pointer-events: none;
}

/* Header title: hidden at top, fades in when scrolled */
.headerTitle{
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

body.scrolled .headerTitle{
  opacity: 1;
  transform: translateY(0);
}

/* ---------- LOGO ---------- */
.logoTitle{
  display:flex;
  align-items:center;
  gap:8px;
}
.siteLogo{
  height:38px;
}

/* Header social: visible only when scrolled (next to title) */
.headerSocial{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

body.scrolled .headerSocial{
  opacity: 1;
  transform: translateY(0);
}

.headerSocialBtn{
  width: 34px;
  height: 34px;
}

.headerSocial .socialIcon{
  width: 18px;
  height: 18px;
}

.headerTermsLink{
  margin-left: 4px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 999px;
  color: rgba(255,255,255,0.95);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  width: auto;
  font-family: inherit;
}

.headerTermsLink:hover{
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.5);
}

/* ---------- GRID ---------- */
#songList{
  display:grid;
  grid-template-columns: repeat(auto-fill,minmax(280px,1fr));
  gap:28px;
  padding:35px;
}

.emptyState,
.errorState{
  grid-column:1 / -1;
  max-width:400px;
  margin:0 auto;
  text-align:center;
  padding:48px 24px;
  background:rgba(0,0,0,0.4);
  border-radius:20px;
  border:1px solid rgba(255,255,255,0.15);
}

.emptyState p,
.errorState p{
  margin:0 0 16px 0;
  font-size:16px;
  opacity:0.95;
}

.errorState button,
.emptyState button{
  width:auto;
  padding:10px 20px;
}

/* ---------- CARD ---------- */
.songCard{
  position:relative;
  background:rgba(0,0,0,0.55);
  backdrop-filter:blur(18px);
  border:1px solid rgba(255,255,255,0.15);
  padding:22px;
  border-radius:20px;
  color:white;
  /* no default drop shadow to avoid horizontal banding between rows */
  box-shadow:none;
  transition: box-shadow 0.25s ease, border 0.25s ease;
}

.songCard:hover{
  /* use a radial glow instead of a vertical drop shadow
     so it doesn't form a horizontal line across rows */
  box-shadow:0 0 16px rgba(0,0,0,0.7);
  border:1px solid rgba(255,255,255,0.28);
}

.songSelected{
  border:2px solid #8f5cff;
  box-shadow:0 0 14px rgba(143,92,255,0.7),0 12px 35px rgba(0,0,0,0.65);
  transform:translateY(-4px);
}

/* ---------- NEW SONG CARD ---------- */
.songCard.newSong{
  border: 2px solid #00b4d8;
  box-shadow:
    0 0 10px rgba(0,180,216,0.5),
    0 0 20px rgba(0,180,216,0.3),
    0 0 30px rgba(0,180,216,0.2);
  animation: newSongGlow 2s ease-in-out infinite;
}

.songCard.newSong:hover{
  border: 2px solid #00b4d8;
  box-shadow:
    0 0 15px rgba(0,180,216,0.6),
    0 0 25px rgba(0,180,216,0.4),
    0 0 35px rgba(0,180,216,0.3);
}

@keyframes newSongGlow{
  0%, 100%{
    box-shadow:
      0 0 10px rgba(0,180,216,0.5),
      0 0 20px rgba(0,180,216,0.3),
      0 0 30px rgba(0,180,216,0.2);
  }
  50%{
    box-shadow:
      0 0 15px rgba(0,180,216,0.7),
      0 0 30px rgba(0,180,216,0.5),
      0 0 45px rgba(0,180,216,0.3);
  }
}

.newBadge{
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  background: linear-gradient(135deg, #00b4d8, #0096b4);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 6px;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(0,180,216,0.5);
}

.songCard.newSong .songTitle{
  margin-top: 24px;
}

/* ---------- TITLE ---------- */
.songTitle{
  font-size:18px;
  font-weight:700;
  margin-bottom:6px;
  position:relative;
}

.songTitle::after{
  content:"";
  position:absolute;
  left:0;
  bottom:-6px;
  width:129px;
  height:3px;
  background:linear-gradient(90deg,#8f5cff,#ffd84d);
  border-radius:3px;
}

.songArtist{
  font-size:14px;
  opacity:0.8;
  margin-bottom:18px;
}

/* ---------- META BOXES ---------- */
.songMeta{
  display:flex;
  gap:10px;
  justify-content:center;
  margin-bottom:18px;
  flex-wrap:wrap;
}

.metaBox{
  flex:1 1 90px;
  background:rgba(0,0,0,0.55);
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.25);
  padding:8px;
}

.metaLabel{
  font-size:11px;
  opacity:0.7;
  margin-bottom:4px;
}

.metaValue{
  font-size:14px;
  font-weight:600;
  word-break:break-word;
}

/* ---------- BUTTONS ---------- */
.buttonRow{
  margin-top:14px;
  display:flex;
  justify-content:center;
  align-items:center;
  gap:12px;
}

/* base button style */
button{
  background:rgba(0,0,0,0.6);
  border:1px solid rgba(255,255,255,0.3);
  color:white;
  padding:8px 14px;
  border-radius:12px;
  font-size:13px;
  font-weight:600;
  cursor:pointer;
  transition:0.25s;
  width:110px;
}

/* only card buttons get hover lift animation */
.buttonRow button:hover{
  transform: translateY(-3px) scale(1.05);
  background:rgba(0,0,0,0.85);
  box-shadow:0 12px 25px rgba(0,0,0,0.5);
}

/* ---------- CONTROL BAR ---------- */
.controlBar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin:16px 35px;
  padding:6px;
  background:rgba(255,255,255,0.06);
  backdrop-filter:blur(16px);
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.08);
}

/* ---------- SEARCH WRAPPER ---------- */
.searchWrapper{
  display:flex;
  align-items:center;
  gap:8px;
  flex:1;
  max-width:280px;
  padding:0 12px;
  height:34px;
  background:rgba(0,0,0,0.25);
  border-radius:8px;
  border:1px solid rgba(255,255,255,0.08);
  transition:border-color 0.2s, background 0.2s;
}

.searchWrapper:focus-within{
  border-color:rgba(143,92,255,0.5);
  background:rgba(0,0,0,0.35);
}

.searchIcon{
  width:15px;
  height:15px;
  color:rgba(255,255,255,0.4);
  flex-shrink:0;
}

.searchWrapper:focus-within .searchIcon{
  color:rgba(143,92,255,0.8);
}

.searchWrapper input{
  flex:1;
  min-width:0;
  background:transparent;
  border:none;
  outline:none;
  color:white;
  font-size:13px;
  font-family:inherit;
}

.searchWrapper input::placeholder{
  color:rgba(255,255,255,0.35);
}

.clearSearchBtn{
  display:flex;
  align-items:center;
  justify-content:center;
  width:16px;
  height:16px;
  min-width:16px;
  padding:0;
  border:none;
  background:rgba(255,255,255,0.1);
  color:rgba(255,255,255,0.5);
  border-radius:4px;
  cursor:pointer;
  opacity:0;
  transition:opacity 0.15s, background 0.15s, color 0.15s;
}

.clearSearchBtn svg{
  width:10px;
  height:10px;
}

.searchWrapper:focus-within .clearSearchBtn,
.searchWrapper input:not(:placeholder-shown) ~ .clearSearchBtn{
  opacity:1;
}

.clearSearchBtn:hover{
  background:rgba(255,255,255,0.2);
  color:white;
}

/* ---------- RESULT BADGE ---------- */
.resultBadge{
  display:flex;
  align-items:center;
  justify-content:center;
  min-width:24px;
  height:20px;
  padding:0 6px;
  background:rgba(143,92,255,0.25);
  border-radius:5px;
  font-size:11px;
  font-weight:600;
  color:rgba(255,255,255,0.9);
  flex-shrink:0;
}

/* ---------- SORT TABS ---------- */
.sortTabs{
  display:flex;
  gap:2px;
  padding:3px;
  background:rgba(0,0,0,0.2);
  border-radius:8px;
}

.sortTabs button{
  height:28px;
  padding:0 12px;
  border:none;
  background:transparent;
  color:rgba(255,255,255,0.55);
  font-family:inherit;
  font-size:12px;
  font-weight:500;
  border-radius:6px;
  cursor:pointer;
  transition:color 0.2s, background 0.2s;
}

.sortTabs button:hover{
  color:rgba(255,255,255,0.85);
  background:rgba(255,255,255,0.05);
}

.sortTabs button.sortActive{
  background:rgba(143,92,255,0.35);
  color:white;
}

/* ---------- DOWNLOAD POPUP ---------- */
.popupOverlay{
  position:fixed;
  top:0;
  left:0;
  width:100%;
  height:100%;
  background:rgba(0,0,0,0.6);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:2000;
}

.popupBox{
  background:rgba(0,0,0,0.75);
  backdrop-filter:blur(18px);
  border:1px solid rgba(255,255,255,0.2);
  border-radius:20px;
  padding:32px;
  width:min(520px, 92vw);
  text-align:left;
  box-shadow:0 20px 60px rgba(0,0,0,0.7);
}

.popupBox h3{
  margin:0 0 12px 0;
  text-align:center;
  font-size:20px;
}

.popupIntro{
  margin:0 0 16px 0;
  font-size:15px;
  opacity:0.95;
}

.popupSteps{
  margin:0;
  padding-left:22px;
  font-size:15px;
  line-height:1.65;
}

.popupSteps li{
  margin-bottom:10px;
}

.popupSteps li:last-child{
  margin-bottom:0;
}

.pathCopyRow{
  display:flex;
  align-items:center;
  gap:8px;
  margin:12px 0 16px 0;
  padding:10px 12px;
  background:rgba(0,0,0,0.5);
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.15);
}

.pathCopyRow code{
  flex:1;
  min-width:0;
  font-size:13px;
  white-space:nowrap;
  overflow-x:auto;
  color:#b8e0ff;
}

.copyPathBtn{
  flex-shrink:0;
  width:auto;
  padding:7px 14px;
  font-size:13px;
  cursor:pointer;
  background:rgba(143,92,255,0.6);
  border:1px solid rgba(255,255,255,0.25);
}

.copyPathBtn:hover{
  background:rgba(143,92,255,0.85);
}

.copyPathBtn.copied{
  background:rgba(124,255,107,0.5);
  border-color:rgba(124,255,107,0.6);
}

.popupButtons{
  margin-top:20px;
  display:flex;
  gap:10px;
  justify-content:center;
}

.popupButtons button{
  width:120px;
}

/* ---------- TERMS POPUP ---------- */
.popupBoxScroll{
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.popupBoxScroll .termsContent{
  overflow-y: auto;
  padding-right: 8px;
  margin: 0 0 20px 0;
}

.termsContent h4{
  margin: 18px 0 8px 0;
  font-size: 15px;
}

.termsContent h4:first-of-type{
  margin-top: 0;
}

.termsContent p{
  margin: 0 0 12px 0;
  font-size: 14px;
  line-height: 1.6;
  opacity: 0.95;
}

/* ---------- MOBILE / RESPONSIVE ---------- */
@media (max-width: 768px){
  .heroTitleWrap{
    padding: 32px 16px 40px;
  }

  .heroTitle{
    font-size: clamp(2rem, 12vw, 3rem);
  }

  header{
    flex-wrap:wrap;
    height:auto;
    min-height:60px;
    padding:12px 16px;
    padding-top:max(12px, env(safe-area-inset-top));
    padding-left:max(16px, env(safe-area-inset-left));
    padding-right:max(16px, env(safe-area-inset-right));
    gap:12px;
  }

  .controlBar{
    flex-direction:column;
    gap:8px;
    margin:12px 16px;
    margin-left:max(16px, env(safe-area-inset-left));
    margin-right:max(16px, env(safe-area-inset-right));
    padding:8px;
  }

  .searchWrapper{
    max-width:none;
    height:38px;
    padding:0 12px;
  }

  .searchWrapper input{
    font-size:16px;
  }

  .resultBadge{
    height:22px;
    min-width:28px;
    font-size:12px;
  }

  .sortTabs{
    width:100%;
    padding:3px;
  }

  .sortTabs button{
    flex:1;
    height:34px;
    padding:0 8px;
    font-size:12px;
  }

  #songList{
    grid-template-columns:1fr;
    gap:18px;
    padding:16px;
    padding-left:max(16px, env(safe-area-inset-left));
    padding-right:max(16px, env(safe-area-inset-right));
    padding-bottom:max(24px, env(safe-area-inset-bottom));
  }

  .songCard{
    padding:20px;
  }

  .songTitle{
    font-size:18px;
  }

  .songArtist{
    font-size:15px;
  }

  .metaBox{
    flex:1 1 70px;
  }

  .metaValue{
    font-size:14px;
  }

  .buttonRow{
    gap:12px;
    margin-top:16px;
  }

  .buttonRow button{
    flex:1;
    min-width:0;
    min-height:44px;
    padding:14px 16px;
    font-size:15px;
    width:auto;
  }

  .emptyState,
  .errorState{
    padding:32px 20px;
    margin:0 16px;
  }

  .emptyState p,
  .errorState p{
    font-size:15px;
  }
}

@media (max-width: 480px){
  header{
    flex-direction:column;
    align-items:stretch;
    padding:12px 14px;
    padding-top:max(12px, env(safe-area-inset-top));
    padding-left:max(14px, env(safe-area-inset-left));
    padding-right:max(14px, env(safe-area-inset-right));
  }

  h1,
  .headerTitle{
    font-size:19px;
  }

  .siteLogo{
    height:34px;
  }

  .controlBar{
    margin:10px 14px;
    margin-left:max(14px, env(safe-area-inset-left));
    margin-right:max(14px, env(safe-area-inset-right));
    padding:6px;
  }

  .searchWrapper{
    height:40px;
  }

  .sortTabs button{
    height:36px;
    font-size:11px;
  }

  #songList{
    padding:14px;
    padding-left:max(14px, env(safe-area-inset-left));
    padding-right:max(14px, env(safe-area-inset-right));
    padding-bottom:max(28px, env(safe-area-inset-bottom));
    gap:20px;
  }

  .songCard{
    padding:20px;
  }

  .songTitle{
    font-size:17px;
  }

  .songTitle::after{
    width:80px;
  }

  .songArtist{
    font-size:14px;
  }

  .metaBox{
    flex:1 1 65px;
    padding:8px;
  }

  .metaLabel{
    font-size:11px;
  }

  .metaValue{
    font-size:13px;
  }

  .buttonRow button{
    min-height:48px;
    padding:16px 14px;
    font-size:14px;
  }

  .popupBox{
    padding:24px 20px;
    width:95vw;
    max-width:95vw;
    margin:max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .popupBox h3{
    font-size:18px;
  }

  .popupSteps{
    font-size:14px;
  }

  .pathCopyRow code{
    font-size:11px;
  }
}