/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
    --navy: #2c3e50;
    --blue: #3498db;
    --blue-dark: #2980b9;
    --text: #333;
    --text-muted: #6b7c8c;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-alt: #f8f9fa;
    --border: #e6eaee;
    --shadow-sm: 0 1px 2px rgba(16, 34, 51, 0.04), 0 2px 8px rgba(16, 34, 51, 0.06);
    --shadow-md: 0 4px 16px rgba(16, 34, 51, 0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --nav-height: 64px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    /* Keep anchor targets clear of the sticky navbar */
    scroll-padding-top: calc(var(--nav-height) + 1rem);
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.65;
    overflow-x: hidden;
    /* Keeps the footer at the bottom of short pages */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body > .main-content,
body > .blog-container {
    flex: 1 0 auto;
}

img {
    max-width: 100%;
    height: auto;
}

a:focus-visible,
button:focus-visible {
    outline: 3px solid var(--blue);
    outline-offset: 2px;
    border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    * {
        transition: none !important;
        animation: none !important;
    }
}

/* ==========================================================================
   Navigation
   ========================================================================== */
.navbar {
    background-color: var(--navy);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.nav-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
    min-height: var(--nav-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.nav-logo {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.4rem;
    line-height: 1;
    padding: 0.5rem;
    cursor: pointer;
}

.nav-menu {
    display: flex;
    list-style: none;
    align-items: center;
    gap: 1.75rem;
}

.nav-menu a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s ease;
}

.nav-menu a:hover {
    color: white;
}

/* Section currently in view (set by the scroll spy) */
.nav-menu a.active:not(.blog-link) {
    color: white;
    box-shadow: inset 0 -2px 0 var(--blue);
}

.blog-link {
    background-color: var(--blue);
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: white !important;
    transition: background-color 0.2s ease;
}

.blog-link:hover {
    background-color: var(--blue-dark);
}

/* ==========================================================================
   Layout
   ========================================================================== */
.main-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 1rem;
}

.section {
    margin-bottom: 2rem;
    background-color: var(--surface);
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    animation: rise-in 0.5s ease both;
}

.section:nth-of-type(2) { animation-delay: 0.06s; }
.section:nth-of-type(3) { animation-delay: 0.12s; }
.section:nth-of-type(4) { animation-delay: 0.18s; }

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.section-title {
    font-size: 1.6rem;
    color: var(--navy);
    margin-bottom: 1.5rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid var(--blue);
}

/* ==========================================================================
   About
   ========================================================================== */
.about-container {
    display: flex;
    gap: 2.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.profile-pic {
    width: 190px;
    height: 190px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
}

.about-text {
    flex: 1;
    min-width: 260px;
}

.about-text h1 {
    font-size: clamp(1.8rem, 5vw, 2.4rem);
    color: var(--navy);
    line-height: 1.2;
    margin-bottom: 0.4rem;
}

.subtitle {
    font-size: 1.15rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-style: italic;
}

.bio {
    font-size: 1.05rem;
    color: #4a5866;
    margin-bottom: 1rem;
    max-width: 60ch;
}

.contact-links {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.contact-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    min-height: 44px;
    background-color: var(--blue);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    /* The email link has no href until it is interacted with */
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.contact-links a:hover {
    background-color: var(--blue-dark);
    transform: translateY(-1px);
}

/* ==========================================================================
   Research interests (inline tags inside the About section)
   ========================================================================== */
.interests {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.interests-label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-right: 0.25rem;
}

.interest-tag {
    padding: 0.25rem 0.75rem;
    background-color: rgba(52, 152, 219, 0.1);
    color: var(--blue-dark);
    border: 1px solid rgba(52, 152, 219, 0.25);
    border-radius: 999px;
    font-size: 0.88rem;
}

/* ==========================================================================
   Publications
   ========================================================================== */
.publications-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.publication-item {
    padding: 1.5rem;
    background-color: var(--surface-alt);
    border: 1px solid var(--border);
    border-left: 4px solid var(--blue);
    border-radius: var(--radius-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.publication-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.pub-badge {
    display: inline-block;
    margin-bottom: 0.6rem;
    padding: 0.2rem 0.6rem;
    background-color: rgba(52, 152, 219, 0.12);
    color: var(--blue-dark);
    border: 1px solid rgba(52, 152, 219, 0.3);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.pub-title {
    font-size: 1.2rem;
    line-height: 1.35;
    color: var(--navy);
    margin-bottom: 0.5rem;
}

.pub-authors {
    font-size: 0.98rem;
    color: #4a5866;
    margin-bottom: 0.2rem;
}

.pub-equal-contrib {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.pub-venue {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.pub-description {
    font-size: 1rem;
    color: #55616d;
    margin-bottom: 1rem;
    max-width: 75ch;
}

.pub-links {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.pub-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.5rem 0.9rem;
    min-height: 40px;
    background-color: var(--blue);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.pub-link:hover {
    background-color: var(--blue-dark);
}

button.pub-link {
    border: none;
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
}

.placeholder-text {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: var(--radius-sm);
    color: #856404;
}

/* ==========================================================================
   BibTeX modal
   ========================================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(16, 34, 51, 0.6);
    z-index: 200;
    padding: 1rem;
    overflow-y: auto;
}

.modal-overlay.open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background-color: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(16, 34, 51, 0.3);
    width: 100%;
    max-width: 680px;
    padding: 1.5rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-header h3 {
    color: var(--navy);
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 0.4rem;
}

.modal-close:hover {
    color: var(--navy);
}

.bibtex-code {
    background-color: var(--surface-alt);
    border: 1px solid var(--border);
    border-left: 4px solid var(--blue);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-family: ui-monospace, SFMono-Regular, 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 55vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Prevents the page behind the modal from scrolling on touch devices */
body.modal-open {
    overflow: hidden;
}

/* ==========================================================================
   News
   ========================================================================== */
.news-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.news-item {
    display: flex;
    gap: 1.25rem;
    padding: 1.15rem 1.25rem;
    background-color: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    align-items: baseline;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.news-item:hover {
    border-color: rgba(52, 152, 219, 0.4);
    box-shadow: var(--shadow-sm);
}

.news-date {
    font-weight: 700;
    color: var(--blue);
    flex-shrink: 0;
    min-width: 84px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.news-content {
    color: #4a5866;
    font-size: 1rem;
}

.news-content a {
    color: var(--blue-dark);
    text-decoration: none;
    border-bottom: 1px solid rgba(41, 128, 185, 0.35);
}

.news-content a:hover {
    border-bottom-color: var(--blue-dark);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
    background-color: var(--navy);
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    padding: 1.75rem 1.5rem;
    margin-top: auto;
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* ==========================================================================
   Info box - reusable component for informational messages
   ========================================================================== */
.info-box {
    background-color: #e8f4f8;
    border-left: 4px solid var(--blue);
    padding: 1.5rem;
    border-radius: var(--radius-sm);
    margin-top: 2rem;
}

.info-box h3 {
    color: var(--navy);
    margin-bottom: 0.5rem;
}

.info-box p {
    color: #555;
    margin-bottom: 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 860px) {
    .nav-toggle {
        display: block;
    }

    .nav-container {
        flex-wrap: wrap;
        padding: 0 1rem;
    }

    .nav-logo {
        font-size: 1.05rem;
        white-space: normal;
    }

    /* Collapsed by default on small screens; .open is set by the toggle */
    .nav-menu {
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        width: 100%;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
        padding: 0.5rem 0 0.75rem;
    }

    .nav-menu.open {
        display: flex;
    }

    .nav-menu a {
        display: block;
        padding: 0.75rem 0.25rem;
        font-size: 1rem;
    }

    .blog-link {
        display: inline-block !important;
        margin-top: 0.5rem;
        align-self: flex-start;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1.5rem 1rem 0.5rem;
    }

    .section {
        padding: 1.5rem 1.25rem;
        margin-bottom: 1.25rem;
    }

    .section-title {
        font-size: 1.4rem;
        margin-bottom: 1.25rem;
    }

    .about-container {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }

    .profile-pic {
        width: 150px;
        height: 150px;
        margin: 0 auto;
    }

    .about-text {
        text-align: center;
        min-width: 0;
    }

    .bio {
        margin-left: auto;
        margin-right: auto;
    }

    .contact-links {
        justify-content: center;
    }

    .interests {
        justify-content: center;
    }

    .news-item {
        flex-direction: column;
        gap: 0.4rem;
    }

    .publication-item {
        padding: 1.25rem 1rem;
    }

    .pub-title {
        font-size: 1.1rem;
    }

    .pub-links {
        gap: 0.5rem;
    }

    .modal-box {
        padding: 1.25rem 1rem;
    }

    .bibtex-code {
        font-size: 0.78rem;
    }
}

@media (max-width: 420px) {
    .contact-links {
        flex-direction: column;
        align-items: stretch;
    }

    .contact-links a {
        justify-content: center;
    }

    .pub-link {
        flex: 1 1 calc(50% - 0.5rem);
    }
}
