/* ====================================================================
   magazine.css — 奶油白 / 暖灰 / 深灰 杂志风
   通过主题 inject.head 引入，只覆盖视觉，不改主题源码
   ==================================================================== */

/* ---------- 浅色模式（默认）变量覆盖 ---------- */
:root,
[data-theme="light"] {
  /* 奶油白背景 */
  --global-bg: #faf7f2;
  --anzhiyu-background: #faf7f2;
  --anzhiyu-meta-theme-color: #faf7f2;
  --anzhiyu-meta-theme-post-color: #faf7f2;

  /* 暖灰正文 */
  --anzhiyu-fontcolor: #4a453e;
  --font-color: #4a453e;
  --anzhiyu-secondtext: rgba(74, 69, 62, 0.78);

  /* 暖调卡片 */
  --anzhiyu-card-bg: #fffdfa;
  --anzhiyu-card-border: #ece5da;
  --anzhiyu-secondbg: #f4efe6;
  --anzhiyu-ahoverbg: #f4efe6;
  --anzhiyu-card-btn-bg: #f0e9dd;

  /* 暖调遮罩 / 毛玻璃 */
  --anzhiyu-maskbg: rgba(250, 247, 242, 0.72);
  --anzhiyu-maskbgdeep: rgba(250, 247, 242, 0.9);

  /* 引用块 / 代码块背景 */
  --anzhiyu-post-blockquote-bg: #f7f2e9;
  --anzhiyu-post-tabs-bg: #f4efe6;
  --blockquote-bg: #f7f2e9;

  /* 主色（暖褐） */
  --anzhiyu-theme: #7c6a53;
  --anzhiyu-theme-op: #7c6a5323;
  --anzhiyu-theme-op-deep: #7c6a53cc;
  --anzhiyu-theme-deep: #6b5a45;
  --anzhiyu-main: #7c6a53;
  --anzhiyu-main-op: #7c6a5323;
  --anzhiyu-hovertext: #7c6a53;
  --anzhiyu-lighttext: #7c6a53;
  --btn-bg: #7c6a53;

  /* 阴影：极轻，避免廉价厚重感 */
  --card-box-shadow: 0 1px 3px rgba(74, 69, 62, 0.04);
  --card-hover-box-shadow: 0 4px 16px rgba(74, 69, 62, 0.08);
  --anzhiyu-shadow-nav: 0 1px 8px rgba(74, 69, 62, 0.05);
  --anzhiyu-shadow-lightblack: 0 1px 3px rgba(74, 69, 62, 0.04);
  --anzhiyu-shadow-light2black: 0 1px 3px rgba(74, 69, 62, 0.04);

  /* 分割线 */
  --hr-border: #ece5da;
  --hr-before-color: #d8ccbb;

  /* 滚动条 */
  --anzhiyu-scrollbar: rgba(124, 106, 83, 0.32);
  --scrollbar-color: rgba(124, 106, 83, 0.32);

  /* 杂志语义色：深色模式靠变量级联自动切换，避免重复选择器 */
  --mag-title: #2d2a26;
  --mag-excerpt: rgba(74, 69, 62, 0.85);
  --mag-meta: rgba(74, 69, 62, 0.78);
  --mag-cat: rgba(74, 69, 62, 0.62);
  --mag-code: #8a5a3a;
  /* 代码块底色：主题的代码文字是 #90a4ae（为深底设计），
     若浅色页用近白底会形成浅字压浅底（对比度仅 2.55），
     故统一用深暖底，同时保留主题文字色以不压平语法高亮 */
  --mag-codeblock-bg: #2b2823;
  /* 自有强调色：--anzhiyu-main 被主题以内联样式注入，深色模式改不动，
     故用本变量保证深色下强调色正确切换 */
  --mag-accent: #7c6a53;

  /* 圆角：稍大，更柔和 */
  --anzhiyu-radius: 10px;
  --anzhiyu-border-radius: 10px;
}

