/* ================= BASE GALLERY LAYOUT ================= */
.gallery-container {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  height: 100vh;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  white-space: nowrap;
  padding: 2rem;
  scroll-snap-type: x mandatory;
}

.gallery {
  display: flex;
  gap: 10rem;
  position: relative;
}

.cd-wrapper {
  position: relative;
  display: inline-block;
}

/* ================= LABELS ================= */

/* NEW label */
.new-label {
  position: absolute;
  top: -4rem; /* above the CD */
  left: 5%;
  transform: translateX(-50%);
  font-size: 1.6rem;
  font-family: monospace;
  font-weight: bold;
  color: #000000;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.cd-wrapper.active .new-label {
  opacity: 1;
}

/* COMING SOON label */
.cd-wrapper.coming-soon {
  position: relative;
  display: inline-block;
}

.cd-wrapper.coming-soon .coming-label {
  position: absolute;
  top: -4rem;
  left: 22%;
  transform: translateX(-50%);
  width: max-content;
  text-align: center;
  font-size: 1.6rem;
  font-family: monospace;
  font-weight: bold;
  color: #000000;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.cd-wrapper.coming-soon.active .coming-label {
  opacity: 1;
}

/* Safari / Instagram WebView vertical offset fix */
/* Safari / Instagram WebView vertical offset + label visibility fix */
@supports (-webkit-touch-callout: none) {
  /* Move COMING SOON label below CD in Safari/Instagram */
  .cd-wrapper.coming-soon .coming-label {
    top: auto;
    bottom: -2rem;
    left: 50%;
    transform: translateX(-50%);
  }

  /* Ensure NEW label only shows on non-coming-soon active CDs */
  .new-label {
    opacity: 0;
  }

  .cd-wrapper.active:not(.coming-soon) .new-label {
    opacity: 1;
  }
}


/* Add invisible spacers to allow first and last items to center */
.gallery::before,
.gallery::after {
  content: '';
  flex: 0 0 calc(25%);
}

.gallery a {
  display: inline-block;
}

.gallery-item {
  max-width: 255px;
  max-height: 255px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 12px;
  transition: transform 0.25s ease, filter 0.25s ease;
  cursor: pointer;
  filter: blur(3px) brightness(0.7);
  transform: scale(0.85);
}

.cd-wrapper.active .gallery-item {
  transform: scale(1.2);
  filter: blur(0) brightness(1);
  z-index: 2;
}

/* ================= PLAYBAR STYLES ================= */
.gallery-playbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 1rem;
  margin-top: -12rem;
  padding-left: calc(50% - 170px);
}

.playbar-btn {
  width: 50px;
  height: 50px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

/* ================= MOBILE FIXES ================= */
@media (max-width: 768px) {
  /* Prevent vertical scrolling */
  body, html {
    overflow-y: hidden;
    height: 100%;
  }

  .content {
    height: 100vh;
    overflow-y: hidden;
  }

  /* Gallery container keeps horizontal scrolling */
  .gallery-container {
    position: relative; /* needed for absolute playbar positioning */
    overflow-x: auto;
    overflow-y: hidden;
    height: 100vh;
    padding: 2rem 0;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
  }

  .gallery {
    justify-content: flex-start; /* normal LTR flow */
    gap: 4rem;
    margin-top: 20vh; /* gallery slightly below top */
  }

  .gallery::before,
  .gallery::after {
    flex: 0 0 0;
  }

  /* CD wrapper */
  .cd-wrapper {
    position: relative;
    display: inline-block;
  }

  /* NEW label */
  .cd-wrapper .new-label {
    bottom: 215%;
    left: -2rem;
    transform: translateY(-50%);
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
  }

  .cd-wrapper.active .new-label {
    opacity: 1;
  }

  /* COMING SOON label mobile */
  .cd-wrapper.coming-soon .coming-label {
    bottom: 215%;
    left: -2rem;
    transform: translateY(-50%);
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
  }

  .cd-wrapper.coming-soon.active .coming-label {
    opacity: 1;
  }

  /* Gallery item */
  .gallery-item {
    max-width: 255px;
    max-height: 255px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 12px;
    transform: scale(0.85);
    filter: blur(3px) brightness(0.7);
    transition: transform 0.25s ease, filter 0.25s ease;
  }

  .gallery-item.active {
    transform: scale(1.2);
    filter: blur(0) brightness(1);
    z-index: 2;
  }

  /* MOBILE PLAYBAR BELOW GALLERY */
  .gallery-playbar {
    position: absolute;        /* relative to gallery-container */
    top: calc(100% - 15rem);   /* 20rem below gallery container */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    gap: 1rem;
    z-index: 5;
    margin: 0;
    padding: 0;
  }

  .playbar-btn {
    width: 50px;
    height: 50px;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
  }
}
