/* xi.css — system fonts for text; KaTeX ships its own fonts (katex.min.css). */

:root {
  --bg: #ffffff;
  --fg: #24292f;
  --muted: #6a737d;
  --accent: #1a5fb4;
  --border: #e1e4e8;
  --code-bg: #f6f8fa;
  --err: #b00020;
  --err-bg: #fff0f2;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --fg: #e6e6e6;
    --muted: #9aa1a9;
    --accent: #79b8ff;
    --border: #2d333b;
    --code-bg: #1c2026;
    --err: #ff8a8a;
    --err-bg: #2a1215;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-size: 1.0625rem;
  line-height: 1.75;
}

.wrap {
  max-width: 44rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

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

/* ---------- header / footer ---------- */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-bottom: 2.75rem;
}

.site-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--fg);
}

.site-nav a { margin-left: 1.25rem; color: var(--muted); }
.site-nav a:hover { color: var(--accent); }

.site-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer p { margin: 0; }

/* ---------- typography ---------- */

h1, h2, h3, h4, h5, h6 {
  font-weight: 650;
  line-height: 1.3;
  margin: 2.25rem 0 0.85rem;
}

h2 { font-size: 1.55rem; }
h3 { font-size: 1.25rem; }

p, ul, ol, dl { margin: 0 0 1.15rem; }

li { margin: 0.25rem 0; }

blockquote {
  margin: 1.75rem 0;
  padding: 0.15rem 1.25rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
blockquote p:last-child { margin-bottom: 0; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

img, video { max-width: 100%; height: auto; }

table {
  border-collapse: collapse;
  margin: 1.75rem 0;
  width: 100%;
  font-size: 0.97rem;
}
th, td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.75rem;
  text-align: left;
}
tr:nth-child(even) { background: var(--code-bg); }

sup a { text-decoration: none; }

/* ---------- code ---------- */

code, kbd, pre {
  font-size: 0.92em;
}

:not(pre) > code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.08em 0.32em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.9rem 1.15rem;
  overflow-x: auto;
  line-height: 1.55;
}
pre code { background: none; border: 0; padding: 0; font-size: 0.9em; }

.highlight pre { margin: 0; }

/* ---------- lists / home ---------- */

.post-header h1 { font-size: 2.1rem; margin: 0 0 0.3rem; }

.post-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 2.25rem;
}
.post-meta .tag { color: var(--muted); margin-left: 0.55rem; }
.post-meta .tag:hover { color: var(--accent); }

.post-list .post-item { margin-bottom: 2.15rem; }
.post-list h2, .post-list h3 { margin: 0 0 0.2rem; font-size: 1.35rem; }
.post-list h3 { font-size: 1.15rem; }
.post-list .post-meta { margin-bottom: 0.35rem; }
.post-list p { margin: 0.35rem 0 0; }

.home-heading { margin-top: 0; }
.intro { margin-bottom: 2.5rem; }
.intro p:last-child { margin-bottom: 0; }

.list-intro { margin-bottom: 2.25rem; }

.crumbs { margin: 0 0 0.75rem; font-size: 0.9rem; }
.taxonomy-count { color: var(--muted); font-size: 0.95rem; margin: -0.4rem 0 2rem; }

.term-list {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.25rem;
}
.term-list li { margin: 0; }
.term { font-size: 1.05rem; }
.term-count {
  color: var(--muted);
  font-size: 0.85em;
  margin-left: 0.35rem;
}
.term-count::before { content: "("; }
.term-count::after { content: ")"; }

.error-404 { text-align: center; padding: 4rem 0; }
.error-404 h1 { font-size: 4rem; margin: 0 0 0.5rem; }

/* ---------- math (KaTeX) ---------- */

/* long display equations scroll instead of overflowing */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.35rem 0;
}
.katex-display > .katex { white-space: normal; }
.katex { font-size: 1.07em; }

.xi-math-error {
  color: var(--err);
  background: var(--err-bg);
  border: 1px solid var(--err);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
}

/* ---------- print ---------- */

@media print {
  .site-nav, .site-footer { display: none; }
  body { font-size: 11pt; }
}

/* ---------- system fonts for text ---------- */

body, h1, h2, h3, h4, h5, h6 {
  font-family: system-ui, sans-serif;
}
