/*
 * Syntax Highlighting - "Compiler Craft" Theme
 *
 * NOTE: This book uses ONLY the Rust theme. All highlighting is optimized for
 * the warm cream background of the Rust theme.
 *
 * Color Palette Philosophy:
 * - Built on warm/cool contrast for visual interest and readability
 * - Warm tones (oranges, golds): literals, numbers, strings
 * - Cool tones (blues, purples): keywords, functions, types
 * - Neutral: comments, punctuation, parameters
 *
 * Contrast ratios meet WCAG AA standards for readability
 */

/* Base code block styling - Rust theme (warm cream) */
pre code.hljs,
pre>code {
    display: block;
    overflow-x: auto;
    padding: 1.2em 1.4em;
    background: #faf8f5;
    color: #3c3836;
    font-size: 0.95rem;
    line-height: 1.65;
}

pre .hljs,
.hljs {
    background: #faf8f5;
    color: #3c3836;
    font-size: 0.95rem;
    line-height: 1.65;
}

/* Ensure inline code stays inline */
:not(pre)>code {
    display: inline !important;
    padding: 0.2em 0.5em !important;
    background: inherit;
    overflow-x: visible;
}

/* Comments - warm gray */
.hljs-comment,
.hljs-quote {
    color: #928374;
    font-style: italic;
}

/* Keywords - deep purple (maintains contrast on cream bg) */
.hljs-keyword,
.hljs-selector-tag {
    color: #8839ef;
    font-weight: 500;
}

/* Types and classes - rich amber (warm, readable on cream) */
.hljs-type,
.hljs-class .hljs-title,
.hljs-title.class_,
.hljs-built_in {
    color: #b45309;
}

/* Functions - deep blue (cool contrast) */
.hljs-function .hljs-title,
.hljs-title.function_,
.hljs-attr {
    color: #2563eb;
}

/* Strings - forest green (natural, readable) */
.hljs-string,
.hljs-doctag,
.hljs-regexp,
.hljs-template-variable,
.hljs-template-tag {
    color: #166534;
}

/* Numbers - rust orange (brand consistency) */
.hljs-number,
.hljs-literal,
.hljs-bullet {
    color: #c45b29;
}

/* Variables - darker cyan for light bg */
.hljs-variable {
    color: #0e7490;
}

/* Symbols and atoms - teal */
.hljs-symbol,
.hljs-selector-id,
.hljs-selector-class,
.hljs-selector-attr,
.hljs-selector-pseudo {
    color: #0891b2;
}

/* Meta and preprocessor - rust brand orange */
.hljs-meta,
.hljs-meta .hljs-keyword,
.hljs-meta .hljs-string {
    color: #c45b29;
}

/* Attributes - soft purple */
.hljs-attribute {
    color: #7c3aed;
}

/* Section headers and tags - coral red */
.hljs-section,
.hljs-name,
.hljs-tag {
    color: #dc2626;
}

/* Params - neutral, blends with base text */
.hljs-params {
    color: #3c3836;
}

/* Deletion - clear red signal */
.hljs-deletion {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

/* Addition - clear green signal */
.hljs-addition {
    color: #166534;
    background: rgba(22, 101, 52, 0.1);
}

/* Emphasis and strong */
.hljs-emphasis {
    font-style: italic;
}

.hljs-strong {
    font-weight: bold;
}

/* Links - consistent with UI links */
.hljs-link {
    color: #60a5fa;
    text-decoration: underline;
}

/* ========================================
   LANGUAGE-SPECIFIC OVERRIDES
   ======================================== */

/* Rust-specific styling */
.language-rust .hljs-keyword {
    color: #c084fc;
}

.language-rust .hljs-title.function_ {
    color: #60a5fa;
}

.language-rust .hljs-type,
.language-rust .hljs-built_in {
    color: #fbbf24;
}

/* Rust macros - brand orange */
.language-rust .hljs-meta {
    color: #c45b29;
}

/* Bash/Shell styling */
.language-bash .hljs-keyword,
.language-shell .hljs-keyword {
    color: #c084fc;
}

.language-bash .hljs-built_in,
.language-shell .hljs-built_in {
    color: #60a5fa;
}

.language-bash .hljs-variable,
.language-shell .hljs-variable {
    color: #0e7490;
}

/* TOML styling */
.language-toml .hljs-section {
    color: #60a5fa;
}

.language-toml .hljs-attr {
    color: #fbbf24;
}

/* Pest grammar styling */
.language-pest .hljs-keyword {
    color: #c084fc;
}

/* Assembly styling */
.language-asm .hljs-keyword,
.language-x86asm .hljs-keyword {
    color: #c084fc;
}

.language-asm .hljs-built_in,
.language-x86asm .hljs-built_in {
    color: #60a5fa;
}

/* ========================================
   CODE BLOCK ENHANCEMENTS
   ======================================== */

/* Line numbers styling (if enabled) */
.hljs-ln-numbers {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    text-align: center;
    color: #928374;
    border-right: 1px solid #e5ddd2;
    vertical-align: top;
    padding-right: 10px !important;
}

.hljs-ln-code {
    padding-left: 10px !important;
}

/* Selection styling in code blocks */
.hljs ::selection,
.hljs::selection {
    background: rgba(196, 91, 41, 0.3);
}

.hljs ::-moz-selection,
.hljs::-moz-selection {
    background: rgba(196, 91, 41, 0.3);
}
