/*
Theme Name: Gridfolio
Theme URI: https://example.com/gridfolio
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: gridfolio
*/


:root {
  --paper: #f6f1e3;          /* 旧纸张底色 */
  --ink: #22201a;            /* 油墨色 */
  --ink-soft: #4c4636;
  --accent: #8c1d18;         /* 朱砂红 */
  --rule: #1c1a14;           /* 版线 */
  --grid-line: rgba(74, 64, 42, 0.10);
  --serif: "Noto Serif", "Noto Serif SC", "Songti SC", "SimSun", serif;
  --measure: 68ch;
}

/* ---------- Reset（极简） ---------- */
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, p, ul, ol, figure, blockquote, dl, dd { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; }
img, picture { max-width: 100%; height: auto; display: block; }
input, button, textarea, select { font: inherit; }
a { color: var(--ink); }

/* ---------- 基础排版 ---------- */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--ink);
  background-color: var(--paper);
  /* SVG 网格纸背景：内联 data URI，零 HTTP 请求，平铺 28px 方格 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Cpath d='M28 .5H.5V28' fill='none' stroke='%234a402a' stroke-opacity='.14' stroke-width='1'/%3E%3C/svg%3E");
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-weight: 900;
  line-height: 1.3;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

/* ---------- 布局骨架 ---------- */
.wrap {
  width: min(1120px, 100% - 2.5rem);
  margin-inline: auto;
}

/* ---------- 报头 Masthead ---------- */
.masthead {
  border-bottom: 3px double var(--rule);
  padding: 1.1rem 0 0.9rem;
}
.masthead__top {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1rem;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.45rem;
}
.masthead__title {
  text-align: center;
  padding: 0.9rem 0 0.35rem;
}
.masthead__title .site-title {
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.1;
}
.masthead__title .site-title a { text-decoration: none; }
.masthead__title .site-description {
  font-size: 0.85rem;
  letter-spacing: 0.32em;
  color: var(--ink-soft);
  margin-top: 0.3rem;
}
.masthead__title .site-description::before,
.masthead__title .site-description::after {
  content: "——";
  letter-spacing: 0;
  margin: 0 0.6em;
  color: var(--accent);
}

/* ---------- 导航 ---------- */
.nav {
  border-top: 1px solid var(--rule);
  margin-top: 0.6rem;
}
.nav ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 0;
  padding: 0;
  margin: 0;
  list-style: none;
}
.nav a {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-decoration: none;
}
.nav li + li a { border-left: 1px solid var(--rule); }
.nav a:hover { background: var(--ink); color: var(--paper); }

/* ---------- 主区布局 ---------- */
.site-main { padding: 2.2rem 0 3rem; }
.layout { display: grid; gap: 2.5rem; }
@media (min-width: 880px) {
  .layout--sidebar { grid-template-columns: minmax(0, 1fr) 300px; }
}

/* ---------- 文章预览（目录页）：直接落在网格纸背景上，仅以版线分隔 ---------- */
.post-list { display: grid; gap: 2rem; }
.post-card {
  background: none;
  padding: 0 0 1.8rem;
  border-bottom: 1px solid var(--rule);
}
.post-card:last-child { border-bottom: none; }
.post-card__kicker {
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}
.post-card__title {
  font-size: 1.55rem;
  margin-top: 0.35rem;
}
.post-card__title a { text-decoration: none; }
.post-card__title a:hover { color: var(--accent); }
.post-card__meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  margin-top: 0.35rem;
}
.post-card__excerpt { margin-top: 0.7rem; color: var(--ink-soft); }
.post-card__thumb { margin: 0 0 1rem; }
.post-card__thumb img {
  width: 100%;
  aspect-ratio: 21 / 9;
  object-fit: cover;
  border: 1px solid var(--rule);
}

/* 第一篇头条放大，上下加双细线 */
.post-card--lead {
  grid-column: 1 / -1;
  border-top: 3px double var(--rule);
  border-bottom: 3px double var(--rule);
  padding-top: 1.6rem;
}
.post-card--lead .post-card__title { font-size: clamp(1.8rem, 4vw, 2.6rem); }