/* ---------- 深色模式（保留可用，微调为暖调） ---------- */
[data-theme="dark"] {
  --global-bg: #1a1815;
  --anzhiyu-background: #1a1815;
  --anzhiyu-fontcolor: #e8e2d8;
  --font-color: #e8e2d8;
  --anzhiyu-secondtext: #bfb6a6;
  --anzhiyu-card-bg: #211f1b;
  --anzhiyu-card-border: #3a352d;
  --anzhiyu-secondbg: #26231e;
  /* 引用块 / 代码块背景：浅色块的暖白必须在深色下换成深底，
     否则会形成「浅底 + 浅字」，对比度崩到 1.8 */
  --anzhiyu-post-blockquote-bg: #26231e;
  --anzhiyu-post-tabs-bg: #26231e;
  --blockquote-bg: #26231e;
  --anzhiyu-theme: #c9a86a;
  --anzhiyu-theme-op: #c9a86a23;
  --anzhiyu-main: #c9a86a;
  --anzhiyu-hovertext: #c9a86a;
  --anzhiyu-lighttext: #c9a86a;
  --btn-bg: #c9a86a;

  /* 杂志语义色（深色） */
  --mag-title: #f4efe6;
  --mag-excerpt: rgba(232, 226, 216, 0.72);
  --mag-meta: rgba(232, 226, 216, 0.66);
  --mag-cat: rgba(232, 226, 216, 0.58);
  --mag-code: #d4b896;
  --mag-codeblock-bg: #211f1b;
  --mag-accent: #c9a86a;
}

/* ---------- 全局排版 ---------- */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.85;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- 标题层次 ---------- */
h1, h2, h3, h4, h5, h6 {
  font-family: Georgia, "Times New Roman", "Songti SC", "Noto Serif SC",
    "Source Han Serif SC", "Noto Serif CJK SC", "SimSun", serif;
  color: var(--mag-title);
  font-weight: 600;
  letter-spacing: 0.015em;
  line-height: 1.4;
}

h2 {
  font-size: 1.5em;
  margin-top: 2.2em;
  margin-bottom: 0.9em;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--anzhiyu-card-border);
}

h3 {
  font-size: 1.25em;
  margin-top: 1.8em;
  margin-bottom: 0.7em;
}

/* ---------- 文章正文（杂志阅读宽度 + 舒适行距） ---------- */
#post-content,
.post-content,
#article-container {
  max-width: 720px;
  font-size: 1.0625rem;
  line-height: 1.95;
  color: var(--anzhiyu-fontcolor);
  text-align: justify;
  text-justify: inter-ideograph;
}

#article-container p {
  margin: 1.15em 0;
  line-height: 1.95;
}

/* 段落首行缩进（杂志感，可按需关闭） */
#article-container p {
  text-indent: 0;
}

/* ---------- 引用块：安静的暖调 ---------- */
#article-container blockquote {
  background: var(--anzhiyu-post-blockquote-bg);
  border-left: 3px solid #c9b8a0;
  border-radius: 6px;
  padding: 1em 1.3em;
  margin: 1.6em 0;
  color: var(--anzhiyu-secondtext);
  font-style: normal;
}

#article-container blockquote p {
  margin: 0.5em 0;
  text-indent: 0;
}

/* ---------- 图片：自然、有质感、不过度装饰 ---------- */
#article-container img,
.post-image img {
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(74, 69, 62, 0.08);
  transition: box-shadow 0.3s ease;
  max-width: 100%;
}

#article-container img:hover {
  box-shadow: 0 4px 18px rgba(74, 69, 62, 0.12);
}

/* 游记竖图保留完整人物与街景，不按正文宽度无限拉长 */
#article-container img.trip-portrait {
  display: block;
  width: 100%;
  max-width: 440px;
  height: auto;
  margin: 1.6em auto;
}

#article-container img.trip-route-map {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
  margin: 1.6em auto;
}

/* 游记视频：横屏与竖屏分别按原始画幅居中 */
#article-container .trip-video {
  width: 100%;
  margin: 1.6em auto;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}

#article-container .trip-video--landscape {
  max-width: 720px;
  aspect-ratio: 16 / 9;
}

#article-container .trip-video--portrait {
  max-width: 420px;
  aspect-ratio: 9 / 16;
}

