/* Custom "ccode" theme - light mode based on Rust, dark mode inspired by Dark Reader. */

.ccode {
    --bg: hsl(60, 9%, 87%);
    --fg: #262625;

    --sidebar-bg: #3b2e2a;
    --sidebar-fg: #c8c9db;
    --sidebar-non-existant: #505254;
    --sidebar-active: #e69f67;
    --sidebar-spacer: #45373a;

    --scrollbar: var(--sidebar-fg);

    --icons: #737480;
    --icons-hover: #262625;

    --links: #d77655;

    --inline-code-color: #6e6b5e;

    --theme-popup-bg: #e1e1db;
    --theme-popup-border: #b38f6b;
    --theme-hover: #99908a;

    --quote-bg: hsl(60, 5%, 75%);
    --quote-border: hsl(60, 5%, 70%);

    --warning-border: #ff8e00;

    --table-border-color: hsl(60, 9%, 82%);
    --table-header-bg: #b3a497;
    --table-alternate-bg: hsl(60, 9%, 84%);

    --searchbar-border-color: #aaa;
    --searchbar-bg: #fafafa;
    --searchbar-fg: #000;
    --searchbar-shadow-color: #aaa;
    --searchresults-header-fg: #666;
    --searchresults-border-color: #888;
    --searchresults-li-bg: #dec2a2;
    --search-mark-bg: #e69f67;

    /* Same as --icons */
    --copy-button-filter: invert(51%) sepia(10%) saturate(393%)
        hue-rotate(198deg) brightness(86%) contrast(87%);
    /* Same as --sidebar-active */
    --copy-button-filter-hover: invert(77%) sepia(16%) saturate(1798%)
        hue-rotate(328deg) brightness(98%) contrast(83%);

    --footnote-highlight: #d3a17a;

    --overlay-bg: rgba(150, 150, 150, 0.25);

    --blockquote-note-color: #023b95;
    --blockquote-tip-color: #007700;
    --blockquote-important-color: #8250df;
    --blockquote-warning-color: #603700;
    --blockquote-caution-color: #aa1721;

    --sidebar-header-border-color: #8c391f;
}

@media (prefers-color-scheme: dark) {
    .ccode {
        --bg: #2b2e30;
        --fg: #e8e6e3;

        /* Keep the warm Rust sidebar */
        --sidebar-bg: #3b2e2a;
        --sidebar-fg: #c8c9db;
        --sidebar-non-existant: #505254;
        --sidebar-active: #d77655;
        --sidebar-spacer: #45373a;

        --scrollbar: var(--sidebar-fg);

        --icons: #8a8e92;
        --icons-hover: #e8e6e3;

        --links: #d77655;

        --inline-code-color: #e8e6e3;

        --theme-popup-bg: #1d1f20;
        --theme-popup-border: #4a4f52;
        --theme-hover: #3c4144;

        --quote-bg: #3c4144;
        --quote-border: #4a4f52;

        --warning-border: #ff8e00;

        --table-border-color: #3c4144;
        --table-header-bg: #3c4144;
        --table-alternate-bg: #323538;

        --searchbar-border-color: #4a4f52;
        --searchbar-bg: #3c4144;
        --searchbar-fg: #e8e6e3;
        --searchbar-shadow-color: rgba(0, 0, 0, 0.3);
        --searchresults-header-fg: #b1aba0;
        --searchresults-border-color: #4a4f52;
        --searchresults-li-bg: #3c4144;
        --search-mark-bg: #e69f67;

        --color-scheme: dark;

        /* Matches --icons (#8a8e92) */
        --copy-button-filter: invert(60%) sepia(5%) saturate(300%)
            hue-rotate(170deg) brightness(90%) contrast(90%);
        /* Matches --sidebar-active (#e69f67) */
        --copy-button-filter-hover: invert(77%) sepia(16%) saturate(1798%)
            hue-rotate(328deg) brightness(98%) contrast(83%);

        --footnote-highlight: #5cacda;

        --overlay-bg: rgba(0, 0, 0, 0.4);

        --blockquote-note-color: #4493f8;
        --blockquote-tip-color: #08ae08;
        --blockquote-important-color: #ab7df8;
        --blockquote-warning-color: #d29922;
        --blockquote-caution-color: #d91b29;

        --sidebar-header-border-color: #8c391f;
    }

    /* Dark code blocks */
    .ccode code {
        color: #e8e6e3;
    }
    .ccode pre {
        background-color: #1d1f20;
    }
    .ccode pre > .buttons {
        background-color: #1d1f20;
    }

    /* Dark syntax highlighting (overrides highlight.js light theme) */
    .ccode .hljs {
        background: #1d1f20;
        color: #e8e6e3;
    }
    .ccode .hljs-comment,
    .ccode .hljs-quote {
        color: #b1aba0;
    }
    .ccode .hljs-keyword,
    .ccode .hljs-selector-tag,
    .ccode .hljs-type {
        color: #cc99cd;
    }
    .ccode .hljs-string,
    .ccode .hljs-addition {
        color: #7ec699;
    }
    .ccode .hljs-number,
    .ccode .hljs-literal,
    .ccode .hljs-selector-id,
    .ccode .hljs-selector-class {
        color: #f08d49;
    }
    .ccode .hljs-built_in,
    .ccode .hljs-title,
    .ccode .hljs-name,
    .ccode .hljs-section {
        color: #6cb6ff;
    }
    .ccode .hljs-attr,
    .ccode .hljs-attribute {
        color: #f08d49;
    }
    .ccode .hljs-variable,
    .ccode .hljs-template-variable {
        color: #f08d49;
    }
    .ccode .hljs-symbol,
    .ccode .hljs-bullet {
        color: #cc99cd;
    }
    .ccode .hljs-deletion {
        color: #e05252;
    }
    .ccode .hljs-meta {
        color: #b1aba0;
    }
    .ccode .hljs-emphasis {
        font-style: italic;
    }
    .ccode .hljs-strong {
        font-weight: bold;
    }
}
