:root {
    /* Ink blue + moss palette */
    --bg-color: #F4F6F1;
    --sidebar-bg: #FFFFFF;
    --card-bg: #FFFFFF;
    --text-primary: #1A2227;
    --text-secondary: #566069;
    --accent-color: #0A7B9A; /* Vivid peacock teal */
    --accent-hover: #2D9E5C; /* Emerald */
    --accent-tint: rgba(10, 123, 154, 0.10);
    --border-color: #DDE3D6;
    --card-shadow: 0 2px 14px rgba(20, 35, 45, 0.05);
    --transition-speed: 0.3s;
    --toggle-bg: #E8EEE3;

    /* Typography */
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Inter', sans-serif;
}

[data-theme="dark"] {
    --bg-color: #0F1418;
    --sidebar-bg: #1A2226;
    --card-bg: #1F282D;
    --text-primary: #E8EDE7;
    --text-secondary: #9AA8A2;
    --accent-color: #5BC9E8; /* Bright sky */
    --accent-hover: #7DD79A; /* Bright mint */
    --accent-tint: rgba(91, 201, 232, 0.14);
    --border-color: #2D3940;
    --card-shadow: 0 4px 20px rgba(0,0,0,0.35);
    --toggle-bg: #2D3940;
}

/* --- Magical Background Depth --- */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 20%, rgba(14, 92, 122, 0.05), transparent 60%),
                radial-gradient(circle at 70% 80%, rgba(63, 133, 56, 0.04), transparent 60%);
    z-index: -1;
    animation: breathe 20s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes breathe {
    0% { transform: scale(1); }
    100% { transform: scale(1.1); }
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
    font-feature-settings: "cv11", "ss01", "ss03", "cv02";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Dark Mode Toggle --- */
.theme-toggle {
    background: var(--toggle-bg);
    border: none;
    color: var(--text-primary);
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px auto;
    transition: transform 0.3s, background 0.3s;
    width: 40px;
    height: 40px;
}

.theme-toggle:hover {
    background: var(--accent-tint);
    color: var(--accent-color);
}

/* --- Sidebar Navigation --- */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    padding: 40px 30px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 100;
    transition: background 0.3s, border-color 0.3s;
}

.profile-header {
    text-align: center;
    margin-bottom: 40px;
}

.profile-img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 20px;
    box-shadow: var(--card-shadow), 0 0 0 2px var(--accent-color);
    border: 4px solid var(--sidebar-bg);
}

.profile-name {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.profile-role {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

nav ul {
    list-style: none;
}

nav li {
    margin-bottom: 15px;
}

nav a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 1.05rem;
    display: block;
    padding: 10px 15px;
    border-radius: 8px;
    transition: var(--transition-speed);
}

nav a {
    border-left: 2px solid transparent;
}

nav a:hover, nav a.active {
    color: var(--accent-color);
    background: var(--accent-tint);
    border-left-color: var(--accent-color);
}


.sidebar-bottom {
    margin-top: auto;
    text-align: center;
}

.copyright {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 15px;
    opacity: 0.8;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.social-icon {
    color: var(--text-secondary);
    transition: var(--transition-speed);
}

.social-icon:hover {
    color: var(--accent-color);
    transform: translateY(-3px);
}

/* --- Main Content Area --- */
.main-content {
    flex: 1;
    margin-left: 280px; /* Match sidebar width */
    padding: 60px 80px;
    max-width: 1200px; /* Prevent stretching on huge screens */
}

/* --- Section Switching --- */
section {
    display: none;
    opacity: 0;
    animation: fadeIn 0.4s ease-in-out forwards;
    padding-bottom: 50px;
}

section.active-section {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

h1, h2, h3 {
    font-family: var(--font-heading);
    color: var(--text-primary);
}

h2 {
    font-size: 2.2rem;
    margin-bottom: 40px;
    position: relative;
    display: inline-block;
}

h2::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 0;
    width: 72px;
    height: 3px;
    background: var(--accent-color);
    border-radius: 2px;
}

h2 {
    letter-spacing: -0.01em;
}

p {
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 1.05rem;
}

.main-content p em, .pub-list em, .teaching-card em {
    color: var(--text-primary);
    font-style: italic;
}

/* --- Links: visible accent at rest, hover deepens --- */
.main-content p a, .teaching-card li a, .pub-list a {
    color: var(--accent-color);
    text-decoration: none;
    background-image: linear-gradient(var(--accent-color), var(--accent-color));
    background-size: 100% 1px;
    background-repeat: no-repeat;
    background-position: left 95%;
    transition: background-size 0.3s ease, color 0.2s ease;
    padding-bottom: 1px;
    font-weight: 500;
}

.main-content p a:hover, .teaching-card li a:hover, .pub-list a:hover {
    background-size: 100% 2px;
    color: var(--accent-hover);
}

/* Regular links elsewhere (like "Link" buttons) */
a {
    color: var(--accent-color);
    text-decoration: none;
    transition: var(--transition-speed);
}

/* --- Projects Section Headers --- */
#projects h3 {
    font-size: 1.5rem;
    font-family: var(--font-heading);
    color: var(--text-primary);
    margin-top: 50px;
    margin-bottom: 25px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
}

#projects h3:first-of-type {
    margin-top: 10px; /* Less space for the first one */
}