@media (min-width: 640px) {
  .post-list--grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- 正文页 ---------- */
.article { max-width: var(--measure); margin-inline: auto; }
.article--wide { max-width: 52rem; }
.article__header {
  text-align: center;
  border-bottom: 3px double var(--rule);
  padding-bottom: 1.2rem;
  margin-bottom: 1.6rem;
}
.article__kicker {
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  color: var(--accent);
  font-weight: 700;
}
.article__title { font-size: clamp(1.9rem, 4.5vw, 2.9rem); margin-top: 0.5rem; }
.article__meta {
  margin-top: 0.7rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  letter-spacing: 0.1em;
}
.article__content > p + p { margin-top: 1.1em; }
.article__content > p:first-of-type::first-letter {
  /* 老杂志首字下沉 */
  float: left;
  font-size: 3.4em;
  line-height: 0.85;
  padding: 0.08em 0.12em 0 0;
  font-weight: 900;
  color: var(--accent);
}
.article__content h2, .article__content h3 { margin: 1.8em 0 0.6em; }
.article__content h2 {
  text-align: center;
  font-size: 1.4rem;
}
.article__content h2::after {
  content: "";
  display: block;
  width: 3rem;
  border-bottom: 2px solid var(--accent);
  margin: 0.4rem auto 0;
}
.article__content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.3rem 0 0.3rem 1.1rem;
  margin: 1.4em 0;
  font-style: italic;
  color: var(--ink-soft);
}
.article__content ul, .article__content ol { margin: 1.1em 0 1.1em 1.4em; }
.article__content img { border: 1px solid var(--rule); padding: 4px; background: #fffdf6; }
.article__content a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.article__content a:hover { color: var(--accent); }
.article__content code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.9em;
  background: rgba(34, 32, 26, 0.08);
  padding: 0.1em 0.35em;
}
.article__content pre {
  border: 1px solid var(--rule);
  background: #fffdf6;
  padding: 1rem;
  overflow-x: auto;
  margin: 1.4em 0;
}
.article__content pre code { background: none; padding: 0; }
.wp-caption, .article__content figcaption {
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 0.4rem;
  font-style: italic;
}
.aligncenter { margin-inline: auto; text-align: center; }
.alignleft { float: left; margin: 0.3rem 1.2rem 0.8rem 0; }
.alignright { float: right; margin: 0.3rem 0 0.8rem 1.2rem; }

/* 文章 footer：标签、翻页 */
.article__footer {
  margin-top: 2.2rem;
  border-top: 3px double var(--rule);
  padding-top: 1rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
  font-size: 0.9rem;
  font-weight: 700;
}
.post-nav a { text-decoration: none; }
.post-nav a:hover { color: var(--accent); }

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 2.5rem;
  font-size: 0.9rem;
}
.pagination .page-numbers {
  display: inline-block;
  min-width: 2.2rem;
  text-align: center;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--rule);
  text-decoration: none;
  background: rgba(255, 252, 244, 0.6);
}
.pagination .page-numbers.current { background: var(--ink); color: var(--paper); }
.pagination a.page-numbers:hover { background: var(--accent); color: var(--paper); border-color: var(--accent); }

/* ---------- 侧边栏 ---------- */
.sidebar { display: grid; gap: 1.6rem; align-content: start; }
.widget {
  border: 1px solid var(--rule);
  background: rgba(255, 252, 244, 0.6);
  padding: 1.1rem 1.2rem 1.2rem;
}
.widget__title {
  font-size: 0.95rem;
  letter-spacing: 0.22em;
  text-align: center;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.5rem;
  margin-bottom: 0.8rem;
  font-weight: 900;
}
.widget ul { padding-left: 1.1em; }
.widget li { padding: 0.2rem 0; }
.widget a { text-decoration: none; }
.widget a:hover { color: var(--accent); }

