/* ============================================================
   KENSHIN Theme — minimal, typography-first, single-column
   Inspired by academic blogs (kexue.fm style)
   ============================================================ */

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

/* --- Variables --------------------------------------------- */
:root {
  --bg-outer:     #c4c4c4;
  --bg:           #ffffff;
  --bg-alt:       #f8f9fa;
  --text:         #1a1a1a;
  --text-dim:     #6b7280;
  --border:       #e5e7eb;
  --link:         #1a56db;
  --link-hover:   #1e40af;
  --code-bg:      #f1f5f9;
  --accent:       #2563eb;
  --max-width:    720px;
  --font-serif:   "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", Georgia, "Times New Roman", serif;
  --font-sans:    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono:    "JetBrains Mono", "Fira Code", "Cascadia Code", "SF Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-outer:   #101012;
    --bg:         #1a1a1e;
    --bg-alt:     #222228;
    --text:       #d4d4d8;
    --text-dim:   #71717a;
    --border:     #2e2e36;
    --link:       #60a5fa;
    --link-hover: #93bbfd;
    --code-bg:    #27272a;
    --accent:     #3b82f6;
  }
}

/* --- Base -------------------------------------------------- */
html {
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-outer);
}

body {
  font-family: var(--font-serif);
  line-height: 1.82;
  color: var(--text);
  background: var(--bg-outer);
  min-height: 100vh;
}

/* --- Header ------------------------------------------------ */
header {
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem 1.25rem;
}

.site-title {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

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

header nav {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  display: flex;
  gap: 1.5rem;
}

header nav a {
  color: var(--text-dim);
  text-decoration: none;
}

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

/* --- Main content area ------------------------------------- */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  background: var(--bg);
  min-height: 60vh;
}

/* --- Homepage ---------------------------------------------- */
.home-hero {
  padding: 2.5rem 0 1.5rem;
}

.home-title {
  font-family: var(--font-sans);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 0.4rem;
  border: none;
  padding: 0;
}

.home-desc {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text-dim);
  margin-bottom: 0.8rem;
}

.home-links {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

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

.home-links .dot {
  color: var(--border);
}

.home-divider {
  margin: 1.5rem 0 1rem;
}

.home-stats {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.home-stats .dot {
  color: var(--border);
}

.year-group h2 {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dim);
  margin: 2rem 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.post-list {
  list-style: none;
}

.post-list li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.4rem 0;
  font-size: 1rem;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.post-list li:hover {
  border-bottom-color: var(--border);
}

.post-list li time {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
  min-width: 2.8rem;
}

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

.post-list li a:hover {
  color: var(--link);
}

/* --- Article ----------------------------------------------- */
.article-header {
  margin-bottom: 2rem;
}

.article-header h1 {
  font-family: var(--font-sans);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.article-meta {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-dim);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* --- Article body ------------------------------------------ */
.article-body h2 {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2.2em 0 0.6em;
}

.article-body h3 {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.8em 0 0.5em;
}

.article-body p {
  margin: 0.9em 0;
}

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

.article-body a:hover {
  text-decoration: underline;
}

.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

/* --- Lists in article -------------------------------------- */
.article-body ul,
.article-body ol {
  padding-left: 1.5rem;
  margin: 0.7em 0;
}

.article-body li {
  margin: 0.25em 0;
}

/* --- Blockquote -------------------------------------------- */
.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.4em 1em;
  margin: 1.2em 0;
  color: var(--text-dim);
  background: var(--bg-alt);
  border-radius: 0 4px 4px 0;
}

.article-body blockquote p {
  margin: 0.3em 0;
}

/* --- Code -------------------------------------------------- */
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.12em 0.4em;
  border-radius: 3px;
  color: var(--text);
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1em 1.2em;
  overflow-x: auto;
  margin: 1.2em 0;
  line-height: 1.55;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
  border-radius: 0;
}

/* Hugo Chroma overrides */
.highlight {
  background: var(--code-bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  margin: 1.2em 0;
}

.highlight pre {
  margin: 0;
  border: none;
  padding: 1em 1.2em;
}

/* --- Tables ------------------------------------------------ */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-family: var(--font-sans);
  font-size: 0.92em;
}

.article-body thead th {
  background: var(--bg-alt);
  border-bottom: 2px solid var(--border);
  padding: 0.5em 0.75em;
  text-align: left;
  font-weight: 600;
}

.article-body tbody td {
  border-bottom: 1px solid var(--border);
  padding: 0.45em 0.75em;
}

/* --- Horizontal rule --------------------------------------- */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5em 0;
}

/* --- Article footer ---------------------------------------- */
.article-footer {
  margin-top: 2.5rem;
  font-family: var(--font-sans);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tags a {
  font-size: 0.82rem;
  color: var(--text-dim);
  text-decoration: none;
}

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

.categories {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.categories a {
  color: var(--text-dim);
  text-decoration: none;
  margin-right: 0.75rem;
}

/* --- Post navigation --------------------------------------- */
.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.post-nav a {
  color: var(--text-dim);
  text-decoration: none;
  max-width: 45%;
}

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

.post-nav .next {
  text-align: right;
  margin-left: auto;
}

/* --- About page -------------------------------------------- */
.about-quote {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  text-align: center;
}

.quote-text {
  font-size: 1.3rem;
  font-style: italic;
  line-height: 1.7;
  color: var(--text);
  max-width: 560px;
}

.quote-author {
  margin-top: 1.2rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* --- List page --------------------------------------------- */
.list-page h1 {
  font-family: var(--font-sans);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

/* --- Footer ------------------------------------------------ */
footer {
  border-top: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--text-dim);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.footer-inner a {
  color: var(--text-dim);
  text-decoration: none;
}

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

/* --- KaTeX overrides --------------------------------------- */
.katex { font-size: 1.05em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.4em 0; }

/* --- Responsive -------------------------------------------- */
@media (max-width: 600px) {
  html { font-size: 16px; }
  main { padding: 1.25rem 1rem 3rem; }
  .header-inner { padding: 1rem 1rem; }
  .footer-inner { padding: 1.25rem 1rem 2rem; }
  .article-header h1 { font-size: 1.35rem; }
  .post-nav { flex-direction: column; gap: 0.5rem; }
  .post-nav a { max-width: 100%; }
  .post-nav .next { text-align: left; }
}

/* --- Selection --------------------------------------------- */
::selection {
  background: var(--accent);
  color: #fff;
}

/* --- Focus ------------------------------------------------- */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
