/* ============================================================
   个人知识库 · 深色主题全局样式
   参照 runoob 的信息架构：顶栏 + 分类导航 + 卡片内容区 + 页脚
   ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  --bg: #0a0e1a;
  --bg-soft: #0e1424;
  --card: #131b30;
  --card-hover: #18233c;
  --border: #24314f;
  --border-light: #2e3d61;
  --text: #e7ecf6;
  --text-dim: #93a1bd;
  --text-faint: #5c6b8a;

  --accent: #6366f1;
  --accent-2: #22d3ee;
  --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #22d3ee 100%);
  --gradient-soft: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(34, 211, 238, 0.10));

  /* 分类主题色 */
  --c-frontend: #f97316;
  --c-backend: #22c55e;
  --c-database: #eab308;
  --c-ai: #a855f7;
  --c-tool: #06b6d4;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "Fira Code", Consolas, "Courier New", monospace;
}

/* ---------- 基础重置 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
ul, ol { list-style: none; }
::selection { background: rgba(99, 102, 241, 0.45); color: #fff; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-soft); }
::-webkit-scrollbar-thumb { background: #2a3a5e; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #37508a; }

/* ---------- 背景装饰 ---------- */
.bg-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(600px 320px at 15% -5%, rgba(99, 102, 241, 0.16), transparent 65%),
    radial-gradient(700px 380px at 90% 0%, rgba(34, 211, 238, 0.10), transparent 60%),
    radial-gradient(500px 300px at 55% 110%, rgba(139, 92, 246, 0.08), transparent 60%),
    var(--bg);
}

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 26, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 22px;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 26px;
}

/* Logo */
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--gradient);
  display: grid; place-items: center;
  font-weight: 800; font-size: 17px; color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 0.5px; }
.brand-name em { font-style: normal; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* 主导航 */
.main-nav { display: flex; gap: 4px; flex: 1; }
.main-nav a {
  padding: 8px 13px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14.5px;
  transition: all 0.2s;
}
.main-nav a:hover { color: var(--text); background: rgba(99, 102, 241, 0.12); }
.main-nav a.active { color: #fff; background: rgba(99, 102, 241, 0.18); }

/* 搜索框 */
.search-box {
  position: relative;
  width: 240px;
  flex-shrink: 0;
}
.search-box svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: all 0.25s;
}
.search-box input::placeholder { color: var(--text-faint); }
.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22);
}

/* 汉堡菜单 */
.burger {
  display: none;
  width: 38px; height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  place-items: center;
  flex-shrink: 0;
}
.burger svg { width: 19px; height: 19px; color: var(--text); }

