:root {
    --bg: hsl(220, 30%, 8%);
    --surface: hsla(220, 30%, 15%, 0.7);
    --accent: hsl(180, 70%, 50%);
    --accent-muted: hsla(180, 70%, 50%, 0.2);
    --text: hsl(210, 20%, 95%);
    --text-muted: hsl(210, 10%, 70%);
    --border: hsla(210, 20%, 95%, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --header-height: 80px;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--accent);
    margin-top: 0.5rem;
    transition: var(--transition);
}

details summary:hover {
    opacity: 0.8;
}

details summary::before {
    content: '→';
    transition: transform 0.3s ease;
}

details[open] summary::before {
    transform: rotate(90deg);
}

.timeline-content {
    padding: 1rem 0;
}

.timeline-content ul {
    padding-left: 1.5rem;
    margin-top: 0.5rem;
}

.timeline-content li {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) var(--bg);
}

body::-webkit-scrollbar {
    width: 6px;
}

body::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

/* Base Styles */
h1,
h2,
h3,
h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

section {
    padding: 100px 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#publications {
    padding-top: 50px;
}

/* Glassmorphism */
.glass {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 16px;
}

/* Navigation */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    height: var(--header-height);
    display: flex;
    align-items: center;
    z-index: 1000;
    transition: var(--transition);
}

nav.scrolled {
    background: hsla(220, 30%, 8%, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent);
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    z-index: 1001;
}

.menu-toggle span {
    width: 25px;
    height: 2px;
    background: var(--text);
    transition: var(--transition);
}

.nav-links a:hover {
    color: var(--accent);
}

/* Hero Section */
#home .hero-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

.hero-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: var(--accent-muted);
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    animation: morph 8s ease-in-out infinite;
    overflow: hidden;
    border: 2px solid var(--accent);
}

.hero-content h1 {
    font-size: 4rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.hero-content p {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    max-width: 600px;
}

.expertise-highlights {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    margin-bottom: 5rem;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    flex-wrap: nowrap;
}

.expertise-highlights span:not(:last-child) {
    display: flex;
    align-items: center;
}

.expertise-highlights span:not(:last-child)::after {
    content: '|';
    margin-left: 1.25rem;
    color: var(--accent);
    font-weight: 400;
    opacity: 0.6;
}

.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    animation: bounce 2s infinite;
}

.scroll-indicator::after {
    content: '';
    width: 2px;
    height: 40px;
    background: linear-gradient(to bottom, var(--accent), transparent);
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0) translateX(-50%);
    }

    40% {
        transform: translateY(-10px) translateX(-50%);
    }

    60% {
        transform: translateY(-5px) translateX(-50%);
    }
}

.pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.pill {
    padding: 0.5rem 1.25rem;
    background: var(--accent-muted);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 99px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: var(--transition);
}

.pill:hover {
    background: var(--accent);
    color: var(--bg);
    transform: translateY(-2px);
}

.btn-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg);
}

