
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns */
    grid-template-rows: repeat(2, auto);    /* 2 rows */
    gap: 20px;
    padding: 20px;
    max-width: 1200px;
    margin: auto;
}

.gallery-slot {
    position: relative;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    overflow: hidden; /* Important for aspect ratio */
}

.gallery-slot .image-container {
    width: 100%;
    /* Aspect Ratio: 16:9 example. (9 / 16 * 100%) */
    /* padding-bottom: 56.25%; */
    /* Aspect Ratio: 3:4 example. (4 / 3 * 100%) */
    padding-bottom: 133.33%; /* Default to 3:4, can be overridden */
    position: relative;
    cursor: pointer;
    overflow: hidden; /* Add this to ensure images don't 'pop' outside during transition if absolutely positioned slightly off */
}

/* You can add classes to slots for different aspect ratios if needed */
.gallery-slot.aspect-16-9 .image-container {
    padding-bottom: 56.25%;
}

.gallery-slot.aspect-3-4 .image-container {
    padding-bottom: 133.33%;
}


.gallery-slot .image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.7s ease-in-out; /* Increased duration for a smoother effect */
    /* z-index: 1; remove default z-index here if any, active class will handle it */
}

.gallery-slot .image-container img.active {
    opacity: 1;
    z-index: 2; /* Ensure active image is on top */
}

.gallery-slot .image-container img.exiting {
    opacity: 0;
    z-index: 1; /* Ensure exiting image is behind the new active one */
}


.project-tag {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    text-align: center;
    padding: 8px 0;
    font-size: 0.9em;
    transition: background-color 0.3s;
    z-index: 3; /* Ensure it's above the image */
}

/* Lightbox Styles */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.lightbox-content {
    position: relative;
    background-color: #fff;
    padding: 20px;
    border-radius: 5px;
    max-width: 90%;
    max-height: 90%;
    display: flex; /* For centering image if it's smaller */
    justify-content: center;
    align-items: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: calc(90vh - 80px); /* Viewport height minus some padding */
    display: block;
    margin: auto;
}

.lightbox-close {
    position: absolute;
    top: -10px;
    right: -10px;
    background: white;
    color: #333;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    line-height: 32px;
    text-align: center;
    border: 1px solid #ccc;
}

.lightbox-prev,
.lightbox-next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    padding: 16px;
    color: white;
    background-color: rgba(0,0,0,0.5);
    font-weight: bold;
    font-size: 20px;
    transition: 0.3s ease;
    user-select: none;
    border-radius: 0 3px 3px 0;
}

.lightbox-prev {
    left: 0;
    border-radius: 3px 0 0 3px;
}

.lightbox-next {
    right: 0;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

#lightbox-caption {
    text-align: center;
    color: #ccc;
    padding: 10px 0 0;
    position: absolute;
    bottom: -30px; /* Adjust as needed */
    width: 100%;
    left: 0;
    font-size: 0.9em;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: 1fr; /* Single column on smaller screens */
    }
    .lightbox-content {
        padding: 10px;
    }
    .lightbox-prev, .lightbox-next {
        font-size: 16px;
        padding: 12px;
    }
    #lightbox-caption {
        font-size: 0.8em;
        bottom: -25px;
    }
}