/* === CSS Variables === */
:root {
    color-scheme: light dark;
    --transition-duration: 0.2s;
    --container-width-desktop: 66%;
    --container-width-tablet: 85%;
    --container-width-mobile: 92%;
    --font-size-h1: clamp(3rem, 8vw, 5rem);
    --font-size-h2: clamp(2rem, 5vw, 3rem);
    --font-size-h3: clamp(1.5rem, 3vw, 2rem);
    --font-size-h4: clamp(1.25rem, 2vw, 1.5rem);
    --font-size-body: 1rem;
    --header-spacing-bottom: 0.5em;
    --header-spacing-top: 1.2em;
}

/* === Light Theme === */
:root:not([data-theme=dark]),
[data-theme=light] {
    --color-bg: #ffffff;
    --color-text: #2e2e2e;
    --color-subtext: #4f566b;
    --primary: #1155cc;
    --primary-hover: #0d47a1;
    --color-gray: #f0f7ff;
    --color-gray-border: #e0ebf7;
    --color-footer-text: #4f566b;
    --link-color: #0066cc;
    --link-hover-color: #004c99;
    --color-code-bg: #f5f7ff;
    --color-code-text: #3c4257;
    --color-code-border: #e4e8ff;
    --color-blockquote-border: #1155cc;
    --color-blockquote-bg: #f9faff;
}

/* === Dark Theme === */
[data-theme=dark] {
    --color-bg: #0a0c14;
    --color-text: #f7fafc;
    --color-subtext: #a3acb9;
    --primary: #4d8eee;
    --primary-hover: #6fa5f1;
    --color-gray: #1a1f36;
    --color-gray-border: #2a3149;
    --color-footer-text: #a3acb9;
    --link-color: #4d8eee;
    --link-hover-color: #6fa5f1;
    --color-code-bg: #1a1f36;
    --color-code-text: #e3e8ee;
    --color-code-border: #2a3149;
    --color-blockquote-border: #4d8eee;
    --color-blockquote-bg: #1a1f36;
}

[data-theme=dark] a { color: var(--link-color); }
[data-theme=dark] a:hover { color: var(--link-hover-color); }
[data-theme=dark] nav a.active { color: var(--link-color); }
[data-theme=dark] nav a.active::after { background-color: var(--link-color); }

/* === Base === */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    font-family: 'Work Sans', sans-serif;
    color: var(--color-text);
    background-color: var(--color-bg);
    transition: background-color var(--transition-duration), color var(--transition-duration);
    line-height: 1.6;
    font-size: var(--font-size-body);
}

.container {
    width: var(--container-width-desktop);
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Work Sans', sans-serif;
    font-weight: 600;
    line-height: 1.1;
    margin-top: var(--header-spacing-top);
    margin-bottom: var(--header-spacing-bottom);
    letter-spacing: -0.02em;
    color: var(--color-text);
}

h1 {
    font-size: var(--font-size-h1);
    letter-spacing: -0.03em;
    font-weight: 700;
    margin-top: 0.2em;
    margin-bottom: 0.4em;
}

h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }
h4 { font-size: var(--font-size-h4); }

p {
    margin-bottom: 1.2em;
    color: var(--color-text);
}

/* === Links === */
a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease;
    border-bottom: 1px solid transparent;
    font-weight: 500;
}

a:hover {
    color: var(--link-hover-color);
    border-bottom: 1px solid var(--link-hover-color);
}

/* === Navigation === */
nav {
    padding: 0.5rem 0;
}

nav ul {
    gap: 1.5rem;
}

nav ul li a {
    border-bottom: none;
    position: relative;
    transition: all 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
}

nav ul li a:hover {
    transform: translateY(-0.5px);
    border-bottom: none;
}

nav a.active {
    font-weight: 600;
    color: var(--primary);
    position: relative;
}

nav a.active::after {
    content: '';
    position: absolute;
    left: 10%;
    right: 10%;
    bottom: -2px;
    height: 2px;
    background-color: var(--primary);
}

.nav-brand {
    font-weight: 600;
    border-bottom: none !important;
}

