/* ---------- Article page ---------- */

:root {
  color-scheme: light dark;
  --post-ink: #23272f;
  --post-muted: #68707c;
  --post-faint: #a3abb6;
  --post-paper: #fcfbf7;
  --post-accent: #3b6ef5;
  --post-accent-2: #14b8a6;
  --post-card: rgba(255, 255, 255, 0.62);
  --post-border: rgba(35, 39, 47, 0.12);
  --post-glow: rgba(59, 110, 245, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --post-ink: #e7e6e3;
    --post-muted: #9ba3ae;
    --post-faint: #68707c;
    --post-paper: #16181c;
    --post-accent: #7ea2ff;
    --post-accent-2: #4fd1c5;
    --post-card: rgba(255, 255, 255, 0.035);
    --post-border: rgba(255, 255, 255, 0.11);
    --post-glow: rgba(126, 162, 255, 0.16);
  }
}

body:has(.post) {
  margin: 0;
  background: var(--post-paper);
  color: var(--post-ink);
}

body:has(.post) #grid-wrapper {
  display: block;
  padding: 0 1.25rem;
}

body:has(.post) #grid-wrapper > article {
  max-width: 100%;
  font-size: 100%;
}

body:has(.post) > header {
  display: none;
}

body:has(.post) article {
  font-family: "霞鹜文楷", "LXGW WenKai", "Noto Sans SC", serif;
  line-height: 1.95;
  color: var(--post-ink);
}

body:has(.post) article > section.block:first-child {
  max-width: 46rem;
  margin: 0 auto;
  padding: 2.5rem 0 5rem;
}

/* Hide the default article header; the post template renders its own hero */
body:has(.post) article > section.block:first-child > details > summary {
  display: none;
}

/* The reading page should not highlight blocks on hover */
body:has(.post) article section.block:hover {
  background-color: transparent;
}

/* ---------- Top navigation ---------- */

.post-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

body:has(.post) .post-nav a {
  font-family: "Inria Sans", sans-serif;
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  color: var(--post-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

body:has(.post) .post-nav a:hover {
  color: var(--post-accent);
}

.post-nav-mark {
  font-family: "Inria Sans", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--post-faint);
}

/* ---------- Post hero ---------- */

.post-hero {
  padding: 1.5rem 0 2.8rem;
  margin-bottom: 2.6rem;
  border-bottom: 1px solid var(--post-border);
  animation: post-rise 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.post-kicker {
  margin-bottom: 1.1rem;
  font-family: "Inria Sans", sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--post-faint);
}

.post-title {
  font-size: clamp(2rem, 5.5vw, 3.2rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.post-desc {
  max-width: 38rem;
  margin-top: 1rem;
  font-size: 1.02rem;
  color: var(--post-muted);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin-top: 1.4rem;
  font-size: 0.78rem;
  color: var(--post-faint);
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1rem;
}

.post-tag {
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--post-border);
  border-radius: 999px;
  background: var(--post-card);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--post-muted);
}

/* ---------- Headings ---------- */

body:has(.post) article section.block summary {
  pointer-events: none;
  font-weight: 700;
  line-height: 1.5;
}

body:has(.post) article section.block summary > span {
  margin-right: 0.25em;
  font-size: 0.7em;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--post-faint);
}

body:has(.post) article > section.block:first-child > details > section.block > details > summary {
  margin: 2.6rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--post-border);
  font-size: 1.55rem !important;
}

body:has(.post) article > section.block:first-child > details > section.block > details > section.block > details > summary {
  margin: 1.9rem 0 0.75rem;
  border-bottom: none;
  font-size: 1.18rem !important;
}

body:has(.post) article > section.block:first-child > details > section.block > details > section.block > details > section.block > details > summary {
  margin: 1.4rem 0 0.6rem;
  font-size: 1.02rem !important;
  color: var(--post-muted);
}

/* ---------- Body content ---------- */

body:has(.post) article p {
  margin: 0 0 1em;
  line-height: 1.95;
}

body:has(.post) article ul,
body:has(.post) article ol {
  margin: 0 0 1em;
  padding-left: 1.5em;
}

body:has(.post) article li {
  margin: 0.2em 0;
}

