/* Copyright (c) 2026 larkz-hh
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
/* 左侧目录抽屉 */
.pt-toggle-btn {
  position: fixed;
  top: 0.8rem;
  left: 0.9rem;
  z-index: 1200;
  width: 38px;
  height: 38px;
  border: 1px solid var(--anzhiyu-border, rgba(255, 255, 255, 0.12));
  border-radius: 10px;
  background: var(--anzhiyu-secondbg, rgba(0, 0, 0, 0.25));
  color: var(--anzhiyu-fontcolor, #eee);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
  backdrop-filter: blur(6px);
}
.pt-toggle-btn:hover {
  background: var(--anzhiyu-main, #425AEF);
  color: var(--anzhiyu-white, #fff);
}

#post-tree {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 280px;
  max-width: 82vw;
  z-index: 1002;
  background: var(--anzhiyu-card-bg, #fff);
  border-right: 1px solid var(--anzhiyu-border, rgba(0, 0, 0, 0.08));
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.08);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#post-tree.open { transform: translateX(0); }
#post-tree .pt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--anzhiyu-border, rgba(0, 0, 0, 0.08));
  font-size: 1.05rem;
  font-weight: 700;
}
#post-tree .pt-close {
  border: none;
  background: transparent;
  color: var(--anzhiyu-secondtext, #888);
  font-size: 1rem;
  cursor: pointer;
}
#post-tree .pt-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem 0.6rem 1.2rem;
  font-size: 0.9rem;
}
#post-tree .pt-ul { list-style: none; margin: 0; padding: 0; }
#post-tree .pt-ul .pt-ul { padding-left: 1rem; }
#post-tree .pt-dir-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  color: var(--anzhiyu-fontcolor, #333);
}
#post-tree .pt-dir-head:hover { background: var(--anzhiyu-secondbg, rgba(0, 0, 0, 0.05)); }
#post-tree .pt-arrow {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 0.8rem;
  color: var(--anzhiyu-secondtext, #888);
}
#post-tree .pt-dir.open > .pt-dir-head .pt-arrow { transform: rotate(90deg); }
#post-tree .pt-dir > .pt-ul { display: none; }
#post-tree .pt-dir.open > .pt-ul { display: block; }
#post-tree .pt-post a,
#post-tree .pt-top-post {
  display: block;
  padding: 6px 8px 6px 4px;
  color: var(--anzhiyu-secondtext, #666);
  border-radius: 6px;
  text-decoration: none;
}
#post-tree .pt-post a:hover,
#post-tree .pt-top-post:hover {
  color: var(--anzhiyu-main, #425AEF);
  background: var(--anzhiyu-secondbg, rgba(0, 0, 0, 0.05));
}
#post-tree .pt-top-post { padding-left: 8px; }

#pt-mask {
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
body.pt-open #pt-mask { opacity: 1; pointer-events: auto; }

@media (max-width: 768px) {
  .pt-toggle-btn { top: 0.7rem; left: 0.7rem; }
}

/*  文章详情页左侧目录栏 */
#pt-rail {
  position: fixed;
  left: 0;
  top: 64px;
  bottom: 0;
  width: 250px;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  pointer-events: none;
  overflow-y: auto;
  padding: 0.4rem 0.4rem 1.5rem 0.9rem;
  z-index: 800;
  font-size: 0.88rem;
  background: transparent;
  scrollbar-width: thin;
}
#pt-rail .pt-rail-head {
  font-weight: 700;
  padding: 0.3rem 0.3rem 0.6rem;
  color: var(--anzhiyu-fontcolor, #333);
  border-bottom: 1px dashed var(--anzhiyu-border, rgba(128, 128, 128, 0.3));
  margin-bottom: 0.4rem;
}
#pt-rail .pt-ul { list-style: none; margin: 0; padding: 0; }
#pt-rail .pt-ul .pt-ul { padding-left: 1rem; }
#pt-rail .pt-dir-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  color: var(--anzhiyu-fontcolor, #333);
}
#pt-rail .pt-dir-head:hover { background: var(--anzhiyu-secondbg, rgba(128, 128, 128, 0.12)); }
#pt-rail .pt-arrow { transition: transform 0.2s; color: var(--anzhiyu-secondtext, #888); font-size: 0.8rem; }
#pt-rail .pt-dir.open > .pt-dir-head .pt-arrow { transform: rotate(90deg); }
#pt-rail .pt-dir > .pt-ul { display: none; }
#pt-rail .pt-dir.open > .pt-ul { display: block; }
#pt-rail .pt-post a {
  display: block;
  padding: 4px 6px;
  color: var(--anzhiyu-secondtext, #666);
  border-radius: 6px;
  text-decoration: none;
  line-height: 1.5;
}
#pt-rail .pt-post a:hover {
  color: var(--anzhiyu-main, #425AEF);
  background: var(--anzhiyu-secondbg, rgba(128, 128, 128, 0.12));
}

@media (min-width: 1560px) {
  body[data-type="post"] #pt-rail {
    transform: translateX(0);
    pointer-events: auto;
  }
  /* 封面标题文字右移，让出左侧 250px 给目录栏（横幅背景仍全宽） */
  body[data-type="post"] #post-info {
    left: calc(250px + (100% - 1400px + 3rem) / 2);
  }
  body[data-type="post"] .layout {
    margin-left: 250px;
  }
}

/* 目录面板搜索框 */
#post-tree .pt-search {
  padding: 0.55rem 0.9rem 0.25rem;
}
#post-tree .pt-search input,
#pt-rail .pt-rail-head input {
  width: 100%;
  box-sizing: border-box;
  background: var(--anzhiyu-secondbg, rgba(128, 128, 128, 0.1));
  border: 1px solid var(--anzhiyu-border, rgba(128, 128, 128, 0.25));
  border-radius: 8px;
  color: var(--anzhiyu-fontcolor, #333);
  font-size: 0.85rem;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.2s;
}
#post-tree .pt-search input:focus,
#pt-rail .pt-rail-head input:focus {
  border-color: var(--anzhiyu-main, #425AEF);
}
#pt-rail .pt-rail-head {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: stretch;
}

/* 无封面文章白天模式顶部文字深色 */
[data-theme="light"] body[data-type="post"] #page-header.post-bg:has(#post-top-bg[src=""]) #post-info .post-title,
[data-theme="light"] body[data-type="post"] #page-header.post-bg:has(#post-top-bg[src=""]) #post-info a,
[data-theme="light"] body[data-type="post"] #page-header.post-bg:has(#post-top-bg[src=""]) #post-info time,
[data-theme="light"] body[data-type="post"] #page-header.post-bg:has(#post-top-bg[src=""]) #post-info span,
[data-theme="light"] body[data-type="post"] #page-header.post-bg:has(#post-top-bg[src=""]) #post-info i {
  color: var(--anzhiyu-fontcolor, #333) !important;
}
[data-theme="light"] body[data-type="post"] #page-header.post-bg:has(#post-top-bg[src=""]) .post-meta-categories,
[data-theme="light"] body[data-type="post"] #page-header.post-bg:has(#post-top-bg[src=""]) .post-meta-original,
[data-theme="light"] body[data-type="post"] #page-header.post-bg:has(#post-top-bg[src=""]) .article-meta__tags span {
  color: var(--anzhiyu-secondtext, #555) !important;
  background: rgba(128, 128, 128, 0.12);
  border-radius: 4px;
  padding: 1px 6px;
}
