/*
 * Theme-aware code block colors and Pygments token styles.
 *
 * The Prism CDN theme (prism-tomorrow) paints code text a fixed pale gray,
 * which is unreadable on the light theme's light code background. ContentKit
 * highlights with Pygments (codehilite / code-listing), whose token spans
 * (.k, .s, .c, ...) only get colors from this stylesheet — so token colors
 * are defined here, theme-aware, instead of in the CDN theme.
 */

.post-content pre,
.post-content pre[class*="language-"],
.post-content code[class*="language-"] {
    color: var(--text-primary);
    background: transparent;
    text-shadow: none;
}

.post-content pre {
    color: var(--text-primary);
}

/* Code listings keep a distinct surface regardless of the bootstrap utility */
.post-content .code-listing pre,
.post-content .code-listing .code-listing-body {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.post-content .code-listing figcaption {
    color: var(--text-muted);
}

/* Inline code keeps its subtle chip background */
.post-content :not(pre) > code[class*="language-"] {
    background: var(--bg-tertiary);
}

/* --- Pygments token palette (light defaults, dark overrides below) --- */

.post-content .codehilite,
.post-content .code-listing {
    --ck-token-comment: #6a737d;
    --ck-token-keyword: #b64800;
    --ck-token-string: #1b7a43;
    --ck-token-number: #7d3c98;
    --ck-token-function: #2670a1;
    --ck-token-class: #955f0b;
    --ck-token-builtin: #8e52a7;
    --ck-token-operator: #1a1a2e;
    --ck-token-decorator: #b64800;
    --ck-token-error: #bd3e31;
}

:root:where([data-theme="dark"]) .post-content .codehilite,
:root:where([data-theme="dark"]) .post-content .code-listing {
    --ck-token-comment: #8b949e;
    --ck-token-keyword: #f0985c;
    --ck-token-string: #7ec699;
    --ck-token-number: #c39bd3;
    --ck-token-function: #6fb3e0;
    --ck-token-class: #e3b341;
    --ck-token-builtin: #b892d0;
    --ck-token-operator: #e6edf3;
    --ck-token-decorator: #f0985c;
    --ck-token-error: #ff7b72;
}

.post-content .codehilite pre,
.post-content pre[class*="language-"] {
    color: var(--text-primary);
}

/* Comments */
.post-content .c, .post-content .c1, .post-content .ch,
.post-content .cm, .post-content .cp, .post-content .cpf,
.post-content .cs, .post-content .cd {
    color: var(--ck-token-comment, #6a737d);
    font-style: italic;
}

/* Keywords */
.post-content .k, .post-content .kc, .post-content .kd,
.post-content .kn, .post-content .kp, .post-content .kr,
.post-content .kw, .post-content .ow {
    color: var(--ck-token-keyword, #b64800);
    font-weight: 600;
}

/* Strings */
.post-content .s, .post-content .s1, .post-content .s2,
.post-content .sa, .post-content .sb, .post-content .sc,
.post-content .sd, .post-content .se, .post-content .sh,
.post-content .si, .post-content .sr, .post-content .ss,
.post-content .sx {
    color: var(--ck-token-string, #1b7a43);
}

/* Numbers */
.post-content .m, .post-content .mf, .post-content .mh,
.post-content .mi, .post-content .il, .post-content .mo {
    color: var(--ck-token-number, #7d3c98);
}

/* Functions and methods */
.post-content .nf, .post-content .fm {
    color: var(--ck-token-function, #2670a1);
}

/* Classes, constants, decorators */
.post-content .nc, .post-content .ne, .post-content .nd {
    color: var(--ck-token-class, var(--ck-token-decorator, #955f0b));
    font-weight: 600;
}

.post-content .no, .post-content .nt {
    color: var(--ck-token-class, #955f0b);
}

/* Builtins and pseudo-locals */
.post-content .nb, .post-content .bp {
    color: var(--ck-token-builtin, #8e52a7);
}

/* Names, operators, punctuation: keep body color for readability */
.post-content .n, .post-content .nx, .post-content .na,
.post-content .nn, .post-content .o, .post-content .p,
.post-content .w {
    color: var(--ck-token-operator, var(--text-primary));
}

/* Generic diff-ish tokens */
.post-content .gi {
    color: var(--color-success, #1b7a43);
}

.post-content .gd {
    color: var(--color-error, #bd3e31);
}

.post-content .err {
    color: var(--ck-token-error, #bd3e31);
    border-bottom: none;
}