/**
 * VectoSync Prism Theme
 *
 * Dark syntax highlighting matching the VectoSync #0d1117 code background.
 * Optimised for Salesforce/Marketing Cloud content:
 *   - AMPscript, SSJS, Apex, SOQL
 *   - JSON, HTML, CSS, JavaScript
 *
 * Requires prism.js core + optional plugins (line-numbers, line-highlight).
 *
 * @package VectoSync
 */

/* ============================================================
   BASE
   ============================================================ */

code[class*="language-"],
pre[class*="language-"] {
	color: #e2e8f0;
	background: none;
	font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', 'Monaco', monospace;
	font-size: 0.875rem;
	line-height: 1.7;
	white-space: pre;
	word-break: normal;
	word-spacing: normal;
	word-wrap: normal;
	tab-size: 2;
	hyphens: none;
	text-align: left;
	direction: ltr;
}

/* Code blocks */
pre[class*="language-"] {
	padding: 1.5rem;
	margin: 0;
	overflow: auto;
	background: #0d1117;
	border-radius: 0; /* border-radius is on the .vs-code-block wrapper */
}

/* Inline code */
:not(pre) > code[class*="language-"] {
	background: rgba(1, 118, 211, 0.12);
	color: #93c5fd;
	padding: 2px 6px;
	border-radius: 4px;
	font-size: 0.875em;
	white-space: normal;
}

/* Selection */
code[class*="language-"]::-moz-selection,
pre[class*="language-"]::-moz-selection,
code[class*="language-"] ::-moz-selection,
pre[class*="language-"] ::-moz-selection {
	background: rgba(1, 118, 211, 0.25);
}

code[class*="language-"]::selection,
pre[class*="language-"]::selection,
code[class*="language-"] ::selection,
pre[class*="language-"] ::selection {
	background: rgba(1, 118, 211, 0.25);
}


/* ============================================================
   TOKEN COLOURS
   Palette rationale:
     Orange  → numbers, constants, boolean (standout values)
     Green   → strings (safe/content)
     Indigo  → keywords (control flow)
     Blue    → functions, class names
     Cyan    → operators, URLs
     Pink    → variables, regex
     Grey    → comments (de-emphasised)
   ============================================================ */

/* Comments */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
	color: #6a7a96;
	font-style: italic;
}

/* Punctuation */
.token.punctuation {
	color: #94a3b8;
}

/* Namespace */
.token.namespace {
	opacity: 0.7;
}

/* Numbers, constants, booleans */
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
	color: #f97316; /* orange */
}

/* Strings, selectors, attrs */
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
	color: #4ade80; /* green */
}

/* Operators, entities, URLs */
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
	color: #67e8f9; /* cyan */
}

/* At-rules, attr-values, keywords */
.token.atrule,
.token.attr-value,
.token.keyword {
	color: #818cf8; /* indigo */
}

/* Functions, class names */
.token.function,
.token.class-name {
	color: #60a5fa; /* blue */
}

/* Variables, regex, important */
.token.regex,
.token.important,
.token.variable {
	color: #f472b6; /* pink */
}

/* Weight / style modifiers */
.token.important,
.token.bold {
	font-weight: 700;
}

.token.italic {
	font-style: italic;
}

/* Clickable entity */
.token.entity {
	cursor: help;
}


/* ============================================================
   AMPSCRIPT — custom grammar tokens
   Prism AMPscript grammar uses these class names.
   ============================================================ */

/* %% and %%[ delimiters */
.token.ampscript-delimiter {
	color: #f59e0b; /* amber */
	font-weight: 700;
}

/* Built-in functions: CONCAT, VALUE, IIF, LOOKUP, etc. */
.token.ampscript-function {
	color: #34d399; /* emerald */
}

/* Control keywords: SET, VAR, IF, ELSEIF, ELSE, ENDIF, FOR, NEXT, THEN, DO, DOWNTO */
.token.ampscript-keyword {
	color: #818cf8; /* indigo — same as keyword */
	font-weight: 600;
}

/* Data extension attributes used as function arguments */
.token.ampscript-attribute {
	color: #60a5fa; /* blue */
}


/* ============================================================
   LINE NUMBERS PLUGIN
   ============================================================ */

pre[class*="language-"].line-numbers {
	position: relative;
	padding-left: 3.8rem;
	counter-reset: linenumber;
}

pre[class*="language-"].line-numbers > code {
	position: relative;
	white-space: inherit;
}

