* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --song-art: none;          /* set to url(...) of album art at runtime */
  --tint-strength: 0;        /* 0–1, fades in after the art loads */
}

html, body {
  height: 100%;
  /* On iOS Safari, 100vh includes the area behind the address bar / home
     indicator. Using dvh sizes to the actually-visible viewport so the
     footer doesn't hide beneath Safari's toolbar. */
  height: 100dvh;
  background: #000;
  color: #fff;
  font-family: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 300;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Ambient color signature — the album art itself, heavily blurred and
   dimmed, paints behind the comments. Color comes from the artwork's
   natural pixel distribution, not a sampled average. */
#play-screen::before {
  content: "";
  position: absolute;
  inset: -10%;                          /* over-extend so the blur edge isn't visible */
  pointer-events: none;
  z-index: 4;
  background-image: var(--song-art);
  background-size: cover;
  background-position: center;
  filter: blur(110px) saturate(1.5);
  opacity: calc(0.35 * var(--tint-strength));
  transition: opacity 2.5s ease;
  will-change: opacity;
}
/* A radial mask softens the edges so the wash looks like ambient light
   rather than a flat photo behind glass. */
#play-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(
    ellipse 90% 80% at 50% 45%,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.35) 60%,
    rgba(0, 0, 0, 0.85) 100%
  );
}

#app { height: 100%; width: 100%; }

.screen {
  display: none;
  height: 100%;
  width: 100%;
}
.screen.active { display: flex; }

/* ---------- search screen ---------- */
#search-screen {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1.6rem 2rem 2.5rem;
  position: relative;
}

#site-title {
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.95);
  text-align: center;
  margin: 0;
  user-select: none;
}

#site-subtitle {
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.15rem, 2vw, 1.4rem);
  line-height: 1.55;
  color: rgba(255,255,255,0.62);
  text-align: center;
  max-width: min(620px, 88vw);
  margin: 1.4rem auto 0;
  letter-spacing: 0.005em;
}

#search-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
  max-width: 480px;
  margin-top: 2.4rem;
}

/* Footer with donation note — flows naturally to the bottom of the
   search screen, above the floating notes. Using margin-top: auto so it
   always sits below the search hint regardless of how tall it gets. */
#home-footer {
  margin-top: auto;
  margin-bottom: 40px;    /* sits closer to the screen bottom; notes drift behind */
  padding: 0 2rem;
  text-align: center;
  position: relative;
  z-index: 6;             /* above the floating notes (z-index 0 by default) */
}

.footer-text {
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 300;
  color: rgba(255,255,255,0.95);
  font-size: clamp(0.97rem, 1.49vw, 1.1rem);
  line-height: 1.55;
  max-width: 560px;
  margin: 0 auto;
  letter-spacing: 0.005em;
}

#donate-link {
  display: inline-block;
  margin-top: 0.8rem;
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  color: rgba(255,255,255,0.95);
  font-size: clamp(0.99rem, 1.54vw, 1.12rem);
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.55);
  padding-bottom: 1px;
  letter-spacing: 0.01em;
  transition: color 0.3s ease, border-color 0.3s ease;
}
#donate-link:hover {
  color: #fff;
  border-color: #fff;
}

/* Floating music notes — sprinkled across the whole home page, each in
   its own muted color. The container covers the full screen, with notes
   positioned at corners + margins so they don't compete with the central
   text. */
#home-notes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
#home-notes .note {
  position: absolute;
  width: var(--size, 28px);
  height: calc(var(--size, 28px) * 1.6);
  color: var(--note-color, rgba(255,255,255,0.55));
  transform: translateX(-50%);
  opacity: 0;
  animation:
    note-float var(--dur, 12s) ease-in-out infinite,
    note-fade  var(--dur, 12s) ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
#home-notes .note.pair {
  width: calc(var(--size, 32px) * 1.55);
}
@keyframes note-float {
  0%   { transform: translate(-50%, 0) rotate(-4deg); }
  50%  { transform: translate(calc(-50% + var(--drift, 0px)), var(--floatY, -22px)) rotate(3deg); }
  100% { transform: translate(-50%, 0) rotate(-4deg); }
}
@keyframes note-fade {
  0%, 100% { opacity: 0; }
  20%, 80% { opacity: 0.55; }
  50%      { opacity: 0.7; }
}

