/* projects.css */
#projects-section {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-color);
}

.projects-container {
    width: 90%;
    max-width: 1100px;
    /* Widened the container (+10%) */
    height: 85vh;
    height: 85dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 35px;
    margin-top: calc(1dvh - 37px);
    /* Reduced margin to move closer to top */
    position: relative;
    /* Add relative positioning to anchor the new absolute button */
}

/* Header */
.projects-header {
    width: 100%;
    text-align: center;
}

.projects-header h2 {
    font-size: 3rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-color);
}

/* Carousel Tabs */
.project-carousel {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 10px 5px 20px 5px;
    /* Added spacing so hover scale doesn't clip */
    width: 100%;
    align-items: center;
    /* keep centered vertically if heights shift */
    justify-content: center;
    scrollbar-width: none;
    /* Firefox */
}

.project-carousel::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.project-tab {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.1);
    padding: 0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 120px;
    height: 80px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    /* Prevent squishing */
}

.project-tab-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Removed the transition here since the parent zooms now */
}

.project-tab:hover {
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
    /* Zoom the entire tab slightly */
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
    /* Add a subtle glow when hovered */
}

.project-tab.active {
    border-color: var(--text-color);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.4);
    /* Stronger glow for active */
    transform: scale(1.15);
    /* Make the active tab bigger */
    z-index: 5;
    /* Keep it above inactive tabs */
}

/* Slideshow Container */
.project-slideshow-container {
    position: relative;
    width: 100%;
    flex-grow: 1;
    /* Takes remaining height */
    min-height: 0;
    /* Prevents flex item from expanding beyond its parent's height */
    border-radius: 20px;
    overflow: hidden;
    background: transparent;
    /* Changed to transparent so full-size images blend nicely */
    border: 2px solid rgba(255, 255, 255, 0.15);
    /* Added slight elegant border */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    /* Re-added shadow to frame it */
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.project-slideshow-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Full size width/height proportional, uncropped */
    transition: opacity 0.5s ease-in-out, transform 0.3s ease;
    opacity: 0;
    cursor: pointer;
}

.project-slideshow-img.fade-in {
    opacity: 1;
}

.project-slideshow-img:hover {
    transform: scale(1.02);
}

/* Fullscreen Modal */
.project-modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    /* Stay in place */
    z-index: 50000;
    /* Increased z-index significantly so it sits above EVERYTHING including side nav (40000) */
    /* Sit on top of everything */
    padding-top: 50px;
    /* Location of the box */
    left: 0;
    top: 0;
    width: 100%;
    /* Full width */
    height: 100%;
    /* Full height */
    overflow: hidden;
    /* Disable scrolling behind it */
    background-color: rgba(0, 0, 0, 0.9);
    /* Black w/ opacity */
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    /* Smooth fade in/out */
}

.project-modal.active {
    opacity: 1;
}

#project-all-images-modal {
    z-index: 45000;
    /* Sit below the single image modal */
}

.project-modal-wrapper {
    margin: auto;
    display: flex;
    /* Flex constraints for inner image */
    justify-content: center;
    position: relative;
    max-width: 90%;
    max-height: 90%;
    /* No scale here, handled by image */
}

.project-modal-content {
    display: block;
    max-width: 100%;
    /* Take up wrapper space */
    max-height: 90vh;
    /* Re-constrain here so wrapper wraps tightly */
    object-fit: contain;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
    border-radius: 10px;
    transform: scale(0.8);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.5s ease-in-out;
}

.project-modal.active .project-modal-content {
    transform: scale(1);
    opacity: 1;
}

/* Modal Arrows (inherits from .project-nav-btn) */
.project-modal-arrow {
    z-index: 5002;
    padding-bottom: 4px;
    /* visually center arrow */
}

/* Position them inside the wrapper, over the image */
#project-modal-prev-btn {
    left: 20px;
}

