/* ==========================================================================
   SaaS Theme for Halo — editorial edition
   --------------------------------------------------------------------------
   设计取法: 纸质刊物。暖白纸面 + 近黑正文 + 单一强调色;
   层次靠字号、留白和发丝线, 不靠渐变、投影和圆角卡片。
   配色变量由 modules/head.html 注入:
     --color-primary / --color-secondary / --bg-light / --bg-dark
     --box-bg-light / --box-bg-dark / --box-radius / --box-opacity
   ========================================================================== */

:root {
  /* ---- 字体 ---- */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue",
    Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas,
    "Liberation Mono", Menlo, monospace;

  /* ---- 纸面 ---- */
  --bg: var(--bg-light);
  --text: #191815;
  --text-2: #57534b;
  --text-3: #8b857a;
  --line: #e5e0d7;
  --line-2: #cfc8bb;
  --accent: var(--color-primary);
  --code-bg: #f3f0e9;
  --mark-bg: #f6e7c8;

  /* 只有浮层才配投影 */
  --shadow-pop: 0 12px 28px -14px rgba(30, 25, 15, 0.28);

  --radius: 3px;
  --measure: 68ch;
}

html[data-mode="dark"] {
  --bg: var(--bg-dark);
  --text: #ece8e0;
  --text-2: #aca69c;
  --text-3: #79736a;
  --line: #2e2c27;
  --line-2: #45413a;
  --code-bg: #232019;
  --mark-bg: #4a3c1c;
  --shadow-pop: 0 12px 28px -14px rgba(0, 0, 0, 0.7);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html[data-mode="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--accent);
}

img {
  max-width: 100%;
}

::selection {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.container {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* 跳转正文: 仅供键盘与读屏用户 */
.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip-link:focus,
.skip-link:focus-visible {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0.55rem 1rem;
  overflow: visible;
  clip: auto;
  clip-path: none;
  z-index: 300;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
}

/* ------------------------------- 页头 ---------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg, var(--bg));
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.brand:hover {
  color: var(--text);
}
.brand:hover .brand-title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
  text-decoration-color: var(--line-2);
}
.brand-logo {
  width: 26px;
  height: 26px;
  border-radius: 2px;
  object-fit: cover;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  margin-left: auto;
}
.site-nav a {
  color: var(--text-2);
  font-size: 0.9375rem;
  text-decoration: none;
}
.site-nav a:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-color: var(--line-2);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.5rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: color 0.15s ease;
}
.icon-btn:hover {
  color: var(--text);
}

#theme-toggle .icon-moon {
  display: none;
}
html[data-mode="dark"] #theme-toggle .icon-moon {
  display: block;
}
html[data-mode="dark"] #theme-toggle .icon-sun {
  display: none;
}

.nav-burger {
  display: none;
}

/* ------------------------------- 主体 ---------------------------------- */

.site-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 4.5rem;
  padding-top: 3rem;
  padding-bottom: 4.5rem;
  min-height: calc(100vh - 320px);
}
.site-main.single-col {
  grid-template-columns: minmax(0, 1fr);
}

/* --------------------------- 首页刊头 ---------------------------------- */

.masthead {
  margin-bottom: 2.5rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--line-2);
}
.masthead h1 {
  margin: 0;
  font-size: clamp(1.9rem, 1.5rem + 1.6vw, 2.5rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.005em;
}
.masthead-sub {
  margin: 0.6rem 0 0;
  max-width: 52ch;
  color: var(--text-2);
  font-size: 1rem;
  line-height: 1.7;
}

/* --------------------------- 文章条目列表 ------------------------------ */

.entry-list {
  display: block;
}

.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 2.25rem;
  padding: 1.75rem 0;
  border-top: 1px solid var(--line);
}
.entry:first-child {
  border-top: 0;
  padding-top: 0.25rem;
}
.entry:last-child {
  padding-bottom: 0;
}

.entry-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text-3);
}
.entry-meta > * + *::before {
  content: "·";
  margin: 0 0.55rem;
  color: var(--text-3);
  opacity: 0.7;
}
.entry-cat {
  color: var(--text-2);
}
.entry-cat:hover {
  color: var(--accent);
}
.entry-pin {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.entry-title {
  margin: 0.35rem 0 0;
  font-size: 1.25rem;
  font-weight: 650;
  line-height: 1.5;
  letter-spacing: -0.003em;
}
.entry-title a {
  color: var(--text);
}
.entry-title a:hover {
  color: var(--accent);
}

.entry-excerpt {
  margin: 0.5rem 0 0;
  max-width: 62ch;
  color: var(--text-2);
  font-size: 0.9375rem;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-foot {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-3);
}
.entry-author {
  color: var(--text-3);
}
.entry-author:hover {
  color: var(--text);
}

.entry-thumb {
  display: block;
  align-self: start;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: 2px;
  background: var(--code-bg);
}
.entry-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.25s ease;
}
.entry-thumb:hover img {
  opacity: 0.85;
}