.btn-secondary {
    border: 1px solid var(--accent);
    color: var(--accent);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* Research Section */
.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 3rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.tab-btn {
    padding: 1rem 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.tab-btn.active {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.research-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
}

.research-card {
    padding: 2.5rem;
    transition: var(--transition);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.research-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--accent);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    background: hsla(180, 70%, 50%, 0.05);
}

.research-card img {
    width: 100%;
    height: 220px;
    object-fit: contain;
    background: #fff;
    /* Ensures schematics and diagrams are always on a clean white backdrop */
    padding: 1.5rem;
    /* Specific request to "pad the images" */
    border-radius: 8px;
    margin-bottom: 1.5rem;
    transition: transform 0.5s ease;
}

.research-card h3 {
    margin-bottom: 0.8rem;
    font-size: 1.3rem;
    min-height: 3.5rem;
    /* Aligns descriptions even if titles wrap to 2 lines */
    display: flex;
    align-items: center;
    line-height: 1.3;
}

.research-card p {
    line-height: 1.6;
    color: var(--text-muted);
}

.research-card:hover img {
    transform: scale(1.05);
}

.skills-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.skill-tile {
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    transition: var(--transition);
    cursor: default;
}

.skill-tile:hover {
    background: var(--accent-muted);
    border-color: var(--accent);
    transform: translateY(-3px);
    color: var(--accent);
}

.timeline-track {
    position: relative;
    padding-left: 2rem;
    border-left: 2px solid var(--accent);
    margin-left: 1rem;
}

/* Animations */
@keyframes morph {
    0% {
        border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    }

    50% {
        border-radius: 70% 30% 30% 70% / 70% 70% 30% 30%;
    }

    100% {
        border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    }
}

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease-out;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 968px) {
    #home .hero-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    /* Centering Headings and Text */
    h1,
    h2,
    h3,
    .hero-content p {
        text-align: center;
        overflow-wrap: break-word;
    }

    .container {
        padding: 0 1.5rem;
    }

    .hero-image {
        max-width: 300px;
        margin: 5rem auto 0 auto;
    }

    .hero-content h1 {
        font-size: 3rem;
    }

    /* Centering Pills and Buttons */
    .pills,
    .btn-group {
        justify-content: center;
    }

    /* Skills Matrix Compression */
    .skills-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        justify-content: center;
        width: 100%;
    }

    .skill-tile {
        padding: 0.5rem;
        font-size: 0.75rem;
        text-align: center;
        width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .expertise-highlights {
        justify-content: center;
        text-align: center;
        gap: 0.8rem;
        font-size: 0.75rem;
        flex-wrap: wrap;
        line-height: 1.8;
    }

    .expertise-highlights span:not(:last-child)::after {
        display: none;
        /* Remove pipes to allow clean wrapping on small screens */
    }

    /* Timeline Centering */
    .timeline-track {
        padding-left: 0;
        border-left: none;
        margin-left: 0;
        width: 100%;
    }

    .timeline-item {
        text-align: center;
    }

    .timeline-item ul {
        text-align: left;
        display: inline-block;
        padding-left: 1.5rem;
    }

    .menu-toggle {
        display: flex;
    }

    .nav-links {
        display: flex;
        position: fixed;
        top: 80px;
        right: -100%;
        width: auto;
        min-width: 250px;
        height: auto;
        background: var(--surface);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        padding: 1.5rem;
        transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border: 1px solid var(--border);
        border-radius: 12px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
        z-index: 1000;
    }

    .nav-links.active {
        right: 1.5rem;
    }

    .nav-links a {
        font-size: 1.1rem;
        margin-bottom: 1rem;
        width: 100%;
        text-align: left;
    }

    .nav-links a:last-child {
        margin-bottom: 0;
    }

    .scroll-indicator {
        display: none;
    }

    .research-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.5rem;
    }

    .research-card {
        padding: 1.5rem;
    }
}

/* Fix for long contact email and headings on mobile */
@media (max-width: 600px) {
    .research-grid {
        grid-template-columns: 1fr;
    }

    .contact-email {
        font-size: 1rem !important;
        word-break: break-all;
        line-height: 1.4;
    }

    h1 {
        font-size: 2.2rem !important;
    }

    .publication-item {
        margin-bottom: 0.8rem !important;
        border-left: none !important;
        padding-left: 0 !important;
        text-align: center;
    }

    .publication-item h3 {
        font-size: 0.95rem !important;
        font-weight: 400 !important;
        line-height: 1.4;
    }

    .publication-item p {
        display: none !important;
    }

    /* Publication & Outcome Link Truncation */
    .publication-item h3 a,
    .outcomes ul li a {
        display: inline-block;
        max-width: 15ch;
        /* Approx 5-10 chars + highlighting */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        vertical-align: bottom;
        background: var(--accent-muted);
        /* Highlight */
        color: var(--accent);
        padding: 0 0.3rem;
        border-radius: 4px;
        text-decoration: none;
    }

    /* Ensure list items don't look weird with truncated blocks */
    .outcomes ul li,
    .publication-item h3 {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}