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

ul,
ol {
    list-style: none;
}

/* ── Tokens ── */
:root {
    --font: 'JetBrains Mono', monospace;

    /* dot grid */
    --dot-bg: #ffffff;
    --dot-color: #a5aeb850;
    --dot-mask: #ffffff;

    /* surfaces */
    --bg-main: #ffffff;
    --text-main: #1a1a1a;
    --text-muted: rgba(100, 100, 100, 0.8);
    --border: rgba(125, 125, 125, 0.2);

    /* links / accents */
    --link: inherit;
    --link-underline: rgba(100, 100, 100, 0.4);
    --link-hover-bg: rgba(125, 125, 125, 0.08);
}

html.dark {
    --dot-bg: #0d1117;
    --dot-color: #2f353c;
    --dot-mask: #000000;

    --bg-main: #0d1117;
    --text-main: rgba(255, 255, 255, 0.87);
    --text-muted: rgba(255, 255, 255, 0.45);
    --border: rgba(255, 255, 255, 0.12);

    --link-underline: rgba(255, 255, 255, 0.25);
    --link-hover-bg: rgba(255, 255, 255, 0.06);
}

/* ── Base ── */
html {
    font-size: 16px;
    color-scheme: dark;
}

html:not(.dark) {
    color-scheme: light;
}

body {
    font-family: var(--font);
    background: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    position: relative;
}

/* dot grid background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(90deg, var(--dot-bg) 18px, transparent 1%) 50%,
        linear-gradient(var(--dot-bg) 18px, transparent 1%) 50%,
        var(--dot-color);
    background-size: 20px 20px;
    mask-image: linear-gradient(0deg, transparent 5%, var(--dot-mask));
}

/* ── Layout ── */
#app {
    width: 100%;
    max-width: 48rem;
    /* ~768px, same as max-w-3xl */
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
}

/* ── Header ── */
header {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 48rem;
    padding: 0 1.5rem;
    height: 5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 99;
    transition: transform 0.4s ease, backdrop-filter 0.3s;
}

header.scrolled {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

header.hidden {
    transform: translateX(-50%) translateY(-100%);
}

.logo-link img {
    width: 185px;
    height: 85px;
    mix-blend-mode: multiply;
    display: block;
    margin-top: 25px;
}

html.dark .logo-link img {
    mix-blend-mode: normal;
    filter: invert(1);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* ── Nav link style (used everywhere) ── */
.nav-link {
    font-family: var(--font);
    font-size: 0.9rem;
    color: var(--text-main);
    text-decoration: none;
    opacity: 0.6;
    border-bottom: 1px solid transparent;
    padding-bottom: 1px;
    transition: opacity 0.15s, border-color 0.15s, background 0.15s;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.nav-link:hover {
    opacity: 1;
    border-bottom-color: var(--link-underline);
}

/* icon-style nav links (theme toggle, github, rss) */
.nav-icon {
    opacity: 0.6;
    font-size: 1.1rem;
    text-decoration: none;
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    transition: opacity 0.15s;
    cursor: pointer;
    background: none;
    border: none;
}

.nav-icon:hover {
    opacity: 1;
}

/* ── Main content ── */
main {
    padding-top: 9rem;
    padding-bottom: 4rem;
    flex: 1;
}

/* ── Prose article ── */
article.prose {
    font-size: 1rem;
    line-height: 1.75;
    margin: 1em auto;
    overflow: hidden;
    min-height: 38vh;
}

.prose h1 {
    font-weight: 800;
    font-size: 2.25em;
    margin-top: 0;
    margin-bottom: 0.9em;
    line-height: 1.1;
}

.prose h2 {
    font-weight: 700;
    font-size: 1.5em;
    margin-top: 2em;
    margin-bottom: 1em;
    line-height: 1.33;
}

.prose p {
    margin-top: 1.25em;
    margin-bottom: 1.25em;
    color: var(--text-main);
    opacity: 0.85;
    font-size: 0.9rem;
}

.prose a {
    color: var(--text-main);
    text-decoration: none;
    border-bottom: 1px solid var(--link-underline);
    padding-bottom: 1px;
    transition: background 0.15s;
}

.prose a:hover {
    background: var(--link-hover-bg);
}

.prose hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 3em 0;
}

/* ── "Find me on" social links ── */
.social-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.prose-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    font-size: 0.9rem;
    color: var(--text-main);
    text-decoration: none;
    border-bottom: 1px solid var(--link-underline);
    padding-bottom: 1px;
    opacity: 0.75;
    transition: opacity 0.15s, background 0.15s;
}

.prose-link:hover {
    opacity: 1;
    background: var(--link-hover-bg);
}

.prose-link svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ── Projects page ── */
.page {
    display: none;
    padding-top: 9rem;
    padding-bottom: 4rem;
    flex: 1;
}

.page.active {
    display: block;
}

main {
    display: block;
}

.projects-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    min-height: 38vh;
    margin-bottom: 4.5rem;
}

