/* Base Variables for easy theming */
:root {
    --text-main: #333333;
    --text-muted: #666666;
    --accent-color: #00274C; /* UMich Blue */
    --bg-color: #FAFAFA;
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html {
    overflow-y: scroll;
}

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

body {
    font-family: var(--font-stack);
    color: var(--text-main);
    background-color: var(--bg-color);
    line-height: 1.6;
}

/* Navigation */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 5%;
    background-color: white;
    border-bottom: 1px solid #eaeaea;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-main);
}

.nav-links {
    font-size: 1.25rem;
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    transition: color 0.2s;
}

/* Highlights the current page in the top navigation */
.nav-links a.active-nav {
    color: var(--accent-color);
    
    /* Simulates bold text without changing the physical width */
    text-shadow: 0.5px 0 0 var(--accent-color); 
}

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

/* Main Container */
.container {
    width: 910px; /* Locks the container to exactly 910 pixels wide */
    margin: 0 auto;
    padding: 4rem 2rem;
}


/* Typography & Sections */
.intro-section h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--accent-color);
    font-weight: 500;
}

.affiliation {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.bio {
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

/* Container holding all the buttons */
.social-links {
    display: grid;
    grid-template-columns: 6rem 9rem;
    gap: 0.75rem;
    align-items: stretch;
}

.social-links > .social-btn,
.dropdown-container > .social-btn {
    padding: 0 1rem;
}

/* Inline Text Links (Paragraphs) */
p a {
    color: var(--accent-color);
    text-decoration: none; /* Removes the underline */
    font-weight: 500; /* Makes it slightly bolder to stand out from normal text */
    transition: opacity 0.2s; /* Smooth transition for the hover effect */
}

/* Optional: Slight fade effect when someone hovers over the link */
p a:hover {
    opacity: 0.7; 
}

/* The individual buttons */
.social-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 42px; 
    padding: 0 20px; 
    white-space: nowrap; 
    box-sizing: border-box; 
    font-size: 1rem;
    text-decoration: none; 
    font-family: inherit; 
    cursor: pointer; 
    border-radius: 4px; 
    transition: all 0.2s ease; /* Adds a smooth fade effect on hover */
    
    /* Restored Colors (Default State) */
    background-color: #ffffff; 
    color: #00274C; /* Dark Navy Blue */
    border: 1px solid #00274C; 
}

/* Hover State and Active Dropdown State */
.social-btn:hover,
.social-btn.active {
    background-color: #00274C; /* Dark background */
    color: #ffffff; /* White text */
}

/* Dropdown specific styles */
.dropdown-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative; /* Tells the pop-out box to position itself relative to this container */
}

.dropdown-content {
    display: none; 
    flex-direction: column;
    gap: 0.8rem;
    padding: 1rem;
    background-color: white;
    border: 1px solid #eaeaea;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    width: max-content; /* Replaces min-width: 200px; */
    max-width: 365px; /* Optional: prevents it from getting too wide on small screens */
    
    /* New Absolute Positioning Rules */
    position: absolute; /* Takes the box out of the document flow so it doesn't push the page */
    top: 100%; /* Positions it directly below the Email button */
    left: 0; /* Aligns it with the left edge of the Email button */
    margin-top: 0.5rem; /* Creates a small gap between the button and the box */
    z-index: 10; /* Ensures the box floats on top of any other text or borders below it */
}

/* Show dropdown on hover OR when clicked (via JS .show class) */
.dropdown-container:hover .dropdown-content,
.dropdown-content.show {
    display: flex;
}

.dropdown-content p {
    font-size: 0.95rem;
    color: var(--text-main);
    margin: 0;
    font-weight: 500;
}

.copy-field {
    display: grid;
}

.copy-field > * {
    grid-area: 1 / 1;
}

.copy-contact {
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.copy-field.has-feedback .copy-contact {
    color: transparent;
}

.copy-feedback {
    color: var(--accent-color);
    pointer-events: none;
}

/* Invisible bridge to prevent the hover gap dead zone */
.dropdown-content::before {
    content: "";
    position: absolute;
    top: -0.5rem; /* Matches the exact size of your margin-top gap */
    left: 0;
    width: 100%;
    height: 0.5rem;
}

/* Prevents the button inside the dropdown from stretching to full width */
.dropdown-content .social-btn {
    align-self: flex-start;
}

footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 2rem;
}


/* Profile Picture Layout */
.intro-content {
    display: flex;
    flex-direction: column-reverse;
    gap: 3rem;
    align-items: center;
}

.intro-text {
    flex: 1;
}

.intro-image {
    flex-shrink: 0;
}

.profile-pic {
    width: 280px;
    aspect-ratio: 4 / 5;
    border-radius: 4%; /* Slightly rounded corners instead of a full circle */
    object-fit: cover;
    border: 0.0px solid var(--accent-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Desktop Layout */
@media (min-width: 768px) {
    .intro-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

@media (min-width: 901px) {
    .social-links {
        grid-template-columns: repeat(2, 6rem 9rem);
    }
}

/* Sub-section Spacing */
.sub-section-title {
    font-size: 2rem;
    margin-top: 3.0rem; /* Increased to push the title further down from the list above */
    margin-bottom: 2rem;
    color: var(--accent-color);
}

/* Generic Content Sections */
.content-section {
    margin-top: 4rem;
    border-top: 1px solid #eaeaea;
    padding-top: 3rem;
}

.content-section h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--accent-color);
}

/* Publication List & Cards - Minimalist Flat Style */
.pub-list {
    --entry-spacing: 1rem;
    display: flex;
    flex-direction: column;
    gap: var(--entry-spacing);
}

.pub-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-bottom: var(--entry-spacing);
    border-bottom: 1px solid #cccccc;
}

