/* ==========================================================================
   theme-Joe3 设计语言对齐 · 纯前端视觉优化
   颜色 / 阴影 / 圆角 等全部取自 theme-Joe3 设计 token
   ========================================================================== */

:root {
  /* 表面与文字 */
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #303133;
  --text-strong: #333333;
  --text-muted: #909399;

  /* 边框 */
  --border: #ebeef5;
  --border-strong: #dcdfe6;

  /* 品牌主色：Joe3 浅色主题橙 */
  --primary: #fb6c28;
  --primary-hover: #e85d1a;

  /* 彩色渐变（colorfulgz 的"彩色"味，用于渐变徽章 / 标题） */
  --gradient: linear-gradient(270deg, #986fee, #8695e6, #68b7dd, #18d7d3);

  /* 行内代码 */
  --code: #409eff;
  --code-bg: #e8f3ff;

  /* 阴影：Joe3 很克制，不要大阴影 */
  --shadow: 0 0 10px -5px #949494;
  --shadow-hover: 0 6px 18px -6px rgba(0, 0, 0, 0.18);

  /* 圆角 */
  --radius: 8px;
  --radius-sm: 4px;
  --radius-pill: 999px;

  /* 布局 */
  --max-width: 1100px;
  --header-h: 60px;

  /* 间距 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 36px;
  --space-7: 60px;

  /* 字号 */
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-base: 16px;
  --text-lg: 19px;
  --text-xl: 24px;
  --text-2xl: 30px;
  --text-3xl: 40px;

  /* 动效 */
  --dur-fast: 120ms;
  --dur: 200ms;
  --ease: cubic-bezier(.2, .8, .2, 1);

  /* 焦点环（统一复用） */
  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  /* Joe3 字体栈 */
  font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color .2s; }
a:hover { color: var(--primary-hover); }

a:focus-visible,
button:focus-visible,
.post-card:focus-visible,
.pagination__item:focus-visible,
.tag:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* logo 用了 transparent 文字，单独给个外圈轮廓 */
.site-logo:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

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

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  /* 保留轻微毛玻璃 */
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  /* 克制的阴影（滚动时不强制变化，保持简单） */
  box-shadow: var(--shadow);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
}
.site-logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .5px;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.site-nav a { margin-left: 22px; font-weight: 600; color: var(--text); }
.site-nav a:hover { color: var(--primary); }

.site-main { padding: 36px 20px 60px; min-height: 62vh; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 28px 0;
  color: var(--text-muted);
  text-align: center;
}
.site-footer__links a { margin: 0 10px; font-weight: 600; }
.site-footer__beian { margin: 4px 0 0; }
.site-footer__beian a { font-weight: 600; }
.beian-icon { width: 16px; height: 16px; vertical-align: middle; margin-right: 6px; color: var(--text-muted); }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 30px 0 6px; }
.hero__title {
  font-size: 40px;
  font-weight: 800;
  margin: 0 0 12px;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__desc { font-size: 18px; color: var(--text-muted); margin: 0 auto 18px; max-width: 640px; }
.hero__tags { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ---------- Section head ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 40px 0 18px; }
.section-head__title { font-size: 22px; margin: 0; color: var(--text-strong); }
.section-head__more { font-weight: 600; color: var(--text-muted); }
.section-head__more:hover { color: var(--primary); }

/* ---------- Post grid & cards ---------- */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform .25s ease, box-shadow .25s ease;
}
/* 克制上浮 */
.post-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.post-card__cover { display: block; height: 160px; position: relative; }
.post-card__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-card__cover--gradient { display: flex; align-items: flex-end; padding: 14px; }
.post-card__cover-cat {
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  background: rgba(0, 0, 0, .28);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}
.post-card__body { padding: 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.post-card__meta { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-muted); }
.post-card__title { font-size: 19px; margin: 0; line-height: 1.4; }
.post-card__title a { color: var(--text); }
.post-card__title a:hover { color: var(--primary); }
.post-card__summary {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card__tags { display: flex; flex-wrap: wrap; gap: 8px; }
.post-card__footer { font-size: 13px; color: var(--text-muted); }

/* ---------- Badges & tags ---------- */
.badge { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: var(--radius-pill); }
/* 分类徽章：Joe3 渐变 type 徽章（紫→蓝→青） */
.badge--cat { background: var(--gradient); color: #fff; }

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(251, 108, 40, .10);
  color: var(--primary);
  transition: background .2s, color .2s;
}
.tag:hover { background: var(--gradient); color: #fff; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
/* 与 .tag 同步的 Joe3 观感 */
.tag--cloud {
  font-size: 15px;
  padding: 8px 16px;
  background: rgba(251, 108, 40, .10);
  color: var(--primary);
  border: 1px solid transparent;
  box-shadow: var(--shadow);
  transition: background .2s, color .2s;
}
.tag--cloud:hover { background: var(--gradient); color: #fff; }
.tag--count { margin-left: 6px; font-size: 12px; color: var(--text-muted); }

/* ---------- Page head ---------- */
.page-head { margin: 10px 0 24px; }
.page-head__title { font-size: 28px; margin: 0 0 6px; color: var(--text-strong); }
.page-head__sub { color: var(--text-muted); margin: 0; }
.empty { color: var(--text-muted); text-align: center; padding: 40px 0; }

/* ---------- 面包屑（对应 Joe3 的 .joe_bread） ---------- */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-muted);
}
.breadcrumb a { color: var(--text-muted); font-weight: 600; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--border-strong); }
.breadcrumb .cur { color: var(--text-strong); font-weight: 600; }