/* --- Projects Grid --- */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
}

.project-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: all 0.4s ease;
    cursor: pointer;
    position: relative;
    border: 1px solid transparent;
    padding: 15px; /* Restored padding logic */
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 28px rgba(20, 35, 45, 0.10);
    border-color: var(--accent-color);
}

.project-img-wrapper {
    height: 250px; /* Restored height */
    overflow: hidden;
    background: #ffffff; /* Keep white for logos */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.project-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.5s ease;
}

.project-card:hover img {
    transform: scale(1.05);
}

.project-info {
    padding: 15px; /* Consistent padding all around */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70px; /* Ensure 2-line titles fit comfortably */
}

.project-title {
    font-size: 1.2rem;
    margin-bottom: 0; /* No bottom margin needed if no desc */
    font-weight: 700;
    text-align: center; /* Center the title */
}

.project-desc {
    display: none; /* Hide descriptions in the grid */
}

/* --- Tools Grid --- */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.tool-card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease, border-color 0.3s ease;
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    text-decoration: none; /* Remove underline from the whole card */
    color: inherit; /* Inherit text color */
}

.tool-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-color);
}

/* .tool-card h3 is now handled by .project-title class for consistency */
.tool-card .project-title {
    padding-bottom: 10px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.tool-card:hover .project-title {
    border-color: var(--accent-color); /* Highlight line on hover too */
    color: var(--accent-color);
}

.tool-card p {
    flex-grow: 1;
    margin-bottom: 0; /* No need for bottom margin now */
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* --- Publications (Accordion Style) --- */
.pub-category {
    background: var(--card-bg);
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    overflow: hidden;
}

.pub-header {
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: var(--card-bg);
    transition: background 0.2s;
}

.pub-header:hover {
    background: var(--accent-tint);
}

.pub-header:hover h3 {
    color: var(--accent-color);
}

.pub-header h3 {
    transition: color 0.2s;
}

.pub-header h3 {
    font-size: 1.2rem;
    margin: 0;
    font-family: var(--font-body);
}

.pub-icon {
    transition: transform 0.3s ease;
}

.pub-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
    background: var(--card-bg);
    border-top: 1px solid transparent;
}

.pub-content.open {
    border-top-color: var(--border-color);
}

.pub-list {
    padding: 25px;
    list-style: none;
}

.pub-list li {
    margin-bottom: 15px;
    padding-left: 20px;
    position: relative;
}

.pub-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.65em;
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 2px;
}

/* --- Teaching Section --- */
.teaching-card {
    background: var(--card-bg);
    padding: 32px 36px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 30px;
}

