/* 博客前台基础样式 */
* { box-sizing: border-box; }
img { max-width: 100%; height: auto; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: #333;
    line-height: 1.6;
}

/* ============================================================
   页头：桌面端「站名 - 导航(绝对居中) - 登录注册」三段，手机端见下方媒体查询
   ============================================================ */
.site-header {
    position: relative;               /* 为导航绝对居中提供定位参照 */
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 56px;                     /* 首行条固定高度 56px */
    box-sizing: border-box;
    padding: 0 2rem;
    background: #2c3e50;              /* 首行背景：深蓝灰 */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.site-logo {
    order: 1;
    flex: 0 0 auto;
    display: inline-flex;             /* 徽章与站名同行 */
    align-items: baseline;            /* 徽章文字与站名文字底部（基线）对齐 */
    gap: 0.4rem;
    font-size: 1.15rem;                /* 站点名字号 */
    font-weight: bold;                 /* 站点名加粗 */
    text-decoration: none;
    color: #fff;                       /* 站名白色，配深蓝灰首行 */
    white-space: nowrap;
}
/* 首行站点徽章：纯文字、无蓝底，文字用之前的品牌蓝；字号与登录页图标同源 */
.site-badge {
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    color: #2b6cf0;                    /* 之前蓝底的蓝色，直接作为文字色 */
    font-size: 1rem;                   /* 与登录页图标文字同源，统一为 1rem */
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
/* 手机端导航收缩按钮，桌面端隐藏 */
.nav-toggle {
    display: none;
    order: 0;
    background: none;
    border: 1px solid #eaeaea;
    border-radius: 4px;
    color: #333;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0.35rem 0.6rem;
    cursor: pointer;
}
.site-header .site-nav {
    /* 绝对居中：相对页头水平正中，不受左侧站名/右侧登录入口宽度影响而漂移 */
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    max-width: calc(100% - 22rem);    /* 预留两侧空间，避免与站名/入口重叠 */
}
.site-header .site-nav a {
    margin: 0;
    color: #ecf0f1;                    /* 深蓝灰首行上的浅色文字 */
    font-size: 1.125rem;
    text-decoration: none;
}
.site-header .site-nav a:hover { color: #8ab4ff; }
.auth-links {
    order: 3;
    margin-left: auto;                /* 登录入口推到最右 */
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.auth-links a { color: #8ab4ff; text-decoration: none; font-size: 0.95rem; }
.auth-links a:hover { text-decoration: underline; }
.auth-user { color: #cfd8dc; font-size: 0.9rem; }

/* 内容区绝对居中：父容器用 flex + align-items:center 兜底，所有直接子内容块
   相对屏幕水平正中，不受首行两侧（站名/登录入口）宽度影响；自定义 page 模板
   同样受益（其内容块也作为 main 的直接子元素居中）。 */
.site-main { display: flex; flex-direction: column; align-items: center; }
.container { box-sizing: border-box; width: 100%; max-width: 860px; margin: 2rem auto; padding: 0 1rem; }
.flash-container { margin-bottom: 1rem; }
.flash-container .alert { margin-bottom: 0.5rem; }
.site-footer {
    text-align: center;
    padding: 2rem;
    color: #888;
    border-top: 1px solid #eaeaea;
    margin-top: 3rem;
}
/* 底栏：距灰线半个字体高度，距底部文字一个字体高度；同字体同号不加粗 */
.site-footer.has-footer-links { padding-top: 0.5em; }
.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 1.25rem;
    margin-bottom: 1em;
    font-size: 1em;
    font-weight: normal;
}
.footer-links a {
    color: #888;
    font-size: 1em;
    font-weight: normal;
    text-decoration: none;
}
.footer-links a:hover { color: #409eff; }

/* 文章列表 / 详情 */
/* 标题与正文二级标题统一字号：前端标题此前未设 font-size，走浏览器默认 h1≈2em，
   比正文 H2（≈1.5em）与列表标题（1.4rem）都大，和编辑器「标题/正文同字号」的
   口径不一致。这里把详情页/列表页标题、正文 H2 统一为 1.4rem，标题仍以加粗区分。 */
.post-title, .page-title, .category-title, .tag-title,
.post-summary h2,
.post-content h2, .page-content h2 { font-size: 1.4rem; }
.post-content h3, .page-content h3 { font-size: 1.15rem; }
.post-title, .page-title, .category-title, .tag-title { margin-bottom: 0.5rem; }
.post-summary { padding: 1.5rem 0; border-bottom: 1px solid #eaeaea; }
.post-summary h2 { margin: 0 0 0.5rem; }
.post-summary h2 a { color: #222; text-decoration: none; }
.post-summary h2 a:hover { color: #409eff; }
.post-summary .summary { color: #555; }
.post-meta { color: #888; font-size: 0.9rem; display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.post-meta a { color: #409eff; text-decoration: none; }
.post-tags { margin: 0.5rem 0 1rem; font-size: 0.9rem; color: #888; }
.post-tags a { color: #409eff; text-decoration: none; margin-right: 0.5rem; }
.post-cover { width: 100%; max-height: 260px; object-fit: cover; border-radius: 4px; margin: 0.5rem 0 1rem; }
.post-cover-detail { width: 100%; max-height: 420px; object-fit: cover; border-radius: 6px; margin: 1rem 0; }
/* 标题与正文之间的灰线分隔 */
.post-title-divider { border: 0; border-top: 1px solid #eaeaea; margin: 1rem 0 0; }
.post-content { margin-top: 1.5rem; }
.post-content img { max-width: 100%; }
.post-content pre { background: #f6f8fa; padding: 1rem; overflow-x: auto; border-radius: 4px; }
.post-content blockquote { border-left: 4px solid #ddd; margin-left: 0; padding-left: 1rem; color: #666; }
.empty { color: #999; }
.pagination { margin-top: 2rem; display: flex; gap: 1rem; justify-content: center; align-items: center; }
.pagination a { color: #409eff; text-decoration: none; }
.search-form { display: flex; gap: 0.5rem; margin-bottom: 2rem; }
.search-form .form-control { flex: 1; padding: 0.5rem; border: 1px solid #ddd; border-radius: 4px; }
.btn { padding: 0.5rem 1rem; border: 1px solid #ddd; background: #fff; border-radius: 4px; cursor: pointer; }

/* ============================================================
   登录 / 注册表单
   ============================================================ */
.auth-box {
    width: 100%;
    max-width: 480px;
    margin: 2rem auto;
    padding: 1.5rem;
    background: #fff;
    border: 1px solid #eaeaea;
    border-radius: 6px;
}
.auth-tip { color: #666; font-size: 0.9rem; margin: 0 0 1.25rem; }
.auth-form .form-group { margin-bottom: 1rem; }
.auth-form .form-group label { display: block; margin-bottom: 0.25rem; font-weight: 500; }
.auth-form .form-control {
    width: 100%;
    max-width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}
.field-error { color: #c62828; font-size: 0.85rem; display: block; }
.alert { padding: 0.75rem 1rem; border-radius: 4px; margin-bottom: 1rem; }
.alert-success { background: #e8f5e9; color: #2e7d32; }
.alert-info { background: #e3f2fd; color: #1565c0; }
.alert-warning { background: #fff8e1; color: #ef6c00; }
.alert-danger { background: #ffebee; color: #c62828; }
.auth-foot { margin: 1.25rem 0 0; color: #666; font-size: 0.9rem; }
.auth-foot a { color: #409eff; text-decoration: none; }

/* ============================================================
   评论
   ============================================================ */
.comments { margin-top: 2.5rem; border-top: 1px solid #eaeaea; padding-top: 1.5rem; }
.comments h2 { font-size: 1.3rem; }
.comment-list { list-style: none; margin: 1rem 0; padding: 0; }
.comment-item { padding: 0.75rem 0; border-bottom: 1px dashed #eaeaea; }
.comment-head { display: flex; gap: 0.75rem; align-items: baseline; flex-wrap: wrap; }
.comment-author { font-weight: 600; color: #333; }
.comment-time { color: #999; font-size: 0.8rem; }
.comment-body { margin: 0.4rem 0 0; white-space: pre-wrap; word-break: break-word; }
.comment-form .form-group { margin-bottom: 0.75rem; }
.comment-form .form-control {
    width: 100%; max-width: 100%; padding: 0.5rem;
    border: 1px solid #ddd; border-radius: 4px;
}
.comment-form textarea.form-control { min-height: 90px; resize: vertical; }
.comment-tip { color: #888; font-size: 0.85rem; }

/* ============================================================
   响应式适配：平板与直板手机
   ============================================================ */
@media (max-width: 768px) {
    .site-header {
        /* 三栏：收缩按钮居左、站名居中、登录注册居右 */
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        gap: 0.5rem;
        height: auto;                  /* 手机端导航展开时高度自适应，收起时约 56px */
        min-height: 56px;
        padding: 0.5rem 0.75rem;
    }
    .nav-toggle {
        display: inline-flex; grid-column: 1; grid-row: 1; justify-self: start;
        border-color: rgba(255, 255, 255, 0.3);
        color: #fff;
    }
    /* 手机端导航默认收缩，点击按钮后展开为整行下拉（覆盖桌面的绝对居中） */
    .site-header .site-nav {
        position: static;             /* 覆盖桌面端绝对定位，回归文档流 */
        transform: none;
        max-width: none;
        display: none;
        grid-column: 1 / -1;
        grid-row: 2;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 0.15rem;
        width: 100%;
        padding: 0.5rem 0.25rem;
        background: #34495e;          /* 深蓝灰首行下的下拉底色，保证浅色文字可读 */
        border-top: 1px solid rgba(255, 255, 255, 0.12);
    }
    .site-header.nav-open .site-nav { display: flex; }
    .site-header .site-nav > a { display: block; padding: 0.3rem 0; }
    .site-logo {
        grid-column: 2;
        grid-row: 1;
        justify-self: center;
        text-align: center;
    }
    .auth-links {
        grid-column: 3;
        grid-row: 1;
        justify-content: flex-end;
        gap: 0.4rem 0.6rem;
    }

    .container { margin: 1rem auto; padding: 0 0.75rem; }
    .post-summary { padding: 1rem 0; }
    .post-title, .page-title, .category-title, .tag-title,
    .post-summary h2,
    .post-content h2, .page-content h2 { font-size: 1.2rem; }
    .post-meta { gap: 0.4rem 1rem; font-size: 0.85rem; }
    .post-content { margin-top: 1.25rem; }
    .post-content pre { padding: 0.75rem; font-size: 0.9rem; }
    .post-content table { display: block; width: 100%; overflow-x: auto; }
    .pagination { flex-wrap: wrap; gap: 0.75rem; }
    .search-form { flex-wrap: wrap; }
    .search-form .form-control { flex-basis: 100%; }
    .site-footer { padding: 1.5rem 1rem; }
    .auth-box { margin: 1rem auto; padding: 1.25rem; }
}

@media (max-width: 480px) {
    body { font-size: 15px; }
    .site-logo-img { max-height: 28px; }
    .site-header .site-nav a { font-size: 1rem; }
    /* 标题字号与正文 H2 已在上方统一为 1.2rem，此处不再单独放大 */
}
