* {
    box-sizing: border-box;
}

:root {
    --bg0-hard: #1d2021;
    --bg0: #282828;
    --bg1: #3c3836;
    --bg2: #504945;
    --gray: #928374;
    --fg0: #fbf1c7;
    --fg1: #ebdbb2;
    --fg2: #d5c4a1;
    --fg3: #bdae93;
    --fg4: #a89984;
    --yellow: #fabd2f;
}

body {
    background-color: var(--bg0);
    color: var(--fg1);
    font-family: 'Fira Mono', monospace;
    font-size: 1rem;
    line-height: 1.65;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.container {
    min-height: 100vh;
}

main {
    width: min(100%, 1040px);
    margin: 0 auto;
    padding: 1.5rem clamp(1.25rem, 4vw, 4rem) 4rem;
}

.site-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 1.5rem;
    margin-bottom: clamp(3rem, 8vw, 5rem);
}

.brand {
    display: inline-flex;
    grid-column: 2;
    align-items: center;
    flex-direction: column;
    gap: 0.9rem;
    color: var(--fg2);
    font-size: clamp(1.8rem, 3.2vw, 2.35rem);
    line-height: 1;
    margin-top: 1.6rem;
    text-align: center;
}

.brand-mark {
    display: block;
    width: clamp(6.25rem, 11vw, 9rem);
    height: auto;
    margin: 0;
}

.site-links {
    display: flex;
    grid-column: 3;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.9rem;
    font-size: 0.85rem;
    justify-self: end;
}

.intro {
    max-width: 720px;
    margin: 0 auto;
}

.tagline {
    margin: 0 0 clamp(2rem, 5vw, 3rem);
    color: var(--fg2);
    font-size: clamp(1.05rem, 1.9vw, 1.35rem);
    line-height: 1.45;
    text-align: center;
}

.about {
    color: var(--fg2);
    font-size: clamp(1rem, 1.6vw, 1.12rem);
    line-height: 1.75;
}

.collaborators,
.contact {
    max-width: 720px;
    margin: clamp(3rem, 8vw, 5rem) auto 0;
    padding-top: 1.25rem;
    border-top: 1px solid var(--bg2);
}

.collaborators h2,
.contact h2 {
    margin: 0 0 1.5rem;
    color: var(--fg4);
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.4;
}

.collaborator-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: clamp(1.5rem, 4vw, 3rem);
    align-items: center;
}

.collaborator-link {
    display: inline-flex;
    width: fit-content;
    min-width: 0;
    align-items: center;
    gap: 0.65rem;
    color: var(--fg4);
    font-size: 0.72rem;
    line-height: 1.3;
    opacity: 0.72;
    white-space: nowrap;
}

.collaborator-link:hover {
    opacity: 1;
    text-decoration: none;
}

.collaborator-link img {
    width: auto;
    max-width: 100%;
    height: 1.75rem;
    margin: 0;
}

.collaborator-logo-invert img {
    filter: invert(1);
}

.contact address {
    color: var(--fg2);
    font-size: 1rem;
    font-style: normal;
}

.blog-index {
    max-width: 960px;
    margin: 0 auto;
}

.article {
    max-width: 760px;
    margin: 0 auto;
}

.section-kicker,
.back-link,
.article-header time,
.post-date {
    color: var(--fg4);
    font-size: 0.82rem;
}

.section-kicker {
    margin-bottom: 1rem;
}

.article-header h1 {
    max-width: 720px;
    margin: 0 0 clamp(2rem, 5vw, 3rem);
    color: var(--fg0);
    font-size: clamp(1.6rem, 4vw, 2.65rem);
    line-height: 1.18;
}

.featured-posts {
    margin-top: 0;
}

.latest-posts {
    margin-top: clamp(2.5rem, 6vw, 4rem);
}

.featured-posts h2,
.latest-posts h2 {
    margin: 0 0 1.2rem;
    color: var(--fg0);
    font-size: 1rem;
    line-height: 1.4;
}

.featured-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(1.5rem, 3vw, 2.35rem);
}

.featured-card {
    padding-top: 1rem;
    border-top: 1px solid var(--bg2);
}

.featured-image,
.post-thumb {
    display: block;
    overflow: hidden;
    border: 1px solid var(--bg2);
    background: var(--bg0-hard);
}

.featured-image {
    aspect-ratio: 16 / 10;
    margin-bottom: 1rem;
}

.featured-image img,
.post-thumb img {
    width: 100%;
    max-width: none;
    height: 100%;
    margin: 0;
    object-fit: cover;
}

.featured-image.image-contain img,
.post-thumb.image-contain img {
    padding: clamp(0.75rem, 2vw, 1.35rem);
    object-fit: contain;
}

.featured-card h3 {
    margin: 0.55rem 0 0.6rem;
    color: var(--fg0);
    font-size: clamp(1.1rem, 2vw, 1.35rem);
    line-height: 1.32;
}

.featured-card p {
    color: var(--fg2);
    font-size: 0.98rem;
}

.featured-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 1rem;
    color: var(--fg4);
    font-size: 0.78rem;
    line-height: 1.4;
}

.featured-meta time {
    color: var(--gray);
    font-size: 0.68rem;
    text-align: right;
    white-space: nowrap;
}

.post-taxonomy {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    color: var(--fg4);
    line-height: 1.4;
}

.tag-link {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    padding: 0.1rem 0.42rem;
    border: 1px solid var(--bg2);
    border-radius: 2px;
    color: var(--fg3);
    font-size: 0.7rem;
    line-height: 1.2;
}

.tag-link::before {
    content: "#";
    margin-right: 0.12rem;
    color: var(--gray);
}

