/* ═══════════════════════════════════════════
   projects.css — Project showcase with IMAGES
   ═══════════════════════════════════════════ */

.projects {
    background-color: var(--bg);
}

/* ── Filter Pills ── */
.projects-filter {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 3rem;
}

.filter-btn {
    padding: 0.75rem 2rem;
    background-color: var(--card-bg);
    color: var(--text);
    border: 2px solid transparent;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    background-color: var(--primary);
    color: #fff;
    transform: translateY(-2px);
}

.filter-btn.active {
    background-color: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ── Grid ── */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

/* ── Card ── */
.project-card {
    background-color: var(--card-bg);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    /* Reveal animation */
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.project-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.project-card.visible:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-lg);
}

/* Staggered delays */
.project-card:nth-child(1).visible { transition-delay: 0s; }
.project-card:nth-child(2).visible { transition-delay: 0.15s; }
.project-card:nth-child(3).visible { transition-delay: 0.3s; }
.project-card:nth-child(4).visible { transition-delay: 0.45s; }

/* ── Image Container ── */
.project-image {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;  /* Reserve space - prevents layout shift */
    overflow: hidden;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
}

/* Actual project image */
.project-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    backface-visibility: hidden;
    transform: translateZ(0);  /* GPU acceleration */
}

.project-card.visible:hover .project-img {
    transform: scale(1.1) translateZ(0);
}

/* Overlay with emoji (shown on hover) */
.project-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        rgba(99, 102, 241, 0.9),
        rgba(139, 92, 246, 0.9)
    );
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.project-card.visible:hover .project-overlay {
    opacity: 1;
}

.project-emoji {
    font-size: 4rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.project-card.visible:hover .project-emoji {
    transform: scale(1);
}

/* Fallback: If no image, show emoji by default */
.project-image:not(:has(.project-img)) .project-overlay {
    opacity: 1;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
}

.project-image:not(:has(.project-img)) .project-emoji {
    font-size: 5rem;
    transform: scale(1);
}

/* ── Content ── */
.project-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.project-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-strong);
    margin-bottom: 0.75rem;
}

.project-description {
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1rem;
    flex-grow: 1;
}

/* ── Project Metrics ── */
.project-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 0;
    margin-bottom: 0.75rem;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.metric {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.metric i {
    color: var(--primary);
    font-size: 1rem;
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.project-links {
    display: flex;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.project-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: var(--bg);
    border-radius: 50%;
    color: var(--text);
    font-size: 1.25rem;
    transition: all 0.3s ease;
}

.project-link:hover {
    background-color: var(--primary);
    color: #fff;
    transform: translateY(-3px);
}

/* ═══════════════════════════════════════════
   Loading States
   ═══════════════════════════════════════════ */

/* Shimmer effect while image loads */
.project-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 100%
    );
    animation: shimmer 2s ease-in-out infinite;
    z-index: 1;
    pointer-events: none;
}

.project-image.loaded::before {
    display: none;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* ═══════════════════════════════════════════
   Responsive Design
   ═══════════════════════════════════════════ */

@media (max-width: 768px) {
    .projects-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.5rem;
    }

    .project-image {
        aspect-ratio: 4 / 3;  /* Taller on tablets */
    }

    .project-emoji {
        font-size: 3.5rem;
    }
}

@media (max-width: 480px) {
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .project-image {
        aspect-ratio: 1 / 1;  /* Square on mobile */
    }

    .project-content {
        padding: 1.25rem;
    }

    .project-title {
        font-size: 1.25rem;
    }

    .project-description {
        font-size: 0.95rem;
    }

    .project-emoji {
        font-size: 3rem;
    }

    /* Faster stagger on mobile */
    .project-card:nth-child(1).visible { transition-delay: 0s; }
    .project-card:nth-child(2).visible { transition-delay: 0.1s; }
    .project-card:nth-child(3).visible { transition-delay: 0.2s; }
    .project-card:nth-child(4).visible { transition-delay: 0.3s; }
}

/* ═══════════════════════════════════════════
   Accessibility
   ═══════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    .project-card,
    .project-img,
    .project-overlay,
    .project-emoji {
        transition: none;
    }

    .project-card.visible {
        transform: none;
    }

    .project-image::before {
        animation: none;
    }
}