@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@300;600&display=swap');

html, body {
  margin: 0;
  padding: 0;
  /* dvh handles the dynamic UI bars, 100% ensures Safari has a container to reference */
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: white;
  font-family: 'Barlow Condensed', sans-serif;
  overflow-x: hidden;
}

.grid-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  text-align: center;
  box-sizing: border-box;
  width: 100%;
}

.page-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 960px;
}

h1 {
  margin-bottom: 10px;
  font-size: 84px;
  font-weight: 600;
  color: #222;
  line-height: 1.05;
}

.subtitle {
  margin: -5px 0 25px;
  font-size: 18px;
  color: #555;
  font-weight: 300;
  text-align: center;
  padding: 0 10px;
}

#search {
  margin-bottom: 12px;
  padding: 10px;
  font-size: 16px;
  width: 90%;
  max-width: 400px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-family: 'Barlow Condensed', sans-serif;
  box-sizing: border-box;
}

.surprise-btn {
  margin-bottom: 30px;
  padding: 10px 22px;
  font-size: 17px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  color: white;
  background: #1e90ff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.surprise-btn:hover {
  background: #1873cc;
  animation: wiggle 0.55s ease-in-out;
}

.surprise-btn:active {
  animation: none;
  transform: scale(0.97);
}

.surprise-btn:focus-visible {
  outline: 2px solid #1e90ff;
  outline-offset: 3px;
}

#grid-view {
  width: 100%;
}

.spotlight-view {
  width: 100%;
  padding: 0 20px 150px;
  box-sizing: border-box;
}

.spotlight-view[hidden] {
  display: none;
}

.spotlight-back {
  display: block;
  width: 90%;
  max-width: 400px;
  margin: 0 auto 30px;
  padding: 0;
  border: none;
  background: none;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 500;
  color: #1e90ff;
  cursor: pointer;
  text-align: center;
  position: relative;
  z-index: 51;
}

.spotlight-back[hidden] {
  display: none;
}

.spotlight-back:hover {
  text-decoration: underline;
}

.spotlight-back:focus-visible {
  outline: 2px solid #1e90ff;
  outline-offset: 2px;
}

.spotlight-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 50vh;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  padding: 14px;
  box-sizing: content-box;
}

.spotlight-card {
  position: relative;
  z-index: 51;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.spotlight-card .photo-container {
  width: 100%;
  aspect-ratio: 1;
  height: auto;
}

.spotlight-card .name {
  width: 100%;
  font-size: 28px;
  font-weight: 600;
  margin-top: 18px;
  text-align: center;
}

.spotlight-card.pop-in .photo-container {
  animation: popIn 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  transform-origin: center center;
}

.spotlight-card.pop-in .name {
  animation: fadeUp 0.5s ease 0.25s both;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  15% { transform: rotate(-4deg) scale(1.03); }
  30% { transform: rotate(4deg) scale(1.03); }
  45% { transform: rotate(-3deg) scale(1.02); }
  60% { transform: rotate(3deg) scale(1.02); }
  75% { transform: rotate(-1deg) scale(1.01); }
}

@keyframes popIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  70% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

.grid-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 30px;
  padding: 20px;
  box-sizing: border-box;
  /* Increased margin to prevent content from being hidden behind the fixed footer */
  margin-bottom: 128px;
}

.grid-item {
  text-align: center;
  position: relative;
  width: 158px;
  content-visibility: auto;
  contain-intrinsic-size: 158px 228px;
}

.photo-container {
  position: relative;
  width: 158px;
  height: 158px;
  border-radius: 50%;
  overflow: hidden;
  box-sizing: border-box;
  margin: 0 auto;
  transition: transform 0.3s ease;
  background: linear-gradient(145deg, #ececec 0%, #dcdcdc 100%);
}

.grid-item .photo-container {
  cursor: pointer;
}

.photo-container.no-photo {
  background: #efefef;
}

.photo-container.hover-enabled {
  cursor: pointer;
}

.photo-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 0.45s ease, transform 0.45s ease, filter 0.45s ease;
  position: absolute;
  top: 0;
  left: 0;
  filter: grayscale(100%);
  will-change: opacity, transform;
}

.photo-container img.loaded {
  opacity: 1;
  transform: scale(1);
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(128, 128, 128, 0.4);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 2;
}

.grid-item .photo-container:hover:not(.no-audio) .overlay,
.photo-container.hover-enabled:hover .overlay {
  opacity: 1;
}

.play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  text-align: center;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-item .photo-container:hover:not(.no-audio) .play-icon,
.photo-container.hover-enabled:hover .play-icon,
.grid-item.playing .play-icon,
.spotlight-card.playing .play-icon {
  opacity: 1;
}

.name {
  display: block;
  margin-top: 10px;
  font-size: 16px;
  color: #333;
  font-weight: 300;
  word-wrap: break-word;
  padding: 0 5px;
  text-decoration: none;
}

