.cat-details {
    padding: 1em;
}
  
.media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: auto;
    grid-gap: 1em;
    padding: 1em;
    max-width: 100vw;
    box-sizing: border-box;
}
  
.img-container {
    width: 100%;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    aspect-ratio: 1;
    opacity: 0;
    transition: opacity 0.5s ease-in;
    background-color: #f0f0f0; /* Fallback background color */
}

.img-container.loaded {
    opacity: 1;
}
  
.img-container::before {
    content: "";
    display: block;
    padding-top: 100%;
}
  
.grid-image, .grid-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Ensure videos are visible on mobile */
.grid-video {
    background-color: #e0e0e0; /* Light gray background for videos */
    min-height: 100%;
    /* Force poster to display */
    object-fit: cover;
    background-size: cover;
    background-position: center;
}

/* Ensure play button is always visible on videos */
.img-container:has(.grid-video) .play-button {
    opacity: 1;
    z-index: 2;
}
  
.play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-button::after {
    content: '';
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 10px 0 10px 20px;
    border-color: transparent transparent transparent white;
    margin-left: 5px;
}

.img-container:hover .play-button {
    background-color: rgba(0, 0, 0, 0.9);
}
  
.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,
.modal-content video {
    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 content wrapper for blur effect */
.content-wrapper {
    transition: filter 0.3s ease;
}

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