body {
    font-family: sans-serif;
    margin: 0;
    background-color: #f0f0f0;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    padding: 10px;
}

.gallery-item {
    height: 150px;
    overflow: hidden;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    cursor: pointer;
    transition: transform 0.2s;
}

.gallery-item img:hover {
    transform: scale(1.08);
}

/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
}

.lightbox-content {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.image-with-caption {
    text-align: center;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

#lightbox-image {
    display: block;
    max-width: 90%;
    max-height: 80vh;
    object-fit: contain;
    background-color: black;
}

#image-date {
    color: white;
    font-family: 'Merriweather', serif;
    font-size: 1.2em;
    margin-top: 10px;
    padding: 0 10px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    z-index: 1002;
}

.close-btn:hover,
.close-btn:focus {
    color: #bbb;
    text-decoration: none;
}

/* Desktop navigation buttons */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: transparent;
    border: none;
    color: white;
    font-size: 2.5em;
    cursor: pointer;
    padding: 10px 15px;
    z-index: 1001;
    transition: color 0.3s;
}

.nav-btn:hover {
    color: #ccc;
}

.prev-btn {
    left: 20px;
}

.next-btn {
    right: 20px;
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 5px;
    }
    .gallery-item {
        height: 100px;
    }

    .close-btn {
        font-size: 30px;
        right: 20px;
    }

    /* Hide the navigation buttons on mobile */
    .nav-btn {
        display: none;
    }

    /* Make the image a bit bigger on mobile and clickable */
    #lightbox-image {
        max-width: 100%;
        max-height: 95vh;
        cursor: pointer;
    }

    .image-with-caption {
        position: relative; /* New: Make this a positioning context */
        padding: 0;
        height: 100%; /* Ensure it fills the space for positioning */
    }
    
    /* Position the date text over the image on mobile */
    #image-date {
        position: absolute;
        bottom: 10px; /* Position from the bottom */
        left: 50%;
        transform: translateX(-50%); /* Center horizontally */
        margin: 0; /* Remove top margin */
        padding: 5px 10px;
        background-color: rgba(0, 0, 0, 0.4); /* Semi-transparent background for readability */
        border-radius: 5px;
        white-space: nowrap; /* Prevent date from wrapping */
    }
}