/**
 * EIASM Faculty Modal — Styles
 *
 * Fixes:
 *   - Mobile: sticky close header, safe viewport height, no top-clipping
 *   - Portrait: circular fixed-size frame, consistent across all faculty
 *   - Text: profile header centered, biography left-aligned
 *   - Design: calm institutional panel, restrained teal accents
 */

/* ═══════════════════════════════════════════════════════════════════
   MODAL OVERLAY & CONTAINER
   Always centered. Never flex-end. Safe on all viewports.
   ═══════════════════════════════════════════════════════════════════ */

.eiasm-fr-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.eiasm-fr-modal--open {
    opacity: 1;
    visibility: visible;
}

.eiasm-fr-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(11, 18, 32, 0.5);
    cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════════
   MODAL PANEL
   Flex column: sticky header + scrollable body.
   max-height uses dvh with vh fallback for mobile browser safety.
   ═══════════════════════════════════════════════════════════════════ */

.eiasm-fr-modal__panel {
    position: relative;
    z-index: 1;
    background: #ffffff;
    border-radius: 20px;
    box-shadow:
        0 24px 48px -12px rgba(11, 18, 32, 0.15),
        0 0 0 1px rgba(11, 18, 32, 0.04);
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(6px);
    transition: transform 0.2s ease;
}

.eiasm-fr-modal--open .eiasm-fr-modal__panel {
    transform: translateY(0);
}

/* ═══════════════════════════════════════════════════════════════════
   STICKY HEADER — Close button always reachable
   Uses sticky positioning inside the flex column so it stays
   visible while the content area scrolls beneath it.
   ═══════════════════════════════════════════════════════════════════ */

.eiasm-fr-modal__header {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    justify-content: flex-end;
    padding: 12px 16px 0;
    background: transparent;
    pointer-events: none; /* Let clicks pass through to content below */
}

.eiasm-fr-modal__close {
    pointer-events: auto; /* Re-enable clicks on the button itself */
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    color: #667085;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
    flex-shrink: 0;
}

.eiasm-fr-modal__close:hover {
    color: #0B1220;
    background: rgba(255, 255, 255, 0.95);
    border-color: #d0d5dd;
}

.eiasm-fr-modal__close:focus-visible {
    outline: 2px solid #1587A8;
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════
   SCROLLABLE CONTENT AREA
   ═══════════════════════════════════════════════════════════════════ */

.eiasm-fr-modal__scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Negative margin-top to visually overlap the sticky header's space */
    margin-top: -36px;
}

/* ═══════════════════════════════════════════════════════════════════
   CIRCULAR PORTRAIT — Consistent frame, matching card language
   ═══════════════════════════════════════════════════════════════════ */

.eiasm-fr-modal__portrait-area {
    display: flex;
    justify-content: center;
    padding: 40px 24px 16px;
}

.eiasm-fr-modal__portrait-frame {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    overflow: hidden;
    background: #f1f5f9;
    flex-shrink: 0;
    box-shadow: 0 0 0 4px #ffffff, 0 0 0 5px #e5e7eb;
}

.eiasm-fr-modal__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    display: block;
    border-radius: 50%;
}

.eiasm-fr-modal__placeholder-img {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b0b8c4;
}

/* ═══════════════════════════════════════════════════════════════════
   PROFILE HEADER — Centered name/role/expertise
   ═══════════════════════════════════════════════════════════════════ */

.eiasm-fr-modal__profile-header {
    text-align: center;
    padding: 0 32px 20px;
    border-bottom: 1px solid #f1f5f9;
    margin: 0 24px;
}

.eiasm-fr-modal__name {
    font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: #0B1220;
    margin: 0 0 4px;
    line-height: 1.3;
}

.eiasm-fr-modal__role {
    font-size: 14px;
    font-weight: 500;
    color: #1587A8;
    margin: 0 0 4px;
    line-height: 1.4;
}

.eiasm-fr-modal__expertise {
    font-size: 13px;
    color: #667085;
    margin: 0;
    line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════════════
   BODY — Left-aligned biography and metadata
   ═══════════════════════════════════════════════════════════════════ */

.eiasm-fr-modal__body {
    padding: 24px 32px 32px;
    text-align: left;
}

.eiasm-fr-modal__bio {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: #344054;
    line-height: 1.7;
    margin-bottom: 20px;
}

.eiasm-fr-modal__bio p {
    margin: 0 0 12px;
}

.eiasm-fr-modal__bio p:last-child {
    margin-bottom: 0;
}

/* ─── Meta (Institution, External Link) ───────────────────────────── */

.eiasm-fr-modal__meta {
    border-top: 1px solid #f1f5f9;
    padding-top: 16px;
    margin-top: 4px;
}

.eiasm-fr-modal__institution {
    font-size: 13px;
    color: #667085;
    margin: 0 0 8px;
    line-height: 1.4;
}

.eiasm-fr-modal__link {
    font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #1587A8;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: color 0.15s ease;
}

.eiasm-fr-modal__link:hover {
    color: #0e6a8a;
    text-decoration: underline;
}

.eiasm-fr-modal__link:focus-visible {
    outline: 2px solid #1587A8;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ═══════════════════════════════════════════════════════════════════
   BODY SCROLL LOCK
   ═══════════════════════════════════════════════════════════════════ */

body.eiasm-modal-open {
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .eiasm-fr-modal {
        padding: 16px 12px;
        align-items: center; /* STAY centered — never flex-end */
    }

    .eiasm-fr-modal__panel {
        max-width: 100%;
        max-height: 90vh;
        max-height: 90dvh;
        border-radius: 16px;
    }

    .eiasm-fr-modal__portrait-area {
        padding: 36px 20px 12px;
    }

    .eiasm-fr-modal__portrait-frame {
        width: 110px;
        height: 110px;
    }

    .eiasm-fr-modal__profile-header {
        padding: 0 20px 16px;
        margin: 0 16px;
    }

    .eiasm-fr-modal__name {
        font-size: 19px;
    }

    .eiasm-fr-modal__body {
        padding: 20px 24px 28px;
    }
}

@media (max-width: 480px) {
    .eiasm-fr-modal {
        padding: 10px 8px;
    }

    .eiasm-fr-modal__panel {
        max-height: 88vh;
        max-height: 88dvh;
        border-radius: 14px;
    }

    .eiasm-fr-modal__portrait-area {
        padding: 32px 16px 10px;
    }

    .eiasm-fr-modal__portrait-frame {
        width: 96px;
        height: 96px;
    }

    .eiasm-fr-modal__profile-header {
        margin: 0 12px;
    }

    .eiasm-fr-modal__name {
        font-size: 17px;
    }

    .eiasm-fr-modal__body {
        padding: 18px 20px 24px;
    }

    .eiasm-fr-modal__bio {
        font-size: 13.5px;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    .eiasm-fr-modal,
    .eiasm-fr-modal *,
    .eiasm-fr-modal *::before,
    .eiasm-fr-modal *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
