:root {
    color-scheme: dark;

    --bg: #2d2d2d;
    --panel: #262626;
    --text: #e3e3e3;
    --muted: #a0a0a0;
    --border: #444444;
    --accent: #c78f8f;
    --accent-gradient-end: #927da8;
    --accent-gradient: linear-gradient(90deg, var(--accent), var(--accent-gradient-end));
    --code-bg: #232323;

    --max-width: 960px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scrollbar-gutter: stable both-edges;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family:
        ui-monospace,
        "cascadia code",
        "sfmono-regular",
        consolas,
        "liberation mono",
        monospace;
    font-size: 16px;
    line-height: 1.72;
	font-weight: 300;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.site-header,
.site-footer {
    width: 100%;
}

.header-inner,
.footer-inner,
.site-main {
    width: min(calc(100% - 40px), var(--max-width));
    margin: 0 auto;
}

.header-inner {
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid var(--border);
}

.site-name {
    color: var(--text);
    font-weight: 700;
    letter-spacing: 0.02em;
    font-size: 1.5rem;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.site-nav a {
    color: var(--muted);
}

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

.site-main {
    min-height: calc(100vh - 180px);
    padding: 64px 0 90px;
}

.intro {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    align-items: center;
    gap: 28px;
    margin-bottom: 56px;
    padding-bottom: 32px;
    background: var(--accent-gradient) left bottom / 100% 2px no-repeat;
}

.intro-mark {
    height: 88px;
    display: flex;
    align-items: center;
}

.intro-et {
    display: block;
    width: 72px;
    height: auto;
    color: var(--accent);
}

.intro-et .alien-gradient-start {
    stop-color: var(--accent);
}

.intro-et .alien-gradient-end {
    stop-color: var(--accent-gradient-end);
}

.post-header h1,
.list-page h1 {
    margin: 0 0 12px;
    color: #efefef;
    font-size: clamp(1.7rem, 5vw, 2.5rem);
    line-height: 1.2;
}

.intro h1 {
    max-width: 24ch;
    margin: 0 0 12px;
    color: #efefef;
    font-size: clamp(2rem, 4vw, 3.25rem);
    line-height: 1.12;
    letter-spacing: -0.04em;
}

.intro p {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.post-preview {
    padding: 0 0 56px;
    margin: 0 0 56px;
    border-bottom: 1px solid var(--border);
}

.post-preview h2 {
    margin: 0 0 10px;
    font-size: 1.55rem;
    line-height: 1.3;
}

.post-preview h2 a,
.post-header h1 {
    color: #ededed;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    color: var(--muted);
    font-size: 0.88rem;
}

.post-summary {
    color: #c8c8c8;
}

.read-more {
    display: inline-block;
    margin-top: 12px;
}

.post {
    max-width: 100%;
}

.post-header {
    margin-bottom: 48px;
}

.post-content {
    overflow-wrap: anywhere;
}

.post-content h2,
.post-content h3,
.post-content h4 {
    margin-top: 2.1em;
    margin-bottom: 0.7em;
    color: #ececec;
    line-height: 1.3;
}

.post-content h2 {
    font-size: 1.45rem;
}

.post-content h3 {
    font-size: 1.18rem;
}

.post-content p,
.post-content ul,
.post-content ol,
.post-content blockquote {
    margin-top: 0;
    margin-bottom: 1.35em;
}

.post-content blockquote {
    margin-left: 0;
    padding: 0.1em 0 0.1em 1.1em;
    color: #aaaaaa;
    border-left: 3px solid var(--border);
}

.post-content blockquote > :last-child {
    margin-bottom: 0;
}

.post-content :not(pre) > code {
    padding: 0.15em 0.38em;
    background: var(--code-bg);
    border: 1px solid #292929;
    border-radius: 4px;
    font-size: 0.92em;
}

.post-content pre {
    overflow-x: auto;
    margin: 1.6em 0;
    padding: 18px 20px;
    background: var(--code-bg) !important;
    border: 1px solid var(--border);
    border-radius: 5px;
    line-height: 1.55;
}

.post-content pre code {
    font-size: 0.9rem;
}

/* Semantic code is colored by hand in the post markup. */
.post-content pre.semantic-code {
    color: var(--text);
}

.semantic-code .sh-keyword,
.semantic-code .sh-preprocessor {
    color: #c78f8f;
}

.semantic-code .sh-macro {
    color: #d4a6a6;
}

.semantic-code .sh-type-primitive {
    color: #9bbfd4;
}

.semantic-code .sh-type-alias {
    color: #a8c9da;
}

.semantic-code .sh-type-struct,
.semantic-code .sh-type-class,
.semantic-code .sh-type-union,
.semantic-code .sh-type-enum,
.semantic-code .sh-type-concept {
    color: #b3acd6;
    font-weight: 500;
}

.semantic-code .sh-type-template-param {
    color: #c1b8dc;
}

.semantic-code .sh-enum-member {
    color: #d4b985;
}

.semantic-code .sh-number,
.semantic-code .sh-boolean,
.semantic-code .sh-null {
    color: #d8ab87;
}

.semantic-code .sh-string,
.semantic-code .sh-character {
    color: #c4b77f;
}

.semantic-code .sh-function,
.semantic-code .sh-method,
.semantic-code .sh-constructor,
.semantic-code .sh-destructor {
    color: #b7a6d8;
}

.semantic-code .sh-namespace {
    color: #a9a0d0;
}

.semantic-code .sh-field {
    color: #91c2ba;
}

.semantic-code .sh-static-field,
.semantic-code .sh-global {
    color: #a7ccc3;
}

.semantic-code .sh-parameter {
    color: #dfc5ad;
}

.semantic-code .sh-local {
    color: #e3e3e3;
}

.semantic-code .sh-label,
.semantic-code .sh-register {
    color: #adbeda;
}

.semantic-code .sh-instruction {
    color: #c78f8f;
}

.semantic-code .sh-comment {
    color: #9ca49f;
}

.article-image {
    margin: 2.2em auto;
    text-align: center;
}

.article-image img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    background: transparent;
}

.article-image figcaption {
    margin-top: 0.65em;
    color: var(--muted);
    font-size: 0.85rem;
}

.post-content table {
    width: 100%;
    display: block;
    overflow-x: auto;
    border-collapse: collapse;
    margin: 1.6em 0;
}

.post-content th,
.post-content td {
    padding: 8px 12px;
    border: 1px solid var(--border);
    text-align: left;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 2.5em 0;
}

.simple-list {
    margin: 32px 0 0;
    padding: 0;
    list-style: none;
}

.simple-list li {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 14px;
    margin: 12px 0;
}

.simple-list time {
    color: var(--muted);
}

.pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: center;
    color: var(--muted);
}

.pagination a:last-child {
    text-align: right;
}

.footer-inner {
    min-height: 80px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    color: var(--muted);
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
}

.site-main.about-main {
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
}

.about-city {
    position: relative;
    display: block;
    flex-shrink: 0;
    width: 100%;
    height: auto;
    margin: auto auto 0;
    image-rendering: pixelated;
}

.about-city > svg {
    display: block;
    width: 100%;
    height: auto;
}

.city-activity {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    image-rendering: pixelated;
}

.about-city > .city-foreground {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.about-city-footer .footer-inner {
    border-top: 0;
}

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

.footer-links a {
    color: var(--muted);
}

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

/*
 * Heading permalinks.
 *
 * The # is absolutely positioned outside the content column,
 * so revealing it does not move the heading text.
 */

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    position: relative;
}

.heading-anchor {
    position: absolute;
    right: 100%;
    margin-right: 0.35rem;

    color: var(--muted);
    text-decoration: none;

    opacity: 0;

    transition:
        opacity 0.15s ease,
        color 0.15s ease;
}

.post-content h1:hover .heading-anchor,
.post-content h2:hover .heading-anchor,
.post-content h3:hover .heading-anchor,
.post-content h4:hover .heading-anchor,
.post-content h5:hover .heading-anchor,
.post-content h6:hover .heading-anchor,
.heading-anchor:focus-visible {
    opacity: 1;
}

.heading-anchor:hover,
.heading-anchor:focus-visible {
    color: var(--accent);
    text-decoration: none;
}

/*
 * Copy button shared by Chroma and plain code blocks.
 */

.post-content .highlight,
.post-content .code-block-wrapper {
    position: relative;
    margin: 1.6em 0;
}

.post-content .highlight pre,
.post-content .code-block-wrapper pre {
    margin: 0;
}

.copy-code-button {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    z-index: 2;

    min-width: 2rem;
    height: 2rem;
    padding: 0 0.45rem;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 1px solid var(--border);
    border-radius: 4px;

    background: #2a2a2a;
    color: var(--muted);

    font-family: inherit;
    font-size: 0.75rem;
    line-height: 1;

    cursor: pointer;
    opacity: 0;

    transition:
        opacity 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease,
        background 0.15s ease;
}

.highlight:hover > .copy-code-button,
.code-block-wrapper:hover > .copy-code-button,
.copy-code-button:focus-visible,
.copy-code-button.copied {
    opacity: 1;
}

.copy-code-button:hover,
.copy-code-button:focus-visible {
    color: var(--text);
    border-color: var(--accent);
}

.copy-code-button.copied {
    width: auto;
    padding: 0 0.6rem;
    color: var(--text);
    border-color: var(--accent);
}

.post-content p {
    text-align: justify;
    text-justify: inter-word;
}

@media (max-width: 620px) {
    .header-inner,
    .footer-inner {
        align-items: flex-start;
        flex-direction: column;
        justify-content: center;
        padding: 18px 0;
    }

    .site-main {
        padding-top: 46px;
    }

    .intro {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .intro-mark {
        height: 72px;
    }

    .simple-list li {
        grid-template-columns: 1fr;
        gap: 2px;
        margin-bottom: 18px;
    }

    /*
     * Don't let the permalink disappear outside the viewport
     * on narrow screens.
     */
    .heading-anchor {
        position: static;
        display: inline-block;
        margin-right: 0.35rem;
    }
}
/* Header minigame easter egg.
 * The normal header row never moves. Activating a game only adds space
 * below that existing 82px row, moving the bottom border downward.
 */
.snake-canvas {
    display: none;
}

@media (hover: hover) and (pointer: fine) {
    .header-inner.snake-active {
        position: relative;
        min-height: 390px;
        padding-bottom: 308px;
    }

    /*
     * Keep the original header divider exactly where it was.
     * Once Snake opens, this becomes the game's upper wall while
     * the real border-bottom moves down and becomes the lower wall.
     */
    .header-inner.snake-active::before {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        top: 81px;
        border-top: 1px solid var(--border);
        pointer-events: none;
        z-index: 2;
    }

    .header-inner.snake-active .snake-canvas {
        display: block;
        position: absolute;
        left: 0;
        top: 82px;
        width: 100%;
        height: calc(100% - 83px);
        outline: none;
    }
}

/* Minigame title loader. Hard color steps; no interpolation or layout movement. */
.site-name .snake-letter {
    color: inherit;
    transition: none;
}

.site-name .snake-letter.snake-loaded {
    color: var(--accent);
}

@supports (background-clip: text) {
    a,
    .site-nav a:hover,
    .footer-links a:hover,
    .heading-anchor:hover,
    .heading-anchor:focus-visible,
    .site-name .snake-letter.snake-loaded {
        color: transparent;
        background-image: var(--accent-gradient);
        background-clip: text;
        -webkit-background-clip: text;
    }

    a:hover {
        text-decoration-color: var(--accent-gradient-end);
    }

    .copy-code-button:hover,
    .copy-code-button:focus-visible {
        border-color: transparent;
        background: linear-gradient(#2a2a2a, #2a2a2a) padding-box,
                    var(--accent-gradient) border-box;
    }
}
