/* 前台阅读样式：由 Layout 按路由加载，发布页不加载本文件。
 * 复用 light.css 的明暗主题变量、代码高亮和交互组件，保留原有兼容逻辑。
 */

/* 收敛装饰，让内容、细分隔线与留白构成页面层级。 */
body::before,
[data-theme="dark"] body::after {
  background-image: none;
}

/* 所有前台页面共用一套外层宽度，页面切换时内容、导航和页脚保持对齐。
 * 预留滚动条位置，避免长短页面切换时容器发生轻微横向跳动。
 */
html { --site-content-width: 1040px; scrollbar-gutter: stable; }
.container { max-width: var(--site-content-width); }
/* clip 不会像 hidden 一样把另一轴变成 auto，目录/返回顶部继续使用页面滚动。 */
html, body { overflow-x: clip; }
.site-main { padding: 3.5rem 0 4.5rem; overflow: visible; flex: 1 0 auto; }
.site-header { border-bottom-color: var(--border); }
.site-brand { font-family: var(--font-sans); letter-spacing: .02em; }
.site-brand::before { text-shadow: none; }
.site-nav a { border-radius: 6px; }
.site-nav a.active::after { content: none; }
.theme-toggle { border: 1px solid var(--border); border-radius: 50%; }

.page-header { padding-bottom: 2rem; border-bottom-color: var(--border); }
.page-header::after { content: none; }
.page-header.page-header--hero {
  padding: 1rem 0 3.25rem;
  margin-bottom: 0;
}
.page-eyebrow {
  color: var(--accent);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .16em;
  margin-bottom: 1.15rem;
}
.page-header h1 {
  font-family: var(--font-sans);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 750;
  letter-spacing: -.04em;
  line-height: 1.3;
}
.page-subtitle {
  font-family: var(--font-sans);
  font-weight: 400;
  margin-top: 1rem;
}
.page-subtitle strong {
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--accent);
}

/* 列表保持单列，完整呈现摘要，避免长标题和文章内容被截断。 */
.post-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--border);
}
.post-list-heading h2 {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .9rem;
  font-weight: 650;
}
.post-count {
  font-size: .72rem;
  font-weight: 400;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .05rem .45rem;
  font-variant-numeric: tabular-nums;
}
.post-list-heading a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  gap: .5rem;
  color: var(--text-secondary);
  font-size: .8rem;
  text-decoration: none;
}
.post-list-heading a:hover { color: var(--accent); }
.post-list { gap: .85rem; overflow: visible; }
.post-card {
  padding: 1.75rem 2rem;
  border-radius: 10px;
  box-shadow: none;
  overflow: visible;
}
.post-card::after,
.post-card time::before { content: none; }
.post-card:hover,
.post-card:focus-within {
  border-color: var(--border-accent);
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: none;
}
.post-card time { color: var(--text-secondary); font-size: .75rem; margin-bottom: .7rem; }
.post-card h2 { font-size: 1.22rem; line-height: 1.6; margin-bottom: .6rem; text-wrap: initial; }
.post-card .summary { font-size: .92rem; line-height: 1.85; margin-bottom: 1rem; }
.post-card .read-more { min-height: 32px; font-family: var(--font-sans); font-size: .8rem; }

