/* Theme Extensions - Code Highlighting and Advanced Features
 * Contains syntax highlighting and advanced styling features
 */

/* ==== High-contrast code palette (override safely) ==== */
:root {
    /* tweak these with your site colors */
    --code-fg: #f8f8f2;
    --code-bg: #1f1f24; /* a hair lighter than #1e1e1e for separation */
    --code-border: #3d3d46;

    /* token colors (no "navy") */
    --code-kw: #ff79c6; /* keywords */
    --code-str: #f1fa8c; /* strings */
    --code-com: #8aa0c4; /* comments (brighter than #6272a4) */
    --code-num: #bd93f9; /* numbers/literals */
    --code-type: #8be9fd; /* class/type names */
    --code-fn: #50fa7b; /* function names */
    --code-meta: #ffb86c; /* annotations/@meta */
    --code-var: #e6e6e6; /* variables/identifiers */
    --gutter: 20px;
}

/* Source code highlighting - basic overrides */
.hljs {
    background-color: var(--code-bg-color) !important;
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Consolas', monospace !important;
}

/* Override any specific syntax highlighting themes */
.hljs, .hljs-subst {
    color: var(--code-text-color) !important;
}

/* Java-specific syntax highlighting fixes */
.hljs-annotation,
.hljs-meta {
    color: #ffb86c !important; /* Orange for annotations like @Override */
}

.hljs-keyword {
    color: #ff79c6 !important; /* Pink for keywords */
}

.hljs-string {
    color: #f1fa8c !important; /* Yellow for strings */
}

.hljs-comment {
    color: #6272a4 !important; /* Blue-gray for comments */
    font-style: italic;
}

.hljs-number {
    color: #bd93f9 !important; /* Purple for numbers */
}

.hljs-class .hljs-title,
.hljs-type {
    color: #8be9fd !important; /* Cyan for class names and types */
}

.hljs-function .hljs-title {
    color: #50fa7b !important; /* Green for function names */
}

.hljs-variable,
.hljs-name {
    color: #f8f8f2 !important; /* Light gray for variables */
}

.hljs-attr {
    color: #50fa7b !important; /* Green for attributes */
}

.hljs-symbol,
.hljs-bullet {
    color: #8be9fd !important; /* Cyan for symbols */
}

.hljs-built_in,
.hljs-builtin-name {
    color: #8be9fd !important; /* Cyan for built-ins */
}

.hljs-literal {
    color: #bd93f9 !important; /* Purple for literals */
}

.hljs-params {
    color: #ffb86c !important; /* Orange for parameters */
}

/* Generic syntax highlighting for non-hljs code */
.token.annotation,
.token.meta {
    color: #ffb86c !important;
}

.token.keyword {
    color: #ff79c6 !important;
}

.token.string {
    color: #f1fa8c !important;
}

.token.comment {
    color: #6272a4 !important;
    font-style: italic;
}

.token.number {
    color: #bd93f9 !important;
}

.token.class-name {
    color: #8be9fd !important;
}

.token.function {
    color: #50fa7b !important;
}

/* Callouts */
.conum[data-value] {
    background-color: rgba(80, 160, 250, 0.8) !important;
    color: #fff !important;
}

.conum[data-value] * {
    color: #fff !important;
}

/* Base code blocks */
pre,
.listingblock pre,
.literalblock pre,
.sourceblock pre,
pre code {
    background: var(--code-bg) !important;
    color: var(--code-fg) !important;
    border: 1px solid var(--code-border) !important;
    border-radius: 6px !important;
    overflow-x: auto;
}

/* Inline code */
code, tt {
    background: linear-gradient(
            to bottom,
            #9f77cd 0%,
            #7e64a7 100%
    ) !important;
    color: var(--code-fg) !important;
    border: 0;
    padding: 0.15em 0.4em !important;
    border-radius: 4px !important;
}

/* Inline code inside a quoteblock */
.quoteblock code,
.quoteblock .monospaced {
    background-color: #4b624b !important;
    padding: 0.15em 0.3em;
    border-radius: 3px;
}

/* ===== highlight.js ===== */
.hljs, .hljs-subst {
    color: var(--code-fg) !important;
    background: var(--code-bg) !important;
}

.hljs-keyword {
    color: var(--code-kw) !important;
}

.hljs-string {
    color: var(--code-str) !important;
}

.hljs-number, .hljs-literal {
    color: var(--code-num) !important;
}

.hljs-type, .hljs-class .hljs-title {
    color: var(--code-type) !important;
}

.hljs-function .hljs-title {
    color: var(--code-fn) !important;
}

.hljs-attr, .hljs-params {
    color: var(--code-meta) !important;
}

.hljs-comment, .hljs-quote {
    color: var(--code-com) !important;
    font-style: italic;
}

.hljs-variable, .hljs-name {
    color: var(--code-var) !important;
}

/* ===== Prism ===== */
.token.keyword {
    color: var(--code-kw) !important;
}

.token.string {
    color: var(--code-str) !important;
}

