@font-face {
  font-family: "Maple Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/maple-mono@5.3.0/latin-400-normal.woff2") format("woff2");
}
:root {
  --bg: #f7f7f2;
  --surface: #ffffff;
  --surface-soft: #eff1e8;
  --text: #20251f;
  --muted: #667063;
  --line: #dce0d6;
  --accent: #2f6d55;
  --accent-strong: #1d503d;
  --accent-soft: #dcece3;
  --quote-accent: #7f6df2;
  --code: #20251f;
  --shadow: 0 12px 32px rgba(31, 47, 36, .08);
}

:root[data-theme="dark"] {
  --bg: #151916;
  --surface: #1e241f;
  --surface-soft: #272f28;
  --text: #edf2eb;
  --muted: #aab5a9;
  --line: #384238;
  --accent: #8ac7a3;
  --accent-strong: #b5e1c3;
  --accent-soft: #254332;
  --quote-accent: #a58cff;
  --code: #171b18;
  --shadow: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(247, 247, 242, .76), rgba(247, 247, 242, .76)),
    url("../images/ordinal-spiral-background.jpg");
  background-position: center, center -214px;
  background-repeat: repeat, no-repeat;
  background-size: auto, 1240px auto;
  background-attachment: scroll, fixed;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.75;
}

:root[data-theme="dark"] body {
  background-image:
    linear-gradient(rgba(21, 25, 22, .90), rgba(21, 25, 22, .90)),
    url("../images/ordinal-spiral-background.jpg");
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
}

.nav-wrap, .site-footer, .site-main {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

/* Article pages need extra width for long display equations. */
.site-main--article {
  width: min(1240px, calc(100% - 40px));
}

.nav-wrap {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -.04em;
}
.site-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #ffffff;
  object-fit: cover;
}
.site-brand span { color: var(--accent); }
.site-nav { display: flex; align-items: center; gap: 20px; font-size: .94rem; }
.site-nav a { color: var(--muted); }
.site-nav a:hover { color: var(--accent); }