/* Don't show a line below the last paper in a section */
.pub-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.pub-title {
    font-size: 1.2rem;
    color: var(--text-main);
    line-height: 1.4;
    font-weight: 600;
}

.pub-authors {
    font-size: 1rem;
}

.pub-venue {
    font-size: 0.95rem;
    font-style: italic;
    color: var(--text-muted);
}

/* Links (PDF, Code, etc.) are styled as clean underlines */
.pub-links {
    display: flex;
    gap: 1rem;
}

.btn-small {
    font-size: 0.9rem;
    padding: 0;
    border: none;
    color: var(--accent-color);
    text-decoration: underline;
    background-color: transparent;
    transition: color 0.2s;
}

/* Clean hover color change */
.btn-small:hover {
    background-color: transparent;
    color: var(--text-main);
}

/* Research Interests List */
.interests-content ul li {
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.interests-content ul li:last-child {
    margin-bottom: 0;
}

/* Footer Separator Spacing */
.separator {
    margin: 0 0.25rem; /* This adds horizontal space on the left and right */
}

/* Theme Toggle Button */
.theme-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-left: 1rem;
    color: var(--text-muted);
    transition: color 0.2s;

    /* Strict dimensions to prevent all layout shifts */
    width: 30px;  /* Locks the horizontal space */
    height: 30px; /* Locks the vertical space */
    display: inline-flex; /* Switches from inline-block for perfect centering */
    align-items: center; /* Centers the symbol vertically */
    justify-content: center; /* Centers the symbol horizontally */
}

.theme-btn:hover {
    color: var(--accent-color);
    transform: scale(1.1);
}

.theme-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-icon-sun,
.dark-mode .theme-icon-moon {
    display: none;
}

.dark-mode .theme-icon-sun {
    display: block;
}

/* Dark Mode Variables */
body.dark-mode {
    --bg-color: #121212;
    --text-main: #e0e0e0;
    --text-muted: #a0a0a0;
    --accent-color: #64b5f6; /* A lighter blue/accent for better contrast in dark mode */

    /* Counteract the dark mode font illusion globally */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Ensure the body uses the background variables */
body {
    background-color: var(--bg-color, #ffffff);
    color: var(--text-main);
    transition: background-color 0.3s, color 0.3s;
}

/* Dark Mode Component Overrides */
body.dark-mode .navbar {
    background-color: var(--bg-color);
    border-bottom: 1px solid #333;
}

body.dark-mode .dropdown-content {
    background-color: #1e1e1e;
    border: 1px solid #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

body.dark-mode .pub-item {
    border-bottom: 1px solid #333;
}

body.dark-mode .pub-item:last-child {
    border-bottom: none;
}

/* Dark Mode Button Overrides */
body.dark-mode .social-btn {
    background-color: transparent; /* Makes the button background match the dark page */
    color: var(--accent-color); /* Uses your light blue accent color for the text */
    border: 1px solid var(--accent-color); /* Matches the border to the text */
}

/* Dark Mode Hover/Active State */
body.dark-mode .social-btn:hover,
body.dark-mode .social-btn.active {
    background-color: var(--accent-color); /* Fills the button with light blue */
    color: var(--bg-color); /* Turns the text dark for contrast */
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
    .navbar {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .nav-links {
        flex-wrap: wrap;
        align-items: center;
        gap: 1rem;
        font-size: 1rem;
    }

    .theme-btn {
        margin-left: 0;
    }

    .social-links {
        position: relative;
    }

    .dropdown-container {
        position: static;
    }

    .dropdown-content {
        max-width: 100%;
    }

    .container {
        width: 100%;
        min-width: 0;
        padding: 2rem 1.5rem;
    }
}

/* Phone layouts */
@media (max-width: 767px) {
    .navbar {
        position: relative;
        padding: 1rem 1.5rem;
    }

    .nav-logo {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }

    .nav-links {
        flex-basis: 100%;
        flex-wrap: nowrap;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .nav-links > li:last-child {
        display: flex;
        position: absolute;
        top: 1rem;
        right: 1.5rem;
    }

    .nav-links a,
    .btn-small {
        display: inline-flex;
        align-items: center;
    }

    .nav-links a {
        justify-content: center;
    }

    .nav-links a,
    .theme-btn,
    .btn-small,
    .social-btn,
    .copy-contact {
        min-width: 44px;
        min-height: 44px;
    }

    .theme-btn:hover {
        transform: none;
    }

    .intro-content {
        gap: 2rem;
    }

    .intro-image {
        max-width: 100%;
    }

    .profile-pic {
        width: 240px;
        max-width: 100%;
    }

    .intro-section h1 {
        font-size: 2rem;
    }

    .copy-feedback {
        align-self: center;
    }

    .dropdown-container:hover .dropdown-content:not(.show) {
        display: none;
    }
}
