/*!
 * Copyright (c) 2024-2026 STMicroelectronics.
 * All rights reserved.
 * This software is licensed under terms that can be found in the LICENSE file
 * in the root directory of this software component.
 * If no LICENSE file comes with this software, it is provided AS-IS.
 * SPDX-License-Identifier: SLA0044
 */
/**
 * STMicroelectronics Pygments Syntax Highlighting Overrides
 *
 * Purpose:
 * --------
 * This file provides minimal overrides to Pygments' GitHub Light/Dark Default styles
 * for better visual presentation in STMicroelectronics documentation.
 *
 * Override 1: Preprocessor Directives (Tokenization Tradeoff)
 * -----------------------------------------------------------
 * Pygments' C lexer tokenizes entire preprocessor lines as a single Comment.Preproc (.cp) token.
 * For example: `#define GPIO_PIN_SET 1` becomes one token.
 *
 * On GitHub.com, TextMate grammars enable more granular tokenization:
 *   - `#define` keyword: RED
 *   - `GPIO_PIN_SET` macro name: BLUE
 *   - `1` value: BLACK
 *
 * Pygments cannot split preprocessor lines into separate tokens like TextMate grammars do.
 *
 * Deliberate Choice:
 * We override the entire preprocessor line to BLUE (instead of the default RED) to emphasize
 * the macro name, which is typically the most important element. This means `#define` and
 * numeric values also appear in blue instead of matching GitHub.com's per-token colors.
 *
 * This tradeoff prioritizes making macro definitions visually prominent and distinct from
 * other code elements while working within Pygments' tokenization constraints.
 *
 * Override 2: Code Block Background in Light Theme
 * --------------------------------------------
 * Problem:
 *   In dark theme, code blocks have a distinct background color.
 *   In light theme, they blend with the page background.
 *
 * Solution:
 *   Add a subtle background color (#f6f8fa, GitHub's standard) to code blocks in light theme
 *   for better visual distinction between code and regular text.
 */


/* Override preprocessor directive color to emphasize macro names */
.highlight .cp {
    color: var(--syntax-light-name-constant) !important;  /* Blue instead of red */
}

html.dark .highlight .cp,
html.light .dark-code .highlight .cp {
    color: var(--syntax-dark-name-constant) !important;
}

/* Add subtle background to code blocks in light theme for better distinction
   Uses --color-code-bg from custom.css (#f0f0f0) for better visibility than GitHub's #f6f8fa */

html.light .highlight,
html.light pre.literal-block {
    background-color: var(--color-code-bg);
}

/* Ensure dark theme keeps its existing background */
html.dark .highlight,
html.dark pre.literal-block {
    background-color: var(--code-block-background);
}

/* Also apply to code blocks within tables (for consistency) */
html.light .yue .table-wrapper td .highlight {
    background-color: var(--color-code-bg);
}
