/* --- Project Grid & Image Consistency --- */

/* Force 3 columns on large screens */
@media (min-width: 1024px) {
    .project-list {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 30px;
    }
}

/* Tablet: 2 columns */
@media (min-width: 768px) and (max-width: 1023px) {
    .project-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }
}

/* Ensure images are consistent and square-ish */
.project-img {
    aspect-ratio: 1 / 1;
    /* Make container square */
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 15px;
    position: relative;
    /* For carousel arrows */
}

/* Ensure ALL grid images fill the square completely */
.project-img img,
.project-img picture,
.project-img .carousel-slide img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    aspect-ratio: 1 / 1;
}

/* --- Project Modal (Image Hidden) --- */

/* --- Project Modal (Text-Only Redesign) --- */

.project-modal {
    display: flex !important;
    justify-content: center;
    align-items: center;
}

.project-modal-content {
    width: 95%;
    /* More responsive on small phones */
    max-width: 450px;
    /* Reduced to 450px */
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 25px;
    /* Slightly tighter padding */
    overflow-y: auto;
    text-align: center;
    background: var(--eerie-black-2);
    border: 1px solid var(--jet);
    border-top: 4px solid var(--orange-yellow-crayola);
    box-shadow: var(--shadow-5);
    border-radius: 20px;
}

/* Hide Modal Image Wrapper */
.modal-img-wrapper {
    display: none !important;
}

/* Modal Title */
.project-modal h3 {
    font-size: 26px;
    /* Slightly smaller for better fit */
    line-height: 1.4;
    /* Prevent accent clipping */
    margin-bottom: 15px;
    padding-top: 5px;
    /* Safety space for ascenders */
    background: -webkit-linear-gradient(45deg, var(--white-1), var(--orange-yellow-crayola));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

/* Modal Category */
.project-modal .project-category {
    color: var(--light-gray);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 25px;
    display: inline-block;
    border-bottom: 1px solid var(--jet);
    padding-bottom: 10px;
}

/* --- Desktop Modal Dual-Column Layout --- */
@media (min-width: 1024px) {
    .project-modal-content {
        max-width: 650px;
        /* Compact width for better visual balance */
        display: grid;
        grid-template-columns: 1fr 1fr;
        /* Two equal columns */
        gap: 25px;
        padding: 35px;
        text-align: left;
        /* Align text left */
        align-items: start;
        /* Top align */
    }

    /* Left Column: Header Info + Video */
    .modal-info-left {
        grid-column: 1;
        display: flex;
        flex-direction: column;
    }

    /* Right Column: Description + Tech */
    .modal-info-right {
        grid-column: 2;
        display: flex;
        flex-direction: column;
        height: 100%;
        justify-content: space-between;
        /* Push buttons to bottom if needed */
    }

    /* Since we can't easily change HTML structure without JS refactor, 
       we use Grid Areas or Flex hacks if HTML is flat. 
       
       CURRENT HTML STRUCTURE:
       .modal-info >
          .project-info (meta)
          h3 (title)
          p (category)
          .project-video-container
          div (desc)
          div (tech)
          a (link)
       
       Let's use Grid properly on the parent .modal-info if possible, 
       BUT .modal-info is inside .modal-content.
       
       Actually, .modal-content contains figure (hidden) and .modal-info.
       So let's target .modal-info directly.
    */

    .project-modal-content {
        display: block;
        /* Reset flex from mobile */
        /* width set above */
        overflow-y: visible;
        /* No scroll needed with 2-column layout */
    }

    .project-modal .modal-info {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto auto 1fr auto auto;
        gap: 20px 40px;
        align-items: start;
    }

    /* Title & Category: Span top, or sit on left? User asked for split.
       Let's put Title/Category/Video on Left. Desc/Tech/Link on Right.
    */

    /* Left Column Items */
    .project-modal .modal-info .h3.modal-title {
        grid-column: 1;
        grid-row: 1;
        text-align: left;
        margin: 0;
    }

    .project-modal .modal-info .project-modal-category {
        grid-column: 1;
        grid-row: 2;
        justify-self: start;
        margin-bottom: 10px;
    }

    .project-modal .modal-info .project-info {
        /* Meta tags */
        grid-column: 1;
        grid-row: 3;
        justify-content: flex-start;
    }

    .project-modal .modal-info .project-video-container {
        grid-column: 1;
        grid-row: 4;
        margin: 0 !important;
        width: 100%;
    }

    /* Right Column Items */
    /* Description Container - 5th child */
    .project-modal .modal-info>div:nth-child(5) {
        grid-column: 2;
        grid-row: 1 / span 4;
        /* Span down */
        margin-top: 0 !important;
    }

    /* Tech Container - 6th child */
    .project-modal .modal-info>div:nth-child(6) {
        grid-column: 2;
        grid-row: 5;
    }

    /* Link Button - 7th child */
    .project-modal .modal-info>a.project-link-btn {
        grid-column: 2;
        grid-row: 6;
        margin-left: 0;
        margin-right: auto;
        width: fit-content;
    }
}

/* Project Info (Meta Data) */
.project-info {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    font-size: 14px;
    color: var(--light-gray-70);
}

/* Sections */
.project-modal h4 {
    margin-top: 25px;
    margin-bottom: 15px;
    font-size: 18px;
    color: var(--white-1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    padding: 0;
}

.project-modal h4::before,
.project-modal h4::after {
    content: "";
    display: block;
    height: 1px;
    width: 30px;
    background: var(--jet);
}

.modal-text {
    text-align: left;
    font-size: 16px;
    color: var(--light-gray);
    line-height: 1.7;
}

/* Tech Tags */
.tech-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.tech-badge {
    background: var(--onyx);
    color: var(--orange-yellow-crayola);
    border: 1px solid var(--jet);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

/* Button Wrapper */
.project-link-group {
    display: flex;
    flex-direction: row;
    /* Force row */
    justify-content: center;
    align-items: center;
    gap: 15px;
    /* Consistent gap */
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--jet);
    flex-wrap: wrap;
    /* allow wrap if very small screen */
}

/* Ensure buttons are consistent */
.project-link-group .form-btn {
    margin: 0 !important;
    /* Reset margins */
}

.modal-text,
p[data-project-modal-description] {
    text-align: justify;
    /* Cleaner look for long text */
    text-justify: inter-word;
    font-size: 15px;
    color: var(--light-gray);
    line-height: 1.6;
    margin-bottom: 20px;
}

/* --- Grid Carousel Navigation --- */
.grid-carousel-prev,
.grid-carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    opacity: 0;
    /* Hidden by default */
    transition: opacity 0.3s, background 0.3s;
    z-index: 5;
}

.project-img:hover .grid-carousel-prev,
.project-img:hover .grid-carousel-next {
    opacity: 1;
}

.grid-carousel-prev {
    left: 10px;
}

.grid-carousel-next {
    right: 10px;
}

.grid-carousel-prev:hover,
.grid-carousel-next:hover {
    background: var(--orange-yellow-crayola);
    color: var(--onyx);
}

.carousel-slide {
    display: none;
    width: 100%;
    height: 100%;
}

.carousel-slide.active {
    display: block;
    animation: fadeEffect 0.5s;
}