#project-modal-next-btn {
    right: 20px;
}

/* Remove the old animation entirely */
.project-modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 5001;
}

.project-modal-close:hover,
.project-modal-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

/* Navigation Arrows */
.project-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
    z-index: 40001;
}

.project-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.project-prev-btn {
    left: 20px;
}

.project-next-btn {
    right: 20px;
}

/* Progress Bar */
.project-progress-container {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 150px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
    z-index: 10;
}

.project-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--text-color);
    transition: width linear;
    /* Handled by JS */
}

/* View All Images Button */
.project-view-all-btn {
    position: absolute;
    top: 90px;
    /* Adjusting so it's roughly below the tabs, outside the slideshow */
    left: 0;
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--text-color);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.project-view-all-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

/* All Images Grid Modal Content */
.project-all-images-content {
    margin: 5vh auto;
    /* 5vh top and bottom */
    width: 90%;
    max-width: 1200px;
    height: 80vh;
    /* Fixed height so it doesn't push the bottom */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    overflow-y: auto;
    padding: 20px;
    background: transparent;
    border-radius: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.5) transparent;
}

.project-all-images-content::-webkit-scrollbar {
    width: 8px;
}

.project-all-images-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
}

.project-all-images-item {
    width: 100%;
    aspect-ratio: 1;
    /* Square thumbnails */
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 2px solid transparent;
}

.project-all-images-item:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Wrapper for slideshow images */
.project-run-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.project-run-wrapper.fade-in {
    opacity: 1;
}

.project-run-img {
    position: relative !important;
    height: 100% !important;
    flex: 1;
    min-height: 0;
    /* allows flex children to shrink */
    opacity: 1 !important;
}

/* ========================================= */
/* Mobile Responsive                         */
/* ========================================= */
@media (max-width: 768px) {
    .projects-container {
        justify-content: flex-start;
        padding-top: 10vh;
        padding-top: 10dvh;
        gap: 15px;
    }

    .projects-header h2 {
        font-size: 2.2rem;
    }

    .project-carousel {
        padding: 5px;
        transform: translateY(-4vh);
        transform: translateY(-4dvh);
    }

    .project-tab {
        width: 80px;
        height: 60px;
    }

    .project-view-all-btn {
        position: relative;
        top: auto;
        left: auto;
        margin: 0 auto;
        font-size: 0.8rem;
        padding: 6px 12px;
        transform: translateY(-3.2vh);
        transform: translateY(-3.2dvh);
    }

    .project-slideshow-container {
        border: none;
        box-shadow: none;
        margin-bottom: 25px;
        /* Give space for the progress bar */
        transform: translateY(-2.8vh);
        transform: translateY(-2.8dvh);
        overflow: visible;
        /* Prevent clipping progress bar if placed below */
    }

    .project-run-wrapper {
        gap: 15px;
        /* Increased gap to separate top and bottom image */
    }

    .project-run-img {
        border: 3px solid #fff;
        border-radius: 8px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    }

    /* Move progress bar to the bottom center, with spacing from images */
    .project-progress-container {
        bottom: -35px;
        /* Moved further down */
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        width: 180px;
        /* Slightly wider if needed, or keep 150px */
    }

    #project-prev-btn,
    #project-next-btn {
        top: auto;
        bottom: -53px;
        /* Vertically align with the progress bar's center */
        transform: none;
        /* Overrides the desktop translateY(-50%) */
        background: transparent;
        backdrop-filter: none;
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 0;
        opacity: 0.7;
    }

    #project-prev-btn:hover,
    #project-next-btn:hover {
        background: transparent;
        transform: scale(1.2);
        text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
        opacity: 1;
    }

    #project-prev-btn {
        left: calc(50% - 140px);
        /* Positioned to the left of the progress bar */
    }

    #project-next-btn {
        right: auto;
        left: calc(50% + 100px);
        /* Positioned to the right of the progress bar */
    }
}