/* CSS Variables for easier color management */
:root {
    --primary-color: #2A3B4F;
    --secondary-color-red: #B85042;
    --accent-color: #D4A373;
    --text-color-dark: #333333;
    --text-color-light: #FDFDFF;
    --bg-content: rgba(255, 255, 255, 0.97);
    --bg-content-alt: rgba(249, 250, 252, 0.97);
    --border-color: #ced4da;
    --link-color: #006BA6;
    --link-hover-color: #004F7C;
    --highlight-bg-red: #FBEAE8;
    --shadow-color: rgba(42, 59, 79, 0.12);
    --nav-height-desktop: 70px;
    --nav-height-mobile: 60px;
}

/* Dark mode variables */
[data-theme="dark"] {
    --primary-color: #1f2937;
    --secondary-color-red: #FF7B72;
    --accent-color: #FFB86C;
    --text-color-dark: #E2E8F0;
    --text-color-light: #F8FAFC;
    --bg-content: rgba(30, 41, 59, 0.97);
    --bg-content-alt: rgba(44, 55, 74, 0.97);
    --border-color: #4B5563;
    --link-color: #60A5FA;
    --link-hover-color: #93C5FD;
    --highlight-bg-red: #3A2328;
    --shadow-color: rgba(0, 0, 0, 0.25);
}

/* General Styles */
body {
    font-family: 'Open Sans', sans-serif;
    line-height: 1.75;
    color: var(--text-color-dark);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: var(--nav-height-desktop);

    background-image: url('vancouver-3576062_1920.jpg');
    background-size: cover;
    background-position: center center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    transition: color 0.3s ease;
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px 12px;
    z-index: 10000;
    text-decoration: none;
    transition: top 0.3s;
}
.skip-link:focus {
    top: 10px;
}

/* Text resizing controls */
.text-resizer button {
    background: none;
    border: 2px solid var(--text-color-light);
    color: var(--text-color-light);
    margin-left: 5px;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.9em;
    cursor: pointer;
}
.text-resizer button:focus {
    outline: 2px dashed var(--accent-color);
}

/* Dark mode background overlay */
[data-theme="dark"] body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: -1;
}

main {
    flex-grow: 1;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 30px;
}
.page-content.container { /* For padding within each page's main section content */
    padding-top: 40px;
    padding-bottom: 75px;
}


/* --- Sticky Navigation Bar & Hamburger Menu --- */
.sticky-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--primary-color);
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    height: var(--nav-height-desktop);
    display: flex;
    align-items: center;
    padding: 0 15px;
    transition: background-color 0.3s ease;
}

.sticky-nav .nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1150px;
    margin: 0 auto;
}

.nav-logo {
    color: var(--text-color-light);
    text-decoration: none;
    font-size: 1.3em;
    font-weight: 600;
    font-family: 'Playfair Display', serif;
}

.nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
}

.nav-links li {
    margin: 0 15px;
}

.nav-links a {
    color: var(--text-color-light);
    text-decoration: none;
    font-size: 0.95em;
    font-weight: 400;
    padding: 8px 4px;
    position: relative;
    transition: color 0.3s ease;
}

.nav-links a:hover,
.nav-links a.active-link {
    color: var(--accent-color);
}

.nav-links a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent-color);
    transform: scaleX(0);
    transform-origin: bottom right;
    transition: transform 0.3s ease-out;
}

.nav-links a:hover::after,
.nav-links a.active-link::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

.hamburger-menu {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1005;
}

.hamburger-menu .bar {
    display: block;
    width: 28px;
    height: 3px;
    background-color: var(--text-color-light);
    margin: 6px 0;
    transition: all 0.3s ease-in-out;
    border-radius: 2px;
}

body.nav-open .hamburger-menu .bar:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}
body.nav-open .hamburger-menu .bar:nth-child(2) {
    opacity: 0;
}
body.nav-open .hamburger-menu .bar:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}


/* Header */
header {
    background-color: var(--bg-content-alt);
    color: var(--primary-color);
    padding: 60px 0 50px;
    text-align: center;
    margin-bottom: 0;
    box-shadow: 0 5px 15px var(--shadow-color);
    border-radius: 0 0 15px 15px;
    margin-left: auto;
    margin-right: auto;
    max-width: 1150px;
    position: relative;
}

header .container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.headshot {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    object-fit: cover;
    /* IMPORTANT: Adjust the second percentage (e.g., 30% to 70%) to correctly position your head */
    object-position: center 15%;
    border: 6px solid var(--accent-color);
    margin-bottom: 30px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    display: block;
    margin-left: auto;
    margin-right: auto;
}

