@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400&family=Inter:wght@400;600;700;800&display=swap');

:root {
  --lavender: #B4A7D6;
  --violet: #9B8EC1;
  --green: #8FAE8B;
  --yellow: #F4C542;
  --yellow-deep: #D4A530;
  --cream: #FDF8F0;
  --charcoal: #3C3C3C;
  --sage: #5E6E5E;
  --danger: #C97070;

  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --shadow-card: 0 2px 8px rgba(60, 60, 60, 0.06), 0 12px 28px rgba(60, 60, 60, 0.06);
  --shadow-card-hover: 0 4px 14px rgba(60, 60, 60, 0.1), 0 20px 40px rgba(60, 60, 60, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream) url('assets/paper-texture.png') center/cover fixed;
  color: var(--charcoal);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* --- Name Entry --- */

.entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  text-align: center;
}

.entry__card {
  background: var(--cream);
  border: 1px solid rgba(180, 167, 214, 0.3);
  border-radius: var(--radius);
  padding: clamp(32px, 5vw, 56px) clamp(24px, 4vw, 48px);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-card);
}

.entry__monogram {
  width: clamp(180px, 25vw, 280px);
  height: auto;
  margin: 0 auto clamp(12px, 2vw, 24px);
  display: block;
}

.entry__names {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  font-weight: 600;
  color: var(--charcoal);
  margin: 0 0 4px;
}

.entry__date {
  font-family: var(--font-serif);
  font-size: clamp(1rem, 1.5vw, 1.3rem);
  font-style: italic;
  color: var(--sage);
  margin: 0 0 28px;
}

.entry__label {
  font-size: 0.95rem;
  color: var(--sage);
  margin: 0 0 10px;
}

.entry__input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(180, 167, 214, 0.4);
  border-radius: 10px;
  background: #fff;
  font-size: 1rem;
  color: var(--charcoal);
  outline: none;
  font-family: var(--font-sans);
  transition: border-color 150ms, box-shadow 150ms;
}

.entry__input:focus {
  border-color: var(--lavender);
  box-shadow: 0 0 0 3px rgba(180, 167, 214, 0.2);
}

.entry__btn {
  margin-top: 14px;
  width: 100%;
  padding: 14px;
  background: var(--yellow);
  color: var(--charcoal);
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 120ms, transform 120ms;
  box-shadow: 0 4px 12px rgba(244, 197, 66, 0.3);
}

.entry__btn:hover:not(:disabled) {
  background: var(--yellow-deep);
  transform: translateY(-1px);
}

.entry__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Main Layout --- */

.main {
  max-width: 780px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 40px) clamp(16px, 4vw, 40px) 120px;
}

/* --- Header --- */

.header {
  text-align: center;
  padding: 16px 0 24px;
  position: relative;
}

.header__monogram {
  width: clamp(160px, 25vw, 280px);
  height: auto;
  margin: 0 auto 8px;
  display: block;
}

.header__floral {
  position: absolute;
  width: clamp(40px, 8vw, 80px);
  height: auto;
  opacity: 0.3;
  pointer-events: none;
}

.header__floral--left {
  left: clamp(0px, 5vw, 60px);
  top: 10%;
  transform: rotate(15deg);
}

.header__floral--right {
  right: clamp(0px, 5vw, 60px);
  top: 10%;
  transform: rotate(-15deg) scaleX(-1);
}

.header__names {
  font-family: var(--font-serif);
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 600;
  margin: 0;
}

.header__greeting {
  font-size: clamp(0.85rem, 1.2vw, 1.05rem);
  color: var(--sage);
  margin: 4px 0 0;
}

/* --- Countdown --- */

.countdown {
  display: flex;
  justify-content: center;
  gap: clamp(8px, 1.5vw, 16px);
  margin: clamp(16px, 3vw, 32px) 0 clamp(20px, 3vw, 36px);
}

.countdown__cell {
  background: var(--cream);
  border: 1px solid rgba(180, 167, 214, 0.3);
  border-radius: 12px;
  padding: clamp(10px, 1.5vw, 18px) clamp(12px, 2vw, 22px);
  min-width: clamp(56px, 8vw, 80px);
  text-align: center;
  box-shadow: var(--shadow-card);
  animation: bob 5s ease-in-out infinite;
}

.countdown__cell:nth-child(2) { animation-delay: 0.5s; }
.countdown__cell:nth-child(3) { animation-delay: 1s; }
.countdown__cell:nth-child(4) { animation-delay: 1.5s; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.countdown__num {
  display: block;
  font-size: clamp(1.3rem, 2.5vw, 2rem);
  font-weight: 800;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.countdown__label {
  font-size: clamp(0.6rem, 0.9vw, 0.75rem);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sage);
  font-weight: 700;
}

.countdown__past {
  text-align: center;
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--violet);
  padding: 16px;
}

/* --- Search / Add --- */

.addform-wrapper { position: relative; }

.addform {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 8px 10px;
  margin-bottom: 20px;
}

.addform__input {
  background: #fff;
  border: 1px solid rgba(180, 167, 214, 0.4);
  color: var(--charcoal);
  border-radius: 12px;
  padding: clamp(10px, 1.5vw, 16px) clamp(12px, 1.5vw, 18px);
  font-size: clamp(0.9rem, 1.2vw, 1.05rem);
  outline: none;
  font-family: var(--font-sans);
  transition: border-color 150ms, box-shadow 150ms;
}

