.projects-section.container {
    max-width: 1240px;
    padding-top: var(--home-section-gap);
}

.projects-section > .heading-section {
    margin-bottom: 0;
}

.projects-layout {
    display: grid;
    grid-template-columns: minmax(0, 480px) minmax(0, 1fr);
    gap: 2.5rem;
    align-items: start;
}

.project-index {
    position: sticky;
    top: 9rem;
    overflow: hidden;
    border: 1px solid var(--home-card-border);
    border-radius: 20px;
    background: var(--color-white);
    box-shadow: 0 37px 75px rgba(9, 62, 185, 0.09);
}

.project-index-list {
    display: flex;
    flex-direction: column;
    padding: 1rem 2.5rem;
}

.project-accordion-item + .project-accordion-item {
    border-top: 1px solid var(--home-card-border);
}

.project-index-panel-wrap {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.48s cubic-bezier(0.22, 1, 0.36, 1);
}

.project-accordion-item.active .project-index-panel-wrap {
    grid-template-rows: 1fr;
}

.project-index-panel {
    min-height: 0;
    display: flex;
    overflow: hidden;
    flex-direction: column;
    align-items: flex-start;
    gap: 1.5rem;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.28s ease, transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

.project-accordion-item.active .project-index-panel {
    opacity: 1;
    transform: translateY(0);
}

.project-index-panel p {
    margin: 0;
}

.project-index-panel p {
    color: var(--color-text-light);
    font-size: 1rem;
    line-height: 1.6;
}

.project-index-panel a {
    margin-bottom: 1.75rem;
    color: var(--color-primary);
    font-size: var(--fs-sm);
    font-weight: 700;
    letter-spacing: 0.03em;
    text-decoration: none;
    text-transform: uppercase;
}

.project-index-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.6rem 0;
    border: 0;
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    font: inherit;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: left;
}

.project-index-button.active {
    color: var(--color-primary);
}

.project-accordion-indicator {
    position: relative;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
}

.project-accordion-indicator::before,
.project-accordion-indicator::after {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 2px;
    border-radius: 2px;
    content: "";
    background: currentColor;
    transform: translate(-50%, -50%);
    transition: transform 0.36s ease;
}

.project-accordion-indicator::after {
    transform: translate(-50%, -50%) rotate(90deg);
}

.project-index-button.active .project-accordion-indicator::after {
    transform: translate(-50%, -50%) rotate(0deg);
}

.project-index-button:hover,
.project-index-button:focus-visible {
    color: var(--color-primary);
}

.project-gallery {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem 0;
}

.project-gallery-card {
    display: flex;
    overflow: hidden;
    flex-direction: column;
    border-radius: 10px;
    background: #26354f;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 16px 44px rgba(29, 52, 100, 0.08);
    scroll-margin-top: 18vh;
    transition: box-shadow 0.28s ease;
}

.project-gallery-media {
    position: relative;
    aspect-ratio: 721 / 592;
    display: block;
}

/* Desktop keeps the blurb in the side index, so the card body is image-only. */
.project-gallery-detail {
    display: none;
}

.project-gallery-card img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.project-gallery-shade {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(5, 15, 35, 0.02) 35%, rgba(5, 15, 35, 0.82) 100%);
}

.project-gallery-copy {
    position: absolute;
    right: 3.3rem;
    bottom: 3.8rem;
    left: 3.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.project-gallery-copy strong {
    color: #fff;
    font-size: clamp(2rem, 3.2vw, 3.4rem);
    font-weight: 600;
    line-height: 1.05;
}

.project-gallery-copy > span {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
}

/* The selection ring only means something next to the index, which mobile drops. */
@media (min-width: 901px) {
    .project-gallery-card.is-selected {
        box-shadow: 0 0 0 3px rgba(45, 97, 206, 0.2), 0 20px 50px rgba(29, 52, 100, 0.14);
    }
}

@media (prefers-reduced-motion: reduce) {
    .project-index-panel-wrap,
    .project-index-panel,
    .project-accordion-indicator::before,
    .project-accordion-indicator::after {
        transition: none;
    }

    .project-gallery-card {
        transition: none;
    }
}

@media (max-width: 900px) {
    .projects-section > .heading-section {
        margin-bottom: 3rem;
    }

    .projects-layout {
        grid-template-columns: 1fr;
    }

    /* The index is an accordion that scrolls you to a card somewhere else on the
       page — workable as a desktop sidebar, useless once it stacks on top of the
       cards it points at. Each card carries its own blurb instead. */
    .project-index {
        display: none;
    }

    .project-gallery {
        gap: 2rem;
        padding: 0;
    }

    .project-gallery-card {
        border: 1px solid var(--home-card-border);
        background: var(--color-white);
    }

    .project-gallery-detail {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        padding: 1.4rem 1.6rem 1.1rem;
    }

    .project-gallery-description {
        color: var(--color-text-light);
        font-size: 1rem;
        line-height: 1.6;
        /* A teaser, not the whole blurb: the card links to the full write-up. */
        display: -webkit-box;
        overflow: hidden;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 4;
        line-clamp: 4;
    }

    /* Reads as the card's call to action; the whole card is the tap target. */
    .project-gallery-cta {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        color: var(--color-primary);
        font-size: var(--fs-sm);
        font-weight: 700;
        letter-spacing: 0.03em;
        text-transform: uppercase;
    }
}

@media (max-width: 600px) {
    .project-gallery-media {
        aspect-ratio: 3 / 2;
    }

    .project-gallery-copy {
        right: 1.5rem;
        bottom: 1.5rem;
        left: 1.5rem;
    }

    .project-gallery-copy strong {
        font-size: 1.75rem;
    }

    .project-gallery-detail {
        padding: 1.2rem 1.25rem 1rem;
    }
}
