@font-face {
    font-family: "Inter";
    src: url("../fonts/inter-latin-400.woff2") format("woff2");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Inter";
    src: url("../fonts/inter-latin-500.woff2") format("woff2");
    font-style: normal;
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: "Inter";
    src: url("../fonts/inter-latin-600.woff2") format("woff2");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "Inter";
    src: url("../fonts/inter-latin-700.woff2") format("woff2");
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

@font-face {
    font-family: "Space Mono";
    src: url("../fonts/space-mono-latin-400.woff2") format("woff2");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Space Mono";
    src: url("../fonts/space-mono-latin-700.woff2") format("woff2");
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

:root,
:root[data-theme="light"] {
    color-scheme: light;
    --gh-font-heading: "Space Mono";
    --gh-font-body: "Inter";
    --background: #ffffff;
    --foreground: #0e0e0e;
    --muted: #666666;
    --line: #dedede;
    --line-strong: #0e0e0e;
    --panel: #f3f3f3;
    --code: #0e0e0e;
    --code-foreground: #ffffff;
    --accent: #1748c2;
    --link: #1748c2;
    --on-accent: #ffffff;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --background: #0e0e0e;
    --foreground: #ffffff;
    --muted: #a5a5a5;
    --line: #333333;
    --line-strong: #ffffff;
    --panel: #181818;
    --code: #171717;
    --code-foreground: #ffffff;
    --accent: #1748c2;
    --link: #7398ff;
    --on-accent: #ffffff;
}

* { box-sizing: border-box; }

html {
    font-size: 62.5%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--foreground);
    background: var(--background);
    font: 400 1.7rem/1.65 "Inter", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    transition: color .2s ease, background-color .2s ease;
}

::selection {
    color: var(--on-accent);
    background: var(--accent);
}

a {
    color: inherit;
    text-decoration-thickness: .08em;
    text-underline-offset: .18em;
}

img { display: block; max-width: 100%; }
button, input { color: inherit; font: inherit; }
.site-shell { min-height: 100vh; }
.outer { padding-inline: 3.2rem; }
.outer-wide { max-width: 144rem; margin-inline: auto; padding-inline: 3.2rem; }
.inner { width: min(100%, 132rem); margin-inline: auto; }
.skip-link { position: fixed; z-index: 100; top: -10rem; left: 1.6rem; padding: .8rem 1.2rem; color: #fff; background: #0e0e0e; }
.skip-link:focus { top: 1.6rem; }
.eyebrow { margin: 0 0 1.6rem; color: var(--accent); font: 700 1.1rem/1.2 "Space Mono", monospace; letter-spacing: .06em; text-transform: uppercase; }

/* Header */
.site-header { position: relative; z-index: 30; border-bottom: 1px solid var(--line); background: var(--background); }
.header-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; min-height: 10rem; align-items: center; gap: 4.8rem; }
.site-mark { display: block; width: 11.6rem; text-decoration: none; }
.site-mark img { width: 100%; height: auto; }
.site-nav, .site-nav .nav { display: flex; align-items: center; }
.site-nav { justify-content: center; }
.site-nav .nav { gap: 3rem; margin: 0; padding: 0; list-style: none; }
.site-nav a { font: 400 1.25rem/1 "Space Mono", monospace; text-decoration: none; text-transform: uppercase; }
.site-nav a:hover, .site-nav a:focus { color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: .6rem; }
.icon-button, .nav-toggle { display: grid; width: 4rem; height: 4rem; place-items: center; border: 1px solid var(--line); padding: 0; color: var(--foreground); background: transparent; cursor: pointer; }
.icon-button:hover, .icon-button:focus, .nav-toggle:hover, .nav-toggle:focus { border-color: var(--accent); color: var(--accent); }
.search-button span { position: relative; top: -.1rem; font: 400 2.2rem/1 "Space Mono", monospace; }
.theme-toggle-icon { display: block; width: 1.5rem; height: 1.5rem; border: 1.5px solid currentColor; border-radius: 50%; background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.nav-toggle { display: none; width: auto; padding-inline: 1rem; font: 400 1.1rem/1 "Space Mono", monospace; text-transform: uppercase; }

/* Homepage hero */
.home-hero { padding-block: 6.4rem; border-bottom: 1px solid var(--line); }
.home-hero-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); min-height: 56rem; border: 1px solid var(--line); }
.home-hero-copy { display: flex; min-width: 0; flex-direction: column; justify-content: center; padding: clamp(3.2rem, 5vw, 7.2rem); }
.home-hero-copy h1 { max-width: 66rem; margin: 2rem 0 2.4rem; font: 400 clamp(3.6rem, 4.5vw, 6.8rem)/1.08 "Space Mono", monospace; letter-spacing: -.055em; text-wrap: balance; }
.home-hero-copy h1 a { text-decoration: none; }
.home-hero-copy h1 a:hover { color: var(--accent); }
.home-hero-copy > p { max-width: 58rem; margin: 0; color: var(--muted); font-size: clamp(1.7rem, 1.6vw, 2.1rem); line-height: 1.55; }
.home-hero-author { margin-top: 4rem; font: 400 1.1rem/1.3 "Space Mono", monospace; text-transform: uppercase; }
.home-hero-media { position: relative; min-height: 42rem; overflow: hidden; border-left: 1px solid var(--line); background: var(--accent); }
.home-hero-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .45s ease; }
.home-hero-media:hover img { transform: scale(1.015); }
.home-hero-media.is-empty::after { position: absolute; right: 2.4rem; bottom: 2.4rem; width: 2.4rem; height: 2.4rem; border-right: 1px solid rgba(255,255,255,.8); border-bottom: 1px solid rgba(255,255,255,.8); content: ""; }