.addform__input:focus {
  border-color: var(--lavender);
  box-shadow: 0 0 0 3px rgba(180, 167, 214, 0.2);
}

.addform__submit {
  background: var(--yellow);
  color: var(--charcoal);
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 800;
  cursor: pointer;
  transition: background 120ms, transform 120ms;
  box-shadow: 0 4px 12px rgba(244, 197, 66, 0.3);
}

.addform__submit:hover:not(:disabled) {
  background: var(--yellow-deep);
  transform: translateY(-1px);
}

.addform__submit:disabled { opacity: 0.5; cursor: not-allowed; }

.addform__status {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px 14px;
  font-size: 0.9rem;
  background: var(--cream);
  border: 1px solid rgba(180, 167, 214, 0.3);
  border-radius: 10px;
}

.addform__status--ok { color: var(--green); }
.addform__status--err { color: var(--danger); }

/* --- Search Results Dropdown --- */

.search-results {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: #fff;
  border: 1px solid rgba(180, 167, 214, 0.3);
  border-radius: 12px;
  box-shadow: var(--shadow-card-hover);
  max-height: 320px;
  overflow-y: auto;
}

.search-results__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  font-size: 0.93rem;
  color: var(--charcoal);
  font-family: var(--font-sans);
  transition: background 80ms;
}

.search-results__item:hover { background: var(--cream); }
.search-results__item:disabled { opacity: 0.5; cursor: not-allowed; }

.search-results__thumb {
  border-radius: 4px;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  object-fit: cover;
}

.search-results__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.search-results__title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-results__artist {
  font-size: 0.85rem;
  color: var(--sage);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-results__loading {
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--sage);
}

/* --- Toolbar --- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.toolbar__count {
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: var(--green);
  border-radius: 20px;
}

.toolbar__spotify {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  background: #1db954;
  border-radius: 20px;
  transition: background 120ms, transform 120ms;
}

.toolbar__spotify:hover {
  background: #1ed760;
  transform: translateY(-1px);
}

.toolbar__spotify svg { flex-shrink: 0; }

/* --- Song Cards --- */

.songlist { display: flex; flex-direction: column; gap: 10px; }

.songlist__empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--sage);
  background: var(--cream);
  border: 1px solid rgba(180, 167, 214, 0.3);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-style: italic;
}

.songcard {
  display: grid;
  grid-template-columns: clamp(48px, 6vw, 72px) 1fr auto;
  gap: clamp(10px, 1.5vw, 16px);
  align-items: center;
  background: var(--cream);
  border: 1px solid rgba(180, 167, 214, 0.2);
  border-radius: var(--radius);
  padding: clamp(10px, 1.5vw, 16px);
  box-shadow: var(--shadow-card);
  transition: transform 120ms, box-shadow 120ms;
}

.songcard:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.songcard__play {
  position: relative;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
}

.songcard__play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 1.2rem;
  opacity: 0;
  transition: opacity 120ms;
}

.songcard__play:hover .songcard__play-icon { opacity: 1; }

.songcard__art {
  border-radius: 8px;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
}

.songcard__meta { min-width: 0; }

.songcard__title {
  font-weight: 700;
  text-decoration: none;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--charcoal);
  font-size: 0.95rem;
}

.songcard__title:hover {
  color: var(--violet);
  text-decoration: underline;
}

.songcard__artist {
  color: var(--sage);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.songcard__added {
  color: var(--sage);
  font-size: 0.75rem;
  margin-top: 2px;
}

.songcard__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* --- Vote Button --- */

.vote {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  border: 1px solid rgba(180, 167, 214, 0.3);
  color: var(--sage);
  border-radius: 12px;
  padding: 6px 10px;
  cursor: pointer;
  min-width: 50px;
  transition: color 120ms, border-color 120ms, background 120ms, transform 120ms;
  font-family: var(--font-sans);
}

.vote:hover {
  color: var(--charcoal);
  border-color: var(--lavender);
}

.vote--on {
  color: var(--violet);
  border-color: var(--lavender);
  background: rgba(180, 167, 214, 0.15);
}

.vote--on:hover {
  background: rgba(180, 167, 214, 0.25);
}

.vote:active { transform: scale(0.96); }

.vote__count {
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

/* --- Delete Button --- */

.delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(180, 167, 214, 0.3);
  color: var(--sage);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  transition: color 120ms, border-color 120ms, background 120ms;
}

.delete:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(201, 112, 112, 0.08);
}

/* --- Player Bar --- */

.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(60, 60, 60, 0.95);
  backdrop-filter: blur(12px);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.player-bar__close {
  position: absolute;
  right: 12px;
  top: 8px;
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
}

.player-bar__close:hover { color: #fff; }

.player-bar iframe {
  border: 0;
  border-radius: 12px;
  max-width: 100%;
}

/* --- Reduced Motion --- */

@media (prefers-reduced-motion: reduce) {
  .countdown__cell { animation: none !important; }
}

/* --- Large screens --- */

@media (min-width: 900px) {
  .main { max-width: 860px; }

  .songcard__title { font-size: 1rem; }
  .songcard__artist { font-size: 0.9rem; }

  .toolbar { margin-bottom: 16px; }
  .toolbar__count, .toolbar__spotify { font-size: 0.9rem; padding: 8px 18px; }

  .addform { gap: 10px 14px; margin-bottom: 28px; }
  .addform__submit { padding: 14px 24px; }
}