.project-item {
    display: flex;
    flex-direction: column;
    padding: 0.6rem 0.8rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: var(--text-main);
    transition: background 0.15s;
}

.project-item:hover {
    background: var(--link-hover-bg);
}

.project-name {
    font-size: 1.05rem;
    line-height: 1.3;
}

.project-desc {
    font-size: 0.85rem;
    opacity: 0.5;
    margin-top: 0.15rem;
}

.group-label {
    font-size: 0.8rem;
    font-weight: 600;
    opacity: 0.4;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

/* ── Blog list ── */
.blog-list {
    min-height: 38vh;
    margin-bottom: 4.5rem;
}

.year-marker {
    position: relative;
    height: 4.5rem;
    pointer-events: none;
    user-select: none;
}

.year-text {
    position: absolute;
    top: -0.2em;
    font-size: 7rem;
    font-weight: 700;
    color: transparent;
    -webkit-text-stroke: 2px #aaa;
    opacity: 0.14;
    line-height: 1;
}

.blog-item {
    margin-bottom: 2rem;
}

.blog-item a {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    text-decoration: none;
    color: var(--text-main);
    font-size: 1.05rem;
    line-height: 1.3;
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    transition: background 0.15s;
}

.blog-item a:hover {
    background: var(--link-hover-bg);
}

.blog-meta {
    font-size: 0.82rem;
    opacity: 0.5;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.blog-desc {
    font-size: 0.85rem;
    opacity: 0.5;
}

.blog-tags {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}

.tag {
    font-size: 0.72rem;
    padding: 0.15rem 0.55rem;
    border-radius: 9999px;
    background: rgba(125, 125, 125, 0.12);
    opacity: 0.7;
}

/* ── Footer ── */
footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 0 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-size: 0.78rem;
    opacity: 0.6;
    margin-top: 4.5rem;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.footer-links a {
    color: var(--text-main);
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

.footer-sep {
    opacity: 0.5;
}

.footer-copy {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.footer-copy a {
    color: var(--text-main);
}

/* ── Mobile nav drawer ── */
.nav-hamburger {
    display: none;
}

.nav-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    min-width: 32vw;
    max-width: 50vw;
    background: var(--bg-main);
    padding: 1.5rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1.25rem;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}

.nav-drawer.open {
    transform: translateX(0);
}

.drawer-links {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.drawer-socials {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.nav-mask {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

.nav-mask.visible {
    display: block;
}

@media (max-width: 640px) {
    .nav-desktop {
        display: none !important;
    }

    .nav-hamburger {
        display: inline-flex;
    }

    main,
    .page {
        padding-top: 7rem;
    }

    .prose h1 {
        font-size: 1.75rem;
    }
}

@media (min-width: 641px) {
    .nav-hamburger {
        display: none;
    }
}

/* ── Page transitions (simple fade) ── */
.page-content {
    animation: fadein 0.3s ease;
}

@keyframes fadein {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ── nprogress-like bar (cosmetic) ── */
#progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    background: #888;
    opacity: 0;
    transition: width 0.3s ease, opacity 0.3s;
    z-index: 9999;
    pointer-events: none;
    width: 0%;
}

.theme-toggle {
    margin-left: 10px;
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text, #fff);
    transition: transform 0.2s ease;
}

.theme-toggle:hover {
    transform: scale(1.2);
}

.theme-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.theme-toggle:hover {
    transform: scale(1.2);
}

.theme-toggle .icon {
    transition: opacity 0.2s ease, transform 0.2s ease;
}