/* Shared post metadata */
.post-meta { display: flex; flex-wrap: wrap; gap: .8rem 1.6rem; color: var(--muted); font: 400 1.05rem/1.35 "Space Mono", monospace; text-transform: uppercase; }
.post-meta a { color: var(--accent); }

/* Three-column feed */
.home-feed { padding-block: 6.4rem 9.6rem; }
.post-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5.6rem 2.4rem; }
.post-card { min-width: 0; }
.post-card-image { display: block; aspect-ratio: 4 / 3; overflow: hidden; background: var(--panel); }
.post-card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.post-card:hover .post-card-image img { transform: scale(1.02); }
.post-card-body { padding-top: 2rem; }
.post-card:not(:has(.post-card-image)) .post-card-body { border-top: 1px solid var(--line-strong); }
.post-card h2 { margin: 1.4rem 0 1.2rem; font: 400 clamp(2rem, 2vw, 2.8rem)/1.2 "Space Mono", monospace; letter-spacing: -.035em; }
.post-card h2 a { text-decoration: none; }
.post-card h2 a:hover { color: var(--accent); }
.post-card-body > p { margin: 0; color: var(--muted); font-size: 1.5rem; line-height: 1.55; }
.pagination { display: flex; justify-content: space-between; padding-top: 6rem; font: 400 1.1rem "Space Mono", monospace; text-transform: uppercase; }

