.work {
    padding: 50px 20px;
    background-color: var(--background-color);
    color: var(--text-color);
    text-align: center;
}

.work h2 {
    font-size: 2.5rem;
    margin-bottom: 50px;
    color: var(--primary-color);
}

.work .project-cards {
    max-width: 1220px;
    margin: auto;
    display: flex;
    justify-content: space-evenly;
    gap: 20px;
    flex-wrap: wrap;
}

.work .project-card {
    perspective: 1000px;
    width: 300px;
    height: 200px;
    margin-bottom: 30px;
    transition: transform 0.3s ease;
}

.work .card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.work .project-card:hover .card-inner {
    transform: rotateY(180deg);
}

.work .card-front,
.work .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    /* Hide the back side when not flipped */
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.work .card-front {
    background-size: cover;
    background-position: center;
    color: var(--background-color);
    /* Ensure front is on top when not flipped */
}

.work .card-front .hover-icon,
.work .card-front .project-logo,
.work .card-front .project-title {
    z-index: 2;
}

.work .card-front::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    /* Dark overlay */
    border-radius: 15px;
    /* Matches the card's border-radius */
    z-index: 1;
    /* Ensures the overlay is on top of the background image */
}

.work .card-back {
    background-color: var(--secondary-color);
    color: var(--primary-color);
    transform: rotateY(180deg);
    z-index: 2;
    /* Ensure back is behind the front when not flipped */
}

.work .project-logo {
    padding: 8px;
    border-radius: 8px;
    background-color: var(--background-color);
    margin-bottom: 20px;
    max-width: 90%;
    text-align: center;
}

.work .project-logo img {
    max-width: 100%;
    height: 50px;
}

.work .project-title {
    font-size: 1.5rem;
    margin-top: 10px;
}

.work .project-abstract p {
    font-size: 1rem;
    text-align: center;
    margin: 0;
}

.work .project-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
    display: inline-block;
    transition: color 0.3s ease;
    position: relative;
    z-index: 3;
    padding: 20px 30px;
}

.work .project-link:hover {
    color: var(--accent-color);
}

.work .hover-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.5rem;
    color: var(--secondary-color);
    opacity: 0.8;
    transition: transform 0.3s, opacity 0.3s;
}

.work .project-card:hover .hover-icon {
    transform: scale(1.2);
    opacity: 1;
}

@media (max-width: 768px) {
    .work .project-cards {
        flex-direction: column;
        align-items: center;
    }

    .work .project-card {
        width: 100%;
        margin-bottom: 30px;
    }
}