/* ximi — a quiet reading theme. Tokens only; no colour or face is used below outside this block. */

@font-face {
    font-family: "Garamond Pro";
    src: url("../fonts/eb-garamond-roman.woff2") format("woff2");
    font-weight: 400 600;
    font-style: normal;
    font-display: swap;
}

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

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

:root {
    --paper: #faf8f3;
    --paper-soft: #f2eee4;
    --code-bg: #f0ece2;
    --ink: #1b1a17;
    --ink-soft: #3d3a34;
    --muted: #6f6a5f;
    --rule: #e0dbcd;
    --accent: #a4503a;
    --accent-soft: #f3e6df;

    --font-display: "Garamond Pro", "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
    --font-body: "Inter Text", "Noto Sans SC", "Noto Sans CJK SC", "Source Han Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --font-serif: "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", var(--font-display);
    --font-mono: "Jet Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --measure: 38em;
    --wrap: 44rem;
    --gutter: clamp(1.25rem, 5vw, 2.5rem);
    --step-0: 1.0625rem;
    --step-1: 1.2rem;
    --step-2: 1.45rem;
    --step-3: 1.85rem;
    --step-4: clamp(1.95rem, 4.4vw, 2.6rem);
    --radius: 3px;
}

[data-theme="dark"] {
    --paper: #161513;
    --paper-soft: #1e1d19;
    --code-bg: #201e1a;
    --ink: #e9e4da;
    --ink-soft: #cdc7bb;
    --muted: #9a9385;
    --rule: #2e2c27;
    --accent: #d68a6a;
    --accent-soft: #2a2320;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #161513;
        --paper-soft: #1e1d19;
        --code-bg: #201e1a;
        --ink: #e9e4da;
        --ink-soft: #cdc7bb;
        --muted: #9a9385;
        --rule: #2e2c27;
        --accent: #d68a6a;
        --accent-soft: #2a2320;
    }
}

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

html {
    overflow-x: clip;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    overflow-x: clip;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: 1.9;
    font-synthesis: none;
    -webkit-font-smoothing: antialiased;
    text-autospace: normal;
    text-spacing-trim: normal;
}

:lang(zh) {
    line-break: strict;
    word-break: normal;
    overflow-wrap: anywhere;
}

:lang(zh) :is(h1, h2, h3) {
    text-spacing-trim: trim-start;
    word-break: keep-all;
    overflow-wrap: break-word;
    letter-spacing: 0;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
    text-decoration-color: var(--rule);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.22em;
    transition: color 140ms ease, text-decoration-color 140ms ease;
}

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

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 2px;
}

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.wrap--post {
    max-width: calc(var(--measure) + var(--gutter) * 2);
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--ink);
    color: var(--paper);
    padding: 0.6em 1em;
    z-index: 20;
    text-decoration: none;
}

.skip-link:focus {
    left: 1rem;
    top: 1rem;
}

/* progress */

.progress {
    position: fixed;
    inset: 0 0 auto 0;
    height: 2px;
    background: transparent;
    z-index: 10;
    pointer-events: none;
}

.progress span {
    display: block;
    height: 100%;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 80ms linear;
    opacity: 0.85;
}

/* header */

.site-header {
    padding-block: 1.9rem 0;
}

.site-header__inner {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.wordmark {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    color: var(--ink);
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.35rem;
    font-size: 0.875rem;
}

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

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

.site-nav__rss {
    letter-spacing: 0.04em;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color 140ms ease, background-color 140ms ease;
}

.theme-toggle:hover {
    color: var(--ink);
    background: var(--paper-soft);
}

.theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun {
        display: block;
    }

    :root:not([data-theme="light"]) .theme-toggle .icon-moon {
        display: none;
    }
}

/* main */

.site-main {
    padding-block: clamp(3rem, 8vw, 5.5rem) clamp(4rem, 9vw, 6rem);
}

.masthead {
    padding-bottom: 2.6rem;
    border-bottom: 1px solid var(--rule);
}

.masthead__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(2.1rem, 5vw, 2.9rem);
    font-weight: 600;
    line-height: 1.25;
    max-width: 14em;
}

.masthead__desc {
    margin: 0.9rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
    max-width: 32em;
}

.masthead__label {
    margin: 0 0 0.6rem;
    color: var(--muted);
    font-size: 0.8125rem;
}

.masthead__count {
    margin: 0.9rem 0 0;
    color: var(--muted);
    font-size: 0.8125rem;
}

.masthead--archive .masthead__title {
    font-size: clamp(1.7rem, 4vw, 2.2rem);
}

/* entries */

.entries {
    display: flex;
    flex-direction: column;
}

.entry {
    border-bottom: 1px solid var(--rule);
}

