/* 全站样式自定义 */

/* 纯色背景（比主题页脚色 #262A30 深一档，让 footer 区分出来） */
body {
  background: #1B2026;
}

/* landscape 主题的 #wrap 自带不透明底色（#eee），这里改为透明跟随 body 底色 */
#wrap {
  background: transparent;
}

/* 让页脚贴住页面底部：主题原本 #wrap 是 absolute + height:100%，
 * 内容短的页面页脚会浮在中间、下面留一大块空白 */
#container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#wrap {
  position: static;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* flex 子项带 margin:auto 时不会沿交叉轴拉伸，宽度会塌成内容宽度，
 * 这里显式给回整宽（border-box 保证 padding 不撑破）
 * max-width 从主题默认的 960 加宽到 1120，减少两侧留白 */
#wrap > .outer {
  width: 100%;
  max-width: 1120px;
  box-sizing: border-box;
}

/* flex 子项默认可收缩，会把 300px 高的 header 压扁，禁止收缩 */
#header,
#wrap > .outer,
#footer {
  flex-shrink: 0;
}

#footer {
  margin-top: auto;
}

/* 改成 static 后移动端抽屉导航会以普通流出现在文档末尾，
 * 桌面端隐藏，只在主题原本的移动断点下恢复 */
#mobile-nav {
  display: none;
}

@media screen and (max-width: 479px) {
  #mobile-nav {
    display: block;
  }
}

/* 窄屏下主题的 35px 卡片内边距会把正文撑出视口，收窄一些 */
@media screen and (max-width: 767px) {
  .article-inner {
    padding: 20px 16px 0;
  }
}

/* 页脚与主体之间加一条细亮线，层次更清楚 */
#footer {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

/* 顶部横幅：优先加载 WebP（150KB），不支持的浏览器回落到 JPEG（252KB）
 * 先铺一个底色，图片没加载完也不会闪白 */
#banner {
  background-color: #1B2026;
  background-image: url("/images/banner.jpg");
  background-image: image-set(
    url("/images/banner.webp") type("image/webp"),
    url("/images/banner.jpg") type("image/jpeg")
  );
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

/* 侧边栏可读性优化：整个模块（标题+内容）合成一张半透明卡片 */
#sidebar .widget-wrap {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 3px;
  padding: 10px 15px 15px;
}

#sidebar .widget-title {
  color: #555;
  text-shadow: none;
  padding: 5px 0;
  margin-left: 0;
  margin-bottom: 0.6em;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

#sidebar .widget {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  text-shadow: none;
}

/* /tags 页面的标签云（由 scripts/tags-page.js 注入） */
#main .tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 8px;
}

#main .tag-chip {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid #E4E6E9;
  border-radius: 3px;
  background: #F4F5F7;
  color: #444;
  text-decoration: none;
  line-height: 1.6;
  transition: background 0.2s, border-color 0.2s;
}

#main .tag-chip:hover {
  background: #E9EBEF;
  border-color: #D6D9DE;
  text-decoration: none;
}

#main .tag-chip-1 { font-size: 0.85em; }
#main .tag-chip-2 { font-size: 0.95em; }
#main .tag-chip-3 { font-size: 1.05em; font-weight: bold; }

#main .tag-count {
  margin-left: 5px;
  color: #8A8F98;
  font-size: 0.8em;
}

/* 分页条：按钮 + 页码整体居中排布，窄屏自动换行不溢出 */
#page-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 30px auto;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #E4E6E9;
  border-radius: 3px;
  box-shadow: 1px 2px 3px #E6E8EB;
}

#page-nav::before,
#page-nav::after {
  content: none;
  display: none;
}

#page-nav .pager-side {
  display: flex;
  align-items: center;
}

#page-nav .pager-pages {
  display: flex;
  align-items: center;
  gap: 6px;
}

#page-nav a.pager-btn,
#page-nav span.pager-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border: 1px solid #E4E6E9;
  border-radius: 3px;
  background: #F7F8FA;
  color: #555;
  font-size: 0.9em;
  line-height: 1.4;
  text-decoration: none;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

#page-nav a.pager-btn:hover {
  background: #EEF0F3;
  border-color: #D8DCE1;
  color: #222;
  text-decoration: none;
}

#page-nav span.pager-btn.is-disabled {
  color: #C3C7CC;
  background: #FAFAFB;
  border-color: #EDEFF1;
  cursor: default;
}

#page-nav a.pager-num,
#page-nav span.pager-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 3px;
  color: #666;
  font-size: 0.9em;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

#page-nav a.pager-num:hover {
  background: #F0F2F5;
  color: #222;
  text-decoration: none;
}

#page-nav span.pager-num.is-current {
  background: #262A30;
  color: #fff;
  font-weight: bold;
}

#page-nav .pager-ellipsis {
  color: #B9BEC5;
  padding: 0 4px;
}

/* 小屏下分页只留上一页/下一页，页码会挤成一团 */
@media screen and (max-width: 479px) {
  #page-nav .pager-pages {
    display: none;
  }
}

/* 回到顶部按钮：滚动超过 300px 后淡入，右下角固定 */
#back-to-top {
  position: fixed;
  right: 24px;
  bottom: 32px;
  z-index: 100;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background: rgba(45, 51, 59, 0.95);
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.25s, transform 0.25s, visibility 0.25s,
    background 0.2s, border-color 0.2s;
}

#back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#back-to-top:hover {
  background: #3D4550;
  border-color: rgba(255, 255, 255, 0.65);
}

/* 小屏上收小一点，避免挡正文 */
@media screen and (max-width: 479px) {
  #back-to-top {
    right: 14px;
    bottom: 18px;
    width: 36px;
    height: 36px;
    font-size: 15px;
  }
}

/* 中等窄屏（平板/窄窗口）压缩按钮内边距，给页码腾地方 */
@media screen and (max-width: 767px) {
  #page-nav a.pager-btn,
  #page-nav span.pager-btn {
    padding: 6px 10px;
  }

  #page-nav {
    padding: 10px;
  }
}

/* 文章大纲：固定在右侧，仅超宽屏显示（内容 1120 + 右侧需容纳大纲面板） */
#post-toc {
  display: none;
  position: fixed;
  top: 110px;
  right: 24px;
  width: 250px;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  z-index: 90;
  padding: 14px 16px;
  background: rgba(45, 51, 59, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
  font-size: 13px;
  line-height: 1.5;
}

#post-toc .post-toc-title {
  color: #E8EAED;
  font-weight: bold;
  letter-spacing: 4px;
  margin-bottom: 8px;
}

#post-toc .post-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#post-toc .post-toc-list a {
  display: block;
  color: #AEB4BC;
  text-decoration: none;
  padding: 3px 8px;
  border-left: 2px solid transparent;
  border-radius: 0 3px 3px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#post-toc .post-toc-list a:hover {
  color: #fff;
  text-decoration: none;
}

#post-toc .toc-lv2 a { padding-left: 20px; }
#post-toc .toc-lv3 a { padding-left: 32px; }

#post-toc .post-toc-list a.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-left-color: #6C9FE8;
}

html {
  scroll-behavior: smooth;
}

@media screen and (min-width: 1728px) {
  #post-toc {
    display: block;
    opacity: 0;
    visibility: hidden;
    transform: translateX(16px);
    transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
  }

  /* 滚过顶部 banner（300px 高）后才淡入，避免压在 banner 上 */
  #post-toc.is-visible {
    opacity: 1;
    visibility: visible;
    transform: none;
  }
}