header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 3.8em;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--primary-color);
}

header .subtitle {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: var(--text-color-dark);
    font-weight: 400;
}

header .tagline {
     font-size: 1.2em;
     font-style: italic;
     margin-top: 0;
     margin-bottom: 15px;
     color: #505050;
}

header .profile-link {
    margin-top: 15px;
    margin-bottom: 25px;
    font-size: 1.05em;
}

header .profile-link a {
    color: var(--secondary-color-red);
    background-color: transparent;
    font-weight: 600;
    text-decoration: none;
    padding: 10px 22px;
    border: 2px solid var(--secondary-color-red);
    border-radius: 25px;
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
    display: inline-block;
}

header .profile-link a:hover,
header .profile-link a:focus {
    background-color: var(--secondary-color-red);
    color: var(--text-color-light);
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(42, 59, 79, 0.2);
}
header .profile-link a:active {
    transform: translateY(0px);
    box-shadow: 0 2px 5px rgba(42, 59, 79, 0.15);
}

.header-contact {
    margin-top: 20px;
    font-size: 1.05em;
}
.header-contact p { margin: 6px 0; }
header .header-contact a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px dotted var(--link-color);
    transition: color 0.3s ease, border-bottom-color 0.3s ease;
}
header .header-contact a:hover {
    color: var(--link-hover-color);
    border-bottom-color: var(--link-hover-color);
}

/* --- Main Content Sections (Multi-Page) --- */
section {
    margin-top: 45px;
    margin-bottom: 45px;
    background-color: var(--bg-content);
    border-radius: 15px;
    box-shadow: 0 8px 25px var(--shadow-color);
}
.section-alt {
    background-color: var(--bg-content-alt);
}

/* Standard H2 styling for page titles within sections */
section h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2.9em;
    color: var(--primary-color);
    margin-bottom: 50px;
    text-align: center;
    position: relative;
    font-weight: 600;
}

section h2::after { /* Underline for H2 */
    content: '';
    display: block;
    width: 120px;
    height: 4px;
    background: var(--secondary-color-red);
    margin: 20px auto 0;
}

/* Standard H3 styling */
section h3 {
    font-family: 'Playfair Display', serif;
    font-size: 2em;
    color: var(--secondary-color-red);
    margin-top: 50px;
    margin-bottom: 28px;
    position: relative;
    padding-bottom: 12px;
    font-weight: 600;
    border-bottom: 1px solid #e5e5e5;
}
/* First h3 in a page's content (after the main H2) */
.page-content > h3:first-of-type,
.page-content > div > h3:first-of-type { /* Handle cases where H3 is inside a div like .research-area */
    margin-top: 0;
}


/* Text & Paragraphs */
p {
    margin-bottom: 1.7em;
    font-size: 1.1em;
    color: var(--text-color-dark);
}

/* Links in main content */
section a, .startup-info a, #contact-content a {
    color: var(--link-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}
section a:hover, .startup-info a:hover, #contact-content a:hover {
    color: var(--link-hover-color);
    text-decoration: underline;
}

/* Lists */
ul {
    list-style-type: none;
    padding-left: 0;
    margin-bottom: 1.7em;
}
li {
    margin-bottom: 1.3em;
    line-height: 1.7;
    padding-left: 28px;
    position: relative;
}
li::before {
    content: "›";
    color: var(--secondary-color-red);
    font-weight: bold;
    display: inline-block;
    position: absolute;
    left: 5px;
    top: 1px;
    font-size: 1.7em;
    line-height: 1;
}