.entry:last-of-type {
    border-bottom: none;
}

.entry__link {
    display: grid;
    grid-template-columns: 7.5rem minmax(0, 1fr);
    grid-template-areas:
        "date title"
        "date excerpt";
    gap: 0.5rem 1.5rem;
    padding-block: 1.85rem;
    text-decoration: none;
}

.entry__date {
    grid-area: date;
    color: var(--muted);
    font-size: 0.8125rem;
    line-height: 2.1;
    font-variant-numeric: tabular-nums;
}

.entry__title {
    grid-area: title;
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.4;
    transition: color 140ms ease;
}

.entry__link:hover .entry__title {
    color: var(--accent);
}

.entry__excerpt {
    grid-area: excerpt;
    margin: 0;
    color: var(--muted);
    font-size: 0.9375rem;
    line-height: 1.8;
    max-width: 36em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.entries__empty {
    margin: 0;
    padding-block: 2.6rem;
    color: var(--muted);
    font-size: 0.9375rem;
    border-bottom: 1px solid var(--rule);
}

/* post */

.post__header {
    margin-bottom: 2.2rem;
}

.post__kicker {
    display: inline-block;
    margin-bottom: 1.1rem;
    color: var(--accent);
    font-size: 0.8125rem;
    text-decoration: none;
    letter-spacing: 0.02em;
}

.post__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--step-4);
    font-weight: 600;
    line-height: 1.32;
    text-wrap: balance;
}

.post__title--page {
    font-size: clamp(1.75rem, 3.6vw, 2.2rem);
}

.post__standfirst {
    margin: 1.1rem 0 0;
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--ink-soft);
    font-family: var(--font-serif);
    max-width: 34em;
}

.post__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.1rem;
    margin: 1.5rem 0 0;
    color: var(--muted);
    font-size: 0.8125rem;
}

.post__figure {
    margin: 0 0 2.4rem;
}

.post__figure img {
    display: block;
    width: 100%;
    border-radius: var(--radius);
}

.post__figure figcaption {
    margin-top: 0.7rem;
    color: var(--muted);
    font-size: 0.8125rem;
    text-align: center;
}

.post__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 3rem;
}

.post__tags a {
    padding: 0.25em 0.7em;
    border: 1px solid var(--rule);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.8125rem;
    text-decoration: none;
    transition: color 140ms ease, border-color 140ms ease;
}

.post__tags a:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.post__pager {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.5rem;
    margin-top: 3.4rem;
    padding-top: 1.8rem;
    border-top: 1px solid var(--rule);
}

.post__pager-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    text-decoration: none;
}

.post__pager-item--next {
    text-align: right;
}

.post__pager-label {
    color: var(--muted);
    font-size: 0.75rem;
}

.post__pager-title {
    font-family: var(--font-display);
    font-size: 1rem;
    line-height: 1.5;
}

/* prose */

.prose {
    font-size: var(--step-0);
    line-height: 1.95;
    text-align: justify;
    text-justify: inter-ideograph;
}

.body--serif .prose {
    font-family: var(--font-serif);
}

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

.prose p {
    margin: 0 0 1.4em;
}

.prose :is(h2, h3, h4) {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.45;
    margin: 2.4em 0 0.9em;
    text-align: left;
}

.prose h2 {
    font-size: var(--step-2);
}

.prose h3 {
    font-size: var(--step-1);
}

.prose h4 {
    font-size: 1rem;
}

.prose a {
    color: var(--ink);
    text-decoration-color: var(--accent);
}

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

.prose strong {
    font-weight: 700;
}

.prose em {
    font-style: normal;
    text-emphasis: filled dot;
    text-emphasis-position: under right;
}

.prose blockquote {
    margin: 2em 0;
    padding: 0.1em 0 0.1em 1.3em;
    border-left: 2px solid var(--accent);
    color: var(--ink-soft);
}

.prose blockquote p:last-child {
    margin-bottom: 0;
}

.prose :is(ul, ol) {
    margin: 0 0 1.4em;
    padding-left: 1.5em;
}

.prose li {
    margin-bottom: 0.45em;
}

.prose li::marker {
    color: var(--muted);
}

.prose hr {
    margin: 3em auto;
    width: 4.5rem;
    border: none;
    border-top: 1px solid var(--rule);
}

.prose img {
    display: block;
    margin: 2em auto;
    border-radius: var(--radius);
}

.prose figure {
    margin: 2em 0;
}

.prose figcaption {
    margin-top: 0.7rem;
    color: var(--muted);
    font-size: 0.8125rem;
    text-align: center;
}

.prose code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    padding: 0.12em 0.35em;
    border-radius: 2px;
    background: var(--code-bg);
}