/* On small screens, thin the herd a bit — every fourth note is hidden so
   the home page doesn't feel cluttered on a phone. */
@media (max-width: 640px) {
  #home-notes .note:nth-child(4n+5) { display: none; }
}

#search-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  width: min(420px, 90vw);
}

#search-form input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 300;
  padding: 0.55rem 0.2rem;
  text-align: center;
  outline: none;
  transition: border-color 0.3s ease;
}
#search-form input::placeholder {
  color: rgba(255,255,255,0.35);
  font-style: italic;
}
#search-form input:focus {
  border-bottom-color: rgba(255,255,255,0.9);
}

#search-form button {
  margin-top: 1rem;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 0.55rem 2.2rem;
  font-size: 0.95rem;
  letter-spacing: 0.25em;
  text-transform: lowercase;
  cursor: pointer;
  transition: all 0.3s ease;
}
#search-form button:hover:not(:disabled) {
  border-color: #fff;
  background: rgba(255,255,255,0.04);
}
#search-form button:disabled {
  opacity: 0.4;
  cursor: wait;
}

.error {
  color: rgba(255,180,180,0.9);
  font-size: 0.85rem;
  min-height: 1.2em;
  letter-spacing: 0.05em;
  text-align: center;
  max-width: min(420px, 90vw);
}

#search-hint {
  color: rgba(255,255,255,0.95);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: lowercase;
  font-style: italic;
  text-align: center;
  margin-top: 0.5rem;
}

/* ---------- play screen ---------- */
#play-screen {
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

#play-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 1.4rem 1.8rem 1.1rem;
  z-index: 50;
  pointer-events: none;
  gap: 1.5rem;
}
#play-header > * { pointer-events: auto; }
#play-header #new-search-btn { justify-self: start; }
#play-header .header-spacer { justify-self: end; }

#new-search-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.75);
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: lowercase;
  cursor: pointer;
  transition: all 0.3s ease;
}
#new-search-btn:hover {
  color: #fff;
  border-color: #fff;
}

/* Now-playing epigraph — italic serif, centered, prominent but quiet. */
#now-playing {
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 1.5rem;
  line-height: 1.3;
  color: rgba(255,255,255,0.78);
  letter-spacing: 0.005em;
  text-align: center;
  max-width: min(640px, 60vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 0 28px rgba(0,0,0,0.6);
  opacity: 0;
  transition: opacity 1.6s ease;
}
#now-playing.visible { opacity: 1; }

.header-spacer { min-width: 8rem; }

/* player area — present but never showing video */
#player-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
#player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#player iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

/* permanent black veil — user never sees the video */
#video-veil {
  position: absolute;
  inset: 0;
  background: #000;
  pointer-events: none;
  z-index: 2;
}

/* ad overlay — sits on top of veil, subtle skip hint */
#ad-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 1.4rem;
  pointer-events: none;
  z-index: 3;
  transition: opacity 0.4s ease;
}
#ad-overlay.hidden { opacity: 0; }
.skip-hint {
  color: rgba(255,255,255,0.35);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: lowercase;
  animation: pulse 2.5s ease-in-out infinite;
}

/* ---------- comments (slideshow) ---------- */
#comments-stage {
  position: absolute;
  inset: 0;
  padding: 7rem 8vw 7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#slide-container {
  position: relative;
  width: min(720px, 92%);
  height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.comment {
  position: absolute;
  inset: 0;
  padding: 1rem 0.5rem;
  overflow-y: auto;
  overscroll-behavior: contain;     /* don't bubble scroll to the page */
  /* Hide scrollbars while keeping scroll functional. */
  scrollbar-width: none;
  color: rgba(255,255,255,0.92);
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  font-size: 1.6rem;
  line-height: 1.55;
  font-weight: 400;
  text-align: center;
  opacity: 0;
  filter: blur(6px);
  transform: translateY(8px);
  transition: opacity 0.8s ease, filter 0.8s ease, transform 0.8s ease;
  pointer-events: none;
}
.comment::-webkit-scrollbar { width: 0; display: none; }

