/* Wisdomverse v38 — Highlight.js: syntax tokens for both site themes.
   Only fenced code blocks are targeted. Inline `code`, CodeMirror and MathJax
   are deliberately untouched. Token selectors override previous editor rules. */
:root,
html[data-bs-theme="dark"], html[data-theme="dark"] {
  --wv-code-bg: #0d1722;
  --wv-code-ink: #dce7f3;
  --wv-code-comment: #8295a6;
  --wv-code-keyword: #c5a0ff;
  --wv-code-string: #91d6aa;
  --wv-code-number: #ffc58c;
  --wv-code-function: #77c7fa;
  --wv-code-type: #f3cf87;
  --wv-code-variable: #e4b1db;
  --wv-code-literal: #f09eaf;
  --wv-code-operator: #b2c4db;
  --wv-code-meta: #8fcde2;
  --wv-code-border: #263746;
}
html[data-bs-theme="light"], html[data-theme="light"] {
  --wv-code-bg: #f3f6fb;
  --wv-code-ink: #243244;
  --wv-code-comment: #68788b;
  --wv-code-keyword: #7544b5;
  --wv-code-string: #14774f;
  --wv-code-number: #a65722;
  --wv-code-function: #1261ac;
  --wv-code-type: #9b6616;
  --wv-code-variable: #9e407b;
  --wv-code-literal: #ad3453;
  --wv-code-operator: #556782;
  --wv-code-meta: #21798c;
  --wv-code-border: #d3dce7;
}

/* Applies to article readers, notebook readers, guest pages and EasyMDE preview. */
:is(.article-content, .article-prose, .wv-annotation-reader, .wv-an-prose,
    .public-prose, .editor-preview, .editor-preview-side, .wv-reader,
    .step-markdown) pre:has(> code),
pre:has(> code.hljs) {
  background: var(--wv-code-bg) !important;
  color: var(--wv-code-ink) !important;
  border: 1px solid var(--wv-code-border) !important;
  border-radius: 12px !important;
  /* The padding belongs to <pre>; code stays unpadded for clean scrolling. */
  padding: 18px 22px !important;
  box-sizing: border-box;
  overflow-x: auto !important;
  white-space: pre !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
  tab-size: 4;
}

/* The pre code selector is intentionally broad; inline code is excluded. */
pre > code.hljs,
pre > code[class*="language-"] {
  display: block;
  width: max-content;
  min-width: 100%;
  padding: 0 !important;
  margin: 0;
  background: transparent !important;
  color: var(--wv-code-ink) !important;
  border: 0 !important;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: .9em;
  font-weight: 400;
  line-height: 1.65;
  white-space: pre !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
}

/* Emphasize tokens with explicit specificity to beat legacy editor !important. */
pre code.hljs .hljs-comment,
pre code.hljs .hljs-quote { color: var(--wv-code-comment) !important; font-style: italic; }
pre code.hljs .hljs-keyword,
pre code.hljs .hljs-selector-tag,
pre code.hljs .hljs-doctag,
pre code.hljs .hljs-built_in { color: var(--wv-code-keyword) !important; }
pre code.hljs .hljs-string,
pre code.hljs .hljs-regexp,
pre code.hljs .hljs-addition,
pre code.hljs .hljs-template-tag { color: var(--wv-code-string) !important; }
pre code.hljs .hljs-number,
pre code.hljs .hljs-symbol,
pre code.hljs .hljs-bullet { color: var(--wv-code-number) !important; }
pre code.hljs .hljs-title,
pre code.hljs .hljs-title.function_,
pre code.hljs .hljs-function .hljs-title,
pre code.hljs .hljs-attribute { color: var(--wv-code-function) !important; }
pre code.hljs .hljs-type,
pre code.hljs .hljs-title.class_,
pre code.hljs .hljs-class .hljs-title,
pre code.hljs .hljs-selector-class,
pre code.hljs .hljs-selector-id { color: var(--wv-code-type) !important; }
pre code.hljs .hljs-variable,
pre code.hljs .hljs-params,
pre code.hljs .hljs-property { color: var(--wv-code-variable) !important; }
pre code.hljs .hljs-literal,
pre code.hljs .hljs-deletion { color: var(--wv-code-literal) !important; }
pre code.hljs .hljs-operator,
pre code.hljs .hljs-punctuation { color: var(--wv-code-operator) !important; }
pre code.hljs .hljs-meta,
pre code.hljs .hljs-meta .hljs-keyword,
pre code.hljs .hljs-template-variable { color: var(--wv-code-meta) !important; }
pre code.hljs .hljs-emphasis { font-style: italic; }
pre code.hljs .hljs-strong { font-weight: 700; }

/* Some existing editor styles use .editor-preview code {color: accent !important}.
   This more specific rule ensures dynamic preview tokens remain multicoloured. */
.EasyMDEContainer .editor-preview pre code.hljs,
.EasyMDEContainer .editor-preview-side pre code.hljs {
  color: var(--wv-code-ink) !important;
  background: transparent !important;
  padding: 0 !important;
}
.EasyMDEContainer .editor-preview pre code.hljs :is(.hljs-keyword,.hljs-built_in),
.EasyMDEContainer .editor-preview-side pre code.hljs :is(.hljs-keyword,.hljs-built_in) {
  color: var(--wv-code-keyword) !important;
}
.EasyMDEContainer .editor-preview pre code.hljs .hljs-title,
.EasyMDEContainer .editor-preview-side pre code.hljs .hljs-title {
  color: var(--wv-code-function) !important;
}

@media (max-width: 640px) {
  pre > code.hljs, pre > code[class*="language-"] { font-size: .84em; }
}

/* v04: comfortable inner spacing on narrow screens, including notebook readers. */
@media (max-width: 600px) {
  :is(.article-content, .article-prose, .wv-annotation-reader, .wv-an-prose,
      .public-prose, .editor-preview, .editor-preview-side, .wv-reader,
      .step-markdown) pre:has(> code),
  pre:has(> code.hljs) {
    padding: 14px 16px !important;
  }
}
