/* ---------- Compositions Grid ---------- */
.compositions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  justify-items: center;
  margin: 1rem 0;
}

.composition-item {
  width: 100%;
  cursor: pointer;
}

.composition-img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid #ccc;
}

/* ---------- Overlay Styles ---------- */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.85);
  justify-content: center;
  align-items: center;
  z-index: 10000;  /* VERY HIGH to appear above navbar */
  padding: 1rem;
  box-sizing: border-box;
  overflow: hidden;
  touch-action: none;
}

.overlay.active {
  display: flex;
}

/* Prevent background scroll when overlay is open */
body.no-scroll {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* ---------- Overlay Content ---------- */
.overlay-content {
  position: relative;
  background: #000;
  color: #fff;
  padding: 1rem;
  max-width: 600px;
  width: 100%;
  max-height: 90%;
  overflow: auto;
  text-align: center;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-overflow-scrolling: touch;
}

/* Video iframe */
.overlay-content iframe {
  width: 100%;
  aspect-ratio: 16/9;
  display: block;
  border: none;
}

/* Close button */
.close-overlay {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 2rem;
  color: white;
  cursor: pointer;
  background: rgba(0,0,0,0.3);
  border-radius: 50%;
  padding: 0.2rem 0.5rem;
}

/* Description formatting */
#overlay-description {
  margin-top: 1rem;
  line-height: 1.4;
  max-height: 30vh;
  overflow-y: auto;
  padding: 0 0.5rem;
}

/* ---------- Mobile-specific tweaks ---------- */
@media (max-width: 768px) {
  .overlay-content {
    width: 95%;
    padding: 15px;
    max-height: 85%;
    font-size: 0.95rem;
  }

  .close-overlay {
    font-size: 2.5rem;
    top: 10px;
    right: 10px;
  }

  #overlay-description {
    max-height: 40vh;
    font-size: 0.9rem;
  }
}

.composition-grid-container {
  display: flex;
  justify-content: center; /* centers the grid horizontally */
  margin: 0 auto;
}

/* --- Video Grid Layout --- */
.compositions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* desktop: 3 videos side by side */
  gap: 1rem;
  justify-items: center;
  margin: 1rem 0;
}

/* Keep each video responsive */
.composition-item iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  display: block;
  max-width: 400px; /* prevents them from stretching too wide */
}

/* On smaller screens, stack vertically */
@media (max-width: 768px) {
  .compositions-grid {
    grid-template-columns: 1fr; /* single column */
  }

  .composition-item iframe {
    max-width: 100%; /* allow full width on mobile */
  }
}
