/* ===== Modal Components ===== */

/* Team Modal */
.team-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 4vw, 2rem);
    z-index: 250;
}

    .team-modal:target {
        display: flex;
    }

.team-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 48, 74, 0.72);
    backdrop-filter: blur(3px);
    cursor: pointer;
}

.team-modal__panel {
    position: relative;
    z-index: 1;
    width: min(1100px, 92vw); /* CHANGED: wider */
    max-height: calc(100vh - 2.5rem); /* ADDED: cap to viewport */
    background: var(--color-light);
    border-radius: 18px;
    overflow: hidden; /* CHANGED: internal scroll instead */
    box-shadow: 0 30px 80px rgba(0,0,0,0.35);
    display: flex; /* ADDED: allow grid to fill height */
    flex-direction: column;
}

.team-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,0.92);
    color: var(--color-secondary);
    font-size: 1.6rem;
    line-height: 1;
    box-shadow: 0 10px 22px rgba(0,0,0,0.12);
    cursor: pointer;
    border: 1px solid #999;
}

.team-modal__grid {
    display: grid;
    grid-template-columns: minmax(300px, 400px) 1fr; /* CHANGED: stable media + wider content */
    min-height: 0; /* CHANGED: enables internal scrolling */
    height: 100%; /* ADDED: fill panel height */
}

.team-modal__media {
    background: #eef5f8; /* ADDED */
    min-height: 0; /* ADDED */
    overflow: hidden; /* the photo must never paint outside its own box */
}

    .team-modal__media img {
        width: 100%; /* ADDED */
        height: 100%;
        object-fit: cover;
        object-position: center top; /* CHANGED: better subject framing */
        display: block;
    }

.team-modal__content {
    padding: clamp(1.25rem, 2.4vw, 2.25rem);
    display: flex; /* CHANGED: grid -> flex for reliable scroll */
    flex-direction: column; /* ADDED */
    gap: 0.6rem;
    min-height: 0; /* ADDED: critical for scroll containers */
    min-width: 0; /* ADDED */
    background: var(--color-light); /* opaque panel: name/role always sit on white, never on the photo */
    position: relative;
    z-index: 1;
}

.team-modal__name {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: clamp(1.4rem, 2.2vw, 1.9rem);
    color: var(--color-secondary);
    line-height: 1.2;
    padding-top:20px;
}

.team-modal__role {
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.25rem;
}

.team-modal__bio {
    color: #2c3a49;
    line-height: 1.8;
    display: grid;
    gap: 0.85rem;
    flex: 1 1 auto; /* ADDED */
    min-height: 0; /* ADDED */
    overflow: auto; /* ADDED: bio scrolls for long content */
    padding-right: 0.5rem; /* ADDED: breathing room near scrollbar */
}

    .team-modal__bio p {
        margin: 0;
        max-width: none; /* CHANGED: allow wider content */
    }

/* Project Modal */
.project-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(1rem, 4vw, 2rem);
    overflow-y: auto;
    z-index: 260;
}

    .project-modal:target {
        display: flex;
    }

.project-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 48, 74, 0.72);
    backdrop-filter: blur(3px);
    cursor: pointer;
}

.project-modal__panel {
    position: relative;
    z-index: 1;
    width: min(1240px, 94vw);
    max-height: calc(100vh - 2.5rem);
    background: var(--color-light);
    border-radius: 18px;
    overflow: auto;
    box-shadow: 0 30px 80px rgba(0,0,0,0.35);
    display: flex;
    flex-direction: column;
}

.project-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,0.92);
    color: var(--color-secondary);
    font-size: 1.6rem;
    line-height: 1;
    box-shadow: 0 10px 22px rgba(0,0,0,0.12);
    cursor: pointer;
    border: 1px solid rgba(13, 63, 94, 0.22);
    z-index: 5;
}

/* Old two-column grid (vertical hero) retained for reference, but no longer used by the new markup */
.project-modal__grid {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    min-height: 520px;
}

.project-modal__media {
    position: relative;
    background: #eef5f8;
}

    .project-modal__media img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

/* New horizontal hero */
.project-modal__hero {
    position: relative;
    background: #eef5f8;
    height: clamp(200px, 22.2vw, 300px);
}

    .project-modal__hero img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center var(--hero-focus-y, 50%);
        display: block;
    }

.project-modal__heroText {
    position: absolute;
    bottom: clamp(2.5rem, 6vw, 3.5rem);
    left: 28px;
    right: 72px; /* keeps clear of the close button on the right */
    z-index: 2;
    display: grid;
    gap: clamp(0.35rem, 1vw, 0.6rem);
}

.project-modal__heroTitle {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: clamp(1.8rem, 4.5vw, 3rem);
    line-height: 1.1;
    color: var(--color-light);
    text-shadow: 0 10px 22px rgba(0,0,0,0.35);
    word-break: break-word;
    text-wrap: balance;
}