/* --------------------------- 通用页面标题 ------------------------------ */

.page-head {
  margin-bottom: 2.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line-2);
}
.page-head-label {
  margin: 0;
  color: var(--text-3);
  font-size: 0.8125rem;
  letter-spacing: 0.12em;
}
.page-head h1 {
  margin: 0.3rem 0 0;
  font-size: clamp(1.5rem, 1.25rem + 1vw, 1.9rem);
  font-weight: 700;
  line-height: 1.3;
}
.page-head-desc {
  margin: 0.5rem 0 0;
  max-width: var(--measure);
  color: var(--text-2);
  font-size: 0.9375rem;
}

.author-head {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.author-head .widget-avatar {
  width: 56px;
  height: 56px;
}

/* ------------------------------- 侧栏 ---------------------------------- */

/* 网格子项默认 min-width:auto, 长代码/长链接会撑破栏宽, 显式归零 */
.content-col {
  min-width: 0;
}

.sidebar-col {
  display: flex;
  flex-direction: column;
  align-self: start;
  position: sticky;
  top: 100px;
  max-height: calc(100vh - 124px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
  font-size: 0.9375rem;
}
.sidebar-col::-webkit-scrollbar {
  width: 4px;
}
.sidebar-col::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 999px;
}

.widget {
  padding: 1.5rem 0;
  border-top: 1px solid var(--line);
}
.widget:first-child {
  padding-top: 0;
  border-top: 0;
}

.widget-title {
  margin: 0 0 0.9rem;
  color: var(--text-3);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.4;
}

.widget-profile {
  padding-top: 0;
  border-top: 0;
}
.widget-profile .widget-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}
.widget-profile h3 {
  margin: 0.8rem 0 0.2rem;
  font-size: 1rem;
  font-weight: 650;
}
.widget-profile p {
  margin: 0;
  color: var(--text-2);
  font-size: 0.875rem;
  line-height: 1.65;
}