#article-container .trip-video iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- 链接 ---------- */
#article-container a {
  color: var(--mag-accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

#article-container a:hover {
  border-bottom-color: var(--mag-accent);
}

/* ---------- 行内代码与代码块 ---------- */
#article-container code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier,
    monospace;
  font-size: 0.9em;
  background: var(--anzhiyu-post-tabs-bg);
  color: var(--mag-code);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

#article-container pre {
  border-radius: 8px;
  padding: 1.1em 1.3em;
  background: var(--mag-codeblock-bg);
  border: 1px solid var(--anzhiyu-card-border);
}

#article-container pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

/* ---------- 分割线 ---------- */
#article-container hr {
  border: none;
  height: 1px;
  background: var(--anzhiyu-card-border);
  margin: 2.5em 0;
}

/* ---------- 列表 ---------- */
#article-container ul,
#article-container ol {
  padding-left: 1.6em;
  line-height: 1.9;
}

#article-container li {
  margin: 0.45em 0;
}

/* ---------- 表格：隔行暖色 ---------- */
#article-container table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0;
  font-size: 0.95em;
}

#article-container table th,
#article-container table td {
  border: 1px solid var(--anzhiyu-card-border);
  padding: 0.65em 0.9em;
  text-align: left;
}

#article-container table tbody tr:nth-child(even) {
  background: var(--anzhiyu-secondbg);
}

/* ---------- 文章页头部 ---------- */
.post-head-title,
.page-title {
  font-family: Georgia, "Times New Roman", "Songti SC", "Noto Serif SC",
    serif;
  letter-spacing: 0.02em;
}

/* ---------- 卡片：精致不堆砌 ---------- */
#article-container,
.post-card,
.content {
  border-radius: var(--anzhiyu-radius);
}

/* ---------- 侧边栏卡片 ---------- */
aside .card-widget {
  border-radius: var(--anzhiyu-radius);
  background: var(--anzhiyu-card-bg);
  box-shadow: var(--card-box-shadow);
}

/* ---------- 首页文章标题 ----------
   主题选择器为 #recent-posts .recent-post-item .recent-post-info .article-title
   （含 ID，优先级 1,3,0），此处用 body 提权以确保覆盖，不改主题源码 */
body #recent-posts .recent-post-item .recent-post-info a.article-title {
  font-family: Georgia, "Times New Roman", "Songti SC", "Noto Serif SC",
    "Source Han Serif SC", "Noto Serif CJK SC", "SimSun", serif;
  color: var(--mag-title);
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1.5;
  letter-spacing: 0.01em;
  transition: color 0.25s ease;
  /* 主题钉死 2 行，长标题会被省略号切；放宽到 3 行 */
  -webkit-line-clamp: 3;
}

body
  #recent-posts
  .recent-post-item
  .recent-post-info
  a.article-title:hover {
  color: var(--mag-accent);
}

/* ---------- 首页摘要：主题默认 opacity:0 隐藏，此处显式开启 ---------- */
/* 主题选择器为 #content-inner #recent-posts > ... > .content (2,3,0)，用 body 提权 */
body
  #content-inner
  #recent-posts
  > .recent-post-item
  > .recent-post-info
  > .content {
  opacity: 1;
  height: auto;
  padding: 0 32px;
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--mag-excerpt);
  letter-spacing: 0.01em;
  margin-top: 0.6rem;
  -webkit-line-clamp: 2;
}

/* ---------- 首页信息区：改 flex 列，用 order 排成「标题 → 摘要 → 标签/日期」 ---------- */
/* DOM 原序为 top / meta / content，主题靠 absolute 定位掩盖；此处显式重排。 */
body #recent-posts .recent-post-item .recent-post-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

body #recent-posts .recent-post-item .recent-post-info > .recent-post-info-top {
  order: 1;
}

body #recent-posts .recent-post-item .recent-post-info > .content {
  order: 2;
}

/* meta 行：主题为 position:absolute; bottom:30px，会与摘要重叠，改回文档流。 */
body #recent-posts .recent-post-item .recent-post-info > .article-meta-wrap {
  order: 3;
  position: static;
  margin-top: 0.6rem;
  padding: 0 32px;
}