.teaching-card h3 {
    font-size: 1.3rem;
    font-family: var(--font-heading);
    margin-bottom: 22px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.teaching-card ul {
    list-style: none;
    padding: 0;
}

.teaching-card li {
    padding: 10px 0 10px 18px;
    position: relative;
    line-height: 1.55;
}

.teaching-card li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 1.05em;
    width: 6px;
    height: 6px;
    background: var(--accent-color);
    border-radius: 1px;
}

/* --- Mobile Responsiveness --- */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    background: var(--card-bg);
    border: none;
    padding: 10px;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    cursor: pointer;
    color: var(--text-primary);
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 260px;
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 40px 20px;
    }

    .mobile-menu-btn {
        display: block;
    }
    
    /* Overlay when sidebar is open */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 90;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s;
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

@media (max-width: 600px) {
    .lightbox-content {
        padding: 20px;
        width: 95%;
        max-height: 85vh; /* Leave room for bars */
    }
    
    .lightbox-img {
        height: auto;
        max-height: 180px; /* Much smaller on mobile */
        object-fit: contain;
        margin-bottom: 10px;
    }
    
    .lightbox h3 { /* Target the title */
        font-size: 1.2rem;
        margin-bottom: 10px;
    }
    
    .lightbox p { /* Target the desc */
        font-size: 0.9rem;
    }
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    backdrop-filter: blur(5px);
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    max-width: 800px;
    width: 100%;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.lightbox-img {
    width: 100%;
    height: 300px;
    object-fit: contain;
    background: #f9f9f9;
    border-radius: 8px;
    margin-bottom: 20px;
}

.lightbox-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2.5rem;
    cursor: pointer;
    color: #333; /* Dark for visibility on white */
    background: none;
    border: none;
    line-height: 1;
    padding: 0;
    z-index: 10;
}

/* Lightbox Navigation */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: white;
    font-size: 3rem;
    cursor: pointer;
    padding: 20px;
    z-index: 1002;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.lightbox-nav:hover {
    opacity: 1;
}

.lightbox-nav.prev { left: 10px; }
.lightbox-nav.next { right: 10px; }

@media (max-width: 600px) {
    .lightbox-nav {
        font-size: 2rem;
        padding: 10px;
    }
}

.btn-primary {
    display: inline-block;
    background: var(--accent-color);
    color: white;
    padding: 10px 25px;
    border-radius: 6px;
    margin-top: 15px;
    font-weight: 500;
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: white;
    text-decoration: none;
}


/* --- Print / CV Styles --- */
@media print {
    /* Hide navigation and interactive elements */
    .sidebar, 
    .mobile-menu-btn, 
    .sidebar-overlay, 
    .lightbox, 
    .social-links,
    .pub-icon { 
        display: none !important; 
    }

    /* Reset layout for full width */
    body { 
        display: block; 
        background: white; 
        color: black;
    }

    .main-content { 
        margin: 0 !important; 
        padding: 0 !important; 
        max-width: 100% !important; 
    }

    /* Show all sections */
    section { 
        display: block !important; 
        opacity: 1 !important; 
        margin-bottom: 40px !important; 
        page-break-inside: avoid;
        animation: none !important;
    }

    /* Expand accordions */
    .pub-content { 
        max-height: none !important; 
        border-top: 1px solid #ccc; 
        margin-top: 10px;
        padding-top: 10px;
    }

    /* Typography tweaks for print */
    h1 { font-size: 24pt; margin-bottom: 10px; }
    h2 { font-size: 18pt; border-bottom: 2px solid black; padding-bottom: 5px; margin-bottom: 20px; }
    h2::after { display: none; } /* Remove the colored underline */
    
    a { 
        text-decoration: none; 
        color: black !important; 
    }
    
    /* Add URL after links for reference */
    .teaching-card a::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    .project-card, .tool-card {
        border: 1px solid #ccc;
        box-shadow: none;
        page-break-inside: avoid;
    }
}