/* ===== CSS Custom Properties ===== */
:root {
    --bg: #fafafa;
    --bg-secondary: #f0f0f0;
    --text: #1a1a1a;
    --text-secondary: #555;
    --accent: #2c5282;
    --accent-hover: #1a365d;
    --border: #ddd;
    --nav-bg: rgba(250, 250, 250, 0.95);
    --shadow: rgba(0, 0, 0, 0.08);
    --code-bg: #f5f5f5;
    --max-width: 820px;
}

/* Dark mode via checkbox hack — no JS */
#dark-mode-toggle:checked ~ label ~ * {
    /* We can't easily do sibling traversal into child elements,
       so we use a JS-free class toggle approach instead. */
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 3rem;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
}

/* ===== Theme Switch ===== */
#theme-switch {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s, border-color 0.3s;
    color: var(--text-secondary);
}

#theme-switch:hover {
    border-color: var(--accent);
    color: var(--accent);
}

#theme-switch .sun-icon { display: none; }
#theme-switch .moon-icon { display: block; }

/* Dark mode: JS will toggle this class */
body.dark-mode #theme-switch .sun-icon { display: block; }
body.dark-mode #theme-switch .moon-icon { display: none; }

/* ===== Navigation ===== */
#main-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
}

#main-nav ul {
    display: flex;
    justify-content: center;
    gap: 0.5rem 1.5rem;
    list-style: none;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
    flex-wrap: wrap;
}

#main-nav a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 0.25rem 0;
    transition: color 0.2s;
    border-bottom: 2px solid transparent;
}

#main-nav a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ===== Main Content ===== */
#page-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ===== Section Styling ===== */
section {
    padding: 5rem 0;
    border-bottom: 1px solid var(--border);
}

section:last-child {
    border-bottom: none;
}

section h1,
section h2,
section h3 {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-weight: 400;
    line-height: 1.3;
}

section h2 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    color: var(--text);
}

section h3 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
    color: var(--text);
}

section p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

section a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

section a:hover {
    border-bottom-color: var(--accent);
}

/* ===== Hero Section ===== */
#page-content > section.hero {
    padding: 7rem 0 4rem;
    border-bottom: none;
    text-align: center;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.hero .subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.hero .institution {
    font-size: 1rem;
    color: var(--accent);
    font-weight: 500;
}

.hero img.headshot {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin: 1.5rem 0;
    border: 3px solid var(--border);
}

/* ===== Project Cards ===== */
.project-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.project-card {
    padding: 1.25rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.project-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 12px var(--shadow);
}

.project-card h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.project-card p {
    margin-bottom: 0;
    font-size: 0.95rem;
}

.project-card a {
    display: inline-block;
    margin-top: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ===== Links List ===== */
.link-list {
    list-style: none;
    padding: 0;
}

.link-list li {
    margin-bottom: 0.75rem;
    padding-left: 1rem;
    position: relative;
    color: var(--text-secondary);
}

.link-list li::before {
    content: "\00B7";
    position: absolute;
    left: 0;
    color: var(--accent);
}

.link-list a {
    color: var(--accent);
}

/* ===== Publication Entries ===== */
.publication-entry {
    margin-bottom: 1.25rem;
    padding-left: 1rem;
    border-left: 3px solid var(--border);
}

.publication-entry:hover {
    border-left-color: var(--accent);
}

.publication-entry .title {
    font-weight: 500;
    color: var(--text);
}

.publication-entry .description {
    font-weight: 100;
    color: var(--text);
}

.publication-entry .venue {
    color: var(--text-secondary);
    font-style: italic;
}

.publication-entry .links {
    margin-top: 0.25rem;
    font-size: 0.9rem;
}

/* ===== Contact Section ===== */
.contact-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.contact-item {
    display: flex;
    flex-direction: column;
}

.contact-item .label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.contact-item a,
.contact-item span {
    color: var(--text);
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

/* ===== Dark Mode Styles ===== */
body.dark-mode {
    --bg: #1a1a2e;
    --bg-secondary: #16213e;
    --text: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #63b3ed;
    --accent-hover: #90cdf4;
    --border: #2d3748;
    --nav-bg: rgba(26, 26, 46, 0.95);
    --shadow: rgba(0, 0, 0, 0.3);
    --code-bg: #16213e;
}

body.dark-mode #main-nav {
    border-bottom-color: var(--border);
}

body.dark-mode .project-card {
    border-color: var(--border);
}

body.dark-mode .publication-entry {
    border-left-color: var(--border);
}

body.dark-mode section a {
    color: var(--accent);
}

body.dark-mode section a:hover {
    border-bottom-color: var(--accent);
}

body.dark-mode #theme-switch {
    background: var(--bg-secondary);
    border-color: var(--border);
    color: var(--text-secondary);
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .hero h1 {
        font-size: 1.8rem;
    }

    section h2 {
        font-size: 1.4rem;
    }

    #main-nav ul {
        gap: 0.25rem 0.75rem;
    }

    #main-nav a {
        font-size: 0.75rem;
    }
}