/* Specific content element styles */
.dates { font-style: italic; color: #6c757d; font-size: 0.9em; margin-top: 4px; display: block; }
.course-description, .experience-description, .service-description, .supervision-note { display: block; font-size: 0.94em; color: #5a6268; margin-top: 7px; line-height: 1.6; padding-left: 12px; border-left: 3px solid var(--border-color); }
.publication-highlight { display: block; font-size: 0.98em; color: var(--text-color-dark); margin-top: 15px; margin-bottom: 20px; padding: 18px 22px; background-color: var(--highlight-bg-red); border-left: 5px solid var(--secondary-color-red); line-height: 1.65; border-radius: 0 8px 8px 0; }
cite { font-style: normal; font-weight: 600; color: var(--primary-color); }
.ranking { font-size: 0.88em; color: var(--secondary-color-red); margin-left: 8px; font-weight: 700; background-color: #fdf0ee; padding: 3px 7px; border-radius: 4px; border: 1px solid var(--secondary-color-red); }
.startup-info { background-color: rgba(255, 255, 255, 0.85); padding: 38px; border: 1px solid var(--border-color); border-radius: 12px; margin-top: 35px; box-shadow: 0 4px 12px rgba(0,0,0,0.07); }
.startup-info h3 { margin-top: 0; margin-bottom: 15px; border-bottom: none; padding-bottom: 0; color: var(--primary-color); }
.service-note { display: block; font-size: 0.92em; color: #6c757d; margin-top: 20px; font-style: italic; }

/* --- Styles for Publication Entry with Cover Image --- */
.publication-entry {
    display: flex;
    flex-wrap: wrap;
    gap: 25px; /* Increased gap */
    margin-bottom: 2.5em;
    padding-bottom: 2em; /* Increased padding */
    border-bottom: 1px solid var(--border-color);
}
.publication-entry:last-child {
    border-bottom: none;
    margin-bottom: 1.5em;
}

.publication-details {
    flex: 3;
    min-width: 300px;
}
.publication-details .paper-link { /* Style for the DOI/Link to paper */
    margin-right: 10px;
    /* Additional styling if needed to make it stand out more */
    /* color: var(--secondary-color-red); */ /* Example */
}

.publication-cover {
    flex: 1;
    min-width: 180px;
    max-width: 220px; /* Slightly reduced max-width for better balance */
    text-align: center;
    align-self: flex-start; /* Align cover to the top if details are much longer */
}
.publication-cover a {
    display: inline-block; /* Changed to inline-block for better centering if needed */
    border: none;
}
.publication-cover a:hover img {
    opacity: 0.8;
    box-shadow: 0 5px 15px rgba(0,0,0,0.25);
    transform: scale(1.03); /* Slight zoom effect */
}
.publication-cover img {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd; /* Slightly darker border for image */
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
    border-radius: 4px;
    transition: opacity 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}


/* Footer */
footer {
    text-align: center;
    padding: 50px 0;
    margin-top: 50px;
    font-size: 0.94em;
    color: var(--text-color-light);
    background-color: rgba(42, 59, 79, 0.95);
    box-shadow: 0 -5px 15px var(--shadow-color);
    border-radius: 15px 15px 0 0;
    margin-left: auto;
    margin-right: auto;
    max-width: 1150px;
}
footer p { color: var(--text-color-light); margin-bottom: 0.9em; }
footer a {
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: 1px dotted var(--accent-color);
    transition: color 0.3s ease, border-bottom-color 0.3s ease;
}
footer a:hover { color: var(--text-color-light); border-bottom-color: var(--text-color-light); }

/* --- Responsive Adjustments --- */
@media (max-width: 992px) {
    body { padding-top: var(--nav-height-mobile); }
    .sticky-nav { height: var(--nav-height-mobile); }
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: var(--nav-height-mobile);
        left: 0;
        width: 100%;
        background-color: var(--primary-color);
        padding: 15px 0;
        box-shadow: 0 3px 5px rgba(0,0,0,0.1);
        border-top: 1px solid rgba(255,255,255,0.1);
    }
    body.nav-open .nav-links { display: flex; }
    .nav-links li { margin: 0; width: 100%; text-align: center; }
    .nav-links a { display: block; padding: 15px 20px; font-size: 1.1em; border-bottom: 1px solid rgba(255,255,255,0.05); }
    .nav-links li:last-child a { border-bottom: none; }
    .nav-links a::after { display: none; }
    .hamburger-menu { display: block; }

    header, section, footer { border-radius: 0; margin-left: 0; margin-right: 0; max-width: 100%; }
    .container { padding: 0 20px; }
    .page-content.container { padding-top: 30px; padding-bottom: 50px; }

    section h2 { font-size: 2.5em; }
    section h2::after { width: 100px; }
}

@media (max-width: 768px) {
    .headshot { width: 150px; height: 150px; margin-bottom: 25px; border-width: 5px; }
    header { padding: 40px 0 30px; }
    header h1 { font-size: 3em; }
    header .subtitle { font-size: 1.3em; }
    header .profile-link a { padding: 8px 18px; font-size: 1em; }

    section h2 { font-size: 2.2em; }
    section h2::after { width: 90px; }
    section h3 { font-size: 1.8em; margin-top: 35px; }
    li { margin-bottom: 1.1em; padding-left: 25px; }
    li::before { font-size: 1.6em; left: 3px; top: 1px; }
    p { font-size: 1.05em; }
    footer { padding: 40px 0; }

    .publication-entry {
        flex-direction: column;
        align-items: center; /* Center items if they don't take full width */
    }
    .publication-details {
        flex-basis: 100%;
        order: 2; /* Text below image */
        text-align: center; /* Center text if layout looks odd */
    }
    .publication-details .publication-highlight {
        text-align: left; /* Keep abstract left-aligned */
    }
    .publication-cover {
        flex-basis: auto;
        max-width: 250px; /* Can be a bit wider when stacked */
        margin-bottom: 20px;
        order: 1; /* Image above text */
    }
}

@media (max-width: 480px) {
    .container { padding: 0 15px; }
    .headshot { width: 120px; height: 120px; border-width: 4px; }
    header h1 { font-size: 2.5em; }
    header .subtitle { font-size: 1.15em; }
    header .tagline { font-size: 1em; }
    header .profile-link a { padding: 7px 15px; font-size: 0.95em; }

    section h2 { font-size: 1.9em; }
    section h2::after { width: 70px; }
    section h3 { font-size: 1.6em; }
    .nav-logo { font-size: 1.1em; }
    .nav-links a { font-size: 1em; padding: 12px 15px;}

    .course-description, .experience-description, .service-description, .supervision-note { font-size: 0.92em; padding-left: 10px; }
    .publication-highlight { font-size: 0.94em; padding: 12px 15px; }
    li { padding-left: 22px; }
    li::before { font-size: 1.5em; left: 2px; top: 1px; }

    .publication-cover {
        max-width: 200px; /* Further reduce cover size on very small screens */
    }
}

/* Dark Mode Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    margin-left: 20px;
    cursor: pointer;
    position: relative;
    z-index: 1001;
}

.toggle-track {
    width: 50px;
    height: 24px;
    background-color: #4B5563;
    border-radius: 30px;
    position: relative;
    transition: 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

[data-theme="dark"] .toggle-track {
    background-color: #60A5FA;
}

.toggle-thumb {
    position: absolute;
    left: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: white;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .toggle-thumb {
    left: calc(100% - 21px);
}

.toggle-icon {
    font-size: 10px;
    color: #FFB86C;
}

[data-theme="dark"] .toggle-icon {
    color: #4B5563;
}

/* Dark mode specific style overrides */
[data-theme="dark"] section h2 {
    color: #F8FAFC;
}

[data-theme="dark"] section h3 {
    color: #FF7B72;
    border-bottom-color: #4B5563;
}

[data-theme="dark"] section h4 {
    color: #FFB86C;
}

[data-theme="dark"] header h1 {
    color: #F8FAFC;
}

[data-theme="dark"] header .tagline {
    color: #D1D5DB;
}

[data-theme="dark"] cite {
    color: #A5D6FF;
}

[data-theme="dark"] .publication-highlight {
    background-color: var(--highlight-bg-red);
    border-left: 5px solid var(--secondary-color-red);
}

[data-theme="dark"] .course-description, 
[data-theme="dark"] .experience-description, 
[data-theme="dark"] .service-description, 
[data-theme="dark"] .supervision-note {
    color: #D1D5DB;
    border-left-color: #4B5563;
}

[data-theme="dark"] .dates {
    color: #D1D5DB;
}

[data-theme="dark"] .service-note {
    color: #D1D5DB;
}

[data-theme="dark"] p {
    color: var(--text-color-dark);
}

[data-theme="dark"] footer {
    background-color: rgba(17, 24, 39, 0.97);
}

[data-theme="dark"] section {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .startup-info {
    background-color: rgba(30, 41, 59, 0.9);
    border-color: #4B5563;
}

[data-theme="dark"] .ranking {
    color: #FF7B72;
    background-color: rgba(255, 123, 114, 0.15);
    border-color: #FF7B72;
}

/* Responsive adjustments for dark mode toggle */
@media (max-width: 992px) {
    .theme-toggle {
        position: absolute;
        right: 70px;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .toggle-track {
        width: 44px;
        height: 22px;
    }
    
    .toggle-thumb {
        width: 16px;
        height: 16px;
    }
    
    [data-theme="dark"] .toggle-thumb {
        left: calc(100% - 19px);
    }
}

@media (max-width: 480px) {
    .theme-toggle {
        right: 60px;
    }
    
    .toggle-track {
        width: 36px;
        height: 18px;
    }
    
    .toggle-thumb {
        width: 14px;
        height: 14px;
        top: 2px;
    }
    
    [data-theme="dark"] .toggle-thumb {
        left: calc(100% - 16px);
    }
}