/* Parent Container Fixes */
.main-content #fetch-projects {
    width: 100%;
    padding: 0;
}

.main-content .content-section.active {
    width: 100%;
    max-width: none;
    display: block;
    padding: 0;
}

/* Project Tiles Styles - Responsive Grid with Auto-Fit */
.projects-grid {
    display: grid;
    width: 100%;        
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    gap: 2rem;
    
    /* Dynamic columns based on minimum tile width */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Debug: Ensure grid container is full width */
.projects-grid {
    box-sizing: border-box;
}

/* Adjust minimum tile width and gap for different screen sizes */
@media (min-width: 1400px) {
    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 2.5rem;
        max-width: 1800px;
    }
}

@media (min-width: 1200px) and (max-width: 1399px) {
    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 2rem;
    }
}

@media (min-width: 1000px) and (max-width: 1199px) {
    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1.5rem;
    }
}

/* Mobile-friendly adjustments (1000px threshold) */
@media (max-width: 999px) {
    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1rem;
        padding: 0 0.75rem;
    }
}

@media (max-width: 767px) {
    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 0.75rem;
        padding: 0 0.5rem;
    }
}

@media (max-width: 479px) {
    .projects-grid {
        /* Force single column on very small screens */
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 0 0.25rem;
    }
}

/* Alternative: Use auto-fill instead of auto-fit for testing */
@media (min-width: 480px) {
    .projects-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
    
    @media (min-width: 1000px) {
        .projects-grid {
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        }
    }
    
    @media (min-width: 1400px) {
        .projects-grid {
            grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        }
    }
}

.project-tile {
    background-color: #0a0a0a;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    
    /* Use flexbox for internal layout */
    display: flex;
    flex-direction: column;
    /* Lock aspect ratio for consistent tile proportions */
    aspect-ratio: 3 / 4;
    width: 100%; /* Ensure tiles take full grid cell width */
}

/* Mobile-specific tile adjustments */
@media (max-width: 999px) {
    .project-tile {
        border-radius: 12px;
        /* Slightly taller aspect ratio for mobile */
        aspect-ratio: 4 / 5;
    }
}

@media (max-width: 479px) {
    .project-tile {
        border-radius: 10px;
        /* Even taller for small screens to accommodate content */
        aspect-ratio: 5 / 6;
    }
}

.project-tile:hover,
.project-tile.hover {
    border-color: #1d9bf0;
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(29, 155, 240, 0.1);
    cursor: crosshair;
}

/* Reduce hover effects on mobile for better performance */
@media (max-width: 999px) {
    .project-tile:hover,
    .project-tile.hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 20px rgba(29, 155, 240, 0.15);
    }
}

.project-tile:hover .project-image,
.project-tile.hover .project-image {
    filter: grayscale(0%);
}

.project-image {
    width: 100%;
    /* Use aspect ratio for smooth, proportional scaling */
    aspect-ratio: 16 / 9;
    flex: 0 0 auto;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
    filter: grayscale(100%);
    transition: all 0.5s ease;
}

/* Fallback for browsers without aspect-ratio support */
@supports not (aspect-ratio: 16 / 9) {
    .project-image {
        height: 200px;
    }
    
    @media (min-width: 1400px) {
        .project-image {
            height: 220px;
        }
    }
    
    @media (max-width: 999px) {
        .project-image {
            height: 180px;
        }
    }
    
    @media (max-width: 767px) {
        .project-image {
            height: 160px;
        }
    }
    
    @media (max-width: 479px) {
        .project-image {
            height: 140px;
        }
    }
}

.project-tile:hover .project-image {
    filter: grayscale(0%);
}

.project-image-content {
    position: absolute;
    height: 100%;
    width: 100%;
}

.project-tile-content {
    /* Use flex-grow to fill remaining space */
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 0.5rem;
}

@media (max-width: 999px) {
    .project-tile-content {
        padding: 1.25rem;
    }
}

@media (max-width: 767px) {
    .project-tile-content {
        padding: 1rem;
    }
}

@media (max-width: 479px) {
    .project-tile-content {
        padding: 0.75rem;
    }
}

.project-tile-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    /* Prevent title from growing too much */
    flex: 0 0 auto;
}

@media (max-width: 999px) {
    .project-tile-title {
        font-size: 1.1rem;
    }
}

@media (max-width: 479px) {
    .project-tile-title {
        font-size: 1rem;
        margin-bottom: 0.4rem;
    }
}

.project-tile-tech {
    color: #1d9bf0;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 1rem;
    /* Prevent tech from growing */
    flex: 0 0 auto;
}

@media (max-width: 999px) {
    .project-tile-tech {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
    }
}

@media (max-width: 479px) {
    .project-tile-tech {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }
}

.project-tile-description {
    color: #71767b;
    line-height: 1.5;
    font-size: 0.9rem;
    /* Allow description to fill remaining space */
    flex: 1;
}

@media (max-width: 999px) {
    .project-tile-description {
        font-size: 0.85rem;
        line-height: 1.4;
    }
}

@media (max-width: 479px) {
    .project-tile-description {
        font-size: 0.8rem;
        line-height: 1.35;
    }
}

/* Fallback: If grid is still not working, use flexbox as backup */
@supports not (display: grid) {
    .projects-grid {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .project-tile {
        flex: 0 1 calc(33.333% - 1.33rem);
        margin-bottom: 2rem;
        aspect-ratio: 3 / 4;
    }
    
    @media (max-width: 999px) {
        .project-tile {
            flex: 0 1 calc(50% - 0.5rem);
            aspect-ratio: 4 / 5;
        }
    }
    
    @media (max-width: 767px) {
        .project-tile {
            flex: 0 1 100%;
            aspect-ratio: 5 / 6;
        }
    }
}

/* Fallback for browsers without aspect-ratio support */
@supports not (aspect-ratio: 3 / 4) {
    .project-tile {
        min-height: 400px;
    }
    
    @media (max-width: 999px) {
        .project-tile {
            min-height: 350px;
        }
    }
    
    @media (max-width: 479px) {
        .project-tile {
            min-height: 320px;
        }
    }
}

