@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap");

:root {
    color-scheme: light;
    --bg: #f7f7f5;
    --bg-elevated: #ffffff;
    --bg-soft: #efefeb;
    --text: #1f2328;
    --text-muted: #5a6472;
    --border: #d6dbe1;
    --accent: #2457d6;
    --accent-weak: #e7efff;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 4px 12px rgba(15, 23, 42, 0.1), 0 20px 40px rgba(15, 23, 42, 0.08);
    --radius-sm: 0.5rem;
    --radius-md: 0.9rem;
    --radius-lg: 1.25rem;
    --container: 72rem;
    --container-narrow: 60rem;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-8: 3rem;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d1117;
    --bg-elevated: #141a23;
    --bg-soft: #18202b;
    --text: #e6edf3;
    --text-muted: #9aa5b1;
    --border: #2a3545;
    --accent: #8ab4ff;
    --accent-weak: rgba(138, 180, 255, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 16px 32px rgba(0, 0, 0, 0.24);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4), 0 20px 40px rgba(0, 0, 0, 0.3);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    background: var(--bg);
    color: var(--text);
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--bg);
    color: var(--text);
    font-family: Outfit, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

img,
svg,
video {
    display: block;
    max-width: 100%;
}

a {
    color: var(--accent);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
}

a:hover {
    text-decoration-thickness: 0.1em;
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

button {
    font: inherit;
}

button:hover {
    cursor: pointer;
}

main {
    display: block;
}

.skip-link {
    position: absolute;
    inset-inline-start: 1rem;
    inset-block-start: 1rem;
    z-index: 1000;
    padding: 0.75rem 1rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    transform: translateY(-200%);
    transition: transform 150ms ease;
}

.skip-link:focus {
    transform: translateY(0);
}

.site-shell {
    width: min(100% - 2rem, var(--container));
    margin-inline: auto;
}

.site-shell--narrow {
    width: min(100% - 2rem, var(--container-narrow));
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}

.site-header__inner,
.site-footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding-block: 0.9rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.site-header__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.site-nav__list {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.site-nav__link {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid transparent;
    transition: color 200ms ease, background-color 200ms ease, border-color 200ms ease;
}

.site-nav__link[aria-current="page"] {
    color: var(--text);
    background: var(--accent-weak);
    border-color: color-mix(in srgb, var(--accent) 22%, transparent);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.5rem;
    padding: 0.35rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-elevated);
    color: var(--text);
    box-shadow: var(--shadow);
}

.theme-toggle__icon {
    position: relative;
    width: 1rem;
    height: 1rem;
    align-self: center;
}

.theme-toggle__icon [data-theme-icon] {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transform: rotate(0deg) scale(1);
    transition: opacity 250ms ease, transform 250ms ease;
}

.theme-toggle__icon [data-theme-icon].is-hidden {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
    pointer-events: none;
}

.site-main {
    padding-block: clamp(1.5rem, 4vw, 3rem) 4rem;
}

.section {
    margin-block: clamp(2rem, 5vw, 3.5rem);
}

.section__eyebrow {
    margin: 0 0 0.45rem;
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.section__title,
.hero h1,
.prose h1 {
    margin: 0;
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.section__title {
    font-size: clamp(1.45rem, 3vw, 2rem);
}

.section__description {
    font-style: italic;
    margin: 0.25rem 0 0.5rem 0;
    color: var(--text-muted);
    font-size: clamp(1.02rem, 1.6vw, 1.1rem);
}

.section-link {
    color: inherit;
    text-decoration: none;
}

.experience-timeline {
    position: relative;
    display: grid;
    gap: 0;
    margin-top: 1.25rem;
}

.experience-timeline::before {
    content: "";
    position: absolute;
    top: 0.65rem;
    bottom: 0.65rem;
    left: 0.45rem;
    width: 1px;
    background: var(--border);
}

.timeline-entry {
    position: relative;
    display: grid;
    grid-template-columns: 1rem minmax(0, 1fr);
    gap: 1.25rem;
    padding-bottom: 2.5rem;
}

.timeline-entry:last-child {
    padding-bottom: 0;
}

.timeline-entry__marker {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    padding-top: 0.42rem;
}

.timeline-entry__dot {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 4px var(--bg);
}

.timeline-entry--current .timeline-entry__dot {
    background: var(--accent);
    animation: timeline-dot-pulse 2.4s ease-in-out infinite;
}

@keyframes timeline-dot-pulse {
    0%, 100% {
        box-shadow: 0 0 0 4px var(--bg), 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent);
    }
    50% {
        box-shadow: 0 0 0 4px var(--bg), 0 0 0 9px color-mix(in srgb, var(--accent) 0%, transparent);
    }
}

.timeline-entry__content {
    min-width: 0;
}

.timeline-entry__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
}

.timeline-entry__title {
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.3;
    letter-spacing: -0.015em;
}

.timeline-entry__organization {
    margin: 0.2rem 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.timeline-entry__date {
    flex-shrink: 0;
    padding: 0.25rem 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.timeline-entry__bullets {
    margin: 0.9rem 0 0;
    padding-left: 1.15rem;
    color: var(--text-muted);
}

.timeline-entry__bullets li {
    padding-left: 0.15rem;
}

.timeline-entry__bullets li + li {
    margin-top: 0.35rem;
}

.timeline-entry__bullets li::marker {
    color: var(--accent);
}

@media (max-width: 38rem) {
    .timeline-entry {
        gap: 0.9rem;
    }

    .timeline-entry__header {
        display: grid;
        gap: 0.55rem;
    }

    .timeline-entry__date {
        width: fit-content;
    }
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(15rem, 0.75fr);
    gap: clamp(1.5rem, 4vw, 3rem);
    align-items: center;
    padding: clamp(1.4rem, 4vw, 2.2rem);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    box-shadow: var(--shadow);
}

.hero__copy {
    display: grid;
    gap: 1rem;
    justify-self: center;
    width: 100%;
    max-width: 42rem;
}

.hero__intro {
    display: grid;
    gap: 0.75rem;
}

.hero__lede {
    max-width: 62ch;
    margin: 0 auto;
    color: var(--text-muted);
}

.hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.hero__avatar {
    width: min(100%, 15rem);
    aspect-ratio: 1;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--bg-elevated);
    box-shadow: var(--shadow);
    justify-self: center;
}

.hero__avatar-caption {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
    text-align: center;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
}

.tag {
    display: inline-flex;
    align-items: center;
    min-height: 1.9rem;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    font-size: 0.92rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.7rem;
    padding: 0.55rem 1rem;
    border-radius: 0.75rem;
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    transition: transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn--primary {
    background: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 80%, black);
    color: #fff;
}

.btn--primary:hover {
    background: color-mix(in srgb, var(--accent) 88%, black);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
    gap: 1rem;
}

.project-card,
.skill-group,
.experience-entry,
.publication-card,
.post-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    box-shadow: var(--shadow);
    padding: 1rem;
    transition: translate 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}

.project-card:hover,
.skill-group:hover,
.experience-entry:hover,
.publication-card:hover,
.post-card:hover {
    translate: 0 -3px;
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.project-card__title,
.post-card__title,
.publication-card__title {
    margin: 0 0 0.4rem;
    font-size: 1.05rem;
    line-height: 1.3;
}

.project-card__title a,
.post-card__title a,
.publication-card__title a {
    color: inherit;
    text-decoration: none;
}

.post-card__meta,
.publication-card__meta,
.experience-entry__meta {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.93rem;
}

.project-card__description,
.post-card__description,
.publication-card__description {
    margin: 0.75rem 0 0;
}

.post-page__header {
    margin-bottom: var(--space-6);
}

.post-page__description {
    margin-bottom: 0;
}

.post-page__grid {
    display: grid;
    grid-template-columns: minmax(0, 72ch) minmax(14rem, 18rem);
    gap: clamp(2rem, 5vw, 4rem);
    align-items: start;
    justify-content: space-between;
}

.post-page__content {
    min-width: 0;
    max-width: none;
}

.post-body {
    text-align: justify;
}

.post-body pre,
.post-body table {
    text-align: start;
}

.post-page__toc {
    position: sticky;
    top: 5.5rem;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.toc__list a {
    display: block;
    padding: 0.35rem 0.55rem;
    border-inline-start: 2px solid transparent;
    border-radius: 0.4rem;
    color: var(--text-muted);
    text-decoration: none;
    line-height: 1.4;
    transition: color 150ms ease,
    background-color 150ms ease,
    border-color 150ms ease;
}

.toc__list a:hover {
    color: var(--text);
    background: var(--bg-soft);
}

.toc__list a[aria-current="location"] {
    color: var(--accent);
    background: var(--accent-weak);
    border-inline-start-color: var(--accent);
    font-weight: 600;
}

.post-body :is(h2, h3, h4, h5, h6) {
    transition: color 150ms ease;
}

.post-body :is(h2, h3, h4, h5, h6).is-active-heading {
    color: var(--accent);
}

.skill-group__title,
.experience-entry__title {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.skill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.skill-list__item {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
}

.experience-list {
    display: grid;
    gap: 1rem;
}

.experience-entry__bullets {
    margin: 0.85rem 0 0;
    padding-inline-start: 1.25rem;
}

.experience-entry__bullets li + li {
    margin-top: 0.35rem;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.meta-row__item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.toc {
    padding: 1rem;
}

.toc__title {
    margin: 0 0 0.6rem;
    font-size: 0.98rem;
}

.toc__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.35rem;
}

.toc__list .toc__list {
    margin-block-start: 0.35rem;
    margin-inline-start: 1rem;
    padding-inline-start: 0.75rem;
    border-inline-start: 1px solid var(--border);
}

.toc__list code {
    padding: 0.08em 0.3em;
    border-radius: 0.3rem;
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-soft));
    border: 1px solid var(--border);
    font-size: 0.9em;
}

.toc__list a {
    color: var(--text-muted);
    text-decoration: none;
}

.toc__list a:hover {
    color: var(--text);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    gap: 1rem;
}

.site-footer {
    margin-top: 4rem;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 94%, transparent);
}

.site-footer__inner {
    flex-wrap: wrap;
    color: var(--text-muted);
}

.site-footer__links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

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

.stack {
    display: grid;
    gap: 1rem;
}

.post-grid {
    display: grid;
    gap: 1rem;
}

.prose > :first-child {
    margin-top: 0;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
    scroll-margin-top: 7rem;
}

.prose h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
}

