/* ========== 滚动条 ========== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
.dark ::-webkit-scrollbar-track { background: #1e293b; }
::-webkit-scrollbar-thumb { background: #888; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ========== 防止滚动条导致的布局偏移 ========== */
html { scrollbar-gutter: stable; overflow-y: scroll; }

/* ========== 动画 ========== */
.fade-in-up { animation: fadeInUp 0.6s ease-out forwards; opacity: 0; transform: translateY(20px); }
@keyframes fadeInUp { to { opacity: 1; transform: translateY(0); } }

/* ========== 横向滚动隐藏滚动条 ========== */
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* ========== 导航栏占位，防止 JS 渲染前的布局跳动 ========== */
#navbar { min-height: 64px; background: rgba(255,255,255,0.95); contain: layout style; }
.dark #navbar { background: rgba(15,23,42,0.95); }

/* 页面加载时禁用颜色过渡，JS 初始化后通过 .ready 类启用 */
body { transition: none !important; }
body.ready { transition: background-color 0.3s ease, color 0.3s ease !important; }

/* =========================================================
   统一交互令牌（遵循「专事专用、互不干涉」原则）
   - 覆盖 dark/light 两套模式，纯 CSS 切换，零 JS 重算（避免主题闪烁）
   ========================================================= */

/* 选中/当前态：所有「选中」语义（筛选、导航当前页）统一使用 */
.is-selected {
    background-color: #3B82F6 !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}
.is-selected:hover { background-color: #2563eb !important; }
.dark .is-selected { background-color: rgba(37,99,235,0.9) !important; color: #fff !important; }
.dark .is-selected:hover { background-color: rgba(59,130,246,0.95) !important; }

/* 卡片 hover/选中预览：与项目卡完全同构 —— 未选中带柔化阴影（圆角 + 羽化），hover/选中时灰阴影淡出、显示淡蓝阴影 + 蓝边框（零位移） */
.card-hover {
    border-radius: 12px;
    box-shadow: 0 6px 18px -6px rgba(15,23,42,0.12), 0 2px 8px -4px rgba(15,23,42,0.08) !important;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.card-hover:hover, .card-hover:focus-visible {
    background-color: rgba(59,130,246,0.05) !important;
    box-shadow: 0 10px 28px -6px rgba(59,130,246,0.18), 0 4px 12px -4px rgba(59,130,246,0.12) !important;
    border-color: rgba(59,130,246,0.3) !important;
}
.dark .card-hover {
    box-shadow: 0 8px 20px -6px rgba(0,0,0,0.45), 0 2px 8px -4px rgba(0,0,0,0.35) !important;
}
.dark .card-hover:hover, .dark .card-hover:focus-visible {
    background-color: rgba(59,130,246,0.10) !important;
    border-color: rgba(96,165,250,0.4) !important;
    box-shadow: 0 10px 28px -6px rgba(59,130,246,0.28), 0 4px 12px -4px rgba(59,130,246,0.18) !important;
}
/* 标签 chip：与项目卡保持同构（light 蓝底蓝字 / dark 蓝底蓝字） */
.tag-chip {
    font-size: 0.75rem; line-height: 1rem;
    font-weight: normal;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    background-color: #dbeafe; color: #2563eb;
}
.dark .tag-chip { background-color: rgba(30,58,138,0.3); color: #93c5fd; }

/* 卡片「当前选中」态：稍深一点的蓝底 + 更明显边框 */
.card-selected {
    background-color: rgba(59,130,246,0.10) !important;
    border-color: rgba(59,130,246,0.4) !important;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.3) !important;
}
.dark .card-selected {
    background-color: rgba(59,130,246,0.15) !important;
    border-color: rgba(96,165,250,0.5) !important;
    box-shadow: 0 0 0 2px rgba(96,165,250,0.35) !important;
}

/* 筛选/分类「选中」态：蓝底白字（与博客左侧栏分组选中态 .is-selected 同构，名字/icon 不变蓝） */
.filter-selected {
    background-color: rgba(59,130,246,0.12) !important;
    color: #1d4ed8 !important;
    border-color: rgba(59,130,246,0.4) !important;
}
.filter-selected:hover { background-color: rgba(59,130,246,0.18) !important; }
.dark .filter-selected {
    background-color: rgba(59,130,246,0.22) !important;
    color: #bfdbfe !important;
    border-color: rgba(96,165,250,0.5) !important;
}
.dark .filter-selected:hover { background-color: rgba(59,130,246,0.30) !important; }

/* 主按钮 / 次按钮 统一令牌 */
.btn-primary {
    background-color: #3B82F6; color: #fff; font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 8px 20px rgba(59,130,246,0.3);
}
.btn-primary:hover { background-color: #2563eb; box-shadow: 0 10px 26px rgba(59,130,246,0.4); }
.dark .btn-primary { background-color: rgba(37,99,235,0.9); }
.dark .btn-primary:hover { background-color: rgba(59,130,246,0.95); }

.btn-ghost {
    border: 1px solid #cbd5e1; color: #475569;
    transition: all 0.2s ease;
}
.btn-ghost:hover { background-color: #f1f5f9; border-color: #94a3b8; }
.dark .btn-ghost { border-color: #475569; color: #cbd5e1; }
.dark .btn-ghost:hover { background-color: #1e293b; border-color: #64748b; }

/* 标题等文本统一颜色过渡，切主题只换色不重排（消除翻闪） */
.hover-title, .card-hover h2, .card-hover h3,
.transition-theme-color { transition: color 0.3s ease; }

/* ========== 毛玻璃导航 ========== */
.glass-effect { background: rgba(255,255,255,0.85); }
.dark .glass-effect { background: rgba(15,23,42,0.7); }

/* ========== 博客列表标签按钮 ========== */
/* 选中态统一交由 .is-selected 令牌处理，此处仅保留 hover 预览 */
.tag-btn:hover { background-color: #f1f5f9; color: #0f172a; }
.dark .tag-btn:hover { background-color: #1e293b; color: #e2e8f0; }

/* ========== 博客左侧导航（与专题分类筛选 .topic-filter-item 完全同构，dark+light 一致）========== */
.blog-side-btn {
    display: block; width: 100%; text-align: left;
    padding: 0.65rem 0.85rem; border-radius: 0.75rem;
    color: #334155; background: transparent; border: 1px solid transparent;
    font-weight: 400; cursor: pointer; transition: all .2s ease;
    align-items: center;            /* 图标+文字垂直居中 */
}
.blog-side-btn:hover {
    background: rgba(59,130,246,0.06);
    border-color: rgba(59,130,246,0.18);
}
.dark .blog-side-btn { color: #cbd5e1; }
.dark .blog-side-btn:hover {
    background: rgba(96,165,250,0.06);
    border-color: rgba(96,165,250,0.18);
}

/* ========== 博客标签色块 ========== */
/* 默认不加粗；字号/粗细优先走后端配置（内联 style 覆盖），缺省由后端兜底 */
/* 背景框统一为矩形小圆角（与首页精选项目 card 标签同构） */
.tag-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: normal; }

/* ========== 项目卡标签（首页精选 / 项目列表 两处统一）========== */
/* 默认态：灰色背景 + 灰色文字（无边框）；hover 整张卡片时标签变淡蓝底蓝字（选中视觉） */
.proj-tag {
    display: inline-block;
    font-size: 0.75rem; line-height: 1rem;
    font-weight: normal;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    background-color: #f1f5f9; color: #64748b;
    transition: background-color .15s ease, color .15s ease;
}
.dark .proj-tag { background-color: #334155; color: #cbd5e1; }

/* hover 卡片（选中卡片）→ 内部标签变淡蓝背景 + 蓝色文字，两处 card 统一 */
.card-hover:hover .proj-tag {
    background-color: #dbeafe; color: #2563eb;
}
.dark .card-hover:hover .proj-tag { background-color: rgba(59,130,246,0.25); color: #93c5fd; }

/* 静态选中态（备用，非 hover 触发） */
.proj-tag-selected {
    background-color: #dbeafe; color: #2563eb;
}
.dark .proj-tag-selected { background-color: rgba(59,130,246,0.25); color: #93c5fd; }

/* ========== 文章标签（矩形小圆角，详情页底部用）========== */
.label-tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    background: #e2e8f0;
    color: #475569;
}
.dark .label-tag {
    background: #334155;
    color: #cbd5e1;
}

/* ========== 上下篇导航 ========== */
.post-nav { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid #e2e8f0; }
.dark .post-nav { border-color: #334155; }
.post-nav-link { color: #3B82F6; text-decoration: none; transition: color 0.2s; display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-nav-link:hover { color: #2563eb; text-decoration: underline; }
.post-nav-disabled { color: #94a3b8; }
.post-nav-label { font-size: 13px; color: #64748b; margin-bottom: 2px; }
.dark .post-nav-label { color: #94a3b8; }

/* ========== 文章正文排版 ========== */
.article-content h2 { font-size: 1.5rem; font-weight: 700; margin-top: 2rem; margin-bottom: 1rem; padding-left: 0.75rem; border-left: 3px solid #3B82F6; }
.article-content h3 { font-size: 1.25rem; font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.75rem; }
.article-content p { margin-bottom: 1.25rem; line-height: 1.8; }
.article-content ul, .article-content ol { margin-bottom: 1.25rem; padding-left: 1.5rem; }
.article-content li { margin-bottom: 0.5rem; line-height: 1.8; }
.article-content blockquote { border-left: 3px solid #3B82F6; padding: 1rem 1.5rem; margin: 1.5rem 0; background: rgba(59,130,246,0.05); border-radius: 0 0.5rem 0.5rem 0; }
.dark .article-content blockquote { background: rgba(59,130,246,0.1); }
.article-content code { background: #f1f5f9; padding: 0.15rem 0.4rem; border-radius: 0.25rem; font-size: 0.9em; }
.dark .article-content code { background: #1e293b; }
.article-content pre { background: #f1f5f9; color: #334155; padding: 1.25rem; border-radius: 0.75rem; overflow-x: auto; margin-bottom: 1.5rem; }
.dark .article-content pre { background: #1e293b; color: #e2e8f0; }
.article-content pre code { background: none; padding: 0; }
.article-content img { border-radius: 0.75rem; margin: 1.5rem 0; }
/* 表格（renderer.js 渲染 Tiptap JSON 输出的 .hean-table） */
.hean-table, .article-content table {
    width: 100%; border-collapse: collapse; margin: 0.6rem 0; font-size: 0.95em; line-height: 1.5;
}
/* 根因：正文段落默认 margin-bottom:1.25rem，与表格相邻时其外边距会合并/叠加，直接决定表格上方留白；
   所以必须收紧「表格前一段落」的底边距、「表格后标题」的顶边距，才是治本（而非仅调表格自身 margin）。 */
.article-content p:has(+ .hean-table), .article-content p:has(+ table) { margin-bottom: 0.4rem; }
.article-content .hean-table + h2, .article-content .hean-table + h3 { margin-top: 1rem; }
.hean-table th, .hean-table td, .article-content th, .article-content td {
    border: 1px solid #e2e8f0; padding: 0.4rem 0.7rem; text-align: left; vertical-align: top;
}
.hean-table thead th, .article-content thead th { background: #f8fafc; font-weight: 600; }
/* 单元格内容默认被包成 <p>（块级）：清零外边距、行高继承表格的 1.5，避免单元格被 1.8 行高撑高 */
.hean-table th p, .hean-table td p, .article-content th p, .article-content td p { margin: 0; line-height: inherit; }
.dark .hean-table th, .dark .hean-table td, .dark .article-content th, .dark .article-content td { border-color: #334155; }
.dark .hean-table thead th, .dark .article-content thead th { background: #1e293b; }

/* ========== Footer 联系方式图标 ========== */
.footer-contact-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 1.25rem;
    border-radius: 8px;
    transition: background-color 0.2s, color 0.2s;
}
.footer-contact-icon:hover {
    background-color: rgba(59, 130, 246, 0.1);
}
.footer-contact-icon svg {
    display: block;
}

/* ========== 底部微信 icon 点击弹出的公众号卡片 ========== */
/* 缩小版弹窗：正对微信 icon 上方居中，底部贴 icon 顶部留 padding */
.wechat-popup {
    position: fixed;
    width: 150px;
    z-index: 9999;
    background: #fff;
    color: #1f2937;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.16);
    text-align: center;
    animation: wechat-popup-in 0.15s ease;
}
.dark .wechat-popup {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.wechat-popup-qr {
    width: 120px;
    height: 120px;
    margin: 0 auto;
    border-radius: 8px;
    overflow: hidden;
    background: #f1f5f9;
}
.dark .wechat-popup-qr { background: #334155; }
.wechat-popup-qr img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.wechat-popup-name {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 700;
}
.wechat-popup-tip {
    margin-top: 4px;
    font-size: 11px;
    color: #94a3b8;
}
@keyframes wechat-popup-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== 自定义 select 下拉箭头 ========== */
.custom-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 16px;
    padding-right: 2.75rem;
}
.dark .custom-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* ========== 专题列表页：左右双栏（左侧列表 + 右侧侧边栏） ========== */
/* 右侧栏各区域模块：顶部分割线区分层次 */
.topic-side-block {
    padding-top: 1.25rem;
    border-top: 1px solid #e2e8f0;
}
.topic-side-block:first-of-type { padding-top: 0; border-top: none; }
.dark .topic-side-block { border-top-color: #334155; }
/* 右侧栏模块大标题：强化层次（比内容更大更重更深） */
.topic-side-block > h2 {
    font-size: 1.1rem; font-weight: 700; color: #0f172a;
    margin-bottom: 0.75rem; letter-spacing: .01em;
}
.dark .topic-side-block > h2 { color: #f1f5f9; }
/* 右侧栏「技术栈筛选」区域名（相对标签列表左对齐） */
.topic-tags-title {
    font-size: 0.85rem; font-weight: 600; color: #475569;
    margin-bottom: 0.5rem; text-align: left;
}
.dark .topic-tags-title { color: #cbd5e1; }
/* 右侧栏简单列表（热门专题 / 产品推荐） */
.topic-simple-list { display: flex; flex-direction: column; gap: 0.4rem; }
.topic-simple-item {
    display: flex; align-items: flex-start; gap: 0.5rem;
    padding: 0.4rem 0;
}
/* 热门专题序号点缀 */
.topic-simple-index {
    flex-shrink: 0; font-size: 0.7rem; font-weight: 700;
    color: #2563eb; background: #eff6ff; border-radius: 0.35rem;
    min-width: 1.25rem; height: 1.25rem; line-height: 1.25rem; text-align: center;
}
.dark .topic-simple-index { color: #60a5fa; background: rgba(96,165,250,0.15); }
/* 产品推荐点缀（小图标） */
.topic-simple-icon {
    flex-shrink: 0; margin-top: 0.1rem; color: #94a3b8; font-size: 0.8rem;
}
.dark .topic-simple-icon { color: #64748b; }

/* ========== 专题列表页：分类 tab + 技术栈标签（均置于搜索框上方，左对齐平铺） ========== */
/* 分类 tab：水平左对齐平铺 */
.topic-domain-tabs {
    display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 1rem; margin-bottom: 0.5rem;
}
/* 分类 tab：纯文字，无背景无边框，选中仅文字变色（专事专用），文字下带圆角指示 line */
.topic-domain-item {
    background: none; border: none; padding: 0.25rem 0;
    display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
    color: #1a1a1a; font-size: 0.95rem; font-weight: normal;
    transition: color .2s ease; cursor: pointer;
}
.topic-domain-item:hover { color: #334155; }
/* 分类 tab 指示 line：未选中隐藏，选中显示并着同色（圆角） */
.topic-domain-line {
    width: 1rem; height: 2px; border-radius: 9999px;
    background: transparent; transition: background .2s ease;
}
/* 分类 tab 选中：专事专用，强制去背景（覆盖全局 .filter-selected 的 !important 蓝底），只保留文字变色 + 显示同色 line */
.topic-domain-item.filter-selected {
    background: none !important; border-color: transparent !important;
    color: #2563eb !important; font-weight: 700;
}
.topic-domain-item.filter-selected .topic-domain-line { background: #2563eb !important; }
.dark .topic-domain-item { color: #e5e7eb; }
.dark .topic-domain-item:hover { color: #fff; }
.dark .topic-domain-item.filter-selected {
    background: none !important; border-color: transparent !important;
    color: #60a5fa !important; font-weight: 700;
}
.dark .topic-domain-item.filter-selected .topic-domain-line { background: #60a5fa !important; }

/* 技术栈标签区：分类 tab 下方平铺，无标题 */
.topic-tags {
    margin: 0.25rem 0 0.75rem;
}
.topic-tag-body {
    display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: center; gap: 0.5rem;
}
/* 技术栈标签：带边框 chip，hover/选中加边框，圆角不变 */
.topic-tag-item {
    cursor: pointer; display: inline-flex;
    transition: transform .15s ease;
}
.topic-tag-item:hover { transform: scale(1.06); }
.topic-tag-item.filter-selected { transform: scale(1.06); }
.topic-tag-item .topic-tag {
    font-size: 0.68rem; line-height: 1.4;
    padding: 0.1rem 0.45rem; border-radius: 0.5rem;
    background: #f8fafc; color: #64748b;
    border: 1px solid transparent;
    transition: border-color .2s ease, color .2s ease;
}
.topic-tag-item:hover .topic-tag { border-color: #cbd5e1; color: #475569; }
.topic-tag-item.filter-selected .topic-tag {
    border-color: #2563eb; color: #2563eb; background: #eff6ff;
}
.dark .topic-tag-item .topic-tag { background: #1e293b; color: #94a3b8; border-color: transparent; }
.dark .topic-tag-item:hover .topic-tag { border-color: #475569; color: #e2e8f0; }
.dark .topic-tag-item.filter-selected .topic-tag { border-color: #60a5fa; color: #60a5fa; background: rgba(96,165,250,0.12); }
.topic-tag-empty { font-size: 0.75rem; color: #94a3b8; }
.topic-tag-clear {
    font-size: 0.72rem; padding: 0.1rem 0.5rem; border-radius: 0.4rem;
    border: 1px solid #cbd5e1; background: #f8fafc; color: #475569; cursor: pointer;
}
.topic-tag-clear:hover { background: #eef2ff; color: #2563eb; border-color: #2563eb; }
.dark .topic-tag-clear { background: #1e293b; border-color: #475569; color: #cbd5e1; }

/* ========== 右上角登录态（登录按钮 / 头像下拉） ========== */
/* 登录按钮为「纯文字」样式（无背景卡片），配色沿用 body 的 text-slate-800 / dark:text-slate-200，
   由 auth.js 的 renderAuthArea 直接挂 Tailwind 类，此处不再定义样式 */
/* 头像下拉容器：相对定位锚点 */
.auth-dropdown-wrap { position: relative; }

/* 头像按钮 */
.auth-avatar {
  background: rgba(148,163,184,0.25);
  cursor: pointer;
}
/* 下拉菜单：right-0 锚定到容器右边缘 → 与头像右边缘完全对齐 */
.auth-dropdown {
  min-width: 13rem;
  right: 0;
}
.dark .topic-tag-clear:hover { background: #312e81; color: #93c5fd; }

/* ========== 专题列表页：竖向筛选分类（旧版，已废弃保留位） ========== */

/* ========== Sticky Footer：内容不足时 footer 吸在视口底部 ========== */
html, body { height: 100%; }
body { min-height: 100vh; display: flex; flex-direction: column; }
body > footer { margin-top: auto; }
/* ===== 品牌区最小宽度：站点名长度变化时不再牵动 tab 行左右平移 ===== */
.site-brand { min-width: 138px; }        /* 138px = 当前最长站点名"禾安的笔记"的品牌区实测宽度 */
@media (max-width: 767px) { .site-brand { min-width: 0; } }