/* ---------- 评论 ---------- */
.comments { max-width: var(--measure); margin: 2.8rem auto 0; border-top: 3px double var(--rule); padding-top: 1.4rem; }
.comments__title { font-size: 1.25rem; margin-bottom: 1rem; }
.comment-list { list-style: none; padding: 0; }
.comment-list .comment { border: 1px solid var(--rule); background: rgba(255,252,244,.6); padding: 1rem 1.2rem; margin-bottom: 1rem; }
.comment-list .children { list-style: none; margin-top: 1rem; }
.comment-meta { font-size: 0.8rem; color: var(--ink-soft); margin-bottom: 0.4rem; }
.comment-form { display: grid; gap: 0.8rem; margin-top: 1.4rem; }
.comment-form label { font-size: 0.85rem; font-weight: 700; letter-spacing: 0.08em; }
.comment-form input:not([type="submit"]), .comment-form textarea {
  border: 1px solid var(--rule);
  background: #fffdf6;
  padding: 0.55rem 0.7rem;
  width: 100%;
}
.comment-form input:focus, .comment-form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.comment-form .submit {
  justify-self: start;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--rule);
  padding: 0.5rem 1.6rem;
  letter-spacing: 0.2em;
  cursor: pointer;
}
.comment-form .submit:hover { background: var(--accent); }

/* ---------- 搜索框 ---------- */
.search-form { display: flex; gap: 0.4rem; }
.search-form input[type="search"] {
  flex: 1;
  border: 1px solid var(--rule);
  background: #fffdf6;
  padding: 0.45rem 0.7rem;
  min-width: 0;
}
.search-form button {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--rule);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  letter-spacing: 0.15em;
}
.search-form button:hover { background: var(--accent); }

/* ---------- 页脚 ---------- */
.colophon {
  border-top: 3px double var(--rule);
  margin-top: 3rem;
  padding: 1.6rem 0 2rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}
.colophon .footer-nav ul {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 0 1.2rem; list-style: none; padding: 0; margin: 0 0 0.8rem;
}
.colophon a { text-decoration: none; }
.colophon a:hover { color: var(--accent); }

/* ---------- 辅助 ---------- */
.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
.skip-link:focus {
  position: fixed;
  top: 0.5rem; left: 0.5rem;
  z-index: 999;
  width: auto; height: auto;
  clip: auto; clip-path: none;
  background: var(--ink); color: var(--paper);
  padding: 0.5rem 1rem;
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 640px) {
  body { font-size: 1rem; line-height: 1.7; }

  .wrap { width: calc(100% - 2rem); }

  /* 刊头收紧 */
  .masthead { padding: 0.8rem 0 0.7rem; }
  .masthead__top { font-size: 0.7rem; letter-spacing: 0.1em; }
  .masthead__title { padding: 0.6rem 0 0.2rem; }
  .masthead__title .site-description { letter-spacing: 0.18em; font-size: 0.78rem; }
  .masthead__title .site-description::before,
  .masthead__title .site-description::after { margin: 0 0.3em; }

  /* 导航可换行、触控目标不小于 44px */
  .nav a { padding: 0.6rem 0.85rem; font-size: 0.85rem; letter-spacing: 0.06em; }

  .site-main { padding: 1.6rem 0 2.2rem; }
  .layout { gap: 2rem; }

  /* 文章预览更紧凑 */
  .post-list { gap: 1.6rem; }
  .post-card { padding-bottom: 1.4rem; }
  .post-card--lead { padding-top: 1.2rem; }
  .post-card__title { font-size: 1.3rem; }

  /* 正文标题与首字下沉缩小 */
  .article__content > p:first-of-type::first-letter { font-size: 2.9em; }
  .article__content img { padding: 2px; }

  /* 悬浮图片在窄屏取消浮动，避免文字被挤压 */
  .alignleft, .alignright {
    float: none;
    margin: 0.8rem auto;
  }

  /* 翻页允许换行 */
  .pagination { flex-wrap: wrap; }

  /* 前后文导航上下排列 */
  .post-nav { flex-direction: column; gap: 0.5rem; }

  /* 搜索框按钮不挤压输入框 */
  .search-form button { padding: 0.45rem 0.7rem; }

  /* 页脚行距放松 */
  .colophon { line-height: 1.9; }
}

/* 超窄屏（<360px）进一步压缩 */
@media (max-width: 359px) {
  .nav a { padding: 0.55rem 0.6rem; }
  .post-card__title { font-size: 1.2rem; }
}

/* ---------- 打印：杂志本就属于纸张 ---------- */
@media print {
  body { background: #fff; }
  .nav, .sidebar, .colophon, .comments, .post-nav { display: none; }
}
