.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: auto;
  grid-gap: 1em;
}

.img-container {
  width: 100%;
  overflow: hidden;
  position: relative;
  opacity: 0;
  transition: opacity 0.5s ease-in;
}

.img-container.loaded {
  opacity: 1;
}

.img-container::before {
  content: "";
  display: block;
  padding-top: 100%; /* This creates a 1:1 aspect ratio. */
}

.grid-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.show {
  opacity: 1;
}

.modal-content {
  position: fixed;
  display: block;
  width: 80%;
  max-width: 800px;
  max-height: 90vh;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  position: relative;
  opacity: 0;
  transition: all 0.3s ease;
}

.modal.show .modal-content {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.modal-content img {
  width: 100%;
  height: auto;
  max-height: 90vh;
  object-fit: contain;
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.5);
    width: 50px;
    height: 50px;
    cursor: pointer;
    border: none;
    z-index: 2;
    transition: background-color 0.2s;
}

.modal-nav:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-nav::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 15px;
    height: 15px;
    border: solid white;
    border-width: 3px 0 0 3px;
}

.modal-prev {
    left: -60px;
}

.modal-prev::before {
    transform: translate(-25%, -50%) rotate(-45deg);
}

.modal-next {
    right: -60px;
}

.modal-next::before {
    transform: translate(-75%, -50%) rotate(135deg);
}

/* Reposition buttons on small screens */
@media (max-width: 768px) {
    .modal-nav {
        position: absolute;
        top: 100%;  /* Position below the media */
        margin-top: 20px;
        transform: none;
    }

    .modal-prev {
        left: calc(50% - 60px);  /* Center buttons and space them apart */
    }

    .modal-next {
        right: calc(50% - 60px);
    }

    /* Add space below modal content for buttons */
    .modal-content {
        margin-bottom: 90px;  /* Make room for buttons */
    }
}

/* Add a wrapper for the content that will be blurred */
.content-wrapper {
  transition: filter 0.3s ease;
}

.content-wrapper.blur {
  filter: blur(2px);
}