/* Inner wrapper centers content vertically when short, lets it grow
   beyond the container (which then scrolls) when long. */
.comment .comment-inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0;
}

.comment.active {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0);
  pointer-events: auto;
}

/* Longer, more emotional entrance for the very first memory of a search. */
.comment.first-memory {
  transition: opacity 3s ease, filter 3s ease, transform 3s ease;
}

.comment .author {
  display: block;
  margin-top: 1.2rem;
  font-family: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 0.68rem;
  color: rgba(255,255,255,0.32);
  letter-spacing: 0.22em;
  text-transform: lowercase;
  font-weight: 300;
}

/* Faint radial highlight pulse behind the first memory. */
#slide-container::before {
  content: "";
  position: absolute;
  inset: -8%;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(255,255,255,0.06) 0%,
    rgba(255,255,255,0.02) 40%,
    rgba(0,0,0,0) 70%
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 2s ease;
}
#slide-container.first-pulse::before {
  opacity: 1;
  animation: first-pulse 4s ease forwards;
}
@keyframes first-pulse {
  0%   { opacity: 0; transform: scale(0.9); }
  35%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.05); }
}

/* ---------- slideshow navigation ---------- */
#slide-nav {
  position: absolute;
  bottom: 2.4rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1.6rem;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}
#slide-nav.visible {
  opacity: 1;
  pointer-events: auto;
}

#slide-nav button {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.45);
  font-size: 1.4rem;
  width: 2.4rem;
  height: 2.4rem;
  cursor: pointer;
  transition: color 0.3s ease, transform 0.2s ease;
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
}
#slide-nav button:hover {
  color: rgba(255,255,255,0.95);
}
#slide-nav button:active {
  transform: scale(0.92);
}
#slide-nav button:disabled {
  opacity: 0.25;
  cursor: default;
  color: rgba(255,255,255,0.3);
}

#slide-position {
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 300;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.42);
  letter-spacing: 0.04em;
  min-width: 4rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.empty-hint {
  color: rgba(255,255,255,0.35);
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  font-style: italic;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  animation: pulse 2.5s ease-in-out infinite;
  position: absolute;
}
.empty-hint.hidden { display: none; }

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 0.7; }
}

/* ---------- mobile (≤ 640px) ---------- */
@media (max-width: 640px) {
  /* Stack the play-screen header so the song title isn't squeezed by the
     side button + spacer. Allow the title to wrap to two lines. */
  #play-header {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 0.9rem 1rem 0.5rem;
    gap: 0.65rem;
  }
  #play-header #new-search-btn { justify-self: center; }
  #play-header .header-spacer { display: none; }

  #now-playing {
    font-size: 1.1rem;
    line-height: 1.3;
    max-width: 92vw;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  /* Header is taller when stacked — push the comments stage down a bit. */
  #comments-stage {
    padding-top: 8.5rem;
    padding-left: 5vw;
    padding-right: 5vw;
  }

  /* Slightly smaller comment text on small screens reads more naturally. */
  .comment {
    font-size: 1.3rem;
  }

  /* More breathing room between the blocks under the listen button on phones,
     but keep the footer close enough to the bottom to stay visible on
     short screens. */
  #search-hint {
    margin-top: 1.2rem;
    line-height: 1.6;
    max-width: 88vw;
  }
  #home-footer {
    /* On mobile we let the screen scroll, so the footer sits in normal
       flow below the hint with a fixed gap rather than auto-pushed. */
    margin-top: 2rem;
    margin-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  /* Allow the home screen to scroll vertically on phones — content can be
     taller than the visible viewport when browser chrome is showing. */
  #search-screen.active {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #home-footer .footer-text {
    margin-top: 1.4rem;
    line-height: 1.6;
  }
  #donate-link {
    margin-top: 0.8rem;
  }
  #search-screen {
    padding-bottom: 1.2rem;
  }
}
