/* ===== PaperMod-inspired blog styling ===== */
:root {
  --theme: #fff;
  --entry: #fff;
  --primary: rgb(30, 30, 30);
  --secondary: rgb(108, 108, 108);
  --tertiary: rgb(214, 214, 214);
  --content: rgb(31, 31, 31);
  --code-bg: rgb(245, 245, 245);
  --border: #eaeaea;
  --link: #2563eb;
  --gap: 24px;
  --content-gap: 20px;
  --main-width: 972px;
  --radius: 8px;
  --shadow: 0 6px 22px rgba(15, 23, 42, 0.10);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

html.dark {
  --theme: rgb(29, 30, 32);
  --entry: rgb(46, 46, 51);
  --primary: rgb(218, 218, 219);
  --secondary: rgb(155, 156, 157);
  --tertiary: rgb(65, 66, 68);
  --content: rgb(196, 196, 197);
  --code-bg: rgb(55, 56, 62);
  --border: rgb(51, 51, 51);
  --link: #6ea8fe;
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.6;
  color: var(--primary);
  background: var(--theme);
  word-wrap: break-word;
}

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

::selection { background: rgba(37, 99, 235, 0.2); }

/* ===== Layout ===== */
.main {
  max-width: calc(var(--main-width) + var(--gap) * 2);
  margin: auto;
  padding: var(--gap);
}

/* ===== Header ===== */
.nav {
  max-width: calc(var(--main-width) + var(--gap) * 2);
  margin: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px var(--gap);
  line-height: 2;
}
.nav .logo a {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}
.nav .menu {
  display: flex;
  align-items: center;
  gap: 18px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav .menu a {
  color: var(--secondary);
  font-size: 14px;
  font-weight: 500;
}
.nav .menu a:hover { color: var(--link); }
.nav .menu a:hover { color: var(--link); text-decoration: none; }

#theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
}
#theme-toggle svg { width: 17px; height: 17px; }
html.dark #theme-toggle .moon { display: none; }
html:not(.dark) #theme-toggle .sun { display: none; }

/* ===== Profile / intro (blog home) ===== */
.profile-intro {
  text-align: center;
  padding: 40px 0 24px;
}
.profile-intro h1 { font-size: 32px; margin: 0 0 8px; }
.profile-intro p { color: var(--secondary); margin: 0 auto; max-width: 540px; }

/* ===== Post list ===== */
.post-entry {
  position: relative;
  margin-bottom: var(--gap);
  padding: 22px;
  background: var(--entry);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.post-entry:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--tertiary);
}
.post-entry:active { transform: translateY(-1px); }
.entry-header h2 {
  font-size: 24px;
  line-height: 1.3;
  margin: 0 0 8px;
  color: var(--primary);
}
.entry-content {
  margin: 8px 0;
  color: var(--secondary);
  font-size: 16px;
  line-height: 1.6;
}
.entry-meta, .post-meta {
  color: var(--secondary);
  font-size: 14px;
}
.post-entry a.entry-link {
  position: absolute;
  inset: 0;
}

/* ===== Single post ===== */
.breadcrumbs { color: var(--secondary); font-size: 14px; margin-bottom: 12px; }
.breadcrumbs a { color: var(--secondary); }

.post-header { margin-bottom: 8px; }
.post-title { font-size: 36px; line-height: 1.25; margin: 0 0 6px; }
.post-meta { margin-bottom: 24px; }

.toc {
  margin: 0 0 28px;
  border: 1px solid var(--border);
  background: var(--code-bg);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 15px;
}
.toc summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
}
.toc ul { margin: 10px 0 4px; padding-left: 20px; }
.toc li { margin: 4px 0; }
.toc a { color: var(--link); }

/* ===== Prose ===== */
.post-content { color: var(--content); }
.post-content h2 { font-size: 28px; margin: 36px 0 14px; line-height: 1.3; }
.post-content h3 { font-size: 22px; margin: 28px 0 10px; }
.post-content p { margin: 0 0 var(--content-gap); }
.post-content ul, .post-content ol { margin: 0 0 var(--content-gap); padding-left: 26px; }
.post-content li { margin: 6px 0; }
.post-content a { text-decoration: underline; text-underline-offset: 2px; }
.post-content img { max-width: 100%; height: auto; border-radius: var(--radius); }
.post-content blockquote {
  margin: 0 0 var(--content-gap);
  padding: 4px 18px;
  border-left: 3px solid var(--tertiary);
  color: var(--secondary);
}
.post-content code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: 4px;
}
.post-content pre {
  background: var(--code-bg);
  padding: 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 0 0 var(--content-gap);
  font-size: 15px;
  line-height: 1.5;
}
.post-content pre code { background: none; padding: 0; font-size: inherit; }
.post-content hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }
.post-content table { border-collapse: collapse; width: 100%; margin: 0 0 var(--content-gap); font-size: 16px; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.footnotes { font-size: 15px; color: var(--secondary); border-top: 1px solid var(--border); margin-top: 36px; padding-top: 12px; }

/* ===== Post footer (tags + nav) ===== */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  list-style: none;
  margin: 36px 0 0;
  padding: 0;
}
.post-tags li a {
  display: inline-block;
  padding: 4px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--secondary);
  font-size: 14px;
}
.post-tags li a:hover { border-color: var(--tertiary); text-decoration: none; }

/* ===== Tags cloud (tags index) ===== */
.tags-cloud { margin-top: 4px; }
.tags-cloud li a { font-size: 15px; }
.tag-count { color: var(--secondary); font-size: 12px; }

/* ===== Search ===== */
.search-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 17px;
  font-family: inherit;
  color: var(--primary);
  background: var(--entry);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
}
.search-input:focus { outline: none; border-color: var(--link); }

.paginav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 36px;
}
.paginav a {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.paginav a:hover { border-color: var(--tertiary); text-decoration: none; }
.paginav .label { color: var(--secondary); font-size: 13px; }
.paginav .title { color: var(--primary); }
.paginav .next { text-align: right; }

/* ===== Footer ===== */
.footer {
  max-width: calc(var(--main-width) + var(--gap) * 2);
  margin: auto;
  padding: 24px var(--gap);
  color: var(--secondary);
  font-size: 13px;
  text-align: center;
}

/* ===== Back-to-top button ===== */
.to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: #3f5a78;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s, background 0.15s ease;
  z-index: 60;
}
.to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { background: #34506f; }
.to-top svg { width: 20px; height: 20px; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .post-title { font-size: 28px; }
  .nav { flex-wrap: wrap; gap: 8px; }
}
