/* =========================================
   单篇文章页面 (Single Post Page)
   ========================================= */
.single-layout {
  display: block; 
}
.single-content-area {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.single-header {
  padding-top: 40px;
  margin-bottom: 60px;
}

.single-tags {
  margin-bottom: 20px;
}

.single-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: #111;
  line-height: 1.2;
  margin: 0 0 15px 0;
  letter-spacing: -0.5px;
}

.single-subtitle {
  font-size: 1.3rem;
  font-weight: 400;
  color: #666;
  margin: 0 0 20px 0;
  line-height: 1.5;
}

.single-meta {
  margin-bottom: 0;
}

.meta-separator {
  margin: 0 8px;
  color: #ccc;
}

/* 正文基础排版 (Typography) */
.single-content {
  font-size: 1.05rem;
  line-height: 1.9;
  color: #333;
}

/* 桌面端：两端对齐 */
.single-content p {
  margin-bottom: 1.5em;
  text-align: justify; 
  -webkit-hyphens: auto; 
  -ms-hyphens: auto;
  hyphens: auto; 
}

/* 移动端：左对齐*/
@media (max-width: 768px) {
  .single-content p,
  .post-entry p {
    text-align: left !important; /* 强制左对齐 */
    overflow-wrap: break-word;
  }
}

/* =========================================
   正文标题层级 (Headings Typography)
   ========================================= */
.single-content h2, 
.single-content h3, 
.single-content h4 {
  color: #111;
  font-weight: 700;
  line-height: 1.3;
}

.single-content h2 {
  font-size: 1.8rem;
  margin-top: 3.5rem; 
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eaeaea;
  letter-spacing: -0.5px;
}

.single-content h3 {
  font-size: 1.4rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.single-content h4 {
  font-size: 1.15rem;
  color: #333;
  margin-top: 2rem;
  margin-bottom: 0.8rem;
}

/* --- 正文内部超链接 (In-text Links) --- */

/* 排除目录 #TableOfContents 里的 a */
.single-content a:not(#TableOfContents a) {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease, text-decoration-color 0.3s ease;
  
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}

.single-content a:not(#TableOfContents a):hover {
  color: var(--accent-color);
  text-decoration-color: var(--accent-color);
}

/* 引用 (Blockquotes) */
.single-content blockquote {
  margin: 3rem 0;
  padding: 1.2rem 1.5rem 1.2rem 2rem;
  
  border-left: 4px solid var(--primary-color, #26a69a);
  background-color: rgba(38, 166, 154, 0.04); 
  border-radius: 0 4px 4px 0;
}

.single-content blockquote p {
  margin: 0;
  font-size: 1.15rem;
  font-style: italic;
  color: #555;
  line-height: 1.7;
}

.single-content blockquote p + p {
  margin-top: 1rem;
}

/* =========================================
   行内代码 (Inline Code)
   ========================================= */
.single-content p code,
.single-content li code,
.single-content table code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
  color: #d63200;
  background-color: rgba(0, 0, 0, 0.05);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  word-break: break-word;
}

/* =========================================
   表格 (Tables)
   ========================================= */
.single-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 3rem 0;
  font-size: 0.95rem;
}

.single-content th, 
.single-content td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid #eaeaea;
}

.single-content th {
  font-weight: 700;
  color: #111;
  border-bottom: 2px solid #111; 
  background-color: rgba(0, 0, 0, 0.02);
}

/* =========================================
   列表 (Lists: ul, ol)
   ========================================= */

.single-content ul, 
.single-content ol {
  padding-left: 28px; 
  margin: 1.5rem 0;
}

.single-content li {
  margin-bottom: 0.8rem;
  line-height: 1.7;
  color: #333;
}

.single-content ul {
  list-style: none;
}

.single-content ul li {
  position: relative;
}

.single-content ul li::before {
  content: "";
  position: absolute;
  left: -24px; 
  top: 0.55em; 
  width: 12px;
  height: 12px;
  border: 3px solid #555; 
  background-color: transparent; 
  box-sizing: border-box;
}