/* 首页两栏：仅在桌面启用；侧栏自然随页面滚动，长内容不会被固定高度裁切。 */
.home-columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2.5rem; }
.home-feed, .home-sidebar { min-width: 0; }
.home-sidebar { border-top: 1px solid var(--border); }
.sidebar-section { padding: 1.4rem 0; border-bottom: 1px solid var(--border); }
.sidebar-section:last-child { border-bottom: 0; }
.sidebar-section h2 { font-size: .88rem; font-weight: 650; margin-bottom: 1rem; }
.sidebar-site-name { font-size: 1.1rem; font-weight: 700; margin-bottom: .5rem; }
.sidebar-intro { color: var(--text-secondary); font-size: .84rem; line-height: 1.9; }
.sidebar-links { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-top: .85rem; }
.sidebar-links a, .sidebar-more {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 36px;
  font-size: .78rem;
  color: var(--accent);
  text-decoration: none;
}
.sidebar-links a:hover, .sidebar-more:hover { text-decoration: underline; text-underline-offset: 4px; }
.sidebar-months, .sidebar-featured { list-style: none; }
.sidebar-months a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 42px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .83rem;
  border-radius: 5px;
}
.sidebar-months a:hover { color: var(--accent); background: var(--accent-soft); }
.sidebar-month-count { font-size: .73rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sidebar-more { margin-top: .65rem; }
.sidebar-caption { font-size: .76rem; color: var(--text-secondary); margin-top: -.6rem; margin-bottom: .5rem; }
.sidebar-featured li + li { border-top: 1px solid var(--border-light); }
.sidebar-featured a { display: flex; align-items: baseline; gap: .7rem; padding: 1rem 0; text-decoration: none; color: var(--text-primary); }
.featured-number { flex: 0 0 1.25rem; font-family: var(--font-mono); font-size: .73rem; color: var(--accent); }
.featured-content { min-width: 0; }
.featured-title { display: block; font-size: .86rem; font-weight: 550; line-height: 1.75; overflow-wrap: anywhere; }
.featured-meta { display: block; margin-top: .45rem; color: var(--text-secondary); font-size: .68rem; line-height: 1.8; }
.featured-meta time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.sidebar-featured a:hover .featured-title { color: var(--accent); }
.archive-month[id] { scroll-margin-top: 80px; }
@media (min-width: 1024px) {
  /* 桌面前台统一占视口的 80%，不设像素上限；目录定位复用同一变量。 */
  html { --site-content-width: 80vw; }
  .home-columns { grid-template-columns: minmax(0, 3fr) minmax(224px, 1fr); gap: 2rem; }
  .home-sidebar { padding-left: 1.5rem; border-left: 1px solid var(--border); }
  .home-feed .post-card { padding: 1.5rem; }
}

/* 全站前台容器按 CSS 视口伸展，兼容 4K 系统缩放。
 * 首页专属字号/间距仍按 layout-wide 隔离，发布页不加载本文件。
 */
@media (min-width: 1200px) {
  .layout-wide .home-columns { gap: clamp(2rem, 2.5vw, 5rem); }
  .layout-wide .home-sidebar { padding-left: clamp(1.5rem, 2vw, 3rem); }
  .layout-wide .home-feed .post-card { padding: clamp(1.5rem, 1.5vw, 3rem); }
  /* 拉宽卡片时保留摘要的阅读边界，完整展示文字，不截断内容。 */
  .layout-wide .post-card h2 { font-size: clamp(1.22rem, .8rem + .4vw, 1.65rem); max-width: 55em; }
  .layout-wide .post-card .summary { font-size: clamp(.92rem, .6rem + .3vw, 1.2rem); max-width: 72em; }
  .layout-wide .post-card time,
  .layout-wide .post-card .read-more { font-size: clamp(.8rem, .65rem + .15vw, 1rem); }
  .layout-wide .sidebar-section h2,
  .layout-wide .post-list-heading h2 { font-size: clamp(.9rem, .65rem + .2vw, 1.1rem); }
  .layout-wide .sidebar-intro,
  .layout-wide .sidebar-months a,
  .layout-wide .featured-title { font-size: clamp(.86rem, .6rem + .2vw, 1.1rem); }
  .layout-wide .featured-meta,
  .layout-wide .sidebar-caption,
  .layout-wide .sidebar-month-count { font-size: clamp(.73rem, .55rem + .15vw, .9rem); }
}

/* 正文卡片填满容器分配的空间；取消旧布局向右扩展的负 margin。 */
.article-detail { max-width: 100%; margin: 0 auto; }
.article-detail--bare { margin-top: 0; }
.article-header { padding: .25rem .25rem 1.75rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.article-header h1 {
  font-family: var(--font-sans);
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 1.5;
  letter-spacing: -.025em;
}
.article-header time { color: var(--text-secondary); }
.article-header time::before { box-shadow: none; }
.article-summary { max-width: none; line-height: 1.9; margin-top: .9rem; }
.article-body { padding: 2.5rem; border-radius: 10px; box-shadow: none; line-height: 1.95; }
.article-body :is(h1, h2, h3, h4) { font-family: var(--font-sans); line-height: 1.6; }
.article-body h2 { margin-top: 2.75rem; padding-bottom: .65rem; }
.article-body h2::after { content: none; }
.article-body > :first-child { margin-top: 0; }
.article-body :is(h1, h2, h3, h4, h5, h6)[id] { scroll-margin-top: 80px; }
.article-body blockquote { border-radius: 0 8px 8px 0; }
.article-body pre { max-width: 100%; overflow-x: auto; }
.article-body table { display: block; max-width: 100%; overflow-x: auto; }

/* 与现有脚本保持 1024px 断点和 59px 导航高度一致，目录不再挤出正文。 */
@media (min-width: 1024px) {
  .site-main.has-toc > .container {
    max-width: var(--site-content-width);
    margin: 0 auto;
    padding-left: 280px;
  }
  .toc-sidebar {
    left: calc(max(0px, (100% - var(--site-content-width)) / 2) + 24px);
    width: 224px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-right: 1px solid var(--border);
  }
  .toc-inner { padding: 2.75rem .65rem 2rem 0; }
}
.toc-title { font-family: var(--font-sans); font-size: .78rem; color: var(--text-secondary); }
.toc-item a { overflow-wrap: anywhere; border-radius: 0 5px 5px 0; line-height: 1.7; }
.toc-progress { background: var(--accent); }

/* 宽屏阅读区共用尺寸变量，固定目录与正文按同一容器计算位置。
 * 继续使用现有脚本的 1024px 断点及 59px 顶栏高度；手机保留目录抽屉。
 */
@media (min-width: 1024px) {
  .layout-reading {
    --reading-width: var(--site-content-width);
    --reading-toc-width: clamp(224px, 15vw, 320px);
    --reading-gap: clamp(32px, 3vw, 80px);
  }
  .layout-reading .container { max-width: var(--reading-width); }
  .layout-reading .site-main.has-toc > .container {
    max-width: var(--reading-width);
    padding-left: calc(24px + var(--reading-toc-width) + var(--reading-gap));
  }
  /* 无目录文章直接填满共用容器；有目录时仅由容器内边距预留目录空间。 */
  .layout-reading .article-detail { max-width: 100%; }
  .layout-reading .toc-sidebar {
    left: calc(max(0px, (100% - var(--reading-width)) / 2) + 24px);
    width: var(--reading-toc-width);
  }
  .layout-reading .toc-inner { padding-top: 3.5rem; }
  .layout-reading .toc-title { font-size: clamp(.78rem, .6rem + .2vw, 1rem); }
  .layout-reading .toc-item a { font-size: clamp(.82rem, .65rem + .2vw, 1.05rem); }
  .layout-reading .article-header h1 { font-size: clamp(2rem, 1.3rem + .7vw, 3rem); }
  .layout-reading .article-meta,
  .layout-reading .article-header time { font-size: clamp(.85rem, .65rem + .2vw, 1rem); }
  .layout-reading .article-summary { font-size: clamp(.96rem, .75rem + .25vw, 1.2rem); }
  .layout-reading .article-body {
    padding: clamp(2.25rem, 2.5vw, 4rem);
    font-size: clamp(1rem, .8rem + .25vw, 1.25rem);
  }
  /* 外沿统一后限制长文内部的文字行宽；代码、表格、图片仍可利用完整卡片宽度。 */
  .layout-reading .article-body > :is(p, ul, ol, blockquote) { max-width: 72em; }
  .layout-reading .article-body h2 { font-size: clamp(1.35rem, 1rem + .3vw, 1.75rem); }
  .layout-reading .article-body h3 { font-size: clamp(1.1rem, .9rem + .2vw, 1.4rem); }
  /* 行内代码沿用相对字号，代码块独立放大；长代码/表格仍在块内横向滚动。 */
  .layout-reading .article-body pre,
  .layout-reading .article-body pre code,
  .layout-reading .article-body .highlight { font-size: clamp(.85rem, .65rem + .2vw, 1.1rem); }
}

/* 年月分组沿用现有结构，弱化渐变并强化时间线的对齐。 */
.archive-year { border-left: none; padding-left: 0; margin-top: 2.5rem; align-items: center; }
.archive-year .year-num {
  font-size: 2rem;
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--text-primary);
}
.archive-month { margin-left: 0; background: transparent; border: none; padding-left: 0; }
.archive-month .month-count { background: var(--accent-soft); color: var(--accent); }
.archive-list { border-left: 1px solid var(--border); margin-left: .8rem; padding-left: 1rem; }
.archive-list li { border-radius: 6px; padding: .75rem 1rem; will-change: auto; }
.archive-list li:hover { transform: none; box-shadow: none; background: var(--accent-soft); }
.archive-list time { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.archive-list a { overflow-wrap: anywhere; }
.pagination { justify-content: space-between; border-top: 1px solid var(--border); margin-top: 2rem; }
.pagination a { box-shadow: none; border-radius: 6px; min-height: 44px; }
.pagination span { color: var(--text-secondary); }
.site-footer { border-top-color: var(--border); line-height: 2; font-family: var(--font-sans); }
.site-footer .footer-row { gap: 1rem; }
.site-footer .footer-row > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.site-footer .footer-version { display: inline-block; }
.back-to-top { border-radius: 10px; box-shadow: var(--shadow-card); }

/* 平板/手机目录入口放在左下角，与返回顶部呼应，锚点跳转后不遮挡标题。 */
@media (max-width: 1023px) {
  .toc-sidebar { visibility: hidden; }
  .toc-sidebar.open { visibility: visible; }
  .toc-toggle { top: auto; bottom: calc(1rem + env(safe-area-inset-bottom)); border-radius: 10px; }
}
@media (max-width: 768px) {
  .container { padding: 0 1.15rem; }
  .site-main { padding: 2rem 0 3rem; }
  .site-header .container { gap: .4rem; }
  .site-brand { font-size: .9rem; }
  .site-nav a { padding: .35rem .5rem; }
  .theme-toggle { width: 34px; height: 34px; }
  .page-header.page-header--hero { padding: .5rem 0 2rem; }
  .page-header h1 { font-size: 2rem; }
  .page-eyebrow { font-size: .7rem; margin-bottom: .85rem; }
  .page-subtitle { font-size: .9rem; margin-top: .75rem; }
  .post-card { padding: 1.25rem; }
  .post-card h2 { font-size: 1.1rem; }
  .post-card .summary { font-size: .9rem; }
  .post-card .read-more { min-height: 38px; }
  .article-header { padding-bottom: 1.25rem; }
  .article-header h1 { font-size: 1.6rem; }
  .article-body { padding: 1.25rem; font-size: 1rem; line-height: 1.9; }
  .article-body h2 { font-size: 1.2rem; }
  .archive-list { padding-left: .6rem; margin-left: .25rem; }
  .archive-list li { flex-direction: row; align-items: baseline; gap: .8rem; padding: .65rem .35rem; }
  .archive-list time { flex: 0 0 3rem; }
  .site-footer .footer-row > span { flex-basis: 100%; }
}

/* 小屏导航保留全部入口，并维持脚本使用的顶部栏高度。 */
@media (max-width: 420px) {
  body { padding-top: 59px; }
  .site-header .container { height: 58px; padding-left: .75rem; padding-right: .75rem; }
  .site-brand { font-size: .82rem; gap: .25rem; flex-shrink: 1; overflow-wrap: anywhere; white-space: normal; }
  .site-nav { flex: 0 0 auto; }
  .site-nav a { font-size: .73rem; padding-left: .35rem; padding-right: .35rem; }
  .toc-sidebar, .toc-backdrop { top: 59px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
