/* === Reset & Base === */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --font-body:
    "Source Serif 4", "Noto Serif CJK SC", "Noto Serif SC", "Songti SC", "SimSun", georgia, serif;
  --font-heading:
    "Source Serif 4", "Noto Serif CJK SC", "Noto Serif SC", "Songti SC", "SimSun", georgia, serif;
  --font-mono: "SF Mono", menlo, consolas, "Liberation Mono", "Courier New", monospace;
  --font-nav:
    -apple-system, "Helvetica Neue", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --color-bg: #fff;
  --color-text: #1a1a1a;
  --color-text-secondary: #6b6b6b;
  --color-border: #e0e0e0;
  --color-link: #1a1a1a;
  --color-link-hover: #555;
  --color-code-bg: #f6f6f6;
  --content-width: 720px;
  --nav-width: 960px;
}

html {
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.75;
}

a {
  color: var(--color-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--color-link-hover);
}

/* === Navigation === */
.site-nav {
  max-width: var(--nav-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-nav);
}

.site-title {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--color-text);
}

.site-title:hover {
  color: var(--color-text-secondary);
}

.site-nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.site-nav-links a {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  text-decoration: none;
}

.site-nav-links a:hover {
  color: var(--color-text);
}

/* === Main Content === */
main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* === Home / List Page === */
.page-header {
  margin: 4rem 0 3rem;
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-header .subtitle {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  font-style: italic;
}

/* === Post List === */
.post-list {
  list-style: none;
}

.post-item {
  padding: 1.75rem 0;
  border-top: 1px solid var(--color-border);
}

.post-item:last-child {
  border-bottom: 1px solid var(--color-border);
}

.post-date {
  display: block;
  font-family: var(--font-nav);
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.35rem;
  font-variant-numeric: tabular-nums;
}

.post-item h2 {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.25rem;
}

.post-item h2 a {
  text-decoration: none;
  color: var(--color-text);
}

.post-item h2 a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.post-meta {
  font-family: var(--font-nav);
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.post-summary {
  margin-top: 0.5rem;
  font-size: 0.92rem;
  color: var(--color-text-secondary);
  line-height: 1.65;
}

/* === Single Post === */
.post-header {
  margin: 4rem 0 2.5rem;
}

.post-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.post-header .meta {
  font-family: var(--font-nav);
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.post-header .meta time {
  font-variant-numeric: tabular-nums;
}

/* === Article Content === */
.post-content {
  margin-bottom: 4rem;
}

.post-content p {
  margin-bottom: 1.5rem;
}

.post-content h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 3rem;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

.post-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.post-content h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.post-content li {
  margin-bottom: 0.35rem;
}

.post-content li > ul,
.post-content li > ol {
  margin-top: 0.35rem;
  margin-bottom: 0;
}

.post-content blockquote {
  border-left: 3px solid var(--color-border);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--color-text-secondary);
  font-style: italic;
}

.post-content blockquote p:last-child {
  margin-bottom: 0;
}

.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem auto;
}

.post-content figure {
  margin: 2rem 0;
}

.post-content figure img {
  margin: 0 auto;
}

.post-content figcaption {
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-top: 0.5rem;
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--color-code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

.post-content pre {
  background: var(--color-code-bg);
  padding: 1.25rem 1.5rem;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  line-height: 1.55;
  font-size: 0.88rem;
}

.post-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.92rem;
}

.post-content th,
.post-content td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.post-content th {
  font-weight: 600;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 3rem 0;
}

/* === Math (KaTeX) === */
.katex-display {
  margin: 1.5rem 0;
  overflow-x: auto;
}

/* === Tags === */
.post-tags {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.post-tags a {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  text-decoration: none;
  margin-right: 0.75rem;
}

.post-tags a::before {
  content: "#";
}

.post-tags a:hover {
  color: var(--color-text);
}

/* === Footer === */
.site-footer {
  max-width: var(--nav-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  font-family: var(--font-nav);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.site-footer a {
  color: var(--color-text-secondary);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--color-text);
}

/* === Responsive === */
@media (width <= 640px) {
  html {
    font-size: 16px;
  }

  .site-nav {
    padding: 1.5rem 1rem 0.75rem;
    flex-direction: column;
    gap: 0.5rem;
  }

  .page-header {
    margin: 2.5rem 0 2rem;
  }

  .page-header h1 {
    font-size: 1.6rem;
  }

  .post-header {
    margin: 2.5rem 0 2rem;
  }

  .post-header h1 {
    font-size: 1.6rem;
  }

  main {
    padding: 0 1rem;
  }

  .site-footer {
    padding: 2rem 1rem 1.5rem;
    flex-direction: column;
    gap: 0.25rem;
  }
}
