/*
  Dark theme, deliberately plain. Effects are kept to a minimum so the page
  reads like the academic sites it sits alongside rather than a template.
*/

:root {
    --bg-main: #0a0a0f;
    --bg-secondary: #13131a;
    --bg-card: #16161d;

    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --text-muted: #7e7e8f;

    --accent-text: #8b8ef5;
    --accent-text-alt: #a78bfa;

    --border-color: rgba(255, 255, 255, 0.08);
    --code-bg: rgba(255, 255, 255, 0.06);
    --logo-opacity: 0.72;

    /* backbone trace, N terminus to C terminus */
    --protein-n: #60a5fa;
    --protein-c: #c084fc;

    /* apoptosome: Apaf-1 ring and the cytochrome c bound at each spoke */
    --apo-ring: #6ea8fe;
    --apo-ring-end: #f472b6;
    --apo-core: #fbbf24;

    /* GitHub's own stack, so the page renders in the reader's system UI font */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica,
        Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";

    --transition-fast: 0.15s ease;
}

/* Light theme. The system preference decides by default; an explicit
   data-theme set by the toggle overrides it in either direction. */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
    --bg-main: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-card: #f6f8fa;

    --text-primary: #1f2328;
    --text-secondary: #424a53;
    --text-muted: #59636e;

    --accent-text: #4f46e5;
    --accent-text-alt: #6d28d9;

    --border-color: #d1d9e0;
    --code-bg: rgba(27, 31, 36, 0.06);
    --logo-opacity: 0.85;

    --protein-n: #2563eb;
    --protein-c: #7c3aed;

    --apo-ring: #1d4ed8;
    --apo-ring-end: #be185d;
    --apo-core: #b45309;
    }
}

:root[data-theme="light"] {
    --bg-main: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-card: #f6f8fa;

    --text-primary: #1f2328;
    --text-secondary: #424a53;
    --text-muted: #59636e;

    --accent-text: #4f46e5;
    --accent-text-alt: #6d28d9;

    --border-color: #d1d9e0;
    --code-bg: rgba(27, 31, 36, 0.06);
    --logo-opacity: 0.85;

    --protein-n: #2563eb;
    --protein-c: #7c3aed;

    --apo-ring: #1d4ed8;
    --apo-ring-end: #be185d;
    --apo-core: #b45309;
}


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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.25;
}

a {
    color: var(--accent-text);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-text-alt);
}

:focus-visible {
    outline: 2px solid var(--accent-text);
    outline-offset: 3px;
    border-radius: 4px;
}

.icon {
    width: 1em;
    height: 1em;
    fill: currentColor;
    flex-shrink: 0;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -100px;
    z-index: 1100;
    padding: 0.6rem 1rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.skip-link:focus {
    top: 1rem;
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1.1rem 0;
    background: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
}

.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.nav-brand:hover {
    color: var(--text-primary);
}

.nav-links {
    display: flex;
    gap: 1.75rem;
    list-style: none;
    margin-left: auto;   /* keep links right-aligned now the toggle follows them */
}

.nav-links a {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 0.95rem;
}

.nav-links a:hover {
    color: var(--text-primary);
}

.nav-links a.active {
    color: var(--text-primary);
    border-bottom: 1px solid var(--text-muted);
    padding-bottom: 2px;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    margin-left: 1.25rem;
    background: none;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
}

.theme-toggle:hover {
    color: var(--text-primary);
}

/* one icon per theme */
.theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: block; }
    :root:not([data-theme="dark"]) .theme-toggle .icon-sun { display: none; }
}

:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }

/* Mobile menu button (hidden on desktop) */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
}

