/* ==========================================================================
   Computational Neuroanatomy Lab — Design system
   Tokens (light/dark) + layout + components. Light is default;
   dark applies via [data-theme="dark"] on <html> (set by theme.js).
   ========================================================================== */

:root,
[data-theme="light"] {
    --bg: #ffffff;
    --bg-alt: #f4f6f7;
    --text: #232a2e;
    --text-muted: #5b656c;
    --nav-bg: rgba(255, 255, 255, 0.85);
    --nav-border: #e3e8e9;
    --nav-text: #232a2e;
    --footer-bg: #1a2122;
    --footer-text: #c9d2d3;
    --card-bg: #ffffff;
    --card-border: #e3e8e9;
    --accent: #2c7a7b;
    --accent-hover: #225e5f;
    --accent-soft: rgba(44, 122, 123, 0.10);
    --hero-overlay: linear-gradient(180deg, rgba(20, 30, 31, 0.55), rgba(20, 30, 31, 0.75));
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.10);
    --font-sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
}

[data-theme="dark"] {
    --bg: #13181a;
    --bg-alt: #171e20;
    --text: #d8dee0;
    --text-muted: #97a2a4;
    --nav-bg: rgba(20, 26, 28, 0.85);
    --nav-border: #283133;
    --nav-text: #d8dee0;
    --footer-bg: #0d1112;
    --footer-text: #aab4b6;
    --card-bg: #1b2224;
    --card-border: #2b3537;
    --accent: #4fd1c5;
    --accent-hover: #76e4d9;
    --accent-soft: rgba(79, 209, 197, 0.12);
    --hero-overlay: linear-gradient(180deg, rgba(8, 12, 13, 0.55), rgba(8, 12, 13, 0.82));
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.30);
    --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg: #13181a; --bg-alt: #171e20; --text: #d8dee0; --text-muted: #97a2a4;
        --nav-bg: rgba(20, 26, 28, 0.85); --nav-border: #283133; --nav-text: #d8dee0;
        --footer-bg: #0d1112; --footer-text: #aab4b6; --card-bg: #1b2224;
        --card-border: #2b3537; --accent: #4fd1c5; --accent-hover: #76e4d9;
        --accent-soft: rgba(79, 209, 197, 0.12);
        --hero-overlay: linear-gradient(180deg, rgba(8,12,13,0.55), rgba(8,12,13,0.82));
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.30); --shadow-md: 0 14px 36px rgba(0,0,0,0.45);
    }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 17px;
    line-height: 1.65;
    background-color: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.content { flex: 1; }

h1, h2, h3 {
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text);
}

p { margin: 0 0 1rem; }

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

img { max-width: 100%; }

/* ---------- Navbar ---------- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.6rem;
    padding: 0.6rem 1.5rem;
    background: var(--nav-bg);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--nav-border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    cursor: pointer;
    color: var(--nav-text);
    flex-shrink: 0;
    margin-right: auto;
}

.brand-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    background: #ffffff;
    border-radius: 9px;
    padding: 4px;
    box-sizing: border-box;
}

.brand-name {
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: -0.01em;
    line-height: 1.15;
    max-width: 16ch;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.nav-links a {
    color: var(--nav-text);
    font-size: 0.86rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-links a:hover { background: var(--accent-soft); color: var(--accent); }

.nav-links a.active { color: var(--accent); background: var(--accent-soft); }

/* Theme toggle + hamburger */
.theme-toggle,
.nav-toggle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--nav-border);
    background: var(--card-bg);
    color: var(--text);
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover,
.nav-toggle:hover { transform: scale(1.08); }

.theme-toggle:focus-visible,
.nav-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.nav-toggle { display: none; }

/* ---------- Hero ---------- */
.hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: clamp(360px, 58vh, 540px);
    padding: 3rem 1.5rem;
    background-image: var(--hero-overlay), url('images/header.jpg');
    background-size: cover;
    background-position: center;
    color: #fff;
}

.hero-content { max-width: 760px; }

.hero h1 {
    color: #fff;
    font-size: clamp(2rem, 5vw, 3.4rem);
    font-weight: 800;
    margin: 0 0 0.6rem;
}

.hero-tagline {
    font-size: clamp(1rem, 2.2vw, 1.35rem);
    color: rgba(255, 255, 255, 0.92);
    font-weight: 400;
    margin: 0 0 1.6rem;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.7rem 1.5rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease;
}

