/* ============================================================
 * xlxsec 主题样式
 * 布局参考：卡片式技术博客
 * 配色：浅色，蓝色主色
 * ============================================================ */

:root {
    --bg:          #f4f6f9;
    --surface:     #ffffff;
    --text:        #1f2328;
    --text-2:      #5b6472;
    --text-3:      #98a1ae;
    --line:        #e6e9ee;
    --line-soft:   #f0f2f6;
    --primary:     #185FA5;
    --primary-ink: #124a80;
    --primary-bg:  #e8f1fa;
    --radius:      10px;
    --radius-sm:   7px;
    --wrap:        1320px;
    --shadow:      0 1px 2px rgba(16, 24, 40, .04);
}

/* 分类配色（8 色循环） */
.ph-blue,   .badge-blue,   .tag-blue   { --pc: #185FA5; --pb: #E6F1FB; }
.ph-teal,   .badge-teal,   .tag-teal   { --pc: #0F6E56; --pb: #E1F5EE; }
.ph-purple, .badge-purple, .tag-purple { --pc: #534AB7; --pb: #EEEDFE; }
.ph-amber,  .badge-amber,  .tag-amber  { --pc: #854F0B; --pb: #FAEEDA; }
.ph-coral,  .badge-coral,  .tag-coral  { --pc: #993C1D; --pb: #FAECE7; }
.ph-green,  .badge-green,  .tag-green  { --pc: #3B6D11; --pb: #EAF3DE; }
.ph-pink,   .badge-pink,   .tag-pink   { --pc: #993556; --pb: #FBEAF0; }
.ph-gray,   .badge-gray,   .tag-gray   { --pc: #5F5E5A; --pb: #F1EFE8; }

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans CN", sans-serif;
    font-size: 15px;
    line-height: 1.65;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-ink); }

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

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: 1.4; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 15px; }

.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- 顶栏 ---------- */
#site-header {
    position: sticky; top: 0; z-index: 60;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.header-inner {
    display: flex; align-items: center; gap: 22px;
    height: 62px;
}

.brand { display: flex; align-items: center; flex: 0 0 auto; }
.brand img { max-height: 34px; display: block; }
.brand-text {
    font-size: 19px; font-weight: 700; letter-spacing: -.2px;
    color: var(--primary); white-space: nowrap;
    max-width: 300px; overflow: hidden; text-overflow: ellipsis;
}

.main-nav { display: flex; align-items: center; gap: 4px; flex: 0 1 auto; min-width: 0; }
.main-nav a {
    padding: 6px 11px; border-radius: var(--radius-sm);
    font-size: 14px; color: var(--text-2); white-space: nowrap;
}
.main-nav a:hover { background: var(--line-soft); color: var(--text); }
.main-nav a.current { background: var(--primary-bg); color: var(--primary); font-weight: 600; }

.header-right { display: flex; align-items: center; gap: 12px; margin-left: auto; flex: 0 0 auto; }

.search { position: relative; display: flex; align-items: center; }
.search input {
    width: 190px; height: 34px;
    padding: 0 34px 0 12px;
    border: 1px solid var(--line); border-radius: 17px;
    background: #f7f9fb; color: var(--text); font-size: 13px;
    outline: none; transition: border-color .15s, background .15s;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { border-color: var(--primary); background: #fff; }
.search button {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 26px; height: 26px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border: 0; border-radius: 50%;
    background: transparent; color: var(--text-3); cursor: pointer;
}
.search button:hover { background: var(--primary-bg); color: var(--primary); }

.login-link { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.login-link:hover { color: var(--primary); }

/* ---------- 分类条 ---------- */
.catbar { background: #fbfcfd; border-top: 1px solid var(--line-soft); }
.catbar-inner {
    display: flex; align-items: center; gap: 6px;
    padding-top: 8px; padding-bottom: 8px;
    overflow-x: auto; scrollbar-width: none;
}
.catbar-inner::-webkit-scrollbar { display: none; }
.cat {
    padding: 4px 12px; border-radius: 14px;
    font-size: 13px; color: var(--text-2); white-space: nowrap;
}
.cat:hover { background: var(--line-soft); color: var(--text); }
.cat.current { background: var(--primary); color: #fff; font-weight: 600; }

/* ---------- 主布局 ---------- */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 250px;
    gap: 15px;
    align-items: start;
    padding-top: 22px;
    padding-bottom: 40px;
}
.main-col { min-width: 0; }
.main-col--wide { grid-column: 1 / -1; }
.side-col { min-width: 0; }

/* ---------- 焦点区 ---------- */
.hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 16px;
}

.hero-card {
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: border-color .18s, transform .18s;
}
.hero-card:hover { border-color: #cfd8e3; transform: translateY(-2px); }

.hero-thumb {
    display: flex; align-items: center; justify-content: center;
    height: 158px;
    background-color: var(--line-soft);
    background-size: cover;
    background-position: center;
}
.hero-thumb em {
    font-style: normal; font-size: 13px; font-weight: 600;
    color: var(--pc, var(--text-3));
}
.ph { background: var(--pb, var(--line-soft)); }

.hero-body { display: flex; flex-direction: column; gap: 7px; padding: 13px 15px 15px; }

.hero-title {
    font-size: 16px; font-weight: 600; line-height: 1.45;
    color: var(--text);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.hero-card:hover .hero-title { color: var(--primary); }

.hero-excerpt {
    font-size: 13px; color: var(--text-2); line-height: 1.6;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- 首页通栏横幅（替换焦点区时启用） ---------- */
.hero-banner {
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    background: var(--surface);
    line-height: 0;
}
.hero-banner img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 2752 / 928;
    object-fit: cover;
}

.badge {
    align-self: flex-start;
    padding: 2px 9px; border-radius: 4px;
    font-size: 12px; font-weight: 600;
    background: var(--pb, var(--line-soft)); color: var(--pc, var(--text-2));
}

/* ---------- 卡片网格 ---------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.post-card {
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: border-color .18s, transform .18s;
}
.post-card:hover { border-color: #cfd8e3; transform: translateY(-2px); }

.card-thumb {
    display: flex; align-items: center; justify-content: center;
    height: 92px;
    background-color: var(--line-soft);
    background-size: cover;
    background-position: center;
}
.card-thumb em { font-style: normal; font-size: 12px; font-weight: 600; color: var(--pc, var(--text-3)); }

.card-body { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 12px; }
.card-title {
    font-size: 13.5px; font-weight: 600; line-height: 1.45; color: var(--text);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.post-card:hover .card-title { color: var(--primary); }

/* ---------- 文章列表 ---------- */
.section-title {
    margin: 0 0 12px;
    padding-left: 10px;
    border-left: 3px solid var(--primary);
    font-size: 16px;
}

.post-list { display: flex; flex-direction: column; gap: 12px; }

.post-item {
    display: flex; gap: 14px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: border-color .18s;
}
.post-item:hover { border-color: #cfd8e3; }

.item-thumb-link { flex: 0 0 auto; }
.item-thumb {
    display: flex; align-items: center; justify-content: center;
    width: 132px; height: 88px;
    border-radius: var(--radius-sm);
    background-color: var(--line-soft);
    background-size: cover;
    background-position: center;
}
.item-thumb em { font-style: normal; font-size: 12px; font-weight: 600; color: var(--pc, var(--text-3)); }

.item-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.item-title { font-size: 15.5px; line-height: 1.45; }
.item-title a { color: var(--text); }
.item-title a:hover { color: var(--primary); }

.item-excerpt {
    margin: 0; font-size: 13px; color: var(--text-2); line-height: 1.6;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
    font-size: 12px; color: var(--text-3);
}
.item-meta a { color: var(--text-3); }
.item-meta a:hover { color: var(--primary); }
.item-meta > * + *::before {
    content: "·"; margin-right: 12px; color: var(--line);
}

/* ---------- 侧栏 ---------- */
.widget {
    margin-bottom: 14px;
    padding: 14px 15px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.widget-title {
    margin: 0 0 12px;
    font-size: 14px;
    padding-left: 9px;
    border-left: 3px solid var(--primary);
}

.widget-list { margin: 0; padding: 0; list-style: none; }
.widget-list li { padding: 5px 0; font-size: 13px; line-height: 1.55; }
.widget-list li + li { border-top: 1px dashed var(--line-soft); }
.widget-list a { color: var(--text-2); }
.widget-list a:hover { color: var(--primary); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 7px; }
.tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 5px;
    font-size: 12.5px; font-weight: 500;
    background: var(--pb, var(--line-soft)); color: var(--pc, var(--text-2));
    transition: opacity .15s;
}
.tag:hover { opacity: .78; color: var(--pc, var(--text-2)); }
.tag em {
    font-style: normal; font-size: 11px; opacity: .72;
}

.stat-list { margin: 0; padding: 0; list-style: none; }
.stat-list li {
    display: flex; align-items: center; justify-content: space-between;
    padding: 5px 0; font-size: 13px; color: var(--text-2);
}
.stat-list li + li { border-top: 1px dashed var(--line-soft); }
.stat-list em { font-style: normal; font-weight: 600; color: var(--primary); }

/* ---------- 侧栏图片广告位 ---------- */
.widget-ad { padding: 0; overflow: hidden; }
.side-ad { display: block; line-height: 0; }
.side-ad img { display: block; width: 100%; height: auto; transition: opacity .18s; }
.side-ad:hover img { opacity: .93; }

/* ---------- 归档标题 / 空状态 ---------- */
.archive-title {
    margin: 0 0 16px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 15px; color: var(--text-2);
}

.empty {
    padding: 56px 20px; text-align: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--text-3);
}

/* ---------- 分页 ---------- */
.page-navigator {
    margin: 22px 0 0; padding: 0; list-style: none;
    display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
}
.page-navigator li { display: inline-block; }
.page-navigator a, .page-navigator span {
    display: inline-block; min-width: 34px; padding: 0 11px; height: 34px; line-height: 32px;
    text-align: center; font-size: 13px;
    background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    color: var(--text-2);
}
.page-navigator a:hover { border-color: var(--primary); color: var(--primary); }
.page-navigator .current a,
.page-navigator li.current a {
    background: var(--primary); border-color: var(--primary); color: #fff;
}

/* ============================================================
 * 文章 / 独立页面
 * ============================================================ */
.post {
    padding: 22px 24px 26px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.post-title { margin: 0 0 12px; font-size: 24px; line-height: 1.4; }
.post-title a { color: var(--text); }
.post-title a:hover { color: var(--primary); }

.post-meta {
    display: flex; flex-wrap: wrap; gap: 8px 0;
    margin: 0 0 20px; padding: 0 0 14px; list-style: none;
    border-bottom: 1px solid var(--line-soft);
    font-size: 12.5px; color: var(--text-3);
}
.post-meta li { padding-right: 14px; margin-right: 14px; border-right: 1px solid var(--line); }
.post-meta li:last-child { border-right: 0; }
.post-meta a { color: var(--text-3); }
.post-meta a:hover { color: var(--primary); }

.post-content { font-size: 15.5px; line-height: 1.85; color: #2b3138; word-wrap: break-word; }
.post-content > *:first-child { margin-top: 0; }
.post-content h1, .post-content h2, .post-content h3, .post-content h4 {
    margin: 1.6em 0 .7em; line-height: 1.4;
}
.post-content h2 { font-size: 1.32em; padding-bottom: .35em; border-bottom: 1px solid var(--line-soft); }
.post-content h3 { font-size: 1.16em; }
.post-content p { margin: 0 0 1.05em; }
.post-content ul, .post-content ol { margin: 0 0 1.05em; padding-left: 1.6em; }
.post-content li { margin: .3em 0; }
.post-content img { border-radius: var(--radius-sm); border: 1px solid var(--line); }
.post-content a { border-bottom: 1px solid var(--primary-bg); }
.post-content a:hover { border-bottom-color: var(--primary); }
.post-content blockquote {
    margin: 1.2em 0; padding: .6em 1.1em;
    background: #f8fafc; border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-2);
}
.post-content pre {
    margin: 1.2em 0; padding: 14px 16px;
    background: #1f2430; color: #e6e8ec;
    border-radius: var(--radius-sm);
    overflow-x: auto; font-size: 13px; line-height: 1.6;
}
.post-content pre code { background: none; color: inherit; padding: 0; }
.post-content code {
    padding: 2px 5px; border-radius: 4px;
    background: #f1f3f7; color: #c0392b;
    font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: .9em;
}
.post-content table {
    width: 100%; margin: 1.2em 0;
    border-collapse: collapse; font-size: 14px;
}
.post-content th, .post-content td { padding: 8px 12px; border: 1px solid var(--line); }
.post-content th { background: #f7f9fb; font-weight: 600; }
.post-content hr { margin: 2em 0; border: 0; border-top: 1px solid var(--line); }

.tags { margin: 22px 0 0; font-size: 13px; color: var(--text-3); }
.tags a {
    display: inline-block; margin: 0 4px 4px 0; padding: 2px 9px;
    background: var(--primary-bg); border-radius: 4px;
    font-size: 12.5px; color: var(--primary);
}

.post-near {
    display: flex; flex-wrap: wrap; gap: 10px;
    margin: 16px 0 0; padding: 14px 18px; list-style: none;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); font-size: 13px; color: var(--text-2);
}
.post-near li { flex: 1 1 240px; min-width: 0; }

/* ---------- 评论 ---------- */
#comments { margin-top: 16px; }
#comments > h3 { font-size: 15px; margin: 0 0 12px; }

.comment-list, .comment-list ol { margin: 0; padding: 0; list-style: none; }
.comment-list li {
    margin-top: 10px; padding: 14px 16px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius);
}
.comment-list li.comment-by-author { border-color: #cfe3f6; background: #f7fbff; }
.comment-list li .comment-reply { text-align: right; font-size: 12.5px; }
.comment-meta a { color: var(--text-3); font-size: 12.5px; }
.comment-author { display: block; margin-bottom: 4px; color: var(--text); font-weight: 600; }
.comment-author .avatar { float: left; margin-right: 10px; border-radius: 50%; }
.comment-content { font-size: 14px; line-height: 1.75; color: #2b3138; }

.respond {
    margin-top: 16px; padding: 18px 20px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius);
}
.respond .cancel-comment-reply { float: right; font-size: 12.5px; }
#comment-form label { display: block; margin-bottom: 5px; font-size: 13px; color: var(--text-2); }
#comment-form .required::after { content: " *"; color: #d64545; }
#comment-form p { margin: 0 0 12px; }

input[type="text"], input[type="email"], input[type="url"],
input[type="password"], textarea {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: #fbfcfe; color: var(--text); font-size: 14px;
    font-family: inherit; outline: none;
    transition: border-color .15s, background .15s;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="url"]:focus,
input[type="password"]:focus, textarea:focus {
    border-color: var(--primary); background: #fff;
}
textarea { resize: vertical; min-height: 120px; }

button.submit {
    padding: 9px 22px;
    border: 1px solid var(--primary); border-radius: var(--radius-sm);
    background: var(--primary); color: #fff;
    font-size: 14px; font-family: inherit; cursor: pointer;
    transition: background .15s;
}
button.submit:hover { background: var(--primary-ink); border-color: var(--primary-ink); }

/* ---------- 错误页 ---------- */
.error-page {
    padding: 60px 24px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); text-align: center;
}
.error-page .post-title { font-size: 22px; }
.error-page p { color: var(--text-2); }
.error-page form { max-width: 340px; margin: 16px auto 0; }

/* ---------- 页脚 ---------- */
#footer {
    padding: 26px 0 34px;
    border-top: 1px solid var(--line);
    background: var(--surface);
    font-size: 13px; color: var(--text-3);
}
.footer-inner { text-align: center; }
.footer-line { margin: 0 0 4px; }
.footer-line.muted { font-size: 12.5px; }
#footer a { color: var(--text-2); }
#footer a:hover { color: var(--primary); }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
    .layout { grid-template-columns: minmax(0, 1fr) 250px; gap: 15px; }
    .search input { width: 150px; }
}

@media (max-width: 880px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
    .side-col { order: 2; }
    .main-nav { display: none; }
}

@media (max-width: 640px) {
    body { font-size: 14.5px; }
    .header-inner { height: 56px; gap: 12px; }
    .brand-text { font-size: 17px; }
    .search { display: none; }
    .hero { grid-template-columns: 1fr; }
    .hero-thumb { height: 140px; }
    .card-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
    .post-item { flex-direction: column; }
    .item-thumb { width: 100%; height: 132px; }
    .post { padding: 18px 16px 22px; }
    .post-title { font-size: 20px; }
    .post-content { font-size: 15px; }
    .post-meta li { border-right: 0; }
}