.prose pre {
    margin: 2em 0;
    padding: 1.15rem 1.25rem;
    background: var(--code-bg);
    border-radius: var(--radius);
    overflow-x: auto;
    line-height: 1.75;
    font-size: 0.875rem;
    text-align: left;
}

.prose pre code {
    padding: 0;
    background: none;
    font-size: inherit;
}

.prose table {
    width: 100%;
    margin: 2em 0;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.prose th,
.prose td {
    padding: 0.6em 0.8em;
    border-bottom: 1px solid var(--rule);
    text-align: left;
}

.prose th {
    font-weight: 600;
    color: var(--ink-soft);
}

/* ghost cards */

.kg-width-wide {
    width: min(52rem, 100vw - 2 * var(--gutter));
    margin-inline: calc(50% - min(26rem, (100vw - 2 * var(--gutter)) / 2));
}

.kg-width-full {
    width: calc(100vw - 2 * var(--gutter));
    margin-inline: calc(50% - (100vw - 2 * var(--gutter)) / 2);
}

.kg-gallery-container,
.kg-gallery-card {
    margin: 2em 0;
}

.kg-gallery-row {
    display: flex;
    gap: 0.4rem;
}

.kg-gallery-image img {
    margin: 0;
    border-radius: 2px;
}

.kg-embed-card {
    margin: 2em 0;
    text-align: center;
}

.kg-embed-card iframe {
    max-width: 100%;
    border-radius: var(--radius);
}

.kg-bookmark-card {
    margin: 2em 0;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    text-align: left;
}

.kg-bookmark-container {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.15rem;
    text-decoration: none;
    color: inherit;
}

.kg-bookmark-content {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.kg-bookmark-title {
    font-family: var(--font-display);
    font-size: 1rem;
    line-height: 1.5;
}

.kg-bookmark-description {
    color: var(--muted);
    font-size: 0.8125rem;
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kg-bookmark-metadata {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--muted);
    font-size: 0.75rem;
}

.kg-bookmark-icon {
    width: 16px;
    height: 16px;
    margin: 0;
}

.kg-bookmark-thumbnail {
    width: 6.5rem;
    flex: 0 0 auto;
}

.kg-bookmark-thumbnail img {
    margin: 0;
    height: 100%;
    object-fit: cover;
    border-radius: 2px;
}

.kg-callout-card {
    margin: 2em 0;
    padding: 1.1rem 1.25rem;
    border-radius: var(--radius);
    background: var(--paper-soft);
    text-align: left;
}

.kg-callout-card-accent {
    border-left: 3px solid var(--accent);
}

.kg-callout-emoji {
    display: none;
}

.kg-toggle-card {
    margin: 2em 0;
    padding: 1rem 1.2rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    text-align: left;
}

.kg-toggle-heading-text {
    font-family: var(--font-display);
    font-size: 1rem;
}

/* pagination */

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 1.6rem;
    border-top: 1px solid var(--rule);
    font-size: 0.875rem;
    color: var(--muted);
}

.pager__link {
    text-decoration: none;
    color: var(--muted);
    transition: color 140ms ease;
}

.pager__link:hover {
    color: var(--ink);
}

.pager__link--off {
    opacity: 0.4;
}

.pager__count {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}

/* footer */

.site-footer {
    border-top: 1px solid var(--rule);
    padding-block: 2.6rem 3.4rem;
}

.site-footer__note {
    margin: 0 0 1rem;
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--ink-soft);
}

.site-footer__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.2rem;
    margin: 0;
    color: var(--muted);
    font-size: 0.8125rem;
}

.site-footer__meta a {
    text-decoration: none;
}

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

/* error */

.site-main--error {
    min-height: 52vh;
}

.error__code {
    margin: 0;
    font-family: var(--font-display);
    font-size: 3.2rem;
    line-height: 1;
    color: var(--accent);
}

.error__title {
    margin: 0.8rem 0 0;
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 600;
}

.error__hint {
    color: var(--muted);
    font-size: 0.9375rem;
}

.error__link {
    text-decoration-color: var(--accent);
}

/* responsive */

@media (max-width: 40rem) {
    .entry__link {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "date"
            "title"
            "excerpt";
        gap: 0.4rem;
        padding-block: 1.5rem;
    }

    .entry__date {
        line-height: 1.6;
    }

    .post__pager {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.2rem;
    }

    .post__pager-item--next {
        text-align: left;
    }

    .prose {
        text-align: left;
    }
}

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

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

@media print {
    .site-nav,
    .progress,
    .post__pager,
    .site-footer {
        display: none;
    }

    body {
        background: #fff;
        color: #000;
    }
}