.token.number,
.token.boolean {
    color: var(--code-num) !important;
}

.token.class-name,
.token.type {
    color: var(--code-type) !important;
}

.token.function {
    color: var(--code-fn) !important;
}

.token.atrule,
.token.attr-name,
.token.attr-value {
    color: var(--code-meta) !important;
}

.token.comment {
    color: var(--code-com) !important;
    font-style: italic;
}

.token.variable {
    color: var(--code-var) !important;
}

/* ===== Rouge (default Asciidoctor HTML) ===== */
.rouge pre, pre.rouge {
    background: var(--code-bg) !important;
    color: var(--code-fg) !important;
}

.rouge .k, .rouge .kd, .rouge .kn, .rouge .kr {
    color: var(--code-kw) !important;
}

/* keywords */
.rouge .s, .rouge .sb, .rouge .sc, .rouge .s1,
.rouge .s2, .rouge .sh, .rouge .si, .rouge .sx {
    color: var(--code-str) !important;
}

/* strings */
.rouge .c, .rouge .c1, .rouge .cm, .rouge .cp {
    color: var(--code-com) !important;
    font-style: italic;
}

/* comments */
.rouge .mi, .rouge .mf, .rouge .mh, .rouge .il {
    color: var(--code-num) !important;
}

/* numbers */
.rouge .nc, .rouge .nn, .rouge .no, .rogue .nl {
    color: var(--code-type) !important;
}

/* classes/types */
.rouge .nf {
    color: var(--code-fn) !important;
}

/* functions */
.rouge .na, .rouge .nv, .rouge .vc, .rouge .vg {
    color: var(--code-var) !important;
}

/* variables */
.rouge .nd, .rouge .ne, .rouge .nt {
    color: var(--code-meta) !important;
}

/* meta/attrs */

/* ===== CodeRay (older setups) ===== */
.CodeRay {
    background: var(--code-bg) !important;
    color: var(--code-fg) !important;
}

.CodeRay .kw {
    color: var(--code-kw) !important;
}

.CodeRay .st {
    color: var(--code-str) !important;
}

.CodeRay .co {
    color: var(--code-com) !important;
    font-style: italic;
}

.CodeRay .i, .CodeRay .fl {
    color: var(--code-num) !important;
}

.CodeRay .dt, .CodeRay .ty {
    color: var(--code-type) !important;
}

.CodeRay .fu {
    color: var(--code-fn) !important;
}

.CodeRay .an, .CodeRay .re {
    color: var(--code-meta) !important;
}

.CodeRay .iv, .CodeRay .bk {
    color: var(--code-var) !important;
}

/* Ensure links inside code don't turn "navy" */
pre a, code a {
    color: #fafafa !important;
    text-decoration: underline;
}

/* ===== Operators & Punctuation (fix unreadable braces, = etc.) ===== */

/* highlight.js */
.hljs-operator,
.hljs-punctuation {
    color: var(--code-fg) !important; /* same as base text, but enforced */
    font-weight: 500;
}

/* Prism */
.token.operator,
.token.punctuation {
    color: var(--code-fg) !important;
}

/* Rouge */
.rouge .o, /* operators */
.rouge .p /* punctuation */
{
    color: var(--code-fg) !important;
    font-weight: 500;
}

/* CodeRay */
.CodeRay .op,
.CodeRay .dl, /* delimiters */
.CodeRay .sy /* symbols */
{
    color: var(--code-fg) !important;
    font-weight: 500;
}

/* ===== highlight.js / Prism / Rouge / CodeRay token mapping ===== */

/* Keywords, annotations */
.hljs-keyword,
.token.keyword,
.rouge .k,
.CodeRay .kw {
    color: var(--code-color1) !important; /* purple */
}

/* Strings */
.hljs-string,
.token.string,
.rouge .s,
.CodeRay .st {
    color: var(--code-color2) !important; /* green */
}

/* Comments */
.hljs-comment,
.token.comment,
.rouge .c,
.CodeRay .co {
    color: var(--code-color3) !important; /* blue-gray */
    font-style: italic;
}

/* Numbers, constants, literals */
.hljs-number,
.hljs-literal,
.token.number,
.token.boolean,
.rouge .mi,
.rouge .il,
.CodeRay .i,
.CodeRay .fl {
    color: var(--code-color4) !important; /* amber */
}

/* Function names, class names, important identifiers */
.hljs-function .hljs-title,
.token.function,
.rouge .nf,
.CodeRay .fu {
    color: var(--code-color2) !important; /* green (match strings) */
    font-weight: 500;
}

.hljs-type,
.hljs-class .hljs-title,
.token.class-name,
.rouge .nc,
.CodeRay .ty {
    color: var(--code-color1) !important; /* purple */
    font-weight: 500;
}

/* Rouge keyword variants */
.rouge .k, /* general keywords */
.rouge .kd, /* declaration keywords: class, var */
.rouge .kr, /* reserved keywords: return, public */
.rouge .kt { /* type keywords */
    color: #9f77cd !important; /* purple */
    font-weight: 500;
}

