/*
 * Next-inspired typography overrides for Chirpy post content.
 * Scoped to article pages to avoid affecting global theme components.
 */

:root {
  --next-text-color: #333;
  --next-headings-color: #262a30;
  --next-link-color: rgb(0, 160, 160);
  --next-inline-code-bg: #f0f0f0;
  --next-inline-code-color: rgb(0, 160, 160);
  --next-inline-code-border: #dfdfdf;
  --next-math-block-bg: #f3f3f3;
  --next-math-block-border: #d7d7d7;
  --next-blockquote-border: #ddd;
  --next-blockquote-text: #666;
  --next-table-border: #ddd;
  --next-table-head-bg: #f1f1f1;
  --next-table-head-text: #2f3238;
  --next-table-stripe: #f9f9f9;
  --next-table-hover: #f5f5f5;
}

html[data-mode='dark'] {
  --next-text-color: #ddd;
  --next-headings-color: #ddd;
  --next-link-color: rgb(0, 200, 200);
  --next-inline-code-bg: #2b2b2b;
  --next-inline-code-color: rgb(0, 160, 160);
  --next-inline-code-border: #3d3d3d;
  --next-math-block-bg: #202020;
  --next-math-block-border: #4a4a4a;
  --next-blockquote-border: #555;
  --next-blockquote-text: #aaa;
  --next-table-border: #555;
  --next-table-head-bg: #242424;
  --next-table-head-text: #dfdfdf;
  --next-table-stripe: #282828;
  --next-table-hover: #333;
}

article .content {
  color: var(--next-text-color);
  line-height: 1.7;
}

article .content,
article .content p,
article .content li {
  font-family:
    Overpass, 'GlowSansSC', 'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei',
    sans-serif;
}

article .content p {
  margin: 0 0 8px;
}

article .content h1,
article .content h2,
article .content h3,
article .content h4,
article .content h5,
article .content h6 {
  color: var(--next-headings-color);
  font-weight: 700;
  line-height: 1.5;
}

article .content h2 {
  font-size: 1.75em;
}

article .content h3 {
  font-size: 1.45em;
}

article .content h4 {
  font-size: 1.25em;
}

article .content a:not(.img-link) {
  color: var(--next-link-color);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 0;
  transition: color 0.2s ease;
}

article .content a:not(.img-link):hover {
  text-decoration: underline;
}

/* Inline code only: intentionally excludes pre > code blocks. */
article .content p > code.highlighter-rouge,
article .content li > code.highlighter-rouge,
article .content blockquote p > code.highlighter-rouge,
article .content td > code.highlighter-rouge,
article .content a > code.highlighter-rouge,
article .content :not(pre) > code.language-plaintext.highlighter-rouge {
  background-color: var(--next-inline-code-bg) !important;
  color: var(--next-inline-code-color) !important;
  border: 1px solid var(--next-inline-code-border) !important;
  border-radius: 3px !important;
  display: inline-block;
  font-family:
    'JetBrains Mono', Consolas, 'Liberation Mono', monospace !important;
  font-size: 0.88em !important;
  font-variant-ligatures: none;
  line-height: 1.35;
  overflow-wrap: break-word;
  word-wrap: break-word;
  padding: 0.05em 0.35em !important;
  vertical-align: baseline;
  transform: translateY(-0.02em);
}

article .content blockquote {
  border-left: 4px solid var(--next-blockquote-border);
  color: var(--next-blockquote-text);
  margin: 10px 0;
  padding: 0 15px;
}

article .content blockquote p {
  color: var(--next-blockquote-text);
}

/* Improve display math block spacing and readability. */
article .content mjx-container[display='true'] {
  background: var(--next-math-block-bg);
  border-left: 3px solid var(--next-math-block-border);
  border-radius: 3px;
  margin: 0.85rem 0 1rem;
  overflow-x: auto;
  padding: 0.4rem 0.6rem;
}

article .content .table-wrapper > table {
  border-collapse: collapse;
}

article .content .table-wrapper > table th,
article .content .table-wrapper > table td {
  border: 1px solid var(--next-table-border);
  padding: 8px;
}

article .content .table-wrapper > table th {
  background-color: var(--next-table-head-bg);
  color: var(--next-table-head-text);
  font-weight: 700;
}

article .content .table-wrapper > table thead {
  border-bottom: 0;
}

article .content .table-wrapper > table tbody tr:nth-child(2n + 1) {
  background-color: var(--next-table-stripe);
}

article .content .table-wrapper > table tbody tr:hover {
  background: var(--next-table-hover);
}

article .content hr {
  background-image: repeating-linear-gradient(
    -45deg,
    #ddd,
    #ddd 4px,
    transparent 4px,
    transparent 8px
  );
  border: 0;
  height: 3px;
  margin: 40px 0;
}

html[data-mode='dark'] article .content hr {
  background-image: repeating-linear-gradient(
    -45deg,
    #444,
    #444 4px,
    transparent 4px,
    transparent 8px
  );
}
