/*
 * Argparse/CLI Highlighting Styles
 *
 * Styles for CLI inline roles and argparse help output highlighting.
 * Two parallel palettes are exposed via custom properties:
 *
 *   - Light mode (default)  : CodeMirror light palette (Microviz / social-embed).
 *   - Dark mode (overrides) : "One Dark" inspired palette (the historic
 *                             Python 3.14 argparse style).
 *
 * Dark overrides follow Furo's scoping convention: applied under
 * `body[data-theme="dark"]` and inside
 * `@media (prefers-color-scheme: dark) { body:not([data-theme="light"]) … }`,
 * so theme switches and the OS-level "auto" mode both Just Work.
 *
 * Token role -> Custom property:
 *   Code background       --gp-sphinx-argparse-code-bg
 *   Default text          --gp-sphinx-argparse-text
 *   Usage label           --gp-sphinx-argparse-usage-label   (bold)
 *   Section heading       --gp-sphinx-argparse-section       (bold)
 *   Program / command lbl --gp-sphinx-argparse-command       (bold)
 *   Subcommand            --gp-sphinx-argparse-subcommand    (bold)
 *   Choice value          --gp-sphinx-argparse-choice
 *   Option flag (-h, --x) --gp-sphinx-argparse-option
 *   Metavar (FILE, PATH)  --gp-sphinx-argparse-metavar       (italic)
 *   Default value         --gp-sphinx-argparse-default       (italic)
 *   Punctuation/operator  --gp-sphinx-argparse-punctuation
 *   Meta tag bg / border  --gp-sphinx-argparse-meta-tag-bg / --…-meta-tag-border
 */

/* ==========================================================================
   Palette — light mode defaults
   ========================================================================== */

:root {
	--gp-sphinx-argparse-code-bg: #f1f5f9;
	--gp-sphinx-argparse-text: #0f172a;
	--gp-sphinx-argparse-usage-label: #3b82f6;
	--gp-sphinx-argparse-section: #0f172a;
	--gp-sphinx-argparse-command: #7c3aed;
	--gp-sphinx-argparse-subcommand: #16a34a;
	--gp-sphinx-argparse-choice: #16a34a;
	--gp-sphinx-argparse-option: #a855f7;
	--gp-sphinx-argparse-metavar: #ca8a04;
	--gp-sphinx-argparse-default: #64748b;
	--gp-sphinx-argparse-punctuation: #64748b;
	--gp-sphinx-argparse-meta-tag-bg: #fef3c780;
	--gp-sphinx-argparse-meta-tag-border: #fcd34d80;
	/*
	 * Back-compat alias: pre.argparse-usage and .argparse-meta-value .nv
	 * still reference --argparse-code-background in templates and snapshots.
	 */
	--argparse-code-background: var(--gp-sphinx-argparse-code-bg);
}

/* ==========================================================================
   Palette — dark mode overrides (One Dark)
   ========================================================================== */

body[data-theme="dark"] {
	--gp-sphinx-argparse-code-bg: #272822;
	--gp-sphinx-argparse-text: #ccced4;
	--gp-sphinx-argparse-usage-label: #61afef;
	--gp-sphinx-argparse-section: #e5e5e5;
	--gp-sphinx-argparse-command: #c678dd;
	--gp-sphinx-argparse-subcommand: #98c379;
	--gp-sphinx-argparse-choice: #98c379;
	--gp-sphinx-argparse-option: #56b6c2;
	--gp-sphinx-argparse-metavar: #e5c07b;
	--gp-sphinx-argparse-default: #ccced4;
	--gp-sphinx-argparse-punctuation: #ccced4;
	--gp-sphinx-argparse-meta-tag-bg: #78350f60;
	--gp-sphinx-argparse-meta-tag-border: #b4530980;
}

@media (prefers-color-scheme: dark) {
	body:not([data-theme="light"]) {
		--gp-sphinx-argparse-code-bg: #272822;
		--gp-sphinx-argparse-text: #ccced4;
		--gp-sphinx-argparse-usage-label: #61afef;
		--gp-sphinx-argparse-section: #e5e5e5;
		--gp-sphinx-argparse-command: #c678dd;
		--gp-sphinx-argparse-subcommand: #98c379;
		--gp-sphinx-argparse-choice: #98c379;
		--gp-sphinx-argparse-option: #56b6c2;
		--gp-sphinx-argparse-metavar: #e5c07b;
		--gp-sphinx-argparse-default: #ccced4;
		--gp-sphinx-argparse-punctuation: #ccced4;
		--gp-sphinx-argparse-meta-tag-bg: #78350f60;
		--gp-sphinx-argparse-meta-tag-border: #b4530980;
	}
}