.btn:hover { background: var(--accent-hover); color: #fff; transform: translateY(-2px); }

/* ---------- Sections / layout ---------- */
.section { display: none; }
.section.active { display: block; }

/* Constrained content sections */
#team, #publications, #research, #resources, #contact {
    max-width: 1080px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.home-inner {
    max-width: 880px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

/* Section heading with accent rule */
.section > h2,
.research-content h2,
.resource-content h2,
#publications-content h2 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    margin: 0 0 1.4rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--accent);
    display: inline-block;
}

.research-content h2:not(:first-child),
.resource-content h2:not(:first-child) { margin-top: 2.4rem; }

.home-inner .lead { font-size: 1.08rem; color: var(--text); }
.home-inner h3 { margin-top: 2rem; }
.home-aka img { max-width: 240px; height: auto; margin-top: 0.5rem; }

/* ---------- Team ---------- */
.team-member {
    display: flex;
    align-items: center;
    gap: 1.75rem;
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem 1.75rem;
    margin: 0 0 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.team-member:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.team-photo {
    width: 120px !important;
    height: auto;
    border-radius: 12px;
    flex-shrink: 0;
    margin: 0 !important;
    object-fit: cover;
}

.team-photo.circular {
    width: 120px !important;
    height: 120px !important;
    border-radius: 50%;
    object-fit: cover;
}

.team-member h3 { margin: 0; font-size: 1.2rem; }

/* Role line = first paragraph right after the name */
.team-member h3 + p {
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.78rem;
    margin: 0.25rem 0 0.6rem;
}

.team-member p { margin-bottom: 0; }
.team-member p[style] { margin-top: 0.6rem !important; }

/* ---------- Research project cards ---------- */
.research-gallery {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-top: 0.5rem;
}

.project {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.75rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem 1.75rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.project:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.project-text { flex: 1; min-width: 0; }
.project-text p { margin: 0; font-size: 0.98rem; color: var(--text); text-align: left; }

.project-image {
    flex: 0 0 38%;
    max-width: 38%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Show the whole figure — never crop or over-zoom */
.project-image img {
    width: 100%;
    max-height: 280px;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
}

@media (max-width: 760px) {
    .project { flex-direction: column; align-items: stretch; }
    .project-image { flex-basis: auto; max-width: 100%; }
    .project-image img { max-height: 320px; }
}

/* ---------- Publications ---------- */
#publications-content ul { list-style: none; padding: 0; margin: 0; }

#publications-content li {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
    margin-bottom: 0.85rem;
    font-size: 0.96rem;
}

.google-scholar-link { margin-top: 1.5rem; }
.google-scholar-link img { width: 180px !important; height: auto; }

/* ---------- Resources ---------- */
.resource-content ul { padding-left: 1.2rem; }
.resource-content li { margin-bottom: 0.5rem; }

/* ---------- Contact ---------- */
.contact-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.75rem 2rem;
    box-shadow: var(--shadow-sm);
    line-height: 1.9;
}

/* ---------- Footer ---------- */
footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    text-align: center;
    padding: 1.5rem 1rem;
}

footer p { margin: 0; font-size: 0.9rem; }

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

    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0.15rem;
        padding: 0.5rem;
        background: var(--nav-bg);
        backdrop-filter: saturate(180%) blur(12px);
        -webkit-backdrop-filter: saturate(180%) blur(12px);
        border-bottom: 1px solid var(--nav-border);
        box-shadow: var(--shadow-md);
        display: none;
    }

    .navbar.open .nav-links {
        display: flex;
        animation: menuDown 0.22s ease both;
    }

    .nav-links a { padding: 0.9rem 1rem; border-radius: 10px; font-size: 0.95rem; }
}

@keyframes menuDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: none; }
}

@media (max-width: 600px) {
    body { font-size: 16px; }

    .team-member {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        padding: 1.5rem 1.25rem;
    }

    .team-member h3 + p { margin-left: auto; margin-right: auto; }

    .brand-name { font-size: 0.82rem; line-height: 1.15; max-width: 13ch; }
}

/* ==========================================================================
   Enhancements — editorial type, motion, refined components
   ========================================================================== */

/* Display serif (Fraunces) for headings, paired with Inter body */
.hero h1,
.section > h2,
.research-content h2,
.resource-content h2,
#publications-content h2 {
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ---------- Hero polish ---------- */
.hero { overflow: hidden; isolation: isolate; }

/* soft teal glow behind the title */
.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background: radial-gradient(58% 58% at 50% 32%, rgba(79, 209, 197, 0.20), transparent 70%);
    pointer-events: none;
}

