/* GitHub Dark (Primer "dark default") theme for Zine's tree-sitter
 * highlighting. Class names are nvim-treesitter capture names with
 * dots replaced by underscores (e.g. @keyword.modifier -> .keyword_modifier).
 *
 * Zine stacks every matching capture onto a span (e.g. an identifier can be
 * `class="constant variable_builtin type variable"`), and all these selectors
 * have equal specificity, so ORDER MATTERS: later rules win. Generic
 * identifier captures are ordered so that ambiguous stacks resolve to the
 * plain foreground, like GitHub's own rendering.
 *
 * The `spell`/`nospell` classes are spell-checking regions, not tokens —
 * intentionally unstyled. */

:root {
  --gh-bg: #0d1117;
  --gh-fg: #e6edf3;
  --gh-border: #30363d;
  --gh-gray: #8b949e;   /* comments */
  --gh-red: #ff7b72;    /* keywords, operators */
  --gh-blue: #79c0ff;   /* constants, numbers, builtins, escapes */
  --gh-lblue: #a5d6ff;  /* strings */
  --gh-purple: #d2a8ff; /* functions */
  --gh-orange: #ffa657; /* types */
  --gh-green: #7ee787;  /* tags, regexps */
  --gh-error: #f85149;
}

pre {
  background-color: var(--gh-bg);
  border: 1px solid var(--gh-border);
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  line-height: 1.45;
}

/* Wrapper added by main.js: positioning context for the copy button,
 * kept outside the <pre> scroll container so it doesn't scroll away. */
.code-block {
  position: relative;
}

.code-block .copy-button {
    font-family: monospace;
    border: 0;
    position: absolute;
    top: 20px;
    right: 6px;
    background: #e7e7e7;
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
}

.code-block .copy-button:hover {
    /* background: #d5dae2; */
    color: black;
    opacity: 100;
}


pre code {
  color: var(--gh-fg);
}

/* Inline code, GitHub-style chip. Remove if you don't want it. */
:not(pre) > code {
  background-color: rgba(110, 118, 129, 0.4);
  border-radius: 6px;
  padding: 0.15em 0.4em;
  font-size: 0.9em;
}

/* --- identifiers: most generic first, so stacked captures resolve last --- */

code .constant,
code .constant_builtin,
code .boolean,
code .number,
code .constant_numeric,
code .float {
  color: var(--gh-blue);
}

code .variable_builtin { /* self, this, ... */
  color: var(--gh-blue);
}

code .type,
code .type_builtin,
code .type_definition {
  color: var(--gh-orange);
}

code .module,
code .namespace,
code .variable_member,
code .variable_parameter,
code .field,
code .property {
  color: var(--gh-fg);
}

/* Last of the identifier group: spans stacked with .constant/.type/etc.
 * fall back to plain foreground, matching github.com. */
code .variable {
  color: var(--gh-fg);
}

/* --- everything below is unambiguous and overrides the identifier group --- */

code .function,
code .function_builtin,
code .function_call,
code .function_method,
code .function_macro,
code .constructor,
code .attribute {
  color: var(--gh-purple);
}

code .keyword,
code .keyword_modifier,
code .keyword_type,
code .keyword_function,
code .keyword_return,
code .keyword_operator,
code .keyword_conditional,
code .keyword_repeat,
code .keyword_import,
code .keyword_exception,
code .keyword_directive,
code .label,
code .operator {
  color: var(--gh-red);
}

code .punctuation,
code .punctuation_bracket,
code .punctuation_delimiter,
code .punctuation_special {
  color: var(--gh-fg);
}

code .string,
code .string_special,
code .character,
code .markup_link_url {
  color: var(--gh-lblue);
}

code .string_regexp {
  color: var(--gh-green);
}

code .string_escape,
code .escape,
code .character_special {
  color: var(--gh-blue);
}

code .tag {
  color: var(--gh-green);
}

code .tag_attribute {
  color: var(--gh-blue);
}

/* Last so doc comments stay gray even when stacked with other captures. */
code .comment,
code .comment_line,
code .comment_block,
code .comment_documentation {
  color: var(--gh-gray);
}

code .error {
  color: var(--gh-error);
}

/* --- markdown / diff blocks --- */

code .markup_heading {
  color: var(--gh-blue);
  font-weight: bold;
}

code .markup_strong {
  font-weight: bold;
}

code .markup_italic {
  font-style: italic;
}

code .markup_link,
code .markup_link_label {
  color: var(--gh-lblue);
}

code .diff_plus,
code .markup_inserted {
  color: #aff5b4;
  background-color: #033a16;
}

code .diff_minus,
code .markup_deleted {
  color: #ffdcd7;
  background-color: #67060c;
}

code .diff_delta,
code .markup_changed {
  color: #ffdfb6;
  background-color: #5a1e02;
}