.tag-link:hover,
.tag-link.is-current {
    border-color: var(--fg4);
    background: var(--bg1);
    color: var(--fg0);
    text-decoration: none;
}

.post-list {
    border-top: 1px solid var(--bg2);
}

.post-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(1.35rem, 3vw, 2.25rem);
    padding: clamp(1.75rem, 4vw, 2.5rem) 0;
    border-bottom: 1px solid var(--bg2);
}

.post-row.has-image {
    grid-template-columns: minmax(18rem, 0.92fr) minmax(0, 1fr);
    align-items: center;
}

.post-thumb {
    aspect-ratio: 16 / 9;
}

.post-copy {
    min-width: 0;
}

.post-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 1rem;
}

.post-date {
    color: var(--gray);
    font-size: 0.68rem;
    line-height: 1.4;
    text-align: right;
    white-space: nowrap;
}

.post-row h2,
.post-row h3 {
    margin: 0.55rem 0 0.65rem;
    color: var(--fg0);
    font-size: clamp(1.12rem, 2vw, 1.35rem);
    line-height: 1.35;
}

.post-row p {
    color: var(--fg2);
    font-size: 0.98rem;
}

.article-header {
    margin-bottom: clamp(2rem, 5vw, 3rem);
}

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
}

.article-header time {
    display: block;
}

.article-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 1rem;
}

.article-meta time {
    color: var(--gray);
    font-size: 0.68rem;
    text-align: right;
    white-space: nowrap;
}

.archive-header {
    margin-bottom: clamp(2rem, 5vw, 3rem);
}

.archive-header h1 {
    margin: 0 0 0.45rem;
    color: var(--fg0);
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    line-height: 1.2;
}

.archive-header p {
    margin: 0;
    color: var(--fg4);
    font-size: 0.85rem;
}

.tag-prefix {
    color: var(--yellow);
}

.tag-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--bg2);
}

.tag-directory-link {
    display: flex;
    min-height: 4rem;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-right: 1px solid var(--bg2);
    border-bottom: 1px solid var(--bg2);
    color: var(--fg2);
}

.tag-directory-link:nth-child(even) {
    border-right: 0;
}

.tag-directory-link:hover {
    background: var(--bg1);
    color: var(--fg0);
    text-decoration: none;
}

.tag-name::before {
    content: "#";
    margin-right: 0.2rem;
    color: var(--yellow);
}

.tag-count {
    color: var(--gray);
    font-size: 0.7rem;
    white-space: nowrap;
}

.article-content {
    color: var(--fg2);
    font-size: clamp(1rem, 1.6vw, 1.12rem);
    line-height: 1.78;
}

.article-content h2 {
    margin: 2.75rem 0 1rem;
    color: var(--fg0);
    font-size: clamp(1.2rem, 2vw, 1.45rem);
    line-height: 1.35;
}

.article-content h3 {
    margin: 2rem 0 0.8rem;
    color: var(--fg2);
    font-size: clamp(1.05rem, 1.7vw, 1.2rem);
    line-height: 1.4;
}

.article-content .math {
    color: var(--fg0);
}

.article-content div.math {
    width: 100%;
    margin: 1.4rem 0;
    overflow-x: auto;
    text-align: center;
}

.article-content div.math .MathJax_Display {
    width: max-content;
    min-width: 100%;
    margin-right: auto !important;
    margin-left: auto !important;
    text-align: center !important;
}

.article-content p:has(> img:only-child),
.article-content .image-frame {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    margin: 2rem 0;
    padding: clamp(1rem, 3vw, 2rem);
    overflow: hidden;
    border: 1px solid var(--bg2);
    background: var(--bg0-hard);
}

.article-content p:has(> img:only-child) > img,
.article-content .image-frame > img {
    width: auto;
    max-width: 100%;
    height: auto;
    margin: 0;
    border: 0;
    background: transparent;
}

.article-content .image-frame.image-wide > img {
    width: 100%;
}

h1, h2, h3 {
    color: var(--yellow);
    margin-top: 1rem;
    font-size: 2.2rem;
}

p {
    margin: 0 0 1.4rem;
}

a {
    color: var(--yellow);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

img {
    width: 100%;
    max-width: 400px;
    height: auto;
    display: block;
    margin: 0 auto 2rem auto;
}

@media (max-width: 640px) {
    main {
        padding-top: 1.25rem;
    }

    .site-header {
        display: flex;
        align-items: center;
        flex-direction: column;
        gap: 1.25rem;
        margin-bottom: 3rem;
    }

    .site-links {
        justify-content: flex-start;
        justify-self: auto;
    }

    .brand {
        margin-top: 0;
    }

    .brand-mark {
        width: 5.75rem;
    }

    .tagline {
        text-align: left;
    }

    .post-row {
        display: block;
    }

    .post-thumb {
        max-width: none;
        margin: 0 0 1rem;
    }

    .post-meta {
        display: block;
    }

    .article-meta {
        display: block;
    }

    .article-meta time {
        margin-top: 0.65rem;
        text-align: left;
    }

    .featured-meta {
        display: block;
    }

    .featured-meta time {
        display: block;
        margin-top: 0.45rem;
        text-align: left;
    }

    .post-date {
        display: block;
        margin-top: 0.45rem;
        text-align: left;
    }

    .featured-grid {
        display: block;
    }

    .featured-card + .featured-card {
        margin-top: 1.75rem;
    }

    .tag-grid {
        display: block;
    }

    .tag-directory-link,
    .tag-directory-link:nth-child(even) {
        border-right: 0;
    }
}
