:root {
    --bg-color: #0A0A0A; /* Dark background */
    --text-color: #FFFFFF; /* White text */
    --accent-cyan: #31cee7;
    --accent-pink: #FF007F;
    --secondary-text: #B3B3B3;
}


.work-gallery {
    max-width: 1200px;
    margin: 50px auto;
    padding: 20px;
    text-align: center;
    color: var(--text-color);
}

.work-gallery h2 {
    font-size: 36px;
    margin-bottom: 10px;
}

.work-gallery p {
    font-size: 16px;
    color: var(--secondary-text);
    margin-bottom: 30px;
    font-weight: bold;
}

.gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

/* Image loading optimizations */
.gallery-item {
    cursor: pointer;
    background-color: rgba(0, 0, 0, 0.05);
    border: 2px solid var(--accent-cyan);
    border-radius: 10px;
    padding: 10px;
    width: calc((100% - 80px) / 4); /* Default: 4 items per row */
    max-width: 250px;
    text-align: center;
    color: var(--text-color);
    transition: transform 0.3s;
    position: relative; /* Added for loading indicator positioning */
    min-height: 150px; /* Ensure space for loading indicator */
}

.gallery-item img {
    width: 100%;
    border-radius: 5px;
    margin-bottom: 10px;
    transition: opacity 0.3s ease, transform 0.3s ease; /* Added for smooth loading transitions */
}

/* New loading state styles */
.gallery-item.loading::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -25px 0 0 -15px; /* Adjusted to center in the image area */
    border: 3px solid rgba(0, 255, 255, 0.1); /* Using accent-cyan with low opacity */
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 1;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.gallery-item img.loading {
    opacity: 0.3;
    transform: scale(0.95);
}

.gallery-item img.loaded {
    opacity: 1;
    transform: scale(1);
}

.gallery-item p {
    font-size: 14px;
    color: var(--secondary-text);
}

.gallery-item:hover {
    transform: scale(1.05);
}

/* Adjust to 3 items per row on medium screens */
@media (max-width: 1024px) {
    .gallery-item {
        width: calc((100% - 60px) / 3); /* 3 items per row */
    }
}

/* Adjust to 2 items per row on smaller screens */
@media (max-width: 768px) {
    .gallery-item {
        width: calc((100% - 40px) / 2); /* 2 items per row */
    }
}

/* Adjust to 1 item per row on phone screens */
@media (max-width: 480px) {
    .gallery-item {
        width: 100%; /* 1 item per row */
    }
}


/* Enhanced lightbox styles */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9); /* Slightly darker for better contrast */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.lightbox.loading::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border: 4px solid rgba(0, 255, 255, 0.1);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 2;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2); /* Cyan shadow for branding */
    animation: fadeIn 0.3s ease-in-out;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.lightbox.loading img {
    opacity: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