.widget-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.widget-list li + li {
  margin-top: 0.55rem;
}
.widget-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text-2);
  font-size: 0.9375rem;
  line-height: 1.55;
}
.widget-list a:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--line-2);
}
.widget-count {
  flex-shrink: 0;
  color: var(--text-3);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.widget-recent a {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.widget-sublist {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0 0 0 0.9rem;
  border-left: 1px solid var(--line);
}
.widget-sublist li + li {
  margin-top: 0.35rem;
}
.widget-sublist a {
  font-size: 0.875rem;
}

.widget-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.9rem;
}
.tag-chip {
  color: var(--text-2);
  font-size: 0.875rem;
  line-height: 1.9;
}
.tag-chip:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.widget-empty {
  margin: 0;
  color: var(--text-3);
  font-size: 0.875rem;
}

/* 站点统计: 表格感的两列, 不用色块 */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.25rem;
  margin: 0;
}
.stats-grid > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}
.stats-grid dt {
  color: var(--text-3);
  font-size: 0.8125rem;
}
.stats-grid dd {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------- 目录 --------------------------------- */

.widget-toc {
  position: relative;
}
.toc {
  font-size: 0.875rem;
  max-height: 58vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc li + li {
  margin-top: 0.1rem;
}
.toc a {
  display: block;
  padding: 0.2rem 0;
  color: var(--text-2);
  line-height: 1.55;
  border-bottom: 1px solid transparent;
}
.toc .toc-h3 {
  padding-left: 0.9rem;
}
.toc .toc-h4 {
  padding-left: 1.8rem;
}
.toc a:hover {
  color: var(--text);
}
.toc a.toc-active {
  color: var(--accent);
}

/* ---------------------------- 分类总览 --------------------------------- */

.taxonomy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
}
.taxonomy-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.5rem 1.5rem 1.5rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  min-width: 0;
}
.taxonomy-card:hover {
  color: var(--text);
}
.taxonomy-card-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}
.taxonomy-card-head:hover h2 {
  color: var(--accent);
}
.taxonomy-card h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
}
.taxonomy-card p {
  margin: 0;
  color: var(--text-2);
  font-size: 0.875rem;
  line-height: 1.65;
}
.taxonomy-children {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
}
.taxonomy-children li + li {
  margin-top: 0.3rem;
}
.taxonomy-children a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--text-2);
  font-size: 0.875rem;
}

.subcat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1rem;
  margin-bottom: 1.5rem;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  margin-bottom: 2rem;
}
.tag-cloud .tag-chip {
  font-size: 1rem;
  line-height: 2;
}

/* -------------------------------- 归档 --------------------------------- */

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}
.archive-group h2 {
  margin: 0 0 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line-2);
  font-size: 1.15rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.archive-month + .archive-month {
  margin-top: 1.25rem;
}
.archive-month-title {
  margin: 0 0 0.35rem;
  color: var(--text-3);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.08em;
}
.archive-item {
  display: flex;
  gap: 1.25rem;
  align-items: baseline;
  padding: 0.3rem 0;
  color: var(--text);
  font-size: 0.9375rem;
}
.archive-item time {
  flex-shrink: 0;
  color: var(--text-3);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}
.archive-item:hover {
  color: var(--accent);
}
.archive-item:hover span {
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--line-2);
}

/* ---------------------------- 文章详情 --------------------------------- */

.post-detail {
  max-width: 100%;
}

.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--line);
}
.post-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.8125rem;
}
.post-categories .tag-chip {
  color: var(--text-2);
  font-size: 0.8125rem;
}
.post-header h1 {
  margin: 0 0 0.85rem;
  font-size: clamp(1.7rem, 1.4rem + 1.3vw, 2.1rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.005em;
  text-wrap: balance;
}
.post-header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0;
  color: var(--text-3);
  font-size: 0.8125rem;
}
.post-header-meta > * + *::before {
  content: "·";
  margin: 0 0.55rem;
  opacity: 0.7;
}
.post-header-meta a {
  color: var(--text-2);
}
.post-header-meta a:hover {
  color: var(--accent);
}

.post-cover {
  display: block;
  width: 100%;
  max-height: 420px;
  margin-top: 1.5rem;
  object-fit: cover;
  border-radius: 2px;
}

/* ---------------------------- 正文排版 --------------------------------- */

.post-content {
  max-width: var(--measure);
  font-size: clamp(1rem, 0.96rem + 0.18vw, 1.0625rem);
  line-height: 1.85;
  letter-spacing: 0.01em;
  word-break: break-word;
}
.post-content > *:first-child {
  margin-top: 0;
}

.post-content p {
  margin: 1.15em 0;
}

