/*
 * Argparse/CLI Highlighting Styles
 *
 * Styles for CLI inline roles and argparse help output highlighting.
 * Uses "One Dark" inspired color palette (Python 3.14 argparse style).
 *
 * Color Palette:
 *   Background:    #282C34
 *   Default text:  #CCCED4
 *   Usage label:   #61AFEF (blue, bold)
 *   Program name:  #C678DD (purple, bold)
 *   Subcommands:   #98C379 (green)
 *   Options:       #56B6C2 (teal)
 *   Metavars:      #E5C07B (yellow, italic)
 *   Choices:       #98C379 (green)
 *   Headings:      #E5E5E5 (bright, bold)
 *   Punctuation:   #CCCED4
 */

/* ==========================================================================
   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);
}

/*
 * CLI Options
 *
 * Long options (--verbose) and short options (-h) both use teal color.
 */
.cli-option-long,
.cli-option-short {
	color: #56b6c2;
}

/*
 * CLI Metavars
 *
 * Placeholder values like FILE, PATH, DIRECTORY.
 * Yellow/amber to indicate "replace me" - distinct from flags (teal).
 */
.cli-metavar {
	color: #e5c07b;
	font-style: italic;
}

/*
 * CLI Commands and Choices
 *
 * Both use green to indicate valid enumerated values.
 * Commands: subcommand names like sync, add, list
 * Choices: enumeration values like json, yaml, table
 */
.cli-command,
.cli-choice {
	color: #98c379;
}

.cli-command {
	font-weight: bold;
}

/*
 * CLI Default Values
 *
 * Default values shown in help text like None, "auto".
 * Subtle styling to not distract from options.
 */
.cli-default {
	color: #ccced4;
	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:" - bold blue */
.highlight-argparse .gh,
.highlight-argparse-usage .gh,
.highlight-argparse-help .gh {
	color: #61afef;
	font-weight: bold;
}

/* Section headers like "positional arguments:", "options:" - neutral bright */
.highlight-argparse .gs,
.highlight-argparse-help .gs {
	color: #e5e5e5;
	font-weight: bold;
}

/* Long options --foo - teal */
.highlight-argparse .nt,
.highlight-argparse-usage .nt,
.highlight-argparse-help .nt {
	color: #56b6c2;
	font-weight: normal;
}

/* Short options -h - teal (same as long) */
.highlight-argparse .na,
.highlight-argparse-usage .na,
.highlight-argparse-help .na {
	color: #56b6c2;
	font-weight: normal;
}

/* Metavar placeholders FILE, PATH - yellow/amber italic */
.highlight-argparse .nv,
.highlight-argparse-usage .nv,
.highlight-argparse-help .nv {
	color: #e5c07b;
	font-style: italic;
}

/* Command/program names - purple bold */
.highlight-argparse .nl,
.highlight-argparse-usage .nl,
.highlight-argparse-help .nl {
	color: #c678dd;
	font-weight: bold;
}

/* Subcommands - bold green */
.highlight-argparse .nf,
.highlight-argparse-usage .nf,
.highlight-argparse-help .nf {
	color: #98c379;
	font-weight: bold;
}

/* Choice values - green */
.highlight-argparse .no,
.highlight-argparse-usage .no,
.highlight-argparse-help .no,
.highlight-argparse .nc,
.highlight-argparse-usage .nc,
.highlight-argparse-help .nc {
	color: #98c379;
}

/* Punctuation [], {}, () - neutral gray */
.highlight-argparse .p,
.highlight-argparse-usage .p,
.highlight-argparse-help .p {
	color: #ccced4;
}

/* Operators like | - neutral gray */
.highlight-argparse .o,
.highlight-argparse-usage .o,
.highlight-argparse-help .o {
	color: #ccced4;
	font-weight: normal;
}

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

/*
 * These styles apply to the argparse directive output which uses custom
 * nodes rendered by sphinx_argparse_neo. The directive adds highlight spans
 * directly to the HTML output.
 */

/*
 * Usage Block (.argparse-usage)
 *
 * The usage block now has both .argparse-usage and .highlight-argparse-usage
 * classes. The .highlight-argparse-usage selectors above already handle the
 * token highlighting. These selectors provide fallback and ensure consistent
 * styling.
 */

/* Usage block container - match Pygments monokai background and code block styling */
pre.argparse-usage {
	background: var(--argparse-code-background);
	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: #61afef;
	font-weight: bold;
}

.argparse-usage .nt {
	color: #56b6c2;
	font-weight: normal;
}

.argparse-usage .na {
	color: #56b6c2;
	font-weight: normal;
}

.argparse-usage .nv {
	color: #e5c07b;
	font-style: italic;
}

.argparse-usage .nl {
	color: #c678dd;
	font-weight: bold;
}

.argparse-usage .nf {
	color: #98c379;
	font-weight: bold;
}

.argparse-usage .no,
.argparse-usage .nc {
	color: #98c379;
}

.argparse-usage .o {
	color: #ccced4;
	font-weight: normal;
}

.argparse-usage .p {
	color: #ccced4;
}

/*
 * 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: #56b6c2;
	font-weight: normal;
}

.argparse-argument-name .na {
	color: #56b6c2;
	font-weight: normal;
}

.argparse-argument-name .nv {
	color: #e5c07b;
	font-style: italic;
}

.argparse-argument-name .nl {
	color: #c678dd;
	font-weight: bold;
}

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

/*
 * Argparse-specific code background (monokai #272822)
 * Uses a custom variable to avoid affecting Furo's --color-inline-code-background.
 */
:root {
	--argparse-code-background: #272822;
}

/*
 * Background styling for argument names - subtle background like code.literal
 * This provides visual weight and hierarchy for argument definitions.
 */
.argparse-argument-name {
	background: var(--argparse-code-background);
	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 element to the right.
 * Follows Sphinx documentation 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);
}

/*
 * Light mode headerlink color overrides
 * Needed because code block has dark background regardless of theme
 */
body[data-theme="light"] .argparse-argument-name .headerlink {
	color: #9ca0a5;

	&:hover:not(:visited) {
		color: #cfd0d0;
	}
}

@media (prefers-color-scheme: light) {
	body:not([data-theme="dark"]) .argparse-argument-name .headerlink {
		color: #9ca0a5;

		&:hover:not(:visited) {
			color: #cfd0d0;
		}
	}
}

/*
 * 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(--argparse-code-background);
	border-radius: 0.2rem;
	padding: 0.1rem 0.3rem;
	font-family: var(--font-stack--monospace);
	font-size: var(--code-font-size);
	color: #e5c07b;
}

/*
 * Meta tag (e.g., "Required") - follows Furo's guilabel pattern
 * Uses semi-transparent amber background with border for visibility
 * without the harshness of solid fills. Amber conveys "needs attention".
 */
.argparse-meta-tag {
	background-color: #fef3c780;
	border: 1px solid #fcd34d80;
	color: var(--color-foreground-primary);
	font-size: var(--code-font-size);
	padding: 0.1rem 0.4rem;
	border-radius: 0.2rem;
	font-weight: 500;
}

/* Dark mode: darker amber with adjusted border */
body[data-theme="dark"] .argparse-meta-tag {
	background-color: #78350f60;
	border-color: #b4530980;
}

@media (prefers-color-scheme: dark) {
	body:not([data-theme="light"]) .argparse-meta-tag {
		background-color: #78350f60;
		border-color: #b4530980;
	}
}

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