/* 1. 字体定义 */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/InterVariable.woff2') format('woff2');
}

@font-face {
    font-family: 'Inter';
    font-style: italic;
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/InterVariable-Italic.woff2') format('woff2');
}

@font-face {
    font-family: 'Source Serif 4';
    font-style: normal;
    font-weight: 200 900;
    font-display: swap;
    src: url('/fonts/SourceSerif4Variable-Roman.ttf.woff2') format('woff2');
}

@font-face {
    font-family: 'Source Serif 4';
    font-style: italic;
    font-weight: 200 900;
    font-display: swap;
    src: url('/fonts/SourceSerif4Variable-Italic.ttf.woff2') format('woff2');
}

@font-face {
    font-family: 'Fira Code';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('/fonts/FiraCode-VF.woff2') format('woff2');
}

/* 2. 变量与主题 */
:root {
    /* 颜色 */
    --page-background: #ffffff;
    --text-primary: #212326;
    --text-secondary: #4d4f51;
    --text-muted: #909193;
    --header-background: rgba(255, 255, 255, .9);
    --header-border: rgba(229, 231, 235, .5);
    --header-shadow: rgba(31, 34, 37, .03) 0px 1px 0px 0px;
    --hr-background: rgba(228, 228, 229, .5);
    --code-color: #3d3d3d;
    --code-background: #fbfbfb;
    --code-border: #e9e9e9;
    --link-color: #0f5491;

    /* 字体 */
    --font-serif: "Source Serif 4", serif;
    --font-mono: 'Fira Code', ui-monospace, monospace;
}

/* 深色模式 */
@media (prefers-color-scheme: dark) {
    :root {
        --page-background: #212121;
        --text-primary: #f5f5f5;
        --text-secondary: #c4c4c4;
        --text-muted: #7b7b7b;
        --header-background: rgba(33, 33, 33, .9);
        --header-border: rgba(26, 24, 20, .5);
        --header-shadow: rgba(224, 221, 218, .07) 0px 1px 0px 0px;
        --hr-background: rgba(228, 228, 229, .07);
        --code-color: #e5e5e5;
        --code-background: #2a2a2a;
        --code-border: #424242;
        --link-color: #91defa;
    }
}

/* 3. 全局基础样式 */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    margin: 0;
    padding: 0;
    background: var(--page-background);
    color: var(--text-primary);
    font-family: "Inter", system-ui, sans-serif;
    font-size: 1rem;
    line-height: 1.625;
}

main {
    max-width: 45rem;
    margin: 1.25rem auto 5rem;
    padding: 0 1rem;
}

a {
    color: var(--link-color);
    text-decoration: underline;
}

/* 4. 排版 */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.25;
}

h1, h2 {
    font-weight: 700;
}

h3, h4 {
    font-weight: 600;
}

h5, h6 {
    font-weight: 500;
}

h1 {
    margin: 3rem 0 .75rem;
    font-size: 2rem;
}

h2 {
    margin: 2.5rem 0 .75rem;
    font-size: 1.625rem;
}

h3 {
    margin: 2rem 0 .625rem;
    font-size: 1.375rem;
}

h4, h5, h6 {
    margin: 1.75rem 0 .5rem;
    font-size: 1.1875rem;
}

p, ul, ol, pre {
    margin: 0 0 .6875rem;
}

li {
    margin-bottom: .1875rem;
}

li > p {
    margin-bottom: 0;
}

/* 5. 布局组件 */
/* 导航栏 */
header {
    display: flex;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    height: 2.85rem;
    background: var(--header-background);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--header-border);
    box-shadow: var(--header-shadow);
}

header > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 1.5rem;
}

header a {
    color: var(--text-secondary);
    font-size: .9rem;
    text-decoration: underline;
    text-decoration-thickness: .0625rem;
    text-underline-offset: .175rem;
}

header nav a {
    margin-left: .9375rem;
    text-transform: uppercase;
}

/* 元数据 */
.meta p {
    margin: 0;
    color: var(--text-muted);
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-style: italic;
}

/* 分割线 */
hr {
    width: 100%;
    height: 1px;
    margin: 1.5rem 0;
    background-color: var(--hr-background);
    border: none;
}

/* 6. 页面特有样式 */
/* 首页 */
main > h1 {
    margin: 5rem 0 1.5rem;
}

.post-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2rem;
}

.post-item {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.post-item h2 {
    margin: 0;
    font-size: 1.325rem;
    font-weight: 600;
    line-height: 1.4;
}

.post-item h2 a {
    color: var(--text-primary);
    text-decoration: none;
}

.post-item h2 a:hover {
    text-decoration: underline;
    text-decoration-thickness: .0625rem;
    text-underline-offset: .25rem;
}

.post-item time {
    color: var(--text-secondary);
    font-family: var(--font-serif);
    font-size: .95rem;
    font-style: italic;
}

/* 文章页 */
article > h1 {
    margin: 5rem 0 1.5rem;
    text-align: center;
}

article .meta {
    text-align: center;
}

/* 7. 媒体与区块 */
img, iframe {
    display: block;
    max-width: 100%;
    margin: 1rem 0;
    border-radius: .25rem;
}

blockquote {
    margin: 1rem 0;
    padding-left: .75rem;
    border-left: .25rem solid var(--text-primary);
    color: var(--text-secondary);
    opacity: .9;
}

/* 代码排版 */
code, pre {
    font-family: var(--font-mono);
    font-variant-ligatures: contextual;
}

code {
    margin: 0 .0625rem;
    padding: .125rem .25rem;
    background: var(--code-background);
    border: .0625rem solid var(--code-border);
    border-radius: .25rem;
    color: var(--code-color);
    font-size: .9375rem;
}

pre {
    overflow-x: auto;
    margin: 1rem 0;
    padding: .625rem 1rem;
    background: var(--code-background);
    border: .0625rem solid var(--code-border);
    border-radius: .25rem;
    box-shadow:
        0 .0625rem .125rem rgba(0,0,0,.03),
        0 .375rem .75rem rgba(0,0,0,.02),
        0 0 0 .0625rem rgba(0,0,0,.01);
    color: var(--code-color);
    font-size: .875rem;
}

pre code {
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    color: inherit;
    font-size: inherit;
}
