/* Typography-inspired reading polish for Chirpy. */

:root {
  --tl-accent: #c65d4a;
  --tl-accent-soft: rgba(198, 93, 74, 0.14);
  --tl-paper: #fbfaf7;
  --tl-paper-muted: #f2eee7;
  --tl-card: #fffdf9;
  --tl-radius: 6px;
  --tl-prose-width: 820px;
  --tl-home-width: 900px;
  --tl-ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --tl-serif-font: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
}

html[data-mode="dark"] {
  --tl-accent: #e6a08f;
  --tl-accent-soft: rgba(230, 160, 143, 0.14);
  --tl-paper: #1b1a18;
  --tl-paper-muted: #24221f;
  --tl-card: #211f1c;
}

html:not([data-mode]),
html[data-mode="light"] {
  --main-bg: var(--tl-paper);
  --mask-bg: var(--tl-paper-muted);
  --sidebar-bg: var(--tl-paper-muted);
  --card-bg: var(--tl-card);
  --card-hover-bg: #f7f0e7;
  --heading-color: #2f2d2a;
  --text-color: #3f3a36;
  --text-muted-color: #7b7168;
  --main-border-color: #e3d9cc;
  --link-color: #a84d3e;
  --toc-highlight: var(--tl-accent);
}

html[data-mode="dark"] {
  --main-bg: var(--tl-paper);
  --mask-bg: var(--tl-paper-muted);
  --sidebar-bg: #171614;
  --card-bg: var(--tl-card);
  --card-hover-bg: #2a2723;
  --heading-color: #efe5d8;
  --text-color: #e3d8cb;
  --text-muted-color: #a79b8d;
  --main-border-color: #39342e;
  --link-color: #e6a08f;
  --toc-highlight: var(--tl-accent);
}

body {
  font-family: var(--tl-ui-font);
  font-feature-settings: "kern";
  text-rendering: optimizeLegibility;
}

a {
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.18em;
}

#main-wrapper,
#main {
  background: var(--main-bg);
}

#main > div.row,
#main > div.container {
  max-width: 1180px;
}

#post-list,
#page,
#post {
  color: var(--text-color);
}

#post-list {
  max-width: var(--tl-home-width);
  margin-inline: auto;
}

#post-list .card-wrapper {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--main-border-color);
  border-radius: var(--tl-radius);
  background: var(--card-bg);
  box-shadow: none;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

#post-list .card-wrapper::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--tl-accent);
  content: "";
  opacity: 0.72;
}

#post-list .card-wrapper:hover {
  border-color: rgba(198, 93, 74, 0.36);
  background: var(--card-hover-bg);
  transform: translateY(-2px);
}

#post-list .post-preview {
  padding: 1.75rem 1.5rem 1.65rem 1.85rem;
}

#post-list .post-preview h1,
#post-list .post-preview h2,
#post-list .post-preview .card-title {
  margin-bottom: 0.7rem;
  font-family: var(--tl-serif-font);
  font-size: clamp(1.45rem, 1.12rem + 0.7vw, 1.95rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0;
}

#post-list .post-preview h1 a,
#post-list .post-preview h2 a,
#post-list .post-preview .card-title {
  color: var(--heading-color);
}

#post-list .post-preview h1 a:hover,
#post-list .post-preview h2 a:hover {
  color: var(--tl-accent);
}

#post-list .post-preview .post-content {
  color: var(--text-muted-color);
  font-size: 1rem;
  line-height: 1.85;
}

#post-list .post-preview .content {
  color: var(--text-muted-color);
  font-size: 1rem;
  line-height: 1.85;
}

#post-list .post-preview .post-meta,
#post-list .post-preview .post-meta em {
  color: var(--text-muted-color);
  font-size: 0.82rem;
}

#post,
#page {
  max-width: var(--tl-prose-width);
  margin-inline: auto;
}

#post h1,
#page h1 {
  margin-bottom: 1rem;
  color: var(--heading-color);
  font-family: var(--tl-serif-font);
  font-size: clamp(2rem, 1.75rem + 0.7vw, 2.75rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0;
}

#post .post-meta,
#page .post-meta {
  margin-bottom: 2.2rem;
  color: var(--text-muted-color);
}

.post-content {
  font-family: var(--tl-serif-font);
  font-size: 1.04rem;
  line-height: 1.92;
}

.post-content code,
.post-content pre,
.post-content table,
.post-content kbd {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

.post-content p,
.post-content ul,
.post-content ol,
.post-content blockquote,
.post-content table,
.post-content .table-wrapper,
.post-content .highlighter-rouge,
.post-content div[class^="language-"],
.post-content div[class*=" language-"] {
  margin-bottom: 1.2rem;
}

.post-content h2,
.post-content h3,
.post-content h4 {
  color: var(--heading-color);
  font-weight: 650;
  letter-spacing: 0;
}

.post-content h2 {
  margin-top: 2.7rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--main-border-color);
  font-size: 1.55rem;
}

.post-content h2::before {
  display: inline-block;
  width: 0.38rem;
  height: 1.1rem;
  margin-right: 0.6rem;
  border-radius: 999px;
  background: var(--tl-accent);
  content: "";
  transform: translateY(0.16rem);
}

.post-content h3 {
  margin-top: 2.1rem;
  font-size: 1.25rem;
}

.post-content h4 {
  margin-top: 1.7rem;
  font-size: 1.08rem;
}