.nav-toggle-bar {
    display: block;
    width: 24px;
    height: 2px;
    margin: 0 auto;
    border-radius: 2px;
    background: var(--text-primary);
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Sections */
main {
    padding-top: 64px;
}

.section {
    max-width: 1000px;
    margin: 0 auto;
    padding: 4rem 2rem;
    scroll-margin-top: 80px;
}

.section-title {
    font-size: 1.5em;
    margin-bottom: 1.5rem;
}

.section-intro {
    color: var(--text-secondary);
    max-width: 680px;
    margin-bottom: 2.5rem;
}

.back-link {
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

/* Hero */
.hero {
    padding-top: 5rem;
    padding-bottom: 3rem;
}

.hero-content {
    display: flex;
    align-items: flex-start;
    gap: 3rem;
}

.hero-text {
    flex: 1 1 auto;
    max-width: 680px;
}

.hero-photo {
    flex: 0 0 auto;
    width: 240px;
    height: 240px;
    object-fit: cover;
}

.hero-title {
    font-size: 2em;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
}

.hero-subtitle {
    font-size: 1em;
    color: var(--text-muted);
    font-weight: 400;
    margin-bottom: 1.5rem;
}

.hero-bio {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 680px;
}

.hero-bio p {
    margin-bottom: 1rem;
}

.social-links {
    display: flex;
    gap: 1.25rem;
}

.social-icon {
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary);
    font-size: 1.25rem;
}

.social-icon:hover {
    color: var(--text-primary);
}

.social-cv {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

/* Apoptosome canvas. Only 404.html uses it now, and it sizes the canvas
   itself, so nothing is set here beyond the basics. */
.apoptosome-canvas {
    display: block;
}

/* Generated backbone figure */
.structure-section {
    padding-top: 0;
    padding-bottom: 2rem;
}

.structure-canvas {
    display: block;
    width: 100%;
    height: 400px;
    cursor: grab;
    touch-action: pan-y;   /* horizontal drags rotate, vertical still scrolls */
}

.structure-canvas:active {
    cursor: grabbing;
}

.structure-caption {
    max-width: 640px;
    margin: 0.75rem auto 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

@media (max-width: 640px) {
    .structure-canvas {
        height: 520px;
    }
}

/* Affiliation strip */
.affil-strip {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    gap: 2.5rem 1.5rem;
    list-style: none;
}

/* Slots size to their own content so each name can hold one line. The
   two-mark Chiu Lab slot widens on its own for the same reason. */
.affil {
    flex: 0 0 auto;
    min-width: 110px;
    max-width: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.affil-name {
    font-weight: 600;
    font-size: 0.9375em;
    color: var(--text-primary);
    line-height: 1.35;
    white-space: nowrap;
}

.affil-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    margin-bottom: 1rem;
}

.affil-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    height: 64px;
    /* capped explicitly: the slot is content-sized, so a percentage
       max-width on the image would have nothing to resolve against */
    max-width: 168px;
    margin-top: auto;
    opacity: var(--logo-opacity);
    transition: opacity var(--transition-fast);
}

.affil-logo:hover {
    opacity: 1;
}

.affil-logo img {
    max-height: 100%;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Per-theme logo variants. Done in CSS, not JS, so a reader with scripts off
   and a light system preference still gets marks they can see. */
.logo-light { display: none; }

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .logo-light { display: block; }
    :root:not([data-theme="dark"]) .logo-dark { display: none; }
}

:root[data-theme="light"] .logo-light { display: block; }
:root[data-theme="light"] .logo-dark { display: none; }

/* Two marks sharing one slot (UPMC Hillman and Pitt) */
.affil-logo-pair {
    max-width: 200px;
}

.affil-logo-pair img {
    max-height: 44px;
}

/* Research and teaching entries */
.role {
    max-width: 720px;
    padding-bottom: 2rem;
}

.role:last-child {
    padding-bottom: 0;
}

.role-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.35rem 1.5rem;
    margin-bottom: 0.6rem;
}

.role-where {
    font-size: 1em;
    font-weight: 600;
}

.role-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.role-body {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.role-body:last-child {
    margin-bottom: 0;
}

/* Publications */
.pub-list {
    list-style: none;
    max-width: 760px;
}

.pub-item {
    padding-bottom: 1.5rem;
}

.pub-item:last-child {
    padding-bottom: 0;
}

.pub-title {
    font-size: 1em;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.3rem;
}

.pub-authors {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.pub-authors strong {
    color: var(--text-primary);
    font-weight: 600;
}

.pub-count {
    color: var(--text-muted);
    white-space: nowrap;
}

.pub-count::before {
    content: "\00b7\00a0";
}

.pub-venue {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.pub-note {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.6rem;
}

.pub-item .project-links {
    margin-top: 0.9rem;
    padding-top: 0;
    border-top: none;
}

/* News */
.news-list {
    list-style: none;
    max-width: 760px;
}

.news-item {
    display: flex;
    gap: 1.75rem;
    padding-bottom: 1.5rem;
}

.news-item:last-child {
    padding-bottom: 0;
}

.news-date {
    flex: 0 0 5.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding-top: 0.12rem;
}

.news-body {
    color: var(--text-secondary);
}

/* Project cards (Other page) */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: var(--bg-card);
    border-radius: 6px;
    padding: 1.75rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.project-header {
    margin-bottom: 1rem;
}

.project-header h3 {
    font-size: 1.25em;
    margin-bottom: 0.35rem;
}

.project-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.project-summary {
    color: var(--text-secondary);
    font-size: 0.95rem;
    flex-grow: 1;
}

.project-summary code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85em;
    padding: 0.1em 0.35em;
    border-radius: 3px;
    background: var(--code-bg);
    color: var(--text-primary);
}

.project-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.project-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.9rem;
}

/* Footer */
.footer {
    border-top: 1px solid var(--border-color);
    padding: 2.5rem 2rem;
    text-align: center;
}

.footer-social {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.footer-social a {
    display: inline-flex;
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.footer-social a:hover {
    color: var(--text-primary);
}

.footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
        /* nav-links is absolutely positioned here, so the hamburger needs to
           claim the free space itself to sit beside the theme toggle */
        margin-left: auto;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 0;
        padding: 0.5rem 0;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
    }

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

    .nav-links li {
        list-style: none;
    }

    .nav-links a {
        display: block;
        padding: 0.9rem 2rem;
        font-size: 1rem;
    }

    .nav-links a.active {
        border-bottom: none;
    }

    .hero-content {
        flex-direction: column;
        gap: 2rem;
    }

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

    .news-date {
        flex: none;
    }

    .hero-photo {
        width: 180px;
        height: 180px;
    }

    .affil-name {
        white-space: normal;
    }

    .section {
        padding: 3rem 1.5rem;
    }

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

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

    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* 404 page. The molecule is decoration here, oversized and bleeding off the
   corner, so it carries no caption and is hidden from assistive tech. */
.nf-main {
    position: relative;
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: center;
}

.nf-art {
    /* Fixed rather than absolute so the crop is the viewport edge itself. Any
       clipping ancestor puts a straight cut through the spokes instead. */
    position: fixed;
    /* Oversized and pushed past the corner so the viewport does the cropping.
       The molecule stays inside its canvas (data-fill under 0.5), otherwise the
       canvas edge shows up as a straight cut through the spokes. */
    right: -42vmin;
    bottom: -40vmin;
    width: 105vmin;
    height: 105vmin;
    pointer-events: none;
    opacity: 0.5;
}

/* Lowering opacity on white blends toward white, which desaturates; on black
   it blends toward black and keeps its identity. So light mode needs a higher
   opacity and deeper base hues, not a lower one. */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .nf-art { opacity: 0.58; }
}

:root[data-theme="light"] .nf-art { opacity: 0.58; }

.nf-art .apoptosome-canvas {
    width: 100%;
    height: 100%;
    cursor: default;
}

.nf-copy {
    position: relative;
    max-width: 620px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

.nf-code {
    font-size: 0.9rem;
    letter-spacing: 0.18em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.nf-title {
    font-size: 1.75em;
    font-weight: 600;
    margin-bottom: 1rem;
}

.nf-body {
    color: var(--text-secondary);
    max-width: 46ch;
}

.nf-back {
    margin-top: 1.75rem;
}

@media (max-width: 640px) {
    /* The copy runs full width here and the molecule sits below it, so there is
       nothing to clear. Opacity is deliberately not touched: the theme rules
       below carry more specificity and would win anyway, which made the old
       override apply in dark mode only. */
    .nf-art {
        right: -34vmin;
        bottom: -30vmin;
    }
}