.theme-toggle {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.site-main { min-height: calc(100vh - 210px); }

.hero {
  padding: clamp(76px, 13vw, 160px) 0 90px;
  max-width: 800px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.hero h1, .page-heading h1, .article-header h1, .not-found h1 {
  margin: 0;
  letter-spacing: -.055em;
  line-height: 1.13;
}

.hero h1 { max-width: 720px; font-size: clamp(2.7rem, 7vw, 5.5rem); }
.hero > p:not(.eyebrow) { max-width: 620px; margin: 28px 0 0; color: var(--muted); font-size: 1.12rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 43px;
  padding: 0 18px;
  border-radius: 8px;
  font-size: .92rem;
  font-weight: 700;
  transition: transform .2s ease, background .2s ease;
}

.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover { color: #fff; background: var(--accent-strong); }
.button-secondary { border: 1px solid var(--line); background: var(--surface); }

.home-section, .page-shell { padding: 0 0 88px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 24px; }
.section-heading h2 { margin: 0; font-size: 1.75rem; letter-spacing: -.04em; }
.section-heading > a { color: var(--accent); font-size: .92rem; font-weight: 700; }

.post-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.post-card { min-height: 225px; padding: 26px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.post-card:hover { border-color: var(--accent); }
.post-date { margin: 0 0 12px; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.post-card h2 { margin: 0; font-size: 1.22rem; letter-spacing: -.03em; line-height: 1.35; }
.post-card h2 a:hover { color: var(--accent); }
.post-card > p:not(.post-date) { margin: 13px 0 18px; color: var(--muted); font-size: .93rem; line-height: 1.65; }

.tag-row { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-pill { display: inline-flex; padding: 3px 9px; border-radius: 999px; color: var(--accent-strong); background: var(--accent-soft); font-size: .76rem; font-weight: 700; line-height: 1.5; }
.tag-pill:hover { color: var(--accent-strong); filter: brightness(.96); }

.page-shell { padding-top: 70px; }
.page-heading { max-width: 720px; margin-bottom: 38px; }
.page-heading h1 { font-size: clamp(2.25rem, 5vw, 3.6rem); }
.lead, .page-heading .lead { color: var(--muted); font-size: 1.05rem; }
.lead > p { margin-bottom: 0; }

.article-shell { width: min(1100px, 100%); margin: 0 auto; padding: 72px 0 96px; }
.article-header { padding-bottom: 38px; border-bottom: 1px solid var(--line); }
.article-header h1 { font-size: clamp(2.35rem, 5vw, 4rem); }
.article-description { max-width: 690px; margin: 22px 0; color: var(--muted); font-size: 1.06rem; }
.article-layout { display: grid; grid-template-columns: 185px minmax(0, 1fr); grid-template-areas: "toc content"; gap: 48px; margin-top: 42px; }
.article-content { grid-area: content; min-width: 0; font-size: 1.02rem; }
.article-content h2 { margin: 2.7em 0 .8em; font-size: 1.65rem; letter-spacing: -.035em; line-height: 1.3; }
.article-content h3 { margin: 2em 0 .7em; font-size: 1.25rem; }
.article-content p, .article-content ul, .article-content ol { margin: 1.15em 0; }
.article-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.article-content blockquote {
  margin: 1.5em 0;
  padding: .15em 0 .15em 1em;
  border-left: 4px solid var(--quote-accent);
  color: var(--text);
  background: transparent;
  font-style: normal;
}
.article-content blockquote > :first-child { margin-top: 0; }
.article-content blockquote > :last-child { margin-bottom: 0; }
.article-content pre {
  padding: 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #1f2923;
  background: #ffffff !important;
  font-family: "Maple Mono", "Cascadia Code", Consolas, monospace;
  font-variant-ligatures: normal;
  line-height: 1.65;
}
.article-content code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--surface-soft);
  font-family: "Maple Mono", "Cascadia Code", Consolas, monospace;
  font-size: .88em;
}
.article-content pre code { padding: 0; color: inherit; background: transparent; font-size: .86rem; }
.article-content mjx-container[display="true"] {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 5px 0;
}

.article-toc { grid-area: toc; position: sticky; top: 90px; align-self: start; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.article-toc > p { margin: 0 0 8px; color: var(--text); font-size: .75rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.article-toc ul { margin: 0; padding-left: 16px; }
.article-toc li { margin: 7px 0; }
.article-toc a:hover { color: var(--accent); }

.tag-layout { display: grid; grid-template-columns: 235px minmax(0, 1fr); align-items: start; gap: 36px; }
.tag-sidebar, .tag-tree-panel { padding: 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.tag-sidebar { position: sticky; top: 90px; }
.tag-tree { margin: 0; padding: 0; list-style: none; }
.tag-tree ul { margin: 7px 0 7px 14px; padding: 0 0 0 14px; border-left: 1px solid var(--line); list-style: none; }
.tag-tree li { margin: 7px 0; }
.tag-tree a { color: var(--muted); font-size: .92rem; }
.tag-tree a:hover, .tag-tree a.is-current { color: var(--accent); font-weight: 700; }
.tag-tree-panel { max-width: 580px; padding: 28px; }

.empty-state { margin: 0; padding: 34px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); background: var(--surface); }
.not-found { padding-top: 140px; }
.not-found > p:not(.eyebrow) { color: var(--muted); }
.not-found .button { margin-top: 20px; }

.site-footer { display: flex; justify-content: space-between; gap: 22px; padding: 32px 0 40px; border-top: 1px solid var(--line); color: var(--text); font-size: .86rem; }
.site-footer p { margin: 0; }
.muted { color: var(--muted); }

@media (max-width: 870px) {
  .article-layout { grid-template-columns: 1fr; grid-template-areas: "toc" "content"; gap: 28px; }
  .article-toc { position: static; padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
}

@media (max-width: 760px) {
  body {
    background-position: center, center -148px;
    background-size: auto, 860px auto;
    background-attachment: scroll;
  }
  .nav-wrap, .site-footer, .site-main { width: min(100% - 28px, 1120px); }
  .site-nav { gap: 13px; font-size: .86rem; }
  .post-grid { grid-template-columns: 1fr; }
  .tag-layout { grid-template-columns: 1fr; gap: 28px; }
  .tag-sidebar { position: static; }
  .page-shell { padding-top: 50px; }
  .article-shell { padding-top: 52px; }
  .site-footer { flex-direction: column; }
}

@media (max-width: 430px) {
  .site-brand { font-size: .97rem; }
  .site-nav a:last-of-type { display: none; }
  .post-card { padding: 22px; }
}
/* Semantic theorem-style blocks, rendered by the thmbox shortcode. */
.thmbox {
  --thmbox-color: var(--accent);
  margin: 1.65em 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 4px solid var(--thmbox-color);
  border-radius: 10px;
  background: var(--surface);
}

.thmbox-title {
  padding: .58rem .95rem;
  border-bottom: 1px solid var(--line);
  color: var(--thmbox-color);
  background: var(--surface-soft);
  font-weight: 800;
  letter-spacing: .02em;
}

.thmbox-body { padding: .05rem 1rem .2rem; }
.thmbox-body > :first-child { margin-top: 1em; }
.thmbox-body > :last-child { margin-bottom: 1em; }
.thmbox-body blockquote { margin: 1em 0; }

.thmbox-definition { --thmbox-color: #3f7198; }
.thmbox-lemma { --thmbox-color: #7654a5; }
.thmbox-corollary { --thmbox-color: #2d7b76; }
.thmbox-example { --thmbox-color: #9a672b; }
.thmbox-proof { --thmbox-color: var(--muted); }

:root[data-theme="dark"] .thmbox-definition { --thmbox-color: #92c9ef; }
:root[data-theme="dark"] .thmbox-lemma { --thmbox-color: #c5a5ed; }
:root[data-theme="dark"] .thmbox-corollary { --thmbox-color: #8bd2ca; }
:root[data-theme="dark"] .thmbox-example { --thmbox-color: #efbe7d; }
