:root {
    --card-bg-color: #ffffff;
    --text-color: #333;
    --modal-bg-color: rgba(0, 0, 0, 0.7);
    --animation-duration: 0.3s;
    --primary-color: orange;
}

/* Portfolio */
.card-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    justify-content: center;
    padding: 30px 4rem;
}

.project-card {
    background-color: #222222;
    border-radius: 6px;
    overflow: hidden;
    min-width: 300px;
    max-width: 340px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;

    animation: clipAnimate linear;
    animation-timeline: view();
    animation-range: entry 0% cover 30%;
}

.project-card:hover {
    transform: translateY(-5px);
}

.project-image-container {
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

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

.project-card:hover .project-image {
    transform: scale(1.05);
}

.project-title {
    background-color: #202020;
    color: #ccc;
    height: 40px;
    min-height: 40px;
    width: 100%;
    font-size: 16px;
    font-weight: 300;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
}

.project-title:hover {
    background-color: orange;
    color: #222222;
}

@keyframes clipAnimate {
    from {
        opacity: 0;
        scale: 0.5;
        clip-path: inset(100 100 0 0);
    }
    to {
        opacity: 1;
        scale: 1;
        clip-path: inset(0 0 0 0);
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg-color);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity var(--animation-duration) ease-in-out;
}

.modal.modal-visible {
    opacity: 1;
}

.modal-content {
    background-color: var(--card-bg-color);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    position: relative;
    transform: scale(0.9);
    transition: transform var(--animation-duration) ease-in-out;
}

.modal.modal-visible .modal-content {
    transform: scale(1);
}

.close-btn {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover,
.close-btn:focus {
    color: var(--primary-color);
}

.modal-body {
    display: flex;
    flex-direction: column;
    padding: 30px;
    gap: 30px;
    /* The fix: Set fixed dimensions and prevent overflow on smaller screens */
    width: 100%;
    height: 100%;
    max-width: 800px;
    max-height: 500px;
    overflow: auto; /* Adds scrollbars if content is too large */
}

/* New: Modal image container for a consistent look */
.modal-image-container {
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    /* For responsiveness */
    flex-shrink: 0; 
}

.modal-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-details {
    text-align: center;
    /* For responsiveness */
    flex-shrink: 1;
}

.modal-details h2 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.modal-details p {
    font-size: 1rem;
    color: #666;
    margin-bottom: 20px;
}

.modal-details a {
    display: inline-block;
    padding: 12px 24px;
    background-color: var(--primary-color);
    color: #fff;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    transition: background-color 0.2s, transform 0.2s;
}

.modal-details a:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
}

@media (min-width: 768px) {
    .modal-body {
        flex-direction: row;
        align-items: flex-start;
    }
    
    .modal-image-container {
        width: 60%;
    }
    
    .modal-details {
        width: 40%;
        padding-left: 30px;
        text-align: left;
    }
}