body:has(.post) article li > p {
  margin: 0;
}

body:has(.post) article a {
  color: var(--post-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

body:has(.post) article blockquote,
body:has(.post) article .block-quote {
  margin: 1.5em 0;
  padding: 0.6em 1.2em;
  border-left: 3px solid var(--post-accent);
  border-radius: 0 8px 8px 0;
  background: var(--post-card);
  color: var(--post-muted);
  font-style: normal;
}

body:has(.post) article blockquote p {
  margin: 0;
}

body:has(.post) article pre {
  margin: 1.4em 0;
  padding: 1rem 1.2rem;
  border: 1px solid var(--post-border);
  border-radius: 10px;
  background: var(--post-card);
  font-size: 0.86rem;
  line-height: 1.65;
  overflow-x: auto;
}

body:has(.post) article pre > code {
  padding: 0;
  border-radius: 0;
  background: transparent;
  font-size: inherit;
}

body:has(.post) article code {
  padding: 0.12em 0.4em;
  border-radius: 4px;
  background: rgba(35, 39, 47, 0.06);
  font-size: 0.9em;
}

@media (prefers-color-scheme: dark) {
  body:has(.post) article code {
    background: rgba(255, 255, 255, 0.08);
  }
}

body:has(.post) article table {
  width: 100%;
  margin: 1.4em 0;
  border-collapse: collapse;
  font-size: 0.92rem;
}

body:has(.post) article th,
body:has(.post) article td {
  padding: 0.55em 0.8em;
  border-bottom: 1px solid var(--post-border);
  text-align: left;
}

body:has(.post) article th {
  border-bottom-color: var(--post-ink);
  color: var(--post-muted);
  font-weight: 700;
}

body:has(.post) article img {
  max-width: 100%;
  border-radius: 10px;
}

body:has(.post) article figure {
  margin: 1.6em 0;
}

body:has(.post) article figcaption {
  color: var(--post-muted);
  font-size: 0.85rem;
}

body:has(.post) article hr {
  height: 1px;
  margin: 2rem 0;
  border: 0;
  background: var(--post-border);
}

body:has(.post) article .footnote-definition {
  color: var(--post-muted);
  font-size: 0.85rem;
}

/* ---------- End card ---------- */

.end-card {
  margin-top: 4.5rem;
  padding: 1.5rem 1.6rem 1.3rem;
  border: 1px solid var(--post-border);
  border-radius: 14px;
  background: var(--post-card);
  animation: post-rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.end-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.end-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--post-accent), var(--post-accent-2));
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 8px 22px var(--post-glow);
}

.end-info {
  flex: 1;
  min-width: 0;
}

.end-name {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.4;
}

.end-tag {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  color: var(--post-muted);
}

body:has(.post) .end-top {
  flex: none;
  padding: 0.32rem 0.75rem;
  border: 1px solid var(--post-border);
  border-radius: 999px;
  font-size: 0.76rem;
  color: var(--post-muted);
  text-decoration: none;
  transition: color 0.25s ease, border-color 0.25s ease,
    background 0.25s ease;
}

body:has(.post) .end-top:hover {
  color: var(--post-accent);
  border-color: var(--post-accent);
  background: var(--post-card);
}

.end-rule {
  height: 1px;
  margin: 1.2rem 0 0.9rem;
  background: var(--post-border);
}

.end-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  font-size: 0.76rem;
  color: var(--post-faint);
}

body:has(.post) .end-meta a {
  color: var(--post-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Motion ---------- */

@keyframes post-rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .post-hero,
  .end-card {
    animation: none;
  }
}

@media (max-width: 640px) {
  body:has(.post) article > section.block:first-child {
    padding-top: 1.5rem;
  }
  .post-hero {
    padding-bottom: 2rem;
    margin-bottom: 2rem;
  }
  .post-title {
    font-size: clamp(1.8rem, 8vw, 2.4rem);
  }
  .end-card {
    margin-top: 3.5rem;
    padding: 1.25rem 1.2rem 1.1rem;
  }
  .end-profile {
    flex-wrap: wrap;
  }
  .end-top {
    margin-left: auto;
  }
  .end-meta {
    font-size: 0.72rem;
  }
}