/* 移动端下拉菜单 */
.mobile-menu {
  display: none;
  flex-direction: column;
  padding: 10px 22px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.mobile-menu.open { display: flex; }
.mobile-menu a {
  padding: 11px 8px;
  color: var(--text-dim);
  border-radius: 8px;
  font-size: 15px;
}
.mobile-menu a:hover, .mobile-menu a.active { color: #fff; background: rgba(99, 102, 241, 0.14); }

/* ---------- 主容器 ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 0 22px; }

/* ---------- Hero 区 ---------- */
.hero {
  padding: 58px 0 30px;
  text-align: center;
}
.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 15px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--gradient-soft);
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 20px;
}
.hero-tag .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2);
}
.hero h1 {
  font-size: clamp(30px, 5vw, 46px);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 1px;
}
.hero h1 .grad {
  background: var(--gradient);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.hero .slogan {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 16.5px;
}
.hero-stats {
  margin-top: 26px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.stat {
  padding: 10px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  display: flex; align-items: baseline; gap: 7px;
  font-size: 13.5px;
  color: var(--text-dim);
}
.stat b {
  font-size: 20px;
  background: var(--gradient);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

/* ---------- 分类页签 ---------- */
.tabs {
  margin: 30px 0 6px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.tab {
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-dim);
  font-size: 14px;
  transition: all 0.22s;
}
.tab:hover { color: var(--text); border-color: var(--border-light); transform: translateY(-1px); }
.tab.active {
  color: #fff;
  border-color: transparent;
  background: var(--gradient);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}
.tab .cnt { opacity: 0.75; font-size: 12px; margin-left: 4px; }

/* ---------- 分类区块 ---------- */
.section {
  margin: 26px 0 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section .icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 17px;
  color: #fff;
}
.section h2 { font-size: 20px; font-weight: 700; }
.section .line { flex: 1; height: 1px; background: linear-gradient(90deg, var(--border), transparent); }
.section .more { font-size: 13px; color: var(--accent-2); }

/* 分类色辅助类 */
.c-frontend { background: var(--c-frontend); box-shadow: 0 4px 14px rgba(249, 115, 22, 0.35); }
.c-backend  { background: var(--c-backend);  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.35); }
.c-database { background: var(--c-database); box-shadow: 0 4px 14px rgba(234, 179, 8, 0.35); }
.c-ai       { background: var(--c-ai);       box-shadow: 0 4px 14px rgba(168, 85, 247, 0.35); }
.c-tool     { background: var(--c-tool);     box-shadow: 0 4px 14px rgba(6, 182, 212, 0.35); }

/* ---------- 教程卡片 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin: 14px 0 6px;
}
.card {
  position: relative;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  transition: transform 0.22s, border-color 0.22s, box-shadow 0.22s, background 0.22s;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--card-accent, var(--accent));
  opacity: 0;
  transition: opacity 0.22s;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--border-light);
  background: var(--card-hover);
  box-shadow: var(--shadow);
}
.card:hover::before { opacity: 1; }

.card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 22px;
  background: var(--gradient-soft);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.card h3 { font-size: 16.5px; font-weight: 700; }
.card .tag-row { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.card .tag {
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-faint);
  background: var(--bg-soft);
}
.card p.desc {
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.65;
  min-height: 44px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .go {
  margin-top: 14px;
  font-size: 13px;
  color: var(--card-accent, var(--accent-2));
  display: inline-flex; align-items: center; gap: 5px;
}
.card .go svg { width: 13px; height: 13px; transition: transform 0.2s; }
.card:hover .go svg { transform: translateX(4px); }

/* 空结果提示 */
.empty {
  display: none;
  text-align: center;
  padding: 60px 0;
  color: var(--text-faint);
}
.empty.show { display: block; }
.empty .big { font-size: 44px; margin-bottom: 12px; }

/* ---------- 页脚 ---------- */
.footer {
  margin-top: 70px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}
.footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 22px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 30px;
}
.footer h4 { font-size: 15px; margin-bottom: 12px; }
.footer p, .footer a { font-size: 13.5px; color: var(--text-dim); }
.footer a:hover { color: var(--accent-2); }
.footer .col li { margin-bottom: 8px; }
.footer .brand-desc { margin-top: 10px; line-height: 1.8; }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 16px 22px;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
}
.footer-bottom a { color: var(--text-dim); }

/* ============================================================
   教程详情页
   ============================================================ */
.tutorial-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 34px;
  padding: 30px 0 20px;
  align-items: start;
}

/* 面包屑 */
.crumb {
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
}
.crumb a:hover { color: var(--accent-2); }
.crumb .sep { opacity: 0.5; }