.prose h2 {
    margin-top: 2.2rem;
    font-size: clamp(1.45rem, 3vw, 2rem);
}

.prose h3 {
    margin-top: 1.8rem;
    font-size: 1.2rem;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose figure,
.prose pre,
.prose table {
    margin-block: 1rem;
}

.prose figure {
    display: grid;
    gap: 0.65rem;
}

.prose figcaption {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.prose img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-soft);
}

.prose code {
    padding: 0.15em 0.35em;
    border-radius: 0.35rem;
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-soft));
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.95em;
}

.prose pre {
    overflow-x: auto;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    tab-size: 4;
}

.prose pre code {
    padding: 0;
    background: transparent;
    color: inherit;
    font-size: 0.92rem;
}

.prose blockquote {
    padding-inline-start: 1rem;
    border-inline-start: 3px solid var(--accent);
    color: var(--text-muted);
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.prose th,
.prose td {
    padding: 0.75rem 0.8rem;
    border-bottom: 1px solid var(--border);
    text-align: start;
    vertical-align: top;
}

.prose th {
    background: var(--bg-soft);
}

.prose tr:last-child td {
    border-bottom: 0;
}

.prose .post-nav {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 3rem;
}

.prose .post-nav a {
    display: grid;
    gap: 0.2rem;
    min-height: 100%;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: inherit;
    text-decoration: none;
}

.prose .post-nav a span {
    color: var(--text-muted);
    font-size: 0.92rem;
}

.prose .post-nav a strong {
    font-size: 1rem;
}

.reveal {
    transition: opacity 600ms ease, transform 600ms ease;
}

:root.js-anim .reveal {
    opacity: 0;
    transform: translateY(1.25rem);
}

:root.js-anim .reveal.reveal--visible {
    opacity: 1;
    transform: none;
}

.card-grid.reveal > *,
.stack.reveal > *,
.experience-timeline.reveal > *,
.post-grid.reveal > * {
    transition: opacity 500ms ease, transform 500ms ease, translate 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}

:root.js-anim .card-grid.reveal > *,
:root.js-anim .stack.reveal > *,
:root.js-anim .experience-timeline.reveal > *,
:root.js-anim .post-grid.reveal > * {
    opacity: 0;
    transform: translateY(1rem);
}

:root.js-anim .card-grid.reveal.reveal--visible > *,
:root.js-anim .stack.reveal.reveal--visible > *,
:root.js-anim .experience-timeline.reveal.reveal--visible > *,
:root.js-anim .post-grid.reveal.reveal--visible > * {
    opacity: 1;
    transform: none;
}

:root.js-anim .card-grid.reveal.reveal--visible > *:nth-child(2),
:root.js-anim .stack.reveal.reveal--visible > *:nth-child(2),
:root.js-anim .experience-timeline.reveal.reveal--visible > *:nth-child(2),
:root.js-anim .post-grid.reveal.reveal--visible > *:nth-child(2) { transition-delay: 60ms; }

:root.js-anim .card-grid.reveal.reveal--visible > *:nth-child(3),
:root.js-anim .stack.reveal.reveal--visible > *:nth-child(3),
:root.js-anim .experience-timeline.reveal.reveal--visible > *:nth-child(3),
:root.js-anim .post-grid.reveal.reveal--visible > *:nth-child(3) { transition-delay: 120ms; }

:root.js-anim .card-grid.reveal.reveal--visible > *:nth-child(4),
:root.js-anim .stack.reveal.reveal--visible > *:nth-child(4),
:root.js-anim .experience-timeline.reveal.reveal--visible > *:nth-child(4),
:root.js-anim .post-grid.reveal.reveal--visible > *:nth-child(4) { transition-delay: 180ms; }

:root.js-anim .card-grid.reveal.reveal--visible > *:nth-child(5),
:root.js-anim .stack.reveal.reveal--visible > *:nth-child(5),
:root.js-anim .experience-timeline.reveal.reveal--visible > *:nth-child(5),
:root.js-anim .post-grid.reveal.reveal--visible > *:nth-child(5) { transition-delay: 240ms; }

:root.js-anim .card-grid.reveal.reveal--visible > *:nth-child(n+6),
:root.js-anim .stack.reveal.reveal--visible > *:nth-child(n+6),
:root.js-anim .experience-timeline.reveal.reveal--visible > *:nth-child(n+6),
:root.js-anim .post-grid.reveal.reveal--visible > *:nth-child(n+6) { transition-delay: 300ms; }

@media (max-width: 48rem) {
    .prose .post-nav {
        grid-template-columns: 1fr;
    }

    .hero {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .hero__copy {
        justify-items: center;
    }

    .hero__intro {
        justify-items: center;
    }

    .hero__lede {
        margin-inline: auto;
        text-align: center;
    }

    .hero__actions {
        justify-content: center;
    }

    .hero__avatar {
        justify-self: center;
        order: -1;
    }

    .site-header__inner {
        flex-wrap: wrap;
    }

    .site-nav {
        width: 100%;
        order: 3;
    }
}

@media (max-width: 38rem) {
    .site-shell,
    .site-shell--narrow {
        width: min(100% - 1.25rem, var(--container));
    }

    .site-nav__list {
        gap: 0.25rem;
    }

    .site-nav__link,
    .theme-toggle,
    .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 64rem) {
    .post-page__grid {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--space-6);
    }

    .post-page__toc {
        position: static;
        order: -1;
        width: min(100%, 18rem);
        max-height: none;
    }
}
