/* 文章列表页与详情页（body.articles）专用样式；在 home.css 之上加载 */

.a-intro {
  padding: 48px 0 8px;
}

.a-intro h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.a-intro p {
  margin: 10px 0 0;
  color: var(--h-muted);
}

.a-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  margin: 36px 0 8px;
  font-size: 14px;
  color: var(--h-muted);
}

.a-filter button {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: color 0.15s ease-out;
}

.a-filter button:hover,
.a-filter button[aria-pressed="true"] {
  color: var(--h-ink);
}

.a-filter button[aria-pressed="true"] {
  text-decoration: underline;
  text-underline-offset: 6px;
}

.a-filter button span {
  margin-left: 4px;
  color: var(--h-faint);
  font-variant-numeric: tabular-nums;
}

.a-row {
  display: grid;
  grid-template-columns: 8.5em minmax(0, 1fr);
  gap: 28px;
  padding: 22px 0;
}

/* 摘要两行、条目较多，用极淡的分隔线帮助扫读 */
.a-row + .a-row {
  border-top: 1px solid rgba(26, 28, 30, 0.08);
}

.a-row[hidden] {
  display: none;
}

.a-row time {
  padding-top: 3px;
  font-size: 14px;
  color: var(--h-faint);
  font-variant-numeric: tabular-nums;
}

.a-row__title {
  display: block;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.45;
  text-wrap: balance;
  transition: color 0.15s ease-out;
}

.a-row:hover .a-row__title {
  color: var(--h-accent);
}

.a-row__summary {
  display: block;
  max-width: 46em;
  margin-top: 6px;
  font-size: 14.5px;
  color: var(--h-muted);
  text-wrap: pretty;
}

.a-row__meta {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--h-faint);
}

@media (max-width: 720px) {
  .a-intro {
    padding-top: 24px;
  }

  .a-intro h1 {
    font-size: 32px;
  }

  .a-filter {
    gap: 0 18px;
    margin-top: 24px;
  }

  .a-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 18px 0;
  }

  .a-row__title {
    font-size: 17px;
  }
}

/* ---------- 详情页 ---------- */

.p-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 720px);
  justify-content: center;
  gap: 64px;
  padding-top: 40px;
}

.p-layout--single {
  grid-template-columns: minmax(0, 720px);
}

.p-toc {
  position: sticky;
  top: 24px;
  align-self: start;
  max-height: calc(100vh - 48px);
  overflow: auto;
  font-size: 13.5px;
}

.p-toc b {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
}

.p-toc a {
  display: block;
  padding: 5px 0 5px 12px;
  line-height: 1.45;
  color: var(--h-muted);
  box-shadow: inset 1px 0 0 rgba(26, 28, 30, 0.12);
  transition: color 0.15s ease-out, box-shadow 0.15s ease-out;
}

.p-toc a:hover {
  color: var(--h-ink);
}

.p-toc a[aria-current="true"] {
  color: var(--h-ink);
  box-shadow: inset 2px 0 0 var(--h-ink);
}

.p-back {
  font-size: 14px;
  color: var(--h-muted);
  transition: color 0.15s ease-out;
}

.p-back:hover {
  color: var(--h-ink);
}

.p-meta {
  margin-top: 28px;
  font-size: 13.5px;
  color: var(--h-faint);
  font-variant-numeric: tabular-nums;
}

.p-meta span::before {
  content: "·";
  margin: 0 8px;
}