/* 左侧目录 */
.toc {
  position: sticky;
  top: 84px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 16px 0;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
.toc-title {
  padding: 0 18px 10px;
  font-size: 13px;
  color: var(--text-faint);
  letter-spacing: 1px;
  display: flex; align-items: center; gap: 8px;
}
.toc-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.toc a {
  display: block;
  padding: 7px 18px;
  font-size: 13.5px;
  color: var(--text-dim);
  border-left: 2px solid transparent;
  transition: all 0.15s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc a:hover { color: var(--text); background: rgba(99, 102, 241, 0.08); }
.toc a.active {
  color: var(--accent-2);
  border-left-color: var(--accent-2);
  background: rgba(34, 211, 238, 0.07);
}

/* 右侧正文 */
.article { min-width: 0; }
.article-head {
  padding: 26px 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(99, 102, 241, 0.10), rgba(34, 211, 238, 0.05)),
    var(--card);
  margin-bottom: 22px;
}
.article-head .icon {
  width: 54px; height: 54px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 27px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.article-head h1 { font-size: 26px; font-weight: 800; }
.article-head .desc { margin-top: 8px; color: var(--text-dim); font-size: 14.5px; }
.article-head .meta { margin-top: 14px; display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-faint); }

/* 正文排版 */
.article-body h2 {
  font-size: 21px;
  font-weight: 700;
  margin: 36px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 84px;
  display: flex; align-items: center; gap: 10px;
}
.article-body h2::before {
  content: "";
  width: 4px; height: 20px;
  border-radius: 3px;
  background: var(--gradient);
  flex-shrink: 0;
}
.article-body h3 {
  font-size: 17px;
  font-weight: 700;
  margin: 26px 0 10px;
  scroll-margin-top: 84px;
}
.article-body p { margin: 12px 0; color: #c8d2e6; }
.article-body strong { color: #fff; }
.article-body a { color: var(--accent-2); border-bottom: 1px dashed rgba(34, 211, 238, 0.5); }
.article-body a:hover { border-bottom-style: solid; }
.article-body ul, .article-body ol { margin: 12px 0; padding-left: 22px; color: #c8d2e6; }
.article-body ul { list-style: disc; }
.article-body ol { list-style: decimal; }
.article-body li { margin: 5px 0; }
.article-body li::marker { color: var(--accent); }

/* 代码块 */
.code-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--mono);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
}
.code-block {  /* 兼容旧式写法 */
  position: relative;
  margin: 16px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #0d1322;
  overflow: hidden;
}
.code-head .copy-btn,
.code-block .copy-btn {
  font-size: 12px;
  color: var(--text-dim);
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.code-head .copy-btn:hover,
.code-block .copy-btn:hover { color: #fff; border-color: var(--accent); background: rgba(99, 102, 241, 0.15); }
.code-head + pre,
.code-block pre,
pre.code {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
  color: #c9d4ee;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  border: 1px solid var(--border);
  border-top: none;
  background: #0d1322;
}
pre.code code,
.code-block code { font-family: var(--mono); }

/* 代码高亮配色 */
.tok-kw { color: #c792ea; }
.tok-str { color: #a5e075; }
.tok-num { color: #f78c6c; }
.tok-com { color: #63728c; font-style: italic; }
.tok-tag { color: #82aaff; }
.tok-attr { color: #f78c6c; }
.tok-fn { color: #82aaff; }
.tok-prop { color: #c792ea; }

/* 表格 */
.article-body table {
  width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
  font-size: 14px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.article-body th {
  background: rgba(99, 102, 241, 0.14);
  color: #fff;
  font-weight: 600;
  text-align: left;
}
.article-body th, .article-body td {
  padding: 10px 14px;
  border: 1px solid var(--border);
}
.article-body tr:nth-child(even) td { background: rgba(255, 255, 255, 0.025); }
.article-body td { color: #c8d2e6; }

/* 提示框 */
.note {
  margin: 18px 0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: 14px;
  line-height: 1.7;
}
.note .note-title { font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 7px; }
.note.info { border-color: rgba(34, 211, 238, 0.35); background: rgba(34, 211, 238, 0.07); }
.note.info .note-title { color: var(--accent-2); }
.note.warn { border-color: rgba(234, 179, 8, 0.4); background: rgba(234, 179, 8, 0.08); }
.note.warn .note-title { color: #eab308; }
.note.tip { border-color: rgba(34, 197, 94, 0.4); background: rgba(34, 197, 94, 0.07); }
.note.tip .note-title { color: #22c55e; }

/* 上下篇导航 */
.pager {
  margin-top: 40px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.pager a {
  padding: 15px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  transition: all 0.22s;
  display: block;
}
.pager a:hover { border-color: var(--border-light); background: var(--card-hover); transform: translateY(-2px); }
.pager a.next { text-align: right; }
.pager .label { font-size: 12px; color: var(--text-faint); }
.pager .title { font-size: 14.5px; color: var(--text); margin-top: 3px; font-weight: 600; }

/* ============================================================
   关于页
   ============================================================ */
.about-card {
  margin: 40px auto;
  max-width: 760px;
  padding: 36px 34px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
}
.about-avatar {
  width: 86px; height: 86px;
  border-radius: 50%;
  background: var(--gradient);
  display: grid; place-items: center;
  font-size: 38px;
  margin-bottom: 18px;
  box-shadow: 0 6px 22px rgba(99, 102, 241, 0.4);
}
.about-card h1 { font-size: 26px; margin-bottom: 6px; }
.about-card .sub { color: var(--accent-2); font-size: 14.5px; margin-bottom: 18px; }
.about-card p { color: #c8d2e6; margin-bottom: 12px; }
.skill-bar { margin: 10px 0; }
.skill-bar .row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.skill-bar .track { height: 8px; border-radius: 5px; background: var(--bg-soft); border: 1px solid var(--border); overflow: hidden; }
.skill-bar .fill { height: 100%; border-radius: 5px; background: var(--gradient); width: 0; transition: width 0.8s ease; }

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
  .topbar-inner { gap: 14px; }
  .search-box { width: 170px; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .tutorial-layout { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; }
  .toc a { white-space: normal; }
}

@media (max-width: 760px) {
  .main-nav { display: none; }
  .search-box { display: none; }
  .burger { display: grid; }
  .hero { padding: 40px 0 20px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card { padding: 16px; }
  .card p.desc { -webkit-line-clamp: 3; }
  .footer-inner { grid-template-columns: 1fr; gap: 22px; }
  .pager { grid-template-columns: 1fr; }
  .article-head { padding: 20px 18px; }
}

@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
  .hero-stats .stat { font-size: 12.5px; padding: 8px 14px; }
}