/* ==========================================================================
   Inline Role Styles
   ========================================================================== */

/*
 * Shared monospace font and code font-size for all CLI inline roles
 */
.cli-option,
.cli-metavar,
.cli-command,
.cli-default,
.cli-choice {
	font-family: var(--font-stack--monospace);
	font-size: var(--code-font-size);
}

/* Long options (--verbose) and short options (-h) */
.cli-option-long,
.cli-option-short {
	color: var(--gp-sphinx-argparse-option);
}

/* Placeholder values like FILE, PATH, DIRECTORY */
.cli-metavar {
	color: var(--gp-sphinx-argparse-metavar);
	font-style: italic;
}

/* Subcommand names like sync, add, list */
.cli-command {
	color: var(--gp-sphinx-argparse-subcommand);
	font-weight: bold;
}

/* Enumeration values like json, yaml, table */
.cli-choice {
	color: var(--gp-sphinx-argparse-choice);
}

/* Default values shown in help text like None, "auto" */
.cli-default {
	color: var(--gp-sphinx-argparse-default);
	font-style: italic;
}

/* ==========================================================================
   Argparse Code Block Highlighting
   ========================================================================== */

/*
 * These styles apply within Pygments-highlighted code blocks using the
 * argparse, argparse-usage, or argparse-help lexers.
 */

/* Usage heading "usage:" */
.highlight-argparse .gh,
.highlight-argparse-usage .gh,
.highlight-argparse-help .gh {
	color: var(--gp-sphinx-argparse-usage-label);
	font-weight: bold;
}

/* Section headers like "positional arguments:", "options:" */
.highlight-argparse .gs,
.highlight-argparse-help .gs {
	color: var(--gp-sphinx-argparse-section);
	font-weight: bold;
}

/* Long options --foo */
.highlight-argparse .nt,
.highlight-argparse-usage .nt,
.highlight-argparse-help .nt {
	color: var(--gp-sphinx-argparse-option);
	font-weight: normal;
}

/* Short options -h */
.highlight-argparse .na,
.highlight-argparse-usage .na,
.highlight-argparse-help .na {
	color: var(--gp-sphinx-argparse-option);
	font-weight: normal;
}

/* Metavar placeholders FILE, PATH */
.highlight-argparse .nv,
.highlight-argparse-usage .nv,
.highlight-argparse-help .nv {
	color: var(--gp-sphinx-argparse-metavar);
	font-style: italic;
}

/* Command/program names */
.highlight-argparse .nl,
.highlight-argparse-usage .nl,
.highlight-argparse-help .nl {
	color: var(--gp-sphinx-argparse-command);
	font-weight: bold;
}

/* Subcommands */
.highlight-argparse .nf,
.highlight-argparse-usage .nf,
.highlight-argparse-help .nf {
	color: var(--gp-sphinx-argparse-subcommand);
	font-weight: bold;
}

/* Choice values */
.highlight-argparse .no,
.highlight-argparse-usage .no,
.highlight-argparse-help .no,
.highlight-argparse .nc,
.highlight-argparse-usage .nc,
.highlight-argparse-help .nc {
	color: var(--gp-sphinx-argparse-choice);
}

/* Punctuation [], {}, () */
.highlight-argparse .p,
.highlight-argparse-usage .p,
.highlight-argparse-help .p {
	color: var(--gp-sphinx-argparse-punctuation);
}

/* Operators like | */
.highlight-argparse .o,
.highlight-argparse-usage .o,
.highlight-argparse-help .o {
	color: var(--gp-sphinx-argparse-punctuation);
	font-weight: normal;
}

/* ==========================================================================
   Argparse Directive Highlighting (.. argparse:: output)
   ========================================================================== */

/*
 * These styles apply to the argparse directive output rendered by
 * sphinx_autodoc_argparse, which adds highlight spans directly to HTML.
 */

/* Usage block container */
pre.argparse-usage {
	background: var(--gp-sphinx-argparse-code-bg);
	font-size: var(--code-font-size);
	padding: 0.625rem 0.875rem;
	line-height: 1.5;
	border-radius: 0.2rem;
	scrollbar-color: var(--color-foreground-border) transparent;
	scrollbar-width: thin;
}

.argparse-usage .gh {
	color: var(--gp-sphinx-argparse-usage-label);
	font-weight: bold;
}

.argparse-usage .nt {
	color: var(--gp-sphinx-argparse-option);
	font-weight: normal;
}

.argparse-usage .na {
	color: var(--gp-sphinx-argparse-option);
	font-weight: normal;
}

