/* ============================================================
   Feeeiyuuu — minimal.
   Single narrow column, black on white, serif body, plain
   underlined links. No decoration, no animation, no dark mode.
   Inspired by gregorygundersen.com.
   ============================================================ */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #1a1a1a;
  --soft: #333333;
  --muted: #6b6b6b;
  --faint: #999999;
  --line: #e6e6e6;
  --line-strong: #cccccc;
  --link: #1a56c4;
  --link-hover: #0c3d95;
  --code-bg: #f4f4f2;
  --selection: #d9d9d9;
  --content: 43rem;
  /* 全站主字体：思源黑体（Noto Sans SC）。多字重已加载，粗细分明。
     变量名沿用 --font-serif 以免改动大量引用，实际是黑体。 */
  --font-serif: "Noto Sans SC", -apple-system, BlinkMacSystemFont,
    "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-sans: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "SF Mono", "Menlo", "Consolas", "Liberation Mono",
    ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.search-lock {
  overflow: hidden;
}

::selection {
  background: var(--selection);
}

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

a:hover {
  color: var(--muted);
  text-decoration-color: currentColor;
}

p {
  margin: 0 0 1rem;
}

img,
svg {
  display: block;
}

img {
  max-width: 100%;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 500;
  padding: 0.4rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  color: var(--text);
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 150ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* ── Top navbar (blog / code / article / category pages) ────
   Sits at the top of the content column so its edges line up with the
   content below: home + blog on the left, language on the right, with a
   thin light divider and generous vertical breathing room. */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin: 0 0 3.5rem;
  padding-bottom: 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

/* Full-bleed divider lines: the content stays in the centered column, but the
   rule under the navbar / article title block / article body spans the whole
   viewport width. */
.topbar,
.article-header,
.article-body {
  position: relative;
}

.topbar::after,
.article-header::after,
.article-body::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 100vw;
  height: 1px;
  transform: translateX(-50%);
  background: var(--line);
}

.topbar-nav {
  display: flex;
  gap: 1.4rem;
}

.topbar a {
  color: var(--soft);
  text-decoration: none;
}