.post-content blockquote {
  padding: 0.7rem 1rem;
  border-left: 3px solid var(--tl-accent);
  border-radius: 0 var(--tl-radius) var(--tl-radius) 0;
  background: var(--tl-accent-soft);
}

.post-content blockquote p:last-child {
  margin-bottom: 0;
}

.post-content code {
  border-radius: 4px;
}

.post-content div[class^="language-"],
.post-content div[class*=" language-"],
.post-content .highlight,
.post-content pre {
  border-radius: var(--tl-radius);
}

.post-content table {
  font-size: 0.94rem;
}

.post-content img {
  border-radius: var(--tl-radius);
}

#toc-wrapper,
#panel-wrapper,
.post-tail-wrapper,
.pagination,
.post-navigation {
  border-radius: var(--tl-radius);
}

#toc-wrapper {
  font-size: 0.88rem;
}

#toc-wrapper .toc-link.active {
  color: var(--tl-accent);
}

#sidebar {
  border-right: 1px solid var(--sidebar-border-color);
}

#sidebar .site-title {
  color: var(--heading-color);
  font-family: var(--tl-serif-font);
  font-weight: 700;
  letter-spacing: 0;
}

#sidebar .site-subtitle {
  line-height: 1.6;
}

#sidebar ul li.nav-item a.nav-link {
  border-radius: var(--tl-radius);
}

.tag,
.post-tag,
.post-tail-wrapper .license-wrapper,
.btn,
button {
  border-radius: var(--tl-radius);
}

#reader-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-left: 0.35rem;
  padding: 0;
  border: 1px solid var(--main-border-color);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text-muted-color);
  line-height: 1;
  vertical-align: middle;
}

#reader-theme-toggle:hover,
#reader-theme-toggle[aria-pressed="true"] {
  background: color-mix(in srgb, var(--tl-accent) 12%, var(--card-bg));
  color: var(--tl-accent);
}

html[data-reader-theme="classic"]:not([data-mode]),
html[data-reader-theme="classic"][data-mode="light"] {
  --main-bg: #EFF1F5;
  --mask-bg: #DCE0E8;
  --main-border-color: #CCD0DA;
  --text-color: #4C4F69;
  --text-muted-color: #6C6F85;
  --heading-color: #4C4F69;
  --link-color: #1E66F5;
  --sidebar-bg: #E6E9EF;
  --card-bg: #EFF1F5;
  --card-hover-bg: #DCE0E8;
  --toc-highlight: #1E66F5;
}

html[data-reader-theme="classic"][data-mode="dark"] {
  --main-bg: #1E1E2E;
  --mask-bg: #313244;
  --main-border-color: #45475A;
  --text-color: #CDD6F4;
  --text-muted-color: #A6ADC8;
  --heading-color: #CDD6F4;
  --link-color: #89B4FA;
  --sidebar-bg: #181825;
  --card-bg: #1E1E2E;
  --card-hover-bg: #313244;
  --toc-highlight: #89B4FA;
}

html[data-reader-theme="classic"] body,
html[data-reader-theme="classic"] .post-content,
html[data-reader-theme="classic"] #post-list .post-preview h1,
html[data-reader-theme="classic"] #post-list .post-preview h2,
html[data-reader-theme="classic"] #post-list .post-preview .card-title,
html[data-reader-theme="classic"] #post h1,
html[data-reader-theme="classic"] #page h1,
html[data-reader-theme="classic"] #sidebar .site-title {
  font-family: var(--tl-ui-font);
}

html[data-reader-theme="classic"] #post-list,
html[data-reader-theme="classic"] #post,
html[data-reader-theme="classic"] #page {
  max-width: none;
}

html[data-reader-theme="classic"] #post-list .card-wrapper {
  overflow: visible;
  border-color: transparent;
  background: transparent;
  transform: none;
}

html[data-reader-theme="classic"] #post-list .card-wrapper::before,
html[data-reader-theme="classic"] .post-content h2::before {
  display: none;
}

html[data-reader-theme="classic"] #post-list .post-preview {
  padding: 0.75rem 0;
}

html[data-reader-theme="classic"] #post-list .post-preview h1,
html[data-reader-theme="classic"] #post-list .post-preview h2,
html[data-reader-theme="classic"] #post-list .post-preview .card-title {
  font-size: 1.25rem;
}

html[data-reader-theme="classic"] #post h1,
html[data-reader-theme="classic"] #page h1 {
  font-size: 2rem;
}

html[data-reader-theme="classic"] .post-content {
  font-size: 1rem;
  line-height: 1.75;
}

html[data-reader-theme="classic"] .post-content h2 {
  border-bottom: none;
}

html[data-reader-theme="classic"] .post-content blockquote {
  border-left-color: var(--blockquote-border-color);
  background: transparent;
}

@media (min-width: 1200px) {
  .post-content {
    font-size: 1.07rem;
  }

  html[data-reader-theme="classic"] .post-content {
    font-size: 1rem;
  }
}

@media (max-width: 849px) {
  #post,
  #page,
  #post-list {
    max-width: 100%;
  }

  #post h1,
  #page h1 {
    font-size: 1.9rem;
  }

  .post-content {
    font-size: 1rem;
    line-height: 1.86;
  }

  .post-content h2 {
    font-size: 1.35rem;
  }
}
