.project-item {
    position: relative;
    transition: all 0.4s ease-in-out;
    height: 320px;
    width: 100%;
    overflow: hidden;
    cursor: pointer;
    will-change: transform, height;
    transform-origin: center center;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.project-item.expanded {
    height: auto;
    min-height: 450px;
    z-index: 100;
    transform: scale(1.02);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Fixed state for project items */
.project-item:not(:hover):not(.expanded) {
    transform: scale(1);
    height: 320px;
}

.project-item .project-description,
.project-item .project-technologies {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s ease;
    max-height: 0;
    overflow: hidden;
}

.project-item.expanded .project-description,
.project-item.expanded .project-technologies,
.project-item .project-description.visible,
.project-item .project-technologies.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    max-height: none;
}

.project-item.expanded .project-description {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 15px;
    display: block;
}

.project-item.expanded .project-technologies {
    display: flex;
    flex-wrap: wrap;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    max-height: none;
}

.project-item .project-tech {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    margin-right: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    white-space: nowrap;
    display: inline-block;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* Improve project overlay */
.project-item .project-overlay {
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.85));
    transition: background 0.3s ease;
}

.project-item.expanded .project-overlay {
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.9));
}

/* Custom scrollbar for project descriptions */
.project-description::-webkit-scrollbar {
    width: 5px;
}

.project-description::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.project-description::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    transition: background 0.2s ease;
}

.project-description::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Add close button for expanded projects */
.project-item.expanded .project-info:after {
    content: '×';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s ease;
    z-index: 10;
}

.project-item.expanded .project-info:after:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Animation for project expansion */
@keyframes expandProject {
    from {
        max-height: 320px;
        opacity: 0.9;
    }
    to {
        max-height: 600px;
        opacity: 1;
    }
}

.project-item.expanded {
    animation: expandProject 0.4s forwards;
}