/* ---------- 首页封面图：自然、无重阴影 ---------- */
.recent-post-item .post_bg,
.recent-post-item img.post_bg {
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(74, 69, 62, 0.08);
}

/* ---------- 首页卡片：圆角与间距统一 ---------- */
.recent-post-item {
  border-radius: var(--anzhiyu-radius, 10px);
  transition: box-shadow 0.3s ease;
}

/* ---------- 分类徽标：弱化，不抢标题 ---------- */
.article-categories-original,
.recent-post-info .article-categories-original {
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--mag-cat);
}

/* ---------- 分页按钮：深色模式需反相，否则白字压暖金对比度不足 ---------- */
[data-theme="dark"] .page-number.current,
[data-theme="dark"] .pagination .page-number.current,
[data-theme="dark"] #pagination .page-number.current {
  color: #2d2a26;
  font-weight: 600;
}

[data-theme="dark"] .pagination a,
[data-theme="dark"] #pagination a,
[data-theme="dark"] .pagination .anzhiyufont,
[data-theme="dark"] #pagination .anzhiyufont {
  color: var(--mag-accent);
}

/* ---------- 移动端适配 ---------- */
@media screen and (max-width: 768px) {
  body {
    font-size: 16px;
    line-height: 1.8;
  }

  #article-container,
  .post-content,
  #post-content {
    max-width: 100%;
    font-size: 1rem;
    line-height: 1.85;
    text-align: left;
  }

  h2 {
    font-size: 1.35em;
    margin-top: 1.8em;
  }

  h3 {
    font-size: 1.15em;
  }
}

/* ---------- 首页卡片：高度随内容自适应 ----------
   主题把卡片钉死 18em、信息区钉死 174px，标题两行时会被省略号切掉，
   摘要也一并被压。这里改成 min-height + 拉伸，长标题自然撑高。 */
@media screen and (min-width: 769px) {
  body #recent-posts > .recent-post-item {
    height: auto;
    min-height: 202px;
    align-items: stretch;
  }

  body #recent-posts > .recent-post-item > .recent-post-info {
    height: auto;
    min-height: 174px;
    padding: 22px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  /* 封面必须绝对定位填充，否则去掉固定高度后 <img> 会按原图比例
     把整个卡片撑成正方形（实测出现过 423×423 的巨卡）。 */
  body #recent-posts > .recent-post-item .post_cover {
    height: auto;
    min-height: 202px;
    position: relative;
    overflow: hidden;
  }

  body #recent-posts > .recent-post-item .post_cover > a {
    position: absolute !important;
    inset: 0;
    height: 100% !important;
    width: 100% !important;
  }

  body #recent-posts > .recent-post-item .post_cover img.post_bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

/* ---------- 隐藏「未读」角标 ----------
   主题在 post-ui.pug 里把 <a class="unvisited-post">未读</a> 写死了，
   没有配置开关，只能从样式层消掉。 */
body .unvisited-post {
  display: none !important;
}

/* ---------- 标题锚点圆环 ----------
   主题给 h2 挂了 .headerlink 图标，在杂志风里突兀，去掉。 */
body #article-container h2 > .headerlink,
body #article-container h3 > .headerlink,
body #article-container h4 > .headerlink {
  display: none;
}

/* ---------- 标签前的 # 图标：去掉多余空档 ----------
   模板输出为 <span> <i class="icon-hashtag"></i>标签</span>，
   那个前导空格会撑出 "#  标签" 的缝隙。inline-flex 会丢弃纯空白文本节点。 */
.article-meta__tags > span,
#article-container .article-meta__tags > span {
  display: inline-flex;
  align-items: center;
}

/* ---------- 分页：只有一页时不显示 ---------- */
body #pagination:has(.page-number:only-of-type) {
  display: none;
}

/* ---------- 打印样式（可选，杂志延伸） ---------- */
@media print {
  aside,
  #nav,
  footer,
  .reward,
  #back-top {
    display: none !important;
  }

  #article-container {
    max-width: 100%;
  }
}