/* right gutter for readability */
#content {
    padding-right: calc(1.5rem + var(--gutter));
}

.listingblock,
    /*.literalblock { margin-right: var(--gutter); }*/

    /* outer panel */
.listingblock,
.literalblock {
    background: linear-gradient(
            135deg,
            #131313 0%,
            #181621 40%,
            #161c22 100%
    ) !important;
    border: 1px solid #2a2a2a !important;
    border-radius: 8px;
    padding: 0.75rem; /* space around code */
}

/* remove inner frame to kill the double border */
.listingblock > .content,
.literalblock > .content {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* code itself */
.listingblock pre,
.literalblock pre,
pre.highlight {
    background: #161413 !important;
    border: 0 !important; /* inner border gone */
    border-radius: 8px;
    padding: 1rem 1.25rem;
}

/* Remove the innermost "rim" on code samples (Spring adds an inset box-shadow) */
.doc .listingblock pre:not(.highlight),
.doc .literalblock pre,
.doc pre.highlight code {
    box-shadow: none !important; /* <- this is the culprit */
    border: 0 !important;
    outline: 0 !important;
}

/* Belt-and-suspenders: cover other highlighter wrappers too */
.highlight, .highlight pre, .highlight code,
.highlighter-rouge pre, .highlighter-rouge code,
.rouge pre, .rouge code,
pre.highlight, pre.highlight code {
    box-shadow: none !important;
    border: 0 !important;
    outline: 0 !important;
}

/* Keep your desired colors */
.listingblock pre,
.literalblock pre,
pre.highlight,
pre.highlight code {
    background: #161413 !important; /* inner code bg */
    border-radius: 8px !important;
}


/*!* Use font icons, not images/labels *!*/
/*.admonitionblock .icon img { display: none !important; }*/
/*.admonitionblock .icon i.fa {*/
/*    font-family: "FontAwesome" !important;  !* FA v4 *!*/
/*    font-style: normal;*/
/*    font-size: 1.15em;*/
/*    line-height: 1;*/
/*    background: none !important;*/
/*    filter: none !important;*/
/*}*/
/*.admonitionblock .icon i.fa::after { content: none !important; } !* kill "Tip" label overlays *!*/

/*!* Tidy the icon cell + overall block *!*/
/*.admonitionblock > table {*/
/*    background: #131313;                    !* outer panel to match site *!*/
/*    border: 1px solid #2a2a2a;*/
/*    border-radius: 10px;*/
/*}*/
/*.admonitionblock > table td.icon {*/
/*    width: 2.5rem;*/
/*    text-align: center;*/
/*    vertical-align: top;*/
/*    padding: .9rem .5rem .5rem .9rem;*/
/*    background: transparent !important;*/
/*    border: 0 !important;*/
/*}*/

/*!* Colors per type *!*/
/*.admonitionblock.tip .icon .fa       { color: #3fd73c; }  !* your green *!*/
/*.admonitionblock.note .icon .fa      { color: #9f77cd; }  !* your purple *!*/
/*.admonitionblock.important .icon .fa { color: #e9b306; }  !* amber *!*/
/*.admonitionblock.warning .icon .fa   { color: #ef4444; }  !* red *!*/
/*.admonitionblock.caution .icon .fa   { color: #ef4444; }  !* red *!*/

/*!* Content cell text color stays readable *!*/
/*.admonitionblock > table td.content {*/
/*    color: #e8e8e8;*/
/*    border-left: 1px solid #2a2a2a;*/
/*    padding: 1rem 1.25rem;*/
/*    background: transparent;*/
/*}*/

/* 1) Make sure ALL code has a readable default color on dark bg */
.listingblock pre,
.listingblock pre > code,
.literalblock pre,
.literalblock pre > code,
pre.highlight,
pre.rouge,
pre.highlight > code,
pre.rouge > code,
.highlight code {
    color: var(--code-text-color) !important;
}

/* 2) Booleans / null across Rouge class variants + add specificity */
.listingblock pre .kc, /* Keyword.Constant (often true/false/null) */
.listingblock pre .no, /* Name.Constant (some lexers) */
.listingblock pre .l, /* Literal (fallback in a few lexers) */
.listingblock pre .l-Keyword, /* Some Rouge themes emit subtypes */
pre.highlight .kc,
pre.highlight .no,
pre.highlight .l,
pre.rouge .kc,
pre.rouge .no,
pre.rouge .l {
    color: var(--code-color5) !important;
}

pre.rouge .nl {
    color: var(--code-type) !important;
    font-weight: bold;
}

colist td {
    padding: .25em 0;
    color: #fafafa;
}

.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow: none;cursor:default}
.admonitionblock td.icon .icon-warning::before{content:"\f071";color:#e44d26}

.tableblock td:nth-child(1) {
    max-width: 25%;
    word-break: break-word;
    white-space: pre-wrap;
}

pre code a {
    color: #ffffff;   /* your desired link color */
    text-decoration: underline; /* optional */
}