:root {
    /* Light Mode */
    --bg: #fdfdfc;
    --fg: #1a1a1a;
    --fg-dim: #555555;
    --fg-muted: #666666;
    --accent: #2b5c92;
    --line: #e5e5e0;
    --surface: #f5f5f4;

    /* Fonts */
    --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --font-serif: "Newsreader", serif;
}

html {
    scroll-behavior: smooth;
}

[data-theme="dark"] {
    /* Dark Mode */
    --bg: #161618;
    --fg: #eeeeee;
    --fg-dim: #999999;
    --fg-muted: #aaaaaa;
    --accent: #7aa2f7;
    --line: #262626;
    --surface: #1e1e20;
}

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

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    white-space: nowrap;
}

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: var(--fg);
    color: var(--bg);
    padding: 8px 16px;
    font-family: var(--font-sans);
    font-size: 13px;
    border-radius: 4px;
    z-index: 1000;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 16px;
    border-bottom: none;
}

/* Focus States */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-serif);
    font-size: 17px;
    line-height: 1.7;
    font-variant-numeric: oldstyle-nums;
    hanging-punctuation: first;
    transition:
        background 0.3s ease,
        color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

.layout {
    max-width: 640px;
    margin: 0 auto;
    padding: 80px 24px 40px;
}

h1,
h2,
h3,
.meta,
.date,
.role-title,
.skill-head,
.links a,
.source-link {
    font-family: var(--font-sans);
}

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

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

/* Header */
header {
    margin-bottom: 40px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.name {
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.role {
    font-size: 24px;
    font-weight: 500;
    margin-top: 12px;
    font-style: italic;
}

.meta {
    font-size: 13px;
    color: var(--fg-dim);
    margin-top: 8px;
}

.links {
    margin-top: 24px;
    display: flex;
    gap: 20px;
    font-size: 12px;
}

.links a {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--fg-dim);
    border-bottom: none;
    transition: color 0.2s ease;
}

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

.links svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.links span {
    font-family: var(--font-sans);
    letter-spacing: 0.02em;
}

/* Intro */
.intro {
    font-size: 18px;
    color: var(--fg);
    margin-bottom: 40px;
}

.not-found-layout {
    min-height: 100vh;
}

.not-found {
    margin-top: 80px;
    text-align: center;
}

.not-found-code {
    font-family: var(--font-mono);
    font-size: 48px;
    font-weight: 600;
    color: var(--fg-dim);
    margin-bottom: 16px;
}

.not-found-message {
    font-size: 20px;
    margin-bottom: 32px;
}

.not-found-link {
    font-family: var(--font-sans);
    font-size: 14px;
    padding: 10px 20px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--fg-dim);
}

.subtle {
    font-size: 14px;
    color: var(--fg-dim);
    margin-top: 12px;
    font-style: italic;
}

hr {
    border: none;
    border-top: 0.5px solid var(--line);
    margin: 40px 0;
}

.section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--fg-dim);
    margin-bottom: 32px;
    display: block;
}

/* Entries */
.entry {
    margin-bottom: 48px;
}

/* Project entries get hover states */
#projects .entry {
    padding: 20px;
    margin-left: -20px;
    margin-right: -20px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

#projects .entry:hover {
    background-color: var(--surface);
}

.entry-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}

.entry-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.date {
    font-size: 12px;
    color: var(--fg-dim);
}

.role-title {
    font-size: 13px;
    margin-bottom: 12px;
    color: var(--accent);
}

.tech-list {
    list-style: none;
    margin-top: 12px;
    padding-left: 12px;
    border-left: 2px solid var(--line);
}

.tech-list li {
    font-size: 15px;
    color: var(--fg-muted);
    margin-bottom: 8px;
    line-height: 1.5;
}

.tech-list strong {
    color: var(--fg);
    font-weight: 500;
}

.source-link {
    font-size: 12px;
    margin-top: 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--fg-dim);
    background: transparent;
    transition: all 0.2s ease;
}

.source-link:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--surface);
}

/* Skills */
.skills-container {
    display: flex;
    flex-direction: column;
    gap: 28px;
    margin-bottom: 60px;
}

.skill-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skill-head {
    font-size: 11px;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.skill-tag {
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--fg-muted);
    background: var(--surface);
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--line);
    transition: all 0.2s ease;
}

.skill-tag:hover {
    color: var(--fg);
    border-color: var(--fg-dim);
}

.skill-tag.primary {
    color: var(--accent);
    border-color: var(--accent);
    background: transparent;
}

/* Footer */
footer {
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--fg-dim);
    margin-top: 60px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.back-to-top {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--fg-dim);
    border: none;
    font-size: 12px;
    transition: color 0.2s ease;
}

.back-to-top:hover {
    color: var(--accent);
}

.back-to-top svg {
    width: 14px;
    height: 14px;
}

/* Theme Toggle - Updated for cleanliness */
#theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--fg);
    padding: 8px;
    margin: -8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

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

.icon {
    width: 22px;
    height: 22px;
}

/* Show/Hide logic based on data-theme attribute */
[data-theme="light"] .moon-icon {
    display: none;
}
[data-theme="dark"] .sun-icon {
    display: none;
}

/* Tablet */
@media (max-width: 768px) {
    .layout {
        padding-top: 60px;
    }

    .entry-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* Mobile */
@media (max-width: 600px) {
    .entry-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .layout {
        padding-top: 40px;
    }

    .role {
        font-size: 20px;
    }

    .links {
        flex-wrap: wrap;
        gap: 16px;
    }
}

/* Print Styles */
@media print {
    * {
        background: white !important;
        color: black !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.4;
    }

    .layout {
        max-width: 100%;
        padding: 0;
    }

    .skip-link,
    #theme-toggle,
    .source-link,
    .back-to-top {
        display: none !important;
    }

    .links {
        gap: 12px;
    }

    .links svg {
        display: none;
    }

    .links a {
        color: black !important;
    }

    .links a::after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #666 !important;
    }

    .links a[href^="mailto"]::after,
    .links a[href$=".pdf"]::after {
        content: "";
    }

    #projects .entry {
        padding: 0;
        margin-left: 0;
        margin-right: 0;
    }

    .skill-tag {
        border: 1px solid #ccc !important;
        background: white !important;
    }

    a {
        border-bottom: none !important;
    }

    section {
        page-break-inside: avoid;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}