.post-content h2,
.post-content h3,
.post-content h4 {
  color: var(--text);
  line-height: 1.45;
  letter-spacing: 0;
  text-wrap: balance;
}
.post-content h2 {
  margin: 2.4em 0 0.7em;
  font-size: clamp(1.3rem, 1.2rem + 0.4vw, 1.5rem);
  font-weight: 700;
}
.post-content h3 {
  margin: 1.9em 0 0.6em;
  font-size: clamp(1.13rem, 1.07rem + 0.26vw, 1.25rem);
  font-weight: 650;
}
.post-content h4 {
  margin: 1.6em 0 0.5em;
  font-size: 1.03rem;
  font-weight: 650;
}

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.post-content a:hover {
  text-decoration-color: var(--accent);
}

.post-content ul,
.post-content ol {
  margin: 1.1em 0;
  padding-left: 1.5em;
}
.post-content li + li {
  margin-top: 0.4em;
}
.post-content li::marker {
  color: var(--text-3);
}

.post-content blockquote {
  margin: 1.6em 0;
  padding: 0.1rem 0 0.1rem 1.25rem;
  border-left: 2px solid var(--line-2);
  color: var(--text-2);
  font-size: 0.975em;
  line-height: 1.8;
}
.post-content blockquote p {
  margin: 0.5em 0;
}

.post-content img {
  border-radius: 2px;
  height: auto;
}

.post-content hr {
  margin: 2.5em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.post-content mark {
  background: var(--mark-bg);
  color: inherit;
  padding: 0 0.15em;
}

.post-content table {
  width: 100%;
  margin: 1.5em 0;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.6;
}
.post-content th,
.post-content td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.post-content thead th {
  border-bottom: 1px solid var(--line-2);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}

.post-content :not(pre) > code {
  padding: 0.12em 0.36em;
  border-radius: 3px;
  background: var(--code-bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.86em;
}

.post-content pre {
  position: relative;
  margin: 1.5em 0;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--code-bg);
  font-size: 0.875rem;
  line-height: 1.65;
  tab-size: 2;
}
.post-content pre code {
  padding: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-size: inherit;
  letter-spacing: 0;
}

/* 代码块横向滚动条弱化 */
.post-content pre::-webkit-scrollbar {
  height: 6px;
}
.post-content pre::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 999px;
}

