/* New Modal Styles to replace the old nested approach */

/* The full screen backdrop */
.project-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85); /* Dark background */
    backdrop-filter: blur(8px);
    z-index: 99999; /* Make sure it is on top of everything, including navbar */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    /* Using visibility: hidden ensures it doesn't block clicks when inactive */
    visibility: hidden; 
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.project-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* The actual modal box (pop-up) */
.project-modal-content {
    /* Center in the overlay */
    position: relative;
    width: 900px; /* Much wider for a desktop feel */
    max-width: 90vw;
    height: 85vh;
    overflow: hidden; /* Mask the marquee */
    background-color: #0a0a0a; /* Slightly darker */
    border-radius: 24px;
    
    /* Improved glass border effect */
    border: 1px solid rgba(255, 255, 255, 0.08);
    /* Deeper shadow with a slight glow */
    box-shadow: 0 0 0 1px rgba(0,0,0,0.5), 0 50px 100px -20px rgba(0, 0, 0, 0.7);
    
    /* Entry animation state */
    transform: scale(0.95) translateY(30px);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.4s ease;
}

.project-modal-overlay.active .project-modal-content {
    /* Active animation state */
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Optional: Add a subtle gradient overlay at top/bottom to mask the hard edge of the scrolling images */
.project-modal-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    pointer-events: none;
    z-index: 2;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
}

/* Header Text Overlay Styles */
.modal-header-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 2rem;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, transparent 100%);
    z-index: 10;
    color: #fff;
    pointer-events: none; /* Let scroll underneath be visible if we were interactable */
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.modal-header-overlay h3 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    letter-spacing: 1px;
}

.modal-header-overlay .modal-hint {
    font-size: 0.8rem;
    text-transform: uppercase;
    opacity: 0.7;
    background: rgba(255,255,255,0.1);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.2);
}

/* Marquee track animation */
.project-modal-content .marquee-track {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Two columns */
    gap: 16px;
    padding: 16px;
    width: 100%;
    /* No defined height for track, it flows */
    animation: modal-marquee 25s linear infinite; /* Slower scroll for more content */
}

@keyframes modal-marquee {
    0% { transform: translateY(0); }
    100% { transform: translateY(-50%); }
}

.project-modal-content img {
    width: 100%;
    height: auto; /* Let images show their full content */
    max-height: 500px; /* Cap height on large screens for consistency */
    object-fit: contain; /* Show full image without cropping */
    object-position: center;
    border-radius: 12px;
    display: block;
    background-color: #111; /* Fill background for images with transparent areas */
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

/* ============================== */
/* Responsive Modal Styles        */
/* ============================== */

/* Tablet portrait */
@media (max-width: 768px) {
    .project-modal-content {
        width: 92vw;
        height: 75vh;
        height: 75dvh;
        border-radius: 18px;
    }
    
    .project-modal-content .marquee-track {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px;
    }
    
    .project-modal-content img {
        height: auto;
        max-height: 400px;
        border-radius: 10px;
    }
    
    .modal-header-overlay {
        padding: 1.5rem;
    }
    
    .modal-header-overlay h3 {
        font-size: 1.5rem;
    }
    
    .modal-header-overlay .modal-hint {
        font-size: 0.7rem;
        padding: 3px 8px;
    }
}

/* Large phone */
@media (max-width: 576px) {
    .project-modal-content {
        width: 95vw;
        height: 70vh;
        height: 70dvh;
        border-radius: 14px;
    }
    
    .project-modal-content img {
        height: auto;
        max-height: 350px;
        border-radius: 8px;
    }
    
    .project-modal-content .marquee-track {
        gap: 10px;
        padding: 10px;
    }
    
    .modal-header-overlay {
        padding: 1rem;
    }
    
    .modal-header-overlay h3 {
        font-size: 1.3rem;
    }
    
    .project-modal-content::after {
        height: 60px;
        border-bottom-left-radius: 14px;
        border-bottom-right-radius: 14px;
    }
}

/* Medium phone */
@media (max-width: 480px) {
    .project-modal-content {
        width: 96vw;
        height: 68vh;
        height: 68dvh;
        border-radius: 12px;
    }
    
    .project-modal-content img {
        height: auto;
        max-height: 300px;
    }
    
    .modal-header-overlay h3 {
        font-size: 1.2rem;
    }
}

/* Small phone */
@media (max-width: 360px) {
    .project-modal-content {
        width: 98vw;
        height: 65vh;
        height: 65dvh;
        border-radius: 10px;
    }
    
    .project-modal-content img {
        height: auto;
        max-height: 250px;
        border-radius: 6px;
    }
    
    .project-modal-content .marquee-track {
        gap: 8px;
        padding: 8px;
    }
    
    .modal-header-overlay h3 {
        font-size: 1.1rem;
    }
    
    .project-modal-content::after {
        height: 50px;
        border-bottom-left-radius: 10px;
        border-bottom-right-radius: 10px;
    }
}