.project-modal__heroSubtitle {
    font-weight: 800;
    color: rgba(255,255,255,0.92);
    max-width: 60ch;
    line-height: 1.35;
    text-shadow: 0 10px 22px rgba(0,0,0,0.30);
    margin-bottom: clamp(0.85rem, 1.4vw, 1.15rem);
    font-size: clamp(1.05rem, 3.6vw, 1.35rem);
    word-break: break-word;
    text-wrap: balance;
}

.project-modal__mediaOverlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(10,48,74,0.05), rgba(10,48,74,0.35));
}

.project-modal__chips {
    position: absolute;
    right: 26px;
    bottom: 16px;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    z-index: 1;
}

.project-modal__chip {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--color-light);
    background: rgba(13, 63, 94, 0.85);
    border: 1px solid rgba(255,255,255,0.18);
}

.project-modal__chip--status {
    background: rgba(0, 121, 156, 0.9);
}

/* Old content panel retained for reference, but no longer used by the new markup */
.project-modal__content {
    padding: clamp(1.25rem, 2.4vw, 2.25rem);
    display: grid;
    align-content: start;
    gap: 0.85rem;
}

/* New scrollable body */
.project-modal__body {
    padding: clamp(1.25rem, 2.4vw, 2.25rem);
    overflow: auto;
    flex: 1;
    min-height: 0;
    display: grid;
    align-content: start;
    gap: 0.85rem;
}

.project-modal__title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: clamp(1.4rem, 2.2vw, 2rem);
    color: var(--color-secondary);
    line-height: 1.2;
}

.project-modal__subtitle {
    color: #52616f;
    font-weight: 900;
}

.project-modal__desc {
    color: #2c3a49;
    line-height: 1.8;
    display: grid;
    gap: 0.85rem;
}

    .project-modal__desc p {
        margin: 0;
        max-width: 70ch;
    }

/* New desc + map layout */
.project-modal__layout {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: clamp(1rem, 2vw, 1.5rem);
    align-items: start;
}

.project-modal__left {
    min-width: 0;
}

.project-modal__right {
    min-width: 0;
}

/* Old map block retained for reference, but no longer used by the new markup */
.project-modal__map {
    display: block;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(13, 63, 94, 0.14);
    box-shadow: 0 14px 28px rgba(0,0,0,0.06);
    text-decoration: none;
}

    .project-modal__map img {
        width: 100%;
        aspect-ratio: 16 / 9;
        object-fit: cover;
        display: block;
    }

.project-modal__mapPlaceholder {
    width: 100%;
    aspect-ratio: 16 / 9;
    display: grid;
    place-items: center;
    background: #eef5f8;
    color: var(--color-secondary);
    font-weight: 800;
    font-family: var(--font-heading);
}

/* New embedded map wrapper + clickable overlay link */
.project-modal__mapWrap {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(13, 63, 94, 0.14);
    box-shadow: 0 14px 28px rgba(0,0,0,0.06);
    background: #eef5f8;
}

    .project-modal__mapWrap iframe {
        width: 100%;
        aspect-ratio: 16 / 9;
        border: 0;
        display: block;
        pointer-events: none;
    }

.project-modal__mapLink {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0.75rem;
    text-decoration: none;
    font-weight: 800;
    font-family: var(--font-heading);
    color: var(--color-light);
    background: linear-gradient(180deg, rgba(0,0,0,0.00), rgba(10,48,74,0.55));
}

.project-modal__actions {
    margin-top: 0.25rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Modal Body Scroll Lock */
body:has(.team-modal:target),
body:has(.project-modal:target) {
    overflow: hidden;
}

.team-modal.open,
.project-modal.open {
    display: flex;
}

body.modal-open {
    overflow: hidden;
}

/* Responsive Modals */
@media (max-width: 900px) {
    /* Team Modal */
    .team-modal__grid {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .team-modal__media img {
        /* Cap by viewport height: on short screens (landscape phones, small
           laptops) a fixed height forced the photo past its compressed grid
           row and under the member name. */
        height: min(320px, 45vh);
    }

    /* Project Modal - Old rule retained (if old markup appears anywhere) */
    .project-modal__grid {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .project-modal__media img {
        height: 320px;
    }

    /* Project Modal - New responsive stacking */
    .project-modal__layout {
        grid-template-columns: 1fr;
    }

    .project-modal__panel {
        width: min(1080px, 92vw);
        max-height: calc(100vh - 2rem);
    }

    .project-modal__heroText {
        right: 56px;
    }
}

@media (max-width: 860px) {
    .team-modal__grid {
        grid-template-columns: 1fr;
        min-height: auto;
        overflow:hidden;
    }

    .team-modal__media img {
        /* 400px overflowed the media row on short viewports (iPhone SE,
           landscape iPhones), painting the photo behind the name. */
        height: min(400px, 45vh);
    }
}