/* ---------------------------- 文章负信息 ------------------------------- */

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.post-share {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1.25rem;
  margin-top: 1.25rem;
  font-size: 0.875rem;
}
.post-share-label {
  color: var(--text-3);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
}
.share-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}
.share-btn:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.post-navigation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-top: 3rem;
  border-top: 1px solid var(--line);
}
.post-nav-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.25rem 1.5rem 1.25rem 0;
  color: var(--text);
}
.post-nav-card + .post-nav-card {
  padding-left: 1.5rem;
  border-left: 1px solid var(--line);
}
.post-nav-card:hover {
  color: var(--text);
}
.post-nav-card:hover strong {
  color: var(--accent);
}
.post-nav-card span {
  color: var(--text-3);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
}
.post-nav-card strong {
  font-size: 0.975rem;
  font-weight: 600;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-nav-card.next {
  text-align: right;
}

.comments {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.empty-tip {
  padding: 4rem 0;
  color: var(--text-3);
  font-size: 0.9375rem;
  text-align: center;
}

/* -------------------------------- 分页 --------------------------------- */

.pagination {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
}
.page-btn {
  color: var(--text-2);
  font-size: 0.9375rem;
}
.page-btn:hover {
  color: var(--accent);
}
/* 分页箭头用伪元素, 与 i18n 文案解耦 */
.pagination .page-btn.prev::before {
  content: "← ";
}
.pagination .page-btn.next::after {
  content: " →";
}
.page-info {
  color: var(--text-3);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------- 页脚 --------------------------------- */

.site-footer {
  padding: 2rem 0 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: 0.8125rem;
  line-height: 1.9;
}
.site-footer p {
  margin: 0;
}
.site-footer a {
  color: var(--text-2);
}
.site-footer a:hover {
  color: var(--accent);
}
.footer-meta,
.footer-filing {
  margin-top: 0.15rem !important;
}
/* 备案行: 两项都在时同一行显示, 窄屏再折行, 不做居中也不会散架 */
.footer-filing {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: 0.1rem;
}
.footer-author a {
  word-break: break-all;
}
.footer-sep {
  margin: 0 0.45rem;
  opacity: 0.55;
}

/* --------------------------- 阅读进度与工具 ---------------------------- */

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 130;
  pointer-events: none;
}
.reading-progress-bar {
  display: block;
  width: 100%;
  height: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: var(--accent);
  transition: transform 0.1s linear;
}

.code-copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--line-2);
  border-radius: 2px;
  background: var(--code-bg);
  color: var(--text-3);
  font: inherit;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  line-height: 1.6;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.post-content pre:hover .code-copy-btn,
.code-copy-btn:focus-visible,
.code-copy-btn.is-copied {
  opacity: 1;
}
.code-copy-btn:hover,
.code-copy-btn.is-copied {
  color: var(--accent);
  border-color: var(--accent);
}

.back-to-top {
  position: fixed;
  right: 1.75rem;
  bottom: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 110;
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ------------------------------ 图片灯箱 ------------------------------- */

.post-content img.zoomable {
  cursor: zoom-in;
}
body.lightbox-open {
  overflow: hidden;
}
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  background: rgba(16, 14, 10, 0.92);
}
.lightbox[hidden] {
  display: none;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 2px;
}
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  padding: 0;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover {
  color: #fff;
}

/* ------------------------------ 错误页面 ------------------------------- */

.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.error-card {
  max-width: 460px;
  padding: 3rem 0;
}
.error-code {
  margin: 0;
  color: var(--text-3);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2em;
}
.error-card h1 {
  margin: 0.5rem 0 0.75rem;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.4;
}
.error-desc,
.error-detail {
  margin: 0;
  color: var(--text-2);
  font-size: 0.9375rem;
  line-height: 1.75;
}
.error-detail {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--code-bg);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  word-break: break-word;
}
.error-actions {
  display: flex;
  gap: 1.5rem;
  margin-top: 2rem;
  font-size: 0.9375rem;
}
.error-actions .page-btn {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.error-actions .page-btn:hover {
  text-decoration-color: var(--accent);
}
.error-ref {
  margin: 2rem 0 0;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  word-break: break-all;
}

/* ------------------------------ 多级菜单 ------------------------------- */

.nav-item {
  position: relative;
  display: flex;
}
.nav-item > a {
  display: inline-flex;
  align-items: center;
}
.nav-sub {
  position: absolute;
  top: calc(100% + 0.6rem);
  left: -0.75rem;
  min-width: 150px;
  display: none;
  flex-direction: column;
  padding: 0.4rem 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  z-index: 120;
}
.nav-item:hover .nav-sub,
.nav-item:focus-within .nav-sub {
  display: flex;
}
.nav-sub a {
  padding: 0.45rem 1rem;
  white-space: nowrap;
  font-size: 0.9rem;
  color: var(--text-2);
}
.nav-sub a:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 5%, transparent);
  text-decoration: none;
}

/* ==========================================================================
   大盒子布局 (global-box-mode)
   开关由主题设置 layout.enable_global_box 控制, 由布局模板写到 <body>。
   关闭时 .site-box 只是一个普通 div, 不产生任何视觉变化。
   ========================================================================== */