/* Article */
.article-header { padding-block: 8rem 6rem; border-bottom: 1px solid var(--line); }
.article-header-inner { max-width: 112rem; }
.article-kicker { min-height: 1.4rem; color: var(--accent); font: 700 1.1rem/1.2 "Space Mono", monospace; text-transform: uppercase; }
.article-header h1 { max-width: 108rem; margin: 3.2rem 0 2.4rem; font: 400 clamp(4rem, 6.6vw, 8.8rem)/1.02 "Space Mono", monospace; letter-spacing: -.065em; text-wrap: balance; }
.article-deck { max-width: 80rem; margin: 0; color: var(--muted); font-size: clamp(1.9rem, 2.2vw, 2.6rem); line-height: 1.5; }
.article-byline { display: flex; justify-content: space-between; margin-top: 5rem; border-top: 1px solid var(--line); padding-top: 1.6rem; color: var(--muted); font: 400 1.05rem/1.35 "Space Mono", monospace; text-transform: uppercase; }
.article-byline div { display: flex; gap: 2rem; }
.article-image { margin-top: 4rem; }
.article-image img { width: 100%; max-height: 82rem; object-fit: cover; }
.article-image figcaption, .gh-content figcaption { margin-top: .8rem; color: var(--muted); font: 400 1.1rem/1.5 "Space Mono", monospace; text-align: center; }
.article-body { display: grid; position: relative; }
.article-body > .article-content, .article-body > .article-toc { grid-area: 1 / 1; }
.article-toc { position: sticky; z-index: 20; top: 2.4rem; width: 4.4rem; height: max-content; align-self: start; justify-self: center; margin-top: 7.2rem; transform: translateX(-42rem); }
.article-toc-toggle { display: grid; width: 4.4rem; height: 4.4rem; place-items: center; border: 0; padding: 0; color: var(--muted); background: transparent; cursor: pointer; }
.article-toc-toggle:hover, .article-toc-toggle:focus-visible, .article-toc.is-open .article-toc-toggle { color: var(--foreground); }
.article-toc-bars { display: flex; width: 2.8rem; flex-direction: column; gap: .45rem; align-items: flex-start; }
.article-toc-bars i { display: block; width: 1.2rem; height: 1px; background: currentColor; transition: width .18s ease; }
.article-toc-bars i:nth-child(2), .article-toc-bars i:nth-child(5) { width: 2rem; }
.article-toc-bars i:nth-child(3) { width: 2.8rem; }
.article-toc-bars i:nth-child(4) { width: 2.4rem; }
.article-toc:hover .article-toc-bars i, .article-toc:focus-within .article-toc-bars i, .article-toc.is-open .article-toc-bars i { width: 2.8rem; }
.article-toc-panel { position: absolute; top: 0; left: calc(100% + .8rem); width: 27rem; max-height: min(68vh, 58rem); overflow-y: auto; visibility: hidden; border: 1px solid var(--line); border-radius: 1.6rem; padding: 1.8rem; opacity: 0; background: var(--panel); box-shadow: 0 1.6rem 4rem rgba(0,0,0,.16); transform: translateX(-.8rem); transition: opacity .18s ease, transform .18s ease, visibility .18s; }
.article-toc:hover .article-toc-panel, .article-toc:focus-within .article-toc-panel, .article-toc.is-open .article-toc-panel { visibility: visible; opacity: 1; transform: translateX(0); }
.article-toc-panel > p { margin: 0 0 1.2rem; color: var(--foreground); font: 700 1.05rem/1.3 "Space Mono", monospace; letter-spacing: .05em; text-transform: uppercase; }
.article-toc-panel ol { display: grid; gap: .15rem; margin: 0; padding: 0; list-style: none; }
.article-toc-panel a { display: block; border-left: 2px solid transparent; padding: .55rem .7rem; color: var(--muted); font: 400 1.2rem/1.4 "Inter", Arial, sans-serif; text-decoration: none; }
.article-toc-panel li[data-level="3"] a { padding-left: 1.7rem; font-size: 1.1rem; }
.article-toc-panel a:hover, .article-toc-panel a:focus-visible { color: var(--foreground); }
.article-toc-panel a.is-active { border-left-color: var(--accent); color: var(--link); }
.article-content { padding-block: 7.2rem; }
.gh-content { font-size: 1.7rem; line-height: 1.76; }
.gh-canvas { display: grid; grid-template-columns: [full-start] minmax(3.2rem, 1fr) [wide-start] minmax(0, 18rem) [main-start] min(72rem, calc(100% - 6.4rem)) [main-end] minmax(0, 18rem) [wide-end] minmax(3.2rem, 1fr) [full-end]; }
.gh-canvas > * { grid-column: main; }
.gh-canvas > .kg-width-wide { grid-column: wide; }
.gh-canvas > .kg-width-full { grid-column: full; }
.gh-content > *:first-child { margin-top: 0; }
.gh-content h2, .gh-content h3, .gh-content h4 { scroll-margin-top: 3rem; font-family: "Space Mono", monospace; font-weight: 700; line-height: 1.22; letter-spacing: -.035em; }
.gh-content h2 { margin: 6rem 0 2rem; font-size: 3.4rem; }
.gh-content h3 { margin: 4.5rem 0 1.5rem; font-size: 2.6rem; }
.gh-content h4 { margin: 3.5rem 0 1.2rem; font-size: 2rem; }
.gh-content p, .gh-content ul, .gh-content ol { margin-block: 0 2.6rem; }
.gh-content a { color: var(--link); }
.gh-content blockquote { margin: 3.2rem 0; border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 1.6rem 1.8rem; background: var(--panel); font-size: 1.55rem; line-height: 1.65; }
.gh-content blockquote strong { font-weight: 600; }
.gh-content figure { margin: 3.6rem 0; }
.gh-content .kg-image { width: 100%; height: auto; }
.gh-content pre { overflow-x: auto; margin-block: 3.2rem; padding: 2.4rem; color: var(--code-foreground); background: var(--code); font: 400 1.35rem/1.65 "Space Mono", monospace; }
.gh-content code { padding: .15em .35em; background: var(--panel); font: .86em "Space Mono", monospace; }
.gh-content pre code { padding: 0; color: inherit; background: transparent; }
.gh-content table { width: 100%; border-collapse: collapse; font-size: 1.5rem; }
.gh-content th, .gh-content td { border-bottom: 1px solid var(--line); padding: 1rem; text-align: left; }
.gh-content .katex-display { overflow-x: auto; overflow-y: hidden; margin-block: 3.2rem; padding-block: .8rem; }
.article-footer { padding-bottom: 7rem; }
.article-footer-inner { display: flex; max-width: 112rem; justify-content: space-between; border-top: 1px solid var(--line-strong); padding-top: 2rem; }
.article-tags, .share-row { display: flex; flex-wrap: wrap; gap: 1.2rem; font: 400 1.05rem "Space Mono", monospace; text-transform: uppercase; }
.share-row > span { color: var(--muted); }
.related { padding-block: 7rem; border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 3rem; }
.section-heading h2 { margin: 0; font: 400 2rem/1 "Space Mono", monospace; text-transform: uppercase; }