/* blend the bottom edge into the page */
.hero::before {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 120px;
    z-index: 1;
    background: linear-gradient(to bottom, transparent, var(--bg));
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 2;
}

.hero-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    margin: 0 0 1rem;
}

.btn-row { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }

.btn-ghost {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.55);
    color: #fff;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

.hero-scroll {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 2;
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.hero-scroll:hover { background: rgba(255, 255, 255, 0.2); }

/* ---------- One gentle, in-place fade when a section opens ---------- */
.section.active { animation: sectionFade 0.7s ease-out both; }

@keyframes sectionFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---------- Research: alternating, framed ---------- */
.project { position: relative; }
.project:nth-child(even) { flex-direction: row-reverse; }

.project-image {
    background: var(--bg-alt);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.85rem;
}

/* ---------- Publications hover ---------- */
#publications-content li {
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-left-width 0.18s ease;
}
#publications-content li:hover {
    transform: translateX(4px);
    border-left-width: 6px;
    box-shadow: var(--shadow-sm);
}

/* ---------- Footer ---------- */
footer { position: relative; padding: 2.5rem 1.5rem; }
footer::before {
    content: "";
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.footer-inner { max-width: 1080px; margin: 0 auto; }
.footer-name {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
    margin: 0 0 0.3rem;
}
.footer-meta { font-size: 0.85rem; color: var(--footer-text); margin: 0 0 0.5rem; }
.footer-copy { font-size: 0.8rem; color: var(--footer-text); opacity: 0.7; margin: 0; }

@media (max-width: 760px) {
    /* keep alternating projects stacked on phones */
    .project:nth-child(even) { flex-direction: column; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .section.active { animation: none !important; }
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Accessibility — skip link, visible focus, semantic heading
   ========================================================================== */

/* Keyboard users can jump straight to the main content */
.skip-link {
    position: absolute;
    left: 0.75rem;
    top: 0.6rem;
    z-index: 200;
    transform: translateY(-160%);
    background: var(--accent);
    color: #fff;
    padding: 0.55rem 0.95rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: transform 0.18s ease;
}
.skip-link:focus {
    transform: translateY(0);
    color: #fff;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Visible keyboard focus on every interactive element (links are now real <a>) */
.nav-links a:focus-visible,
.brand:focus-visible,
.btn:focus-visible,
.hero-scroll:focus-visible,
.home-inner a:focus-visible,
#publications-content a:focus-visible,
.resource-content a:focus-visible,
.contact-card a:focus-visible,
.google-scholar-link a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 6px;
}

/* The skip-link target is focused programmatically — no ring needed there */
.content:focus { outline: none; }

/* SVG icons inherit button text colour and centre cleanly */
.theme-toggle svg,
.nav-toggle svg,
.hero-scroll svg { display: block; }

/* "Funding" heading: keeps the editorial look while restoring h1 -> h2 order */
.home-inner h2 {
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-weight: 600;
    letter-spacing: -0.01em;
    font-size: clamp(1.3rem, 2.4vw, 1.6rem);
    margin-top: 2rem;
    padding-bottom: 0.4rem;
    border-bottom: 3px solid var(--accent);
    display: inline-block;
}

/* ==========================================================================
   Team — grouped researcher / intern grid
   Members with bios stay as featured rows (.team-member); everyone else is
   pulled into one compact, modular grid (Swiss grid + Bento card patterns).
   ========================================================================== */
.team-grid-label {
    margin: 2.5rem 0 0;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.member-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: var(--text);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.75rem 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.member-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.member-photo {
    width: 104px;
    height: 104px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 0.9rem;
    background: var(--bg-alt);
    border: 3px solid var(--accent-soft);
}

.member-name {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--text);
}

.member-role {
    margin: 0.35rem 0 0;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.72rem;
}

.member-note {
    margin: 0.55rem 0 0;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--text-muted);
}

/* Open-position / hiring card */
.member-card--cta { border-style: dashed; border-color: var(--accent); background: var(--accent-soft); }
.member-card--cta:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.member-photo--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    border: 3px dashed var(--accent);
    background: transparent;
}
.member-cta { margin-top: 0.7rem; font-size: 0.8rem; font-weight: 600; color: var(--accent); }
.member-card--cta:hover .member-cta { color: var(--accent-hover); }

@media (max-width: 600px) {
    .team-grid { grid-template-columns: repeat(2, 1fr); gap: 0.85rem; }
    .member-card { padding: 1.4rem 0.85rem; }
    .member-photo { width: 88px; height: 88px; }
    .member-name { font-size: 0.92rem; }
}