.single-content ol {
  list-style: decimal outside;
}

.single-content ol li {
  padding-left: 8px; 
}

.single-content ol ul {
  margin: 0.5rem 0;
}

/* =========================================
   图片排版 (Image Typography)
   ========================================= */

.metro-figure {
  margin: 2.5rem 0;
  text-align: center;
  display: block;
}

.metro-figure img {
  max-width: 90%;
  max-height: 55vh;
  width: auto;
  display: block;
  margin: 0 auto; 
  border-radius: 4px; 
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.04);
  cursor: zoom-in;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.metro-figure img:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.metro-caption {
  margin-top: 1rem;
  font-size: 0.85rem;
  font-family: sans-serif;
  color: #888;
  line-height: 1.6;
  font-style: italic; /* 顶刊标准图注斜体 */
}

.metro-caption strong {
  color: #555;
}

/* 多图并排画廊 */
.metro-figure:has(+ .metro-figure),
.metro-figure + .metro-figure {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  
  /* 给每张图分配大约 48% 的宽度，留出中间的缝隙 */
  width: calc(48% - 10px); 
  margin: 1.5rem 1%; 
  vertical-align: top;
}

.metro-figure:has(+ .metro-figure) img,
.metro-figure + .metro-figure img {
  max-width: 100%;
  max-height: 40vh;
}

/* =========================================
   5. 移动端画廊
   ========================================= */
@media (max-width: 600px) {
  .metro-figure:has(+ .metro-figure),
  .metro-figure + .metro-figure {
    display: block;
    width: 100%;
    margin: 2rem 0;
  }
}

.single-sidebar {
  position: fixed; 
  top: 280px; 
  
  left: calc(50% + 380px + 80px); 
  width: 260px; 
  max-height: calc(100vh - 320px); 
  overflow-y: auto;
  scrollbar-width: none; 
  
  transition: opacity 0.4s ease, visibility 0.4s ease, transform 0.4s ease;
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}


.single-sidebar::-webkit-scrollbar { display: none; }

@media (min-width: 1351px) {
  .single-sidebar.fade-out {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-20px);
    pointer-events: none;
  }
}

/* =========================================
   Responsiv TOC
   ========================================= */

/* -----  1351px - 1440px 桌面 ----- */

.close-toc-btn {
  display: none;
}

@media (max-width: 1440px) and (min-width: 1351px) {
  .single-sidebar {
    left: auto !important;
    right: 20px !important;
  }
}

/*  ----- 1001px - 1350px: 右侧飞入面板 ----- */
@media (max-width: 1350px) and (min-width: 1001px) {
  .single-sidebar {
    display: block !important;
    position: fixed;
    top: 0; 
    right: 0; 
    left: auto !important;
    width: 320px;
    height: 100vh;
    max-height: 100vh; 
    background: #ffffff;
    z-index: 999;
    padding: 60px 30px 40px;
    
    border-top: none;
    border-left: 4px solid var(--primary-color);
    box-shadow: none; 
    
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), 
                box-shadow 0.4s ease;
  }
  
  .single-sidebar.sheet-open {
    transform: translateX(0);
    box-shadow: -10px 0 30px rgba(0,0,0,0.1);
  }
}

/* ----- 1000px 以下: 移动端底部抽屉  ----- */
@media (max-width: 1000px) {
  .single-sidebar {
    display: block !important;
    position: fixed;
    top: auto; 
    bottom: 0; 
    left: 0;
    width: 100%;
    box-sizing: border-box;
    max-height: 65vh; 
    background: #ffffff;
    z-index: 999;
    padding: 30px 20px 40px;
    
    border-left: none;
    border-top: 4px solid var(--primary-color);
    box-shadow: 0 -10px 30px rgba(0,0,0,0.1);

    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  }
  
  .single-sidebar.sheet-open {
    transform: translateY(0);
  }

  .close-toc-btn {
    display: block;
    position: absolute;
    top: 26px;
    right: 20px;
    background: none;
    border: none;
    color: #999;
    padding: 4px;
  }
  
  .close-toc-btn svg {
    width: 20px;
    height: 20px;
    display: block;
  }
}