.argparse-usage .nv {
	color: var(--gp-sphinx-argparse-metavar);
	font-style: italic;
}

.argparse-usage .nl {
	color: var(--gp-sphinx-argparse-command);
	font-weight: bold;
}

.argparse-usage .nf {
	color: var(--gp-sphinx-argparse-subcommand);
	font-weight: bold;
}

.argparse-usage .no,
.argparse-usage .nc {
	color: var(--gp-sphinx-argparse-choice);
}

.argparse-usage .o {
	color: var(--gp-sphinx-argparse-punctuation);
	font-weight: normal;
}

.argparse-usage .p {
	color: var(--gp-sphinx-argparse-punctuation);
}

/*
 * Argument Name (<dt class="argparse-argument-name">)
 *
 * The argument names in the dl/dt structure are highlighted with
 * semantic spans for options and metavars.
 */
.argparse-argument-name .nt {
	color: var(--gp-sphinx-argparse-option);
	font-weight: normal;
}

.argparse-argument-name .na {
	color: var(--gp-sphinx-argparse-option);
	font-weight: normal;
}

.argparse-argument-name .nv {
	color: var(--gp-sphinx-argparse-metavar);
	font-style: italic;
}

.argparse-argument-name .nl {
	color: var(--gp-sphinx-argparse-command);
	font-weight: bold;
}

/* ==========================================================================
   Argument Wrapper and Linking Styles
   ========================================================================== */

/*
 * Background styling for argument names — subtle background like code.literal
 * to provide visual weight and hierarchy for argument definitions.
 */
.argparse-argument-name {
	background: var(--gp-sphinx-argparse-code-bg);
	border-radius: 0.2rem;
	padding: 0.485rem 0.875rem;
	font-family: var(--font-stack--monospace);
	font-size: var(--code-font-size);
	width: fit-content;
	position: relative;
}

/*
 * Wrapper for linking — enables scroll-margin for fixed header navigation
 * and :target pseudo-class for highlighting when linked.
 */
.argparse-argument-wrapper {
	scroll-margin-top: 2.5rem;
}

/*
 * Headerlink anchor (¶) — hidden until hover, positioned outside the dt to
 * the right. Follows Sphinx's documented convention for linkable headings.
 */
.argparse-argument-name .headerlink {
	visibility: hidden;
	position: absolute;
	right: -1.5rem;
	top: 50%;
	transform: translateY(-50%);
	color: var(--color-foreground-secondary);
	text-decoration: none;
}

/* Show headerlink on hover or when targeted via URL fragment */
.argparse-argument-wrapper:hover .headerlink,
.argparse-argument-wrapper:target .headerlink {
	visibility: visible;
}

.argparse-argument-name .headerlink:hover:not(:visited) {
	color: var(--color-foreground-primary);
}

/*
 * Highlight when targeted via URL fragment.
 * Uses Furo's highlight-on-target color for consistency.
 */
.argparse-argument-wrapper:target .argparse-argument-name {
	background-color: var(--color-highlight-on-target);
}

/*
 * Argument metadata definition list — renders metadata
 * (Default, Type, Choices, Required) as a horizontal flexbox of key-value
 * pairs and standalone tags.
 */
.argparse-argument-meta {
	margin: 0.5rem 0 0 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1rem;
	align-items: center;
}

.argparse-meta-item {
	display: flex;
	align-items: center;
	gap: 0.25rem;
}

.argparse-meta-key {
	color: var(--color-foreground-secondary, #6c757d);
	font-size: var(--code-font-size);
}

.argparse-meta-key::after {
	content: ":";
}

.argparse-meta-value .nv {
	background: var(--gp-sphinx-argparse-code-bg);
	border-radius: 0.2rem;
	padding: 0.1rem 0.3rem;
	font-family: var(--font-stack--monospace);
	font-size: var(--code-font-size);
	color: var(--gp-sphinx-argparse-metavar);
}

/*
 * Meta tag (e.g., "Required") — follows Furo's guilabel pattern.
 * Semi-transparent amber conveys "needs attention" without harshness.
 */
.argparse-meta-tag {
	background-color: var(--gp-sphinx-argparse-meta-tag-bg);
	border: 1px solid var(--gp-sphinx-argparse-meta-tag-border);
	color: var(--color-foreground-primary);
	font-size: var(--code-font-size);
	padding: 0.1rem 0.4rem;
	border-radius: 0.2rem;
	font-weight: 500;
}

/*
 * Help text description — adds spacing above for visual separation from
 * the argument name.
 */
.argparse-argument-help {
	padding-block-start: 0.5rem;
}