/* Archives, pages, errors */
.archive-header, .error-page { padding-block: 8rem; border-bottom: 1px solid var(--line); }
.archive-header h1, .error-page h1 { max-width: 96rem; margin: 0; font: 400 clamp(4rem, 6vw, 8rem)/1.05 "Space Mono", monospace; letter-spacing: -.055em; }
.archive-header p:not(.eyebrow), .error-page p:not(.eyebrow) { max-width: 70rem; color: var(--muted); font-size: 2rem; }
.author-header { display: flex; align-items: center; gap: 3rem; }
.author-image { width: 12rem; aspect-ratio: 1; border-radius: 50%; object-fit: cover; filter: grayscale(1); }
.button { display: inline-flex; width: max-content; border: 1px solid currentColor; padding: 1rem 1.6rem; font: 400 1.1rem "Space Mono", monospace; text-decoration: none; text-transform: uppercase; }
.button:hover { border-color: var(--accent); color: var(--on-accent); background: var(--accent); }
.error-page .button { margin-top: 2rem; }

/* Footer */
.site-footer { padding-block: 3.2rem; border-top: 1px solid var(--line); color: var(--muted); font: 400 1rem/1.4 "Space Mono", monospace; }
.site-footer p { margin: 0; }

@media (max-width: 1050px) {
    .header-row { gap: 2.4rem; }
    .site-nav .nav { gap: 1.8rem; }
    .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .home-hero-grid { min-height: 48rem; }
}

@media (max-width: 1199px) {
    .article-toc { display: none !important; }
}

@media (max-width: 800px) {
    .outer, .outer-wide { padding-inline: 2rem; }
    .header-row { grid-template-columns: auto 1fr auto; min-height: 7.2rem; gap: 1.6rem; }
    .site-mark { width: 7.8rem; }
    .header-actions { justify-self: end; }
    .nav-toggle { display: grid; }
    .site-nav { grid-column: 1 / -1; display: none; width: calc(100% + 4rem); margin-inline: -2rem; border-top: 1px solid var(--line); padding: .8rem 2rem 1.6rem; background: var(--background); }
    .site-nav.is-open, .site-nav .nav { display: flex; }
    .site-nav .nav { width: 100%; flex-direction: column; align-items: flex-start; gap: 0; }
    .site-nav li { width: 100%; border-bottom: 1px solid var(--line); }
    .site-nav li:last-child { border-bottom: 0; }
    .site-nav a { display: block; padding-block: 1.4rem; }
    .home-hero { padding-block: 2rem 4.8rem; }
    .home-hero-grid { grid-template-columns: 1fr; min-height: 0; }
    .home-hero-copy { padding: 4rem 2.4rem; }
    .home-hero-copy h1 { font-size: clamp(3.1rem, 10vw, 5rem); }
    .home-hero-media { order: -1; min-height: 0; aspect-ratio: 4 / 3; border-bottom: 1px solid var(--line); border-left: 0; }
    .home-feed { padding-block: 4.8rem 7rem; }
    .article-header { padding-block: 5rem 4rem; }
    .article-byline, .article-footer-inner { flex-direction: column; gap: 1.5rem; }
    .article-byline div { flex-direction: column; gap: .6rem; }
    .gh-canvas { grid-template-columns: [full-start] 2rem [wide-start main-start] minmax(0, 1fr) [main-end wide-end] 2rem [full-end]; }
    .gh-content { font-size: 1.65rem; line-height: 1.72; }
}

@media (max-width: 620px) {
    .post-grid { grid-template-columns: 1fr; gap-block: 4.8rem; }
    .icon-button { width: 3.8rem; height: 3.8rem; }
    .article-header h1 { font-size: clamp(3.5rem, 11vw, 5.6rem); }
    .article-content { padding-block: 5rem; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; }
}