:root {
  --box-bg: var(--box-bg-light, #fffefb);
  --box-gap: 28px;
  --box-max: 1300px;
  --box-shadow: 0 1px 1px rgba(40, 32, 18, 0.03),
    0 8px 20px -8px rgba(40, 32, 18, 0.06),
    0 28px 60px -28px rgba(40, 32, 18, 0.1);
}

html[data-mode="dark"] {
  --box-bg: var(--box-bg-dark, #1c1b17);
  --box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4), 0 10px 24px -8px rgba(0, 0, 0, 0.45),
    0 30px 64px -28px rgba(0, 0, 0, 0.6);
}

body.global-box-mode {
  padding: var(--box-gap);
  background: var(--bg);
}

body.global-box-mode .site-box {
  max-width: var(--box-max);
  margin: 0 auto;
  min-height: calc(100vh - var(--box-gap) * 2);
  background: color-mix(in srgb, var(--box-bg) var(--box-opacity, 100%), transparent);
  border-radius: var(--box-radius, 12px);
  box-shadow: var(--box-shadow);
}

/*
  .site-box 不能设 overflow, 否则会成为滚动容器让 sticky 页头失效,
  因此页头与页脚单独跟着圆角裁切。
*/
body.global-box-mode .site-header {
  top: var(--box-gap);
  border-radius: var(--box-radius, 12px) var(--box-radius, 12px) 0 0;
  background: color-mix(in srgb, var(--box-bg) var(--box-opacity, 100%), transparent);
}
body.global-box-mode .site-footer {
  border-radius: 0 0 var(--box-radius, 12px) var(--box-radius, 12px);
}

/* 页头与视口之间那条 --box-gap 的空档, 正文会透出来, 用同色遮罩盖住 */
body.global-box-mode::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--box-gap);
  background: var(--bg);
  z-index: 99;
  pointer-events: none;
}

/* 固定定位元素对齐盒子边界而不是视口 */
body.global-box-mode .reading-progress {
  top: var(--box-gap);
  left: 50%;
  right: auto;
  width: min(calc(100% - var(--box-gap) * 2), var(--box-max));
  transform: translateX(-50%);
}
body.global-box-mode .back-to-top {
  right: calc(max(var(--box-gap), (100% - var(--box-max)) / 2) + 1.5rem);
  bottom: calc(var(--box-gap) + 1.5rem);
}
body.global-box-mode .sidebar-col {
  top: calc(var(--box-gap) + 100px);
  max-height: calc(100vh - var(--box-gap) * 2 - 124px);
}
html:has(body.global-box-mode) {
  scroll-padding-top: calc(var(--box-gap) + 5.5rem);
}
body.global-box-mode .error-page {
  min-height: calc(100vh - var(--box-gap) * 2);
}

/* 关闭投影时只靠配色与描边区分盒子 */
body.global-box-mode.no-box-shadow .site-box {
  box-shadow: none;
  border: 1px solid var(--line);
}
body.global-box-mode.no-box-shadow .site-header {
  border-radius: 0;
}

/* ------------------------------ 三端适配 ------------------------------- */

@media (max-width: 1200px) {
  :root {
    --box-gap: 18px;
  }
}
@media (max-width: 900px) {
  :root {
    --box-gap: 12px;
  }
}

@media (max-width: 960px) {
  .site-main {
    grid-template-columns: minmax(0, 1fr);
    gap: 2.5rem;
    padding-top: 2.25rem;
    padding-bottom: 3rem;
  }
  .sidebar-col {
    position: static;
    max-height: none;
    overflow: visible;
  }
  body.global-box-mode .sidebar-col {
    top: auto;
    max-height: none;
  }
  .widget-toc {
    display: none;
  }
  .post-content {
    max-width: none;
  }
  .entry {
    grid-template-columns: minmax(0, 1fr) 160px;
    gap: 1.5rem;
  }
}