.nav-brand:hover {
    border-bottom: none !important;
}

/* === Headshot === */
.headshot {
    display: block;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    margin: 0 0 2rem 0;
    border: 3px solid var(--color-gray-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    object-fit: cover;
}

/* === Social Links === */
.social-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 2rem 0;
}

.social-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    background-color: var(--color-gray);
    transition: all 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-bottom: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.social-link:hover {
    background-color: var(--color-gray-border);
    transform: translateY(-2px);
    border-bottom: none;
    box-shadow: 0 3px 6px rgba(0,0,0,0.06);
}

/* === Experience Entries === */
.experience-entry {
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--color-gray-border);
}

.experience-entry:last-child {
    border-bottom: none;
}

.experience-entry h3 {
    margin-bottom: 0.2em;
}

.experience-meta {
    color: var(--color-subtext);
    font-size: 0.95rem;
    margin-bottom: 0.8em;
}

.experience-org {
    font-weight: 500;
    color: var(--color-text);
}

/* === Blockquotes === */
blockquote {
    border-left: 4px solid var(--color-blockquote-border);
    padding: 1rem 1.5rem;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 1.5rem;
    background-color: var(--color-blockquote-bg);
    border-radius: 0 4px 4px 0;
}

blockquote p {
    color: var(--color-subtext);
    margin-bottom: 0;
}

/* === Code === */
pre, code {
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    border-radius: 4px;
}

pre {
    background-color: var(--color-code-bg);
    color: var(--color-code-text);
    padding: 1rem;
    overflow-x: auto;
    border: 1px solid var(--color-code-border);
}

code {
    background-color: var(--color-code-bg);
    color: var(--color-code-text);
    padding: 0.2em 0.4em;
    font-size: 0.9em;
}

/* === Theme Toggle === */
#theme-toggle {
    position: fixed;
    right: 2rem;
    bottom: 1.3rem;
    padding: 0.5rem;
    background: var(--color-bg);
    border: 1px solid var(--color-gray-border);
    border-radius: 50%;
    cursor: pointer;
    color: var(--color-text);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#theme-toggle:hover {
    background-color: var(--color-gray);
    transform: scale(1.1);
}

#theme-toggle svg {
    width: 24px;
    height: 24px;
    transition: transform 0.2s ease;
}

[data-theme="dark"] #theme-toggle svg {
    transform: rotate(40deg);
}

/* === Layout === */
main {
    padding: 0.5rem 0;
    flex: 1 0 auto;
}

footer {
    margin-top: 1rem;
    padding: 1rem 0;
    font-size: 0.9rem;
    color: var(--color-footer-text);
    flex-shrink: 0;
}

hr {
    border: 0;
    height: 1px;
    background-color: var(--color-gray-border);
    margin: 2rem 0;
}

ul, ol {
    padding-left: 1.5rem;
    margin-bottom: 1.2em;
}

li { margin-bottom: 0.5em; }

img { max-width: 100%; height: auto; }

/* === Publications === */
.publication {
    margin-bottom: 1.5rem;
    padding-left: 1rem;
    border-left: 3px solid var(--color-gray-border);
}

.publication h4 {
    margin-bottom: 0.2em;
}

.publication-meta {
    color: var(--color-subtext);
    font-size: 0.9rem;
}

/* === Responsive === */
@media (max-width: 992px) {
    .container { width: var(--container-width-tablet); }
}

@media (max-width: 768px) {
    .container {
        width: var(--container-width-mobile);
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    nav ul {
        flex-direction: row;
        gap: 0.5rem;
    }

    .nav-links {
        display: flex;
        justify-content: center;
        gap: 1rem !important;
    }

    .social-links {
        flex-direction: column;
        gap: 0.75rem;
    }

    .social-link {
        width: 100%;
        justify-content: flex-start;
    }

    #theme-toggle {
        right: 1rem;
        bottom: 1rem;
        width: 40px;
        height: 40px;
    }

    .headshot {
        float: none;
        width: 160px;
        height: 160px;
        margin: 0 auto 1.5rem;
        display: block;
    }
}

@media (max-width: 480px) {
    .container {
        width: 96%;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}