.toc-title {
  display: block;
  font-size: 0.85rem;
  font-family: sans-serif;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #999;
  margin-bottom: 15px;
}

#TableOfContents > ul {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 2px solid #f0f0f0; 
}

#TableOfContents li { margin-bottom: 10px; }

#TableOfContents a {
  display: block;
  font-size: 0.9rem;
  color: #666;
  text-decoration: none;
  padding-left: 15px;
  transition: color 0.3s ease, box-shadow 0.3s ease; 
  line-height: 1.6;
}

#TableOfContents a:hover { color: var(--primary-color); }

#TableOfContents a.active {
  color: var(--primary-color);
  font-weight: 700;
  box-shadow: inset 2px 0 0 0 var(--primary-color); 
}

#TableOfContents ul ul {
  list-style: none;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding-left: 15px;
  margin-top: 0;
  
  transition: max-height 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), 
              opacity 0.4s ease, 
              margin-top 0.4s ease;
}

/* 当父级 H2 被标记为 active 时，展开它下面的次级目录 */
#TableOfContents li.active-parent > ul {
  max-height: 800px;
  opacity: 1;
  margin-top: 10px;
}

.single-content hr {
  border: none;
  height: 3px; 
  width: 60px; 
  background-color: #999999;
  margin: 60px 0;
}

/* =========================================
   极简灯箱系统 (Vanilla Lightbox)
   ========================================= */
.metro-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(255, 255, 255, 0.95); 
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.metro-lightbox.active {
  opacity: 1;
  pointer-events: auto;
  cursor: zoom-out;
}

.metro-lightbox img {
  max-width: 95vw; 
  max-height: 95vh; 
  border-radius: 4px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15); 
  
  transform: scale(0.9); 
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.metro-lightbox.active img {
  transform: scale(1);
}

/* =========================================
   极简代码块
   ========================================= */

.highlight {
  background-color: #f6f8fa;
  border: 1px solid #e1e4e8;
  border-radius: 6px; 
  margin: 1.8em 0;
  overflow: hidden; 
  color: #24292e !important; 
}

.highlight,
.highlight pre,
.highlight code,
.highlight span,
.highlight table,
.highlight tr,
.highlight td {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace !important;
  font-size: 0.85rem !important;
  line-height: 1.6 !important;
}

.highlight table {
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  border-collapse: collapse !important;
}

.highlight tr, 
.highlight td {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
}

.highlight code {
  color: inherit !important;
  background-color: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  word-break: normal !important;
}

/* ================================
   场景 A：无行号的普通状态
   ================================ */
.highlight > pre,
.highlight > div > pre { 
  padding: 16px 20px !important;
  margin: 0 !important;
  overflow-x: auto !important;
}

/* ================================
   场景 B：有行号的 Table 状态
   ================================ */
.highlight td:first-child {
  width: 45px !important;
  min-width: 45px !important;
  background-color: #eff3f6 !important;
  border-right: 1px solid #e1e4e8 !important;
  vertical-align: top !important;
  user-select: none !important;
}

.highlight td:first-child pre {
  padding: 16px 10px 16px 0 !important;
  margin: 0 !important;
  text-align: right !important;
  color: #babbbd !important;
}

.highlight td:last-child {
  vertical-align: top !important;
  width: calc(100% - 45px) !important;
}

.highlight td:last-child pre {
  padding: 16px 20px !important;
  margin: 0 !important;
  color: #24292e !important;
  overflow-x: auto !important;
  word-break: normal !important;
  white-space: pre !important;
}

.highlight .chroma {
  background-color: transparent !important;
}

/* =========================================
   移动端排版保护
   ========================================= */

/* 1. 代码块与预格式化文本 */
.single-content pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* iOS 的弹性滚动 */
  padding-bottom: 10px;
}

/* 2. 表格容器 (块级元素以支持局部滚动) */
.single-content table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}

/* 3. KaTeX 数学公式*/
.single-content .katex-display {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overflow-y: hidden;
}