.p-head h1 {
  margin: 10px 0 0;
  font-size: 34px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.p-lede {
  margin: 16px 0 0;
  font-size: 16px;
  line-height: 1.75;
  color: var(--h-muted);
}

.p-body {
  margin-top: 48px;
  font-size: 16.5px;
  line-height: 1.85;
}

.p-body > * {
  margin-top: 0;
  margin-bottom: 0;
}

.p-body > * + * {
  margin-top: 1.1em;
}

/* Markdown 渲染会把标题降一级：## → h3（章节），### → h4，#### → h5 */
.p-body h2,
.p-body h3 {
  margin-top: 2.6em;
  font-size: 23px;
  font-weight: 600;
  line-height: 1.4;
  scroll-margin-top: 24px;
}

.p-body h4 {
  margin-top: 2em;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
  scroll-margin-top: 24px;
}

.p-body h5 {
  margin-top: 1.6em;
  font-size: 16.5px;
  font-weight: 600;
}

.p-body a {
  color: var(--h-accent);
  text-decoration: underline;
  text-decoration-color: rgba(14, 111, 113, 0.35);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s ease-out;
}

.p-body a:hover {
  text-decoration-color: currentColor;
}

.p-body hr {
  margin-top: 2.4em;
  border: 0;
  border-top: 1px solid rgba(26, 28, 30, 0.1);
}

.p-body code {
  padding: 0.1em 0.35em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--h-ground-2);
  overflow-wrap: anywhere;
}

.p-body pre {
  overflow-x: auto;
  padding: 18px 20px;
  font-size: 14px;
  line-height: 1.7;
  background: var(--h-ground-2);
}

.p-body pre code {
  padding: 0;
  font-size: inherit;
  white-space: pre;
  background: none;
}

.p-table {
  overflow-x: auto;
}

.p-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  line-height: 1.6;
}

.p-body th,
.p-body td {
  padding: 10px 14px 10px 0;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(26, 28, 30, 0.1);
}

.p-body th {
  font-weight: 600;
  border-bottom-color: rgba(26, 28, 30, 0.3);
}

.p-body blockquote {
  padding: 14px 18px;
  margin-left: 0;
  margin-right: 0;
  color: var(--h-muted);
  background: var(--h-ground-2);
}

.p-body ul,
.p-body ol {
  padding-left: 1.4em;
}

.p-body li + li {
  margin-top: 0.35em;
}

.p-end {
  margin-top: 64px;
  padding-top: 24px;
  font-size: 14px;
  color: var(--h-muted);
  border-top: 1px solid rgba(26, 28, 30, 0.1);
}

.p-end p {
  margin: 0;
}

.p-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin-top: 32px;
}

.p-nav a {
  display: block;
}

.p-nav small {
  display: block;
  font-size: 13px;
  color: var(--h-faint);
}

.p-nav b {
  display: block;
  margin-top: 4px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--h-ink);
  transition: color 0.15s ease-out;
}

.p-nav a:hover b {
  color: var(--h-accent);
}

.p-nav__next {
  grid-column: 2;
  text-align: right;
}

.p-toc-mobile {
  display: none;
}

@media (max-width: 980px) {
  .p-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .p-toc {
    display: none;
  }

  .p-toc-mobile {
    display: block;
    margin-top: 32px;
    padding: 4px 16px;
    font-size: 14px;
    background: var(--h-ground-2);
  }

  .p-toc-mobile summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 44px;
    font-weight: 600;
    list-style: none;
    cursor: pointer;
  }

  .p-toc-mobile summary::-webkit-details-marker {
    display: none;
  }

  .p-toc-mobile summary::after {
    content: "展开";
    font-weight: 400;
    color: var(--h-muted);
  }

  .p-toc-mobile[open] summary::after {
    content: "收起";
  }

  .p-toc-mobile a {
    display: block;
    padding: 10px 0;
    color: var(--h-muted);
  }
}

@media (max-width: 720px) {
  .p-layout {
    padding-top: 24px;
  }

  .p-back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  .p-meta {
    margin-top: 12px;
  }

  .p-head h1 {
    font-size: 27px;
  }

  .p-body {
    margin-top: 36px;
    font-size: 16px;
  }

  /* 窄屏表格保持可读宽度，在容器内横向滑动 */
  .p-body table {
    min-width: 560px;
  }

  .p-nav {
    grid-template-columns: 1fr;
  }

  .p-nav__next {
    grid-column: auto;
    text-align: left;
  }
}
