/**
 * Pangu White Spacing Styles
 * Additional CSS to enhance the visual appearance of automatic spacing
 */

/* Ensure proper line-height for mixed Chinese-English content */
.post-content,
.page-content,
.post-title,
.post-meta,
.site-title {
  line-height: 1.6;
  word-wrap: break-word;
  word-break: break-word;
}

/* Improve readability for headings with mixed content */
h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.4;
}

/* Ensure search results display properly with spacing */
.search-result {
  line-height: 1.5;
  margin-bottom: 1rem;
}

/* Improve spacing in navigation elements */
nav,
.site-nav {
  line-height: 1.5;
}

/* Ensure proper spacing in code blocks and preserve formatting */
pre {
  /* Disable Pangu spacing in code blocks to preserve formatting */
  white-space: pre;
  word-break: normal;
  overflow-x: auto;
  padding: 1em;
  margin: 1em 0;
  background-color: #f6f8fa;
  border-radius: 6px;
  border: 1px solid #d1d9e0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* Code blocks should not have any special spacing or background from pangu */
pre code {
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  font-size: inherit !important;
  white-space: pre;
  word-break: normal;
  border: none !important;
  box-shadow: none !important;
}

/* Ensure syntax highlighting blocks are properly styled */
.highlight,
.highlighter-rouge {
  background-color: #f6f8fa;
  border-radius: 6px;
  margin: 1em 0;
  overflow-x: auto;
}

.highlight pre,
.highlighter-rouge pre {
  margin: 0;
  padding: 1em;
  background: transparent;
  border: none;
}

/* Prevent any unwanted styling on language-specific code blocks */
pre[class*="language-"],
code[class*="language-"] {
  white-space: pre;
  word-break: normal;
  background: transparent;
}

/* Ensure code blocks inside articles don't get transformed */
.post-content pre,
.page-content pre,
.post-content .highlight,
.page-content .highlight,
.post-content .highlighter-rouge,
.page-content .highlighter-rouge {
  /* Prevent text transformation */
  text-transform: none;
  letter-spacing: normal;
  word-spacing: normal;
}

/* Improve typography for better Chinese-English mixed reading experience */
.post-content p,
.page-content p {
  margin-bottom: 1em;
  text-align: left;
}

/* Special handling for inline code only (not inside pre blocks) */
.post-content p code,
.page-content p code,
.post-content li code,
.page-content li code,
.post-content h1 code,
.post-content h2 code,
.post-content h3 code,
.post-content h4 code,
.post-content h5 code,
.post-content h6 code,
.page-content h1 code,
.page-content h2 code,
.page-content h3 code,
.page-content h4 code,
.page-content h5 code,
.page-content h6 code {
  padding: 0.2em 0.4em;
  margin: 0 0.1em;
  font-size: 85%;
  background-color: rgba(27, 31, 35, 0.05);
  border-radius: 3px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  /* Make inline code breakable across lines */
  white-space: pre-wrap;
  word-break: break-all;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Add more generic inline code styling for better coverage */
code:not(pre code) {
  /* Make inline code breakable across lines */
  white-space: pre-wrap !important;
  word-break: break-all !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
}

/* Additional specific targeting for minima theme */
.post-content code,
.page-content code,
article code,
main code {
  white-space: pre-wrap !important;
  word-break: break-all !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
}

/* Ensure it works in all contexts */
* code:not(pre code):not(.highlight code) {
  white-space: pre-wrap !important;
  word-break: break-all !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
}

/* Ensure proper spacing in lists with mixed content */
.post-content li,
.page-content li {
  margin-bottom: 0.5em;
  line-height: 1.6;
}

/* Improve spacing in blockquotes */
.post-content blockquote,
.page-content blockquote {
  line-height: 1.6;
  padding: 0 1em;
  margin: 0 0 1rem 0;
  border-left: 0.25em solid #dfe2e5;
}

/* Ensure tables display properly with mixed content */
.post-content table,
.page-content table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1rem;
}

.post-content th,
.post-content td,
.page-content th,
.page-content td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #dfe2e5;
  line-height: 1.5;
}

/* Optimize for mobile devices */
@media (max-width: 768px) {
  .post-content,
  .page-content {
    font-size: 16px;
    line-height: 1.7;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    line-height: 1.3;
  }
}

/* Print styles to maintain proper spacing when printing */
@media print {
  .post-content,
  .page-content {
    line-height: 1.5;
    font-size: 12pt;
  }

  /* Ensure code blocks don't break across pages */
  pre,
  code {
    page-break-inside: avoid;
  }
}