a.name:hover {
  color: #1e90ff;
  text-decoration: underline;
  text-underline-offset: 0.12em;
  text-decoration-color: rgba(30, 144, 255, 0.55);
}

.grid-item.playing {
  content-visibility: visible;
  z-index: 2;
}

.grid-item.playing::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 158px;
  height: 158px;
  transform: translateX(-50%);
  border-radius: 50%;
  pointer-events: none;
  animation: pulseBorder 1.2s ease-in-out infinite;
  outline: 3px solid #1e90ff;
  outline-offset: -3px;
}

.spotlight-card .photo-container.audio-active {
  overflow: visible;
  animation: pulseBorder 1.2s ease-in-out infinite;
  outline: 3px solid #1e90ff;
  outline-offset: -3px;
  border-radius: 50%;
}

@keyframes pulseBorder {
  0% { box-shadow: 0 0 0 0 rgba(30, 144, 255, 0.7); }
  50% { box-shadow: 0 0 0 12px rgba(30, 144, 255, 0.2); }
  100% { box-shadow: 0 0 0 0 rgba(30, 144, 255, 0.7); }
}

.photo-container.audio-fadeout {
  overflow: hidden;
  transition: outline 0.3s ease, box-shadow 0.3s ease;
  outline: 0 solid transparent;
  box-shadow: none;
}

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: white;
  text-align: center;
  font-size: 16px;
  color: #555;
  line-height: 1.25;
  /* env() accounts for the "notch" and "home bar" on iOS devices */
  padding: 7px 14px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -1px 5px rgba(0,0,0,0.1);
  z-index: 1000;
  box-sizing: border-box;
}

.footer-primary {
  margin: 0;
}

.footer-attribution {
  margin: 4px 0 0;
  font-size: 11px;
  font-weight: 300;
  line-height: 1.25;
  color: #9a9a9a;
  letter-spacing: 0.01em;
}

.footer a,
.footer-link {
  color: #1e90ff;
  text-decoration: none;
  font-weight: 500;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.footer a:hover,
.footer-link:hover {
  text-decoration: underline;
}

.footer .footer-attribution a {
  color: #888888;
  font-weight: 500;
}

.footer .footer-attribution a:hover {
  color: #1e90ff;
  text-decoration: underline;
}

.mobile-only {
  display: none;
}

@media (max-width: 1024px) {
  .mobile-only {
    display: inline;
  }
}

@media (max-width: 500px) {
  .grid-container {
    gap: 100px;
  }

  .grid-item {
    width: 200px;
    contain-intrinsic-size: 200px 340px;
  }

  .photo-container {
    width: 200px;
    height: 200px;
  }

  .grid-item.playing::before {
    width: 200px;
    height: 200px;
  }

  .spotlight-stage {
    max-width: 240px;
  }

  .spotlight-card .name {
    font-size: 24px;
  }

  h1 { font-size: 46px; }
  .subtitle { font-size: 16px; }
  .name { font-size: 17px; }
}

.end-message {
  text-align: center;
  font-size: 18px;
  color: #555;
  margin-top: 20px;
  margin-bottom: 150px; /* Space for fixed footer */
  font-weight: 300;
  font-family: 'Barlow Condensed', sans-serif;
}

@media (min-width: 1025px) {
  .end-message {
    display: none;
  }
}

#scroll-sentinel {
  width: 100%;
  height: 1px;
}

.seo-links {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .surprise-btn:hover {
    animation: none;
  }

  .photo-container img {
    transition: opacity 0.2s ease;
    transform: none;
    will-change: auto;
  }

  .photo-container img.loaded {
    transform: none;
  }

  .spotlight-card.pop-in .photo-container,
  .spotlight-card.pop-in .name {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  background: white;
  border-radius: 8px;
  padding: 28px 24px 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  text-align: left;
  box-sizing: border-box;
}

.modal-dialog h2 {
  margin: 0 0 12px;
  font-size: 28px;
  font-weight: 600;
  color: #222;
}

.modal-dialog p {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 300;
  color: #444;
  line-height: 1.4;
}

.modal-dialog ul {
  margin: 0 0 16px;
  padding-left: 20px;
  font-size: 17px;
  font-weight: 300;
  color: #444;
  line-height: 1.45;
}

.modal-dialog li + li {
  margin-top: 8px;
}

.modal-dialog a {
  color: #1e90ff;
  text-decoration: none;
  font-weight: 500;
}

.modal-dialog a:hover {
  text-decoration: underline;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: none;
  font-size: 28px;
  line-height: 1;
  color: #888;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-close:hover {
  color: #222;
}

.modal-close:focus-visible {
  outline: 2px solid #1e90ff;
  outline-offset: 2px;
}