.line-numbers .line-numbers-rows {
	position: absolute;
	pointer-events: none;
	top: 1.5rem;   /* match padding of pre */
	left: 0;
	width: 3rem;
	letter-spacing: -1px;
	border-right: 1px solid rgba(255, 255, 255, 0.08);
	padding-right: 0.75rem;
	user-select: none;
}

.line-numbers-rows > span {
	display: block;
	counter-increment: linenumber;
}

.line-numbers-rows > span::before {
	content: counter(linenumber);
	color: #4b5563;
	display: block;
	padding-right: 0.8em;
	text-align: right;
	font-size: 0.8em;
}


/* ============================================================
   LINE HIGHLIGHT PLUGIN
   ============================================================ */

.line-highlight {
	background: rgba(1, 118, 211, 0.08);
	border-left: 3px solid var(--vs-primary, #0176d3);
	margin-left: -1.5rem; /* extend to left edge of pre */
	padding-left: calc(1.5rem - 3px);
}

/* Remove default Prism line-highlight style that adds a pseudo-element */
.line-highlight::before,
.line-highlight[data-end]::after {
	display: none;
}


/* ============================================================
   TOOLBAR PLUGIN (copy button, language label)
   ============================================================ */

div.code-toolbar {
	position: relative;
}

div.code-toolbar > .toolbar {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	opacity: 0;
	transition: opacity 0.2s ease;
	display: flex;
	gap: 0.25rem;
}

div.code-toolbar:hover > .toolbar,
div.code-toolbar:focus-within > .toolbar {
	opacity: 1;
}

div.code-toolbar > .toolbar > .toolbar-item > button,
div.code-toolbar > .toolbar > .toolbar-item > a,
div.code-toolbar > .toolbar > .toolbar-item > span {
	display: inline-flex;
	align-items: center;
	padding: 3px 8px;
	background: rgba(255, 255, 255, 0.06);
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 4px;
	color: #94a3b8;
	font-size: 0.7rem;
	font-family: 'JetBrains Mono', monospace;
	cursor: pointer;
	text-decoration: none;
	transition: background 0.15s ease, color 0.15s ease;
}

div.code-toolbar > .toolbar > .toolbar-item > button:hover,
div.code-toolbar > .toolbar > .toolbar-item > a:hover {
	background: rgba(1, 118, 211, 0.2);
	color: #60a5fa;
	border-color: rgba(1, 118, 211, 0.4);
}


/* ============================================================
   LIGHT MODE OVERRIDES
   When [data-theme="light"] is set on <html>
   ============================================================ */

[data-theme="light"] pre[class*="language-"] {
	background: #f6f8fa; /* GitHub light code bg */
}

[data-theme="light"] code[class*="language-"],
[data-theme="light"] pre[class*="language-"] {
	color: #24292e;
}

[data-theme="light"] .token.comment,
[data-theme="light"] .token.prolog,
[data-theme="light"] .token.doctype,
[data-theme="light"] .token.cdata {
	color: #6a737d;
}

[data-theme="light"] .token.punctuation { color: #586069; }

[data-theme="light"] .token.property,
[data-theme="light"] .token.tag,
[data-theme="light"] .token.boolean,
[data-theme="light"] .token.number,
[data-theme="light"] .token.constant,
[data-theme="light"] .token.symbol { color: #d73a49; }   /* red */

[data-theme="light"] .token.selector,
[data-theme="light"] .token.attr-name,
[data-theme="light"] .token.string,
[data-theme="light"] .token.char,
[data-theme="light"] .token.builtin { color: #032f62; }  /* dark blue */

[data-theme="light"] .token.operator,
[data-theme="light"] .token.entity,
[data-theme="light"] .token.url { color: #d73a49; }

[data-theme="light"] .token.atrule,
[data-theme="light"] .token.attr-value,
[data-theme="light"] .token.keyword { color: #6f42c1; }  /* purple */

[data-theme="light"] .token.function,
[data-theme="light"] .token.class-name { color: #005cc5; } /* blue */

[data-theme="light"] .token.regex,
[data-theme="light"] .token.important,
[data-theme="light"] .token.variable { color: #e36209; }  /* orange */

[data-theme="light"] :not(pre) > code[class*="language-"] {
	background: rgba(27, 31, 35, 0.06);
	color: #24292e;
}

[data-theme="light"] .line-numbers-rows > span::before {
	color: #bbbdbe;
}

[data-theme="light"] .line-highlight {
	background: rgba(1, 118, 211, 0.05);
}
