.projects-hero,
.project-hero {
    width: 100%;
    height: 67vh;
    min-height: 400px;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.projects-hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.project-hero-no-image {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.project-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 0 2rem;
}

.hero-title {
    color: white;
    font-size: 3.5rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    line-height: 1.2;
    max-width: 800px;
}

.projects-archive {
    padding: 2rem 0;
}

.projects-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.projects-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 3rem;
    padding: 2rem 0;
    border-bottom: 1px solid #e5e5e5;
}

.filter-link {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: #fff;
    color: #2563eb;
    text-decoration: none;
    border: 2px solid #2563eb;
    border-radius: 25px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.filter-link:hover {
    background: #2563eb;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.filter-link.active {
    background: #2563eb;
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.project-item {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.project-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.project-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.project-thumbnail {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.project-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.project-thumbnail:hover img {
    transform: scale(1.05);
}

.project-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.project-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 1rem;
}

.project-item:hover .project-overlay {
    opacity: 1;
}

.project-overlay .project-title {
    color: white;
    text-align: center;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
}

.project-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

.project-content-wrapper {
    display: flex;
    gap: 3rem;
    margin-bottom: 4rem;
}

.project-text-section-full {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.project-image-section,
.project-text-section {
    flex: 1;
}

.project-image-section img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.project-details {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.project-content {
    flex: 1;
    font-size: 1.1rem;
    line-height: 1.7;
    color: #555;
}

.project-gallery-section {
    margin-top: 4rem;
}

.project-gallery-section h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: #333;
}

.project-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.gallery-item {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.gallery-item:hover {
    transform: scale(1.02);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lightbox-dialog {
    border: none;
    padding: 0;
    background: rgba(0, 0, 0, 0.5);
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    max-width: none;
    max-height: none;
}

.lightbox-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.lightbox-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 3rem;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lightbox-nav button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease;
    font-family: monospace;
    line-height: 1;
}

.lightbox-nav button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lightbox-prev {
    left: 1rem;
}

.lightbox-next {
    right: 1rem;
}

#lightbox-image {
    max-width: calc(100% - 8rem);
    max-height: calc(100% - 8rem);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-caption {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-size: 0.95rem;
    line-height: 1.4;
    text-align: center;
    max-width: 80%;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.lightbox-caption:empty {
    display: none;
}

/* Tablet Portrait - Always show overlay */
@media (max-width: 1024px) and (orientation: portrait) {
    .project-image-section { margin-top: 1rem; }
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .hero-title {
        font-size: 3rem;
    }
    
    /* Always show overlay on tablet portrait */
    .project-overlay {
        opacity: 1;
        background: rgba(0, 0, 0, 0.6);
    }
    
    /* Optional: Adjust overlay styling for better mobile visibility */
    .project-overlay .project-title {
        font-size: 0.95rem;
        padding: 0.5rem;
    }
}

/* All mobile devices - Always show overlay */
@media (max-width: 768px) {
    .project-image-section { margin-top: 1rem; }
    .projects-hero,
    .project-hero {
        height: 50vh;
        min-height: 300px;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .hero-content {
        padding: 0 1rem;
    }
    
    .projects-filter-bar {
        gap: 0.75rem;
        margin-bottom: 2rem;
        padding: 1.5rem 0;
    }
    
    .filter-link {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .projects-container,
    .project-container {
        padding: 0 1rem;
    }
    
    .project-content-wrapper {
        flex-direction: column;
        gap: 2rem;
    }
    
    .project-gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .lightbox-content {
        padding: 1rem;
    }
    
    .lightbox-caption {
        bottom: 1rem;
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
        max-width: 90%;
    }
    
    /* Always show overlay on mobile */
    .project-overlay {
        opacity: 1;
        background: rgba(0, 0, 0, 0.6);
    }
    
    /* Remove hover effects on mobile that might interfere */
    .project-item:hover {
        transform: none;
    }
    
    .project-thumbnail:hover img {
        transform: none;
    }
}

@media (max-width: 480px) {
    .projects-hero,
    .project-hero {
        height: 40vh;
        min-height: 250px;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .project-gallery-grid {
        grid-template-columns: 1fr;
    }
    
    .project-overlay .project-title {
        font-size: 0.9rem;
    }
    
    /* Ensure overlay is always visible on small screens */
    .project-overlay {
        opacity: 1;
        background: rgba(0, 0, 0, 0.6);
    }
}

/* Additional touch device detection for better coverage */
@media (hover: none) and (pointer: coarse) {
    .project-overlay {
        opacity: 1;
        background: rgba(0, 0, 0, 0.6);
    }
    
    .project-item:hover {
        transform: none;
    }
    
    .project-thumbnail:hover img {
        transform: none;
    }
}