/* ---------- Article detail ---------- */
.post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 38px;
  box-shadow: var(--shadow);
}
.post__head { border-bottom: 1px solid var(--border); padding-bottom: 20px; margin-bottom: 24px; }
.post__meta { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }
.post__title { font-size: 30px; margin: 0 0 14px; line-height: 1.3; color: var(--text-strong); }
.post__tags { display: flex; flex-wrap: wrap; gap: 8px; }

.post__nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
.post__nav a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  flex: 1;
  transition: border-color .2s;
}
.post__nav-next { text-align: right; }
.post__nav-label { font-size: 13px; color: var(--text-muted); }
.post__nav-title { font-weight: 700; color: var(--text); transition: color .2s; }
/* hover：边框 + 标题变品牌橙 */
.post__nav a:hover { border-color: var(--primary); }
.post__nav a:hover .post__nav-title { color: var(--primary); }

/* ---------- Prose (正文排版) ---------- */
.prose { font-size: 16px; line-height: 1.85; color: var(--text); }
.prose h1, .prose h2, .prose h3 { line-height: 1.35; margin: 1.6em 0 .6em; color: var(--text-strong); }
/* 标题左边框用品牌橙 */
.prose h2 { font-size: 24px; padding-left: 12px; border-left: 4px solid var(--primary); }
.prose h3 { font-size: 20px; }
.prose p { margin: .8em 0; }
.prose img { max-width: 100%; border-radius: 10px; }
.prose blockquote {
  margin: 1em 0;
  padding: 10px 18px;
  border-left: 4px solid var(--primary);
  background: rgba(251, 108, 40, .07);
  color: var(--text-muted);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li { margin: .35em 0; }
/* 行内代码：淡蓝底 + 蓝字 */
.prose code {
  font-family: "JetBrains Mono", "Fira Code", Consolas, Monaco, monospace;
  font-size: .9em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--code);
}

/* ---------- 代码块：保留深色底 + Mac 风格彩点容器 ---------- */
.prose pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 18px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.2em 0;
  font-size: 14px;
  line-height: 1.6;
  box-shadow: var(--shadow);
}
.prose pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: 14px;
  border-radius: 0;
}