.topbar a:hover {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Home keeps a single fixed language switch in the top-right corner. */
.lang-switch {
  position: fixed;
  top: 1rem;
  right: 1.1rem;
  z-index: 20;
  color: var(--soft);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  text-decoration: none;
}

.lang-switch:hover {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Shell ─────────────────────────────────────────────────── */
.site-shell {
  width: min(calc(100% - 2.5rem), var(--content));
  margin: 0 auto;
  padding: 1.25rem 0 5rem;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 1rem;
  padding-bottom: 1rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  margin-right: auto;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand:hover {
  color: var(--text);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.9rem;
}

.site-nav a,
.header-tool {
  color: var(--soft);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  text-decoration: none;
}

.site-nav a:hover,
.header-tool:hover {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-nav a.active {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--line-strong);
}

.header-tools {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
}

.header-tool {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

/* ── Home ──────────────────────────────────────────────────── */
.home-intro {
  margin-bottom: 2.75rem;
}

.home-intro h1 {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.home-intro p {
  margin: 0;
  color: var(--soft);
  font-size: 1.1rem;
}

/* Home hero: text block on the left, logo on the right, equal width. */
.home-hero {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
}

.home-text,
.home-figure {
  flex: 1 1 0;
  min-width: 0;
}

.home-figure {
  margin: 0;
}

.home-figure img {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 34rem) {
  .home-hero {
    flex-direction: column;
  }
}

/* Gundersen-style home: a plain list of links under the title. */
.home-links {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.home-links li {
  margin: 0.4rem 0;
  font-size: 1.15rem;
}

.home-links a {
  color: var(--text);
  text-decoration: none;
}

.home-links a:hover {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Blog category filter row (index + category pages). */
.blog-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0 0 2.75rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.blog-cats a {
  color: var(--soft);
  font-weight: 500;
  text-decoration: none;
}

.blog-cats a:hover {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.blog-cats a.active {
  color: var(--text);
  font-weight: 700;
}

.home-section {
  margin-bottom: 2.75rem;
}

.home-section:last-child {
  margin-bottom: 0;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 0.9rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.section-more {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ── Post list (date + title) ──────────────────────────────── */
.post-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1.1rem;
  padding: 0.32rem 0;
}

/* Blog rows carry a one-line description that wraps onto its own line,
   aligned under the title (past the fixed-width date column). */
.post-desc {
  flex-basis: 100%;
  margin: 0.1rem 0 0 9.1rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

@media (max-width: 34rem) {
  .post-desc {
    margin-left: 0;
  }
}

.post-date {
  flex: 0 0 auto;
  width: 8rem;
  color: var(--soft);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
}

.post-list li > a {
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}

.post-list li > a:hover {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-kind {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.list-empty {
  color: var(--muted);
  font-style: italic;
}

/* ── Page header (collection / archive / tags / about) ─────── */
.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  margin: 0 0 0.4rem;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.page-header p {
  margin: 0;
  color: var(--soft);
}

.page-meta {
  margin-top: 0.5rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* ── Archive ───────────────────────────────────────────────── */
.archive-year {
  margin-bottom: 2rem;
}

.archive-year-num {
  margin: 0 0 0.6rem;
  font-size: 1.15rem;
  font-weight: 700;
}

/* ── Tags index ────────────────────────────────────────────── */
.tag-index {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-index li {
  padding: 0.3rem 0;
}

.tag-index .tag-count {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.inline-tags {
  margin-top: 0.5rem;
}

.inline-tags a,
.inline-tags span {
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.inline-tags a {
  text-decoration: none;
}

.inline-tags a:hover {
  color: var(--link);
  text-decoration: underline;
}

/* ── Article ───────────────────────────────────────────────── */
.article-header {
  margin-bottom: 3rem;
  padding-bottom: 1.75rem;
}

.article-kicker {
  margin: 0 0 0.6rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.article-kicker a {
  color: var(--text);
}

.article-header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.article-meta {
  margin-top: 0.6rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.article-meta .meta-dot {
  margin: 0 0.35rem;
  color: var(--faint);
}

.article-links {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.button {
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.entry-cover-article {
  margin: 0 0 1.75rem;
}

.entry-cover-article img {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
}

/* ── Article body (prose) ──────────────────────────────────── */
.article-body {
  font-size: 1.05rem;
  line-height: 1.72;
  padding-bottom: 3rem;
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
  margin: 2rem 0 0.75rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  scroll-margin-top: 1.5rem;
}

.article-body h1 {
  font-size: 1.6rem;
}
.article-body h2 {
  font-size: 1.4rem;
}
.article-body h3 {
  font-size: 1.2rem;
}
.article-body h4 {
  font-size: 1.05rem;
}

.article-body .article-lead {
  margin: 0 0 1.5rem;
  color: var(--soft);
  font-size: 1.15rem;
  line-height: 1.65;
}

.article-body ul,
.article-body ol {
  margin: 1rem 0;
  padding-left: 1.4rem;
}

.article-body li {
  margin: 0.3rem 0;
}

.article-body a {
  color: var(--text);
}

.article-body code {
  padding: 0.1rem 0.35rem;
  background: var(--code-bg);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.86em;
}

.article-body pre {
  margin: 1.2rem 0;
  padding: 0.9rem 1.1rem;
  overflow: auto;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
}

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

.article-body blockquote {
  margin: 1.4rem 0;
  padding: 0.1rem 0 0.1rem 1.1rem;
  border-left: 3px solid var(--line-strong);
  color: var(--soft);
}

.article-body blockquote p:last-child {
  margin-bottom: 0;
}

.article-body img {
  height: auto;
  margin: 1.4rem 0;
  border: 1px solid var(--line);
}

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

.article-body .table-wrap {
  overflow-x: auto;
  margin: 1.4rem 0;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.article-body th,
.article-body td {
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.article-body th {
  background: var(--code-bg);
  font-weight: 700;
}

.article-body ul.task-list {
  padding-left: 0.2rem;
  list-style: none;
}

.article-body .task-item {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
}

.article-body del {
  color: var(--muted);
}

/* ── Rich media figures ────────────────────────────────────── */
.article-body .media {
  margin: 1.4rem 0;
}

.article-body .media img {
  margin: 0;
}

.article-body .media video,
.article-body .embed-frame {
  width: 100%;
  border: 1px solid var(--line);
  background: #000;
}

.article-body .media audio {
  width: 100%;
}

.article-body .embed-frame {
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.article-body .embed-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.article-body .media figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  text-align: center;
}

/* ── Article footer: tags / prev-next / related ────────────── */
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 2rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.article-tags .tag {
  color: var(--muted);
  text-decoration: none;
}

.article-tags .tag::before {
  content: "#";
  color: var(--faint);
}

.article-tags .tag:hover {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 4rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.article-nav-cell {
  max-width: 48%;
  text-decoration: none;
}

.article-nav-older {
  margin-left: auto;
  text-align: right;
}

.article-nav-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.article-nav-title {
  color: var(--text);
}

.article-nav-cell:hover .article-nav-title {
  text-decoration: underline;
}

.article-nav-empty {
  visibility: hidden;
}

.related-block {
  margin-top: 4rem;
}

.related-block h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 700;
}

/* ── Footer ────────────────────────────────────────────────── */
.site-footer {
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0 0 0.25rem;
}

.footer-links {
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
}

/* ── 404 ───────────────────────────────────────────────────── */
.not-found h1 {
  margin: 0 0 0.5rem;
  font-size: 2.5rem;
  font-weight: 700;
}

.not-found-recent {
  margin-top: 2rem;
}

/* ── Search overlay ────────────────────────────────────────── */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 1rem 1rem;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.search-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.search-box {
  width: min(38rem, 100%);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.search-input-wrap {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}

.search-input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 1rem;
}

.search-results {
  max-height: 24rem;
  overflow: auto;
}

.search-result-item {
  display: block;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.search-result-item:last-child {
  border-bottom: 0;
}

.search-result-item:hover,
.search-result-item.active {
  background: var(--code-bg);
}

.search-result-item span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.search-result-item h4 {
  margin: 0.15rem 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.search-result-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.search-result-item mark {
  padding: 0 0.1em;
  background: var(--selection);
  color: inherit;
}

.search-empty {
  padding: 2rem 1rem;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  text-align: center;
}

.search-hint {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  text-align: center;
}

kbd {
  padding: 0.05rem 0.3rem;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

/* ── Math (KaTeX) ──────────────────────────────────────────── */
.katex-display {
  margin: 1.3rem 0;
  padding: 0.2rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 600px) {
  body {
    font-size: 17px;
  }

  .site-shell {
    width: calc(100% - 1.75rem);
    padding-top: 1.75rem;
  }

  .post-list li {
    flex-wrap: wrap;
    gap: 0.15rem 0.9rem;
  }

  .post-date {
    width: auto;
  }

  .post-kind {
    display: none;
  }

  .article-nav {
    flex-direction: column;
    gap: 1rem;
  }

  .article-nav-older {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