@media (max-width: 760px) {
  .container {
    padding: 0 1.25rem;
  }
  .nav-burger {
    display: inline-flex;
  }
  .header-inner {
    height: 60px;
    gap: 1rem;
  }
  /*
    提高特异性: 下方 .site-nav 的 display:flex 在源顺序上不影响这里,
    但 header 内的面板必须是绝对定位, 否则会被推入文档流压在正文上。
  */
  .header-inner .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 0.5rem 1.25rem 1rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--box-bg, var(--bg));
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-pop);
    z-index: 110;
  }
  .header-inner .site-nav.open {
    display: flex;
  }
  .header-inner .site-nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0.4rem 0;
    font-size: 1rem;
    color: var(--text);
  }
  .nav-sub {
    position: static;
    display: flex;
    min-width: 0;
    padding: 0 0 0.5rem 0.9rem;
    border: 0;
    border-left: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }
  .nav-sub a {
    min-height: 40px;
    font-size: 0.9375rem;
    color: var(--text-2);
  }
  .nav-sub a:hover {
    background: transparent;
  }
  body.global-box-mode .header-inner .site-nav {
    border-radius: 0 0 var(--box-radius, 12px) var(--box-radius, 12px);
  }

  .entry {
    grid-template-columns: minmax(0, 1fr) 120px;
    gap: 1.25rem;
    padding: 1.5rem 0;
  }
  .entry-title {
    font-size: 1.125rem;
  }
  .entry-excerpt {
    -webkit-line-clamp: 2;
  }
  .entry-meta > * + *::before {
    content: none;
  }
  .entry-meta {
    column-gap: 0.7rem;
  }

  .post-header-meta > * + *::before {
    content: none;
  }
  .post-header-meta {
    column-gap: 0.75rem;
  }

  .post-navigation {
    grid-template-columns: 1fr;
  }
  .post-nav-card + .post-nav-card {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .post-nav-card.next {
    text-align: left;
  }

  .taxonomy-grid {
    grid-template-columns: 1fr;
  }
  .masthead {
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
  }
  .back-to-top {
    right: 1rem;
    bottom: 1rem;
  }
}

@media (max-width: 640px) {
  :root {
    --box-gap: 0px;
  }
  body.global-box-mode .site-box {
    max-width: none;
    border-radius: 0;
    box-shadow: none;
  }
  body.global-box-mode .site-header,
  body.global-box-mode .site-footer {
    border-radius: 0;
  }
  body.global-box-mode.no-box-shadow .site-box {
    border: 0;
  }
  html:has(body.global-box-mode) {
    scroll-padding-top: 5.5rem;
  }
  body.global-box-mode .back-to-top {
    right: 1rem;
    bottom: 1rem;
  }
  body.global-box-mode .error-page {
    min-height: 100vh;
  }

  .container {
    padding: 0 1.15rem;
  }
  .site-main {
    padding-top: 1.75rem;
    padding-bottom: 2.5rem;
  }
  .entry {
    grid-template-columns: minmax(0, 1fr) 92px;
    gap: 1rem;
    padding: 1.35rem 0;
  }
  .entry-excerpt {
    display: none;
  }
  .entry-foot {
    margin-top: 0.5rem;
  }
  .entry-meta {
    font-size: 0.75rem;
  }
  .entry-title {
    font-size: 1.0625rem;
    line-height: 1.5;
  }
  .masthead h1 {
    font-size: 1.65rem;
  }
  .masthead-sub {
    font-size: 0.9375rem;
  }
  .post-header h1 {
    font-size: 1.45rem;
  }
  .post-content {
    font-size: 1rem;
    line-height: 1.8;
  }
  .post-content pre {
    padding: 0.9rem 1rem;
    font-size: 0.8125rem;
    margin: 1.25em -0.15rem;
  }
  /* 窄屏表格独立滚动, 不撑破页面 */
  .post-content table {
    display: block;
    overflow-x: auto;
    font-size: 0.875rem;
  }
  .post-content th,
  .post-content td {
    padding: 0.5rem 0.7rem;
    white-space: nowrap;
  }
  .post-content h2 {
    margin-top: 2em;
  }
  .post-share {
    gap: 0.35rem 1rem;
  }
  .pagination {
    margin-top: 2rem;
  }
  .archive-list {
    gap: 2rem;
  }
  .error-card {
    padding: 2rem 0;
  }
}