/* .code-block 由前端 JS 包裹每个 <pre> 生成 */
.code-block {
  margin: 1.2em 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.code-block__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  background: #282c34;
  border-radius: var(--radius) var(--radius) 0 0;
}
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot--r { background: #ff5f56; }
.dot--y { background: #ffbd2e; }
.dot--g { background: #27c93f; }
.code-block__copy {
  margin-left: auto;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, .55);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color .2s, background .2s;
}
.code-block__copy:hover { color: #fff; background: rgba(255, 255, 255, .12); }
/* pre 紧贴 bar 下方，去掉自身上方圆角 */
.code-block pre {
  margin: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: none;
}

.prose table { border-collapse: collapse; width: 100%; margin: 1.2em 0; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.prose th { background: var(--bg); }

/* ---------- About ---------- */
.about {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 38px;
  box-shadow: var(--shadow);
}
.about__head { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.about__avatar { width: 84px; height: 84px; border-radius: 50%; box-shadow: var(--shadow); }
.about__title { margin: 0 0 6px; }
.about__author { margin: 0; color: var(--text-muted); }
.about__bio { white-space: pre-line; color: var(--text-muted); }
.about__stack, .about__social { padding-left: 1.4em; }
.about__stack li, .about__social li { margin: .4em 0; }

/* ---------- 404 ---------- */
/* .notfound / .notfound__code / .notfound__text 在文件末尾"增补"段定义，cascade 自然覆盖这里 */
.btn {
  display: inline-block;
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  background: var(--gradient);
  color: #fff;
  font-weight: 700;
}
.btn:hover { color: #fff; opacity: .92; }

/* ---------- 封面渐变占位 ---------- */
.grad-0 { background: linear-gradient(135deg, #667eea, #764ba2); }
.grad-1 { background: linear-gradient(135deg, #11998e, #38ef7d); }
.grad-2 { background: linear-gradient(135deg, #f093fb, #f5576c); }
.grad-3 { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.grad-4 { background: linear-gradient(135deg, #fa709a, #fee140); }
.grad-5 { background: linear-gradient(135deg, #30cfd0, #330867); }

/* ---------- 响应式（移动端单列） ---------- */
@media (max-width: 640px) {
  .hero__title { font-size: 30px; }
  .post-grid { grid-template-columns: 1fr; }
  .post, .about { padding: 22px 20px; }
  .prose { font-size: 15px; }
  .post__nav { flex-direction: column; }
}

/* ==========================================================================
   暗黑模式：对应 Joe3 data-mode=dark
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1f1f;
    --surface: #2a2a2a;
    --text: #c8c8c8;          /* 提亮，原 #999 在 #2a 上约 5.0:1 */
    --text-strong: #ededed;
    --text-muted: #a0a0a0;    /* 提到 #a0，对 surface 对比 ≈ 5.6:1，过 AA */
    --border: #3a3a3a;
    --border-strong: #4a4a4a;
    --primary: #a8a8ff;       /* 比 #9999ff 更"鲜"，hover 状态也提一档 */
    --primary-hover: #c0c0ff;
    --code-bg: #353246;
    --code: #efa141;
  }

  .site-header { background: rgba(42, 42, 42, 0.85); }
  .site-footer { background: var(--surface); }
  .prose blockquote { background: rgba(251, 108, 40, .10); }
}

/* ---------- 分页（Pagnation） ---------- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 36px 0 8px;
}
.pagination__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  transition: border-color .2s, color .2s, background .2s;
}
.pagination__item:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.pagination__item--active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  cursor: default;
}
.pagination__item--active:hover {
  color: #fff;
  opacity: .92;
}
.pagination__item--disabled {
  color: var(--text-muted);
  background: var(--bg);
  border-color: var(--border);
  cursor: not-allowed;
  opacity: .6;
}
.pagination__item--disabled:hover {
  color: var(--text-muted);
  border-color: var(--border);
}

/* ==========================================================================
   增补：可达性 / 体验打磨
   ========================================================================== */

/* ---------- 1. 跳到主要内容 ---------- */
.skip-link {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  border-radius: var(--radius);
  transform: translateY(-150%);
  transition: transform var(--dur) var(--ease);
  z-index: 100;
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  color: #fff;
  box-shadow: var(--focus-ring);
}

/* ---------- 2. 导航当前态 ---------- */
.site-nav a.is-active,
.site-nav a[aria-current="page"] {
  color: var(--primary);
  position: relative;
}
.site-nav a.is-active::after,
.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -22px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}
/* header 已有 1px 底线，避免下划线叠在上面挤一像素 */
.site-header { border-bottom: 1px solid var(--border); }
.site-nav a.is-active::after,
.site-nav a[aria-current="page"]::after { bottom: -21px; }

/* ---------- 3. 锚点跳转避开 sticky header ---------- */
.prose :is(h1, h2, h3),
.page-head__title,
.section-head__title {
  scroll-margin-top: calc(var(--header-h) + 12px);
}

/* ---------- 4. 复制按钮的 a11y 状态区 ---------- */
.code-block__copy {
  position: relative;
}
.code-block__copy::after {
  content: attr(data-state);
  position: absolute;
  right: 0; top: 100%;
  margin-top: 4px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
  pointer-events: none;
}
.code-block__copy[data-state]:not([data-state=""]) { /* no-op, just for spec */ }
.code-block__bar { position: relative; }

/* ---------- 5. prefers-reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .post-card:hover { transform: none; }
  .site-header { backdrop-filter: none; }
}

/* ---------- 6. 空 / 404 视觉强化 ---------- */
.empty,
.notfound {
  text-align: center;
  padding: 60px var(--space-4);
  color: var(--text-muted);
}
.empty__icon,
.notfound__code {
  display: inline-block;
  margin: 0 0 var(--space-3);
  font-size: var(--text-3xl);
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.notfound__code {
  font-size: 90px;
  font-weight: 800;
  line-height: 1;
}
.notfound__text { margin: var(--space-3) 0 var(--space-5); }
