/* --- 1. PROJECTS SECTION ENGINE (APPLE-STYLE SCROLL) --- */

.projects-section {
    position: relative;
    padding: 0;
    overflow: visible;
    /* Optimization: Tells browser to only paint when in viewport */
    content-visibility: auto;
    contain-intrinsic-size: 1000px;
}

/* THE RUNWAY: This defines how 'long' the scroll feels. 
   400vh means the user scrolls 4 screens worth of distance to see all projects. */
.scroll-runway {
    height: 450vh;
    position: relative;
}
/* THE STICKY BOX: This pins the gallery to the viewport while you scroll the runway */
.sticky-container {
    position: sticky;
    top: 0;
    height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    /* GPU Boost */
    will-change: transform;
    transform: translateZ(0);
}

/* --- 2. HEADER & LAYOUT --- */

.section-header {
    padding: 0 8%;
    margin-bottom: 40px; /* Reduced to keep cards visible */
    z-index: 10;
}

#projects .hero-title {
    /* Set to 70% of original as requested previously */
    font-size: clamp(1.8rem, 3.8vw, 3.2rem) !important; /* Balanced scale */
    line-height: 1.0;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
    color: #fff;
    text-transform: uppercase;
}

/* --- 3. THE HORIZONTAL VIEWPORT --- */

.horizontal-scroll-viewport {
    width: 100%;
    padding: 0 8%;
    position: relative;
}

.project-track {
    display: flex;
    gap: 40px;
    width: max-content;
    /* Critical: No transitions here. JS handles the physics. */
    transition: none !important;
    will-change: transform;
    /* Force high-performance rendering */
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}

/* --- 3. THE PROJECT CARD (Memory Optimized) --- */

.project-card {
    width: 450px;
    flex-shrink: 0;
    cursor: pointer;
    /* Optimization: Each card is its own graphics layer */
    transform: translateZ(0);
}

.project-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    background: #0a0a0a;
    overflow: hidden;
    border: 1px solid rgba(0, 71, 171, 0.2);
}

.base-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Only animate transform/opacity on hover */
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

/* THE STRUCTURAL OVERLAY (Optimized) */
.structural-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Use visibility instead of just opacity to save GPU cycles */
    visibility: hidden;
    opacity: 0;
    background: rgba(0, 5, 15, 0.8);
    backdrop-filter: blur(5px);
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

/* Only wake up the SVG on hover */
.project-card:hover .structural-overlay {
    visibility: visible;
    opacity: 1;
}

.wireframe-svg {
    width: 70%;
    height: 70%;
    /* Note: drop-shadow is heavy on mobile. 
       If crashes continue, we may need to simplify this. */
    filter: drop-shadow(0 0 12px #00d4ff);
}

/* --- 5. INFO & PROGRESS --- */

.project-info {
    margin-top: 25px;
}

.project-category {
    font-size: 10px;
    color: #00d4ff;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    font-weight: 900;
}

.project-info h3 {
    color: #fff;
    font-size: 1.5rem;
    margin: 8px 0;
}

.project-info p {
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    line-height: 1.6;
}

.gallery-progress-container {
    width: 300px;
    height: 2px;
    background: rgba(0, 71, 171, 0.1);
    margin: 40px auto 0;
    position: relative;
    border-radius: 2px;
}

/* --- 4. PROGRESS BAR --- */

.gallery-progress-bar {
    position: absolute;
    left: 0; top: 0;
    height: 100%;
    width: 0%;
    background: #00d4ff;
    /* Use transform for width changes if possible for performance */
    will-change: width;
}

/* --- 6. MOBILE ADAPTATION --- */
/* --- 5. MOBILE ADAPTATION --- */

@media (max-width: 768px) {
    .project-card { width: 300px; }
    .scroll-runway { height: 400vh; }
    .sticky-container { padding-top: 10vh; }
    
    /* Optimization: Remove heavy blurs on mobile if crashing persists */
    .structural-overlay {
        backdrop-filter: none;
        background: rgba(0, 5, 15, 0.95);
    }
}