/**
 * tty1 syntax theme for Prism.
 *
 * Colours are pulled straight from the theme's custom properties, so retuning
 * the palette in tty1's style.css retunes code blocks with it. The hex values
 * are fallbacks for when the plugin is active under a different theme.
 *
 * Deliberately does not set background, border, padding or font — tty1 already
 * styles `pre` / `.wp-block-code` and should stay in charge of the container.
 */

pre[class*="language-"],
code[class*="language-"] {
	--tty1ch-base:     var(--fg, #c6cec6);
	--tty1ch-faint:    var(--dim, #64746a);
	--tty1ch-string:   var(--green, #8fce91);
	--tty1ch-number:   var(--amber, #d8a657);
	--tty1ch-function: var(--blue, #89a7cb);
	--tty1ch-keyword:  var(--magenta, #c288ad);
	--tty1ch-type:     var(--cyan, #83c5c0);
	--tty1ch-alert:    var(--red, #d3868f);
	--tty1ch-strong:   var(--bright, #eef2ee);

	color: var(--tty1ch-base);
	tab-size: 4;
}

/* ---------------------------------------------------------------------------
 * tokens
 * ------------------------------------------------------------------------ */

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
	color: var(--tty1ch-faint);
	font-style: italic;
}

.token.punctuation {
	color: var(--tty1ch-faint);
}

.token.namespace {
	opacity: 0.7;
}

.token.tag,
.token.keyword,
.token.atrule,
.token.rule,
.token.selector,
.token.important,
.token.doctype .token.name {
	color: var(--tty1ch-keyword);
}

.token.string,
.token.char,
.token.attr-value,
.token.regex,
.token.url {
	color: var(--tty1ch-string);
}

.token.number,
.token.boolean,
.token.constant,
.token.symbol,
.token.entity {
	color: var(--tty1ch-number);
}

.token.function,
.token.function-name,
.token.method {
	color: var(--tty1ch-function);
}

.token.class-name,
.token.builtin,
.token.type,
.token.type-class-name,
.token.interpolation .token.punctuation {
	color: var(--tty1ch-type);
}

.token.property,
.token.variable,
.token.parameter {
	color: var(--tty1ch-base);
}

.token.attr-name {
	color: var(--tty1ch-number);
}

.token.operator {
	color: var(--tty1ch-type);
	background: none; /* Prism's default themes tint this; tty1 does not. */
}

.token.deleted {
	color: var(--tty1ch-alert);
}

.token.inserted {
	color: var(--tty1ch-string);
}

.token.important,
.token.bold {
	font-weight: 700;
}

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

.token.entity {
	cursor: help;
}

/* Diffs read better as tinted rows than as tinted text. */
pre.language-diff .token.deleted,
pre.language-diff .token.inserted {
	display: block;
}

pre.language-diff .token.deleted {
	background: color-mix( in srgb, var(--tty1ch-alert) 12%, transparent );
}

pre.language-diff .token.inserted {
	background: color-mix( in srgb, var(--tty1ch-string) 12%, transparent );
}

/* Markup: the tag brackets are noise, the names are not. */
.token.tag .token.punctuation {
	color: var(--tty1ch-faint);
}

/* Shell prompts and comments dominate a terminal-themed blog; keep commands
   legible against them. */
pre.language-bash .token.function {
	color: var(--tty1ch-strong);
}

/* ---------------------------------------------------------------------------
 * line numbers
 * ------------------------------------------------------------------------ */

pre[class*="language-"].line-numbers {
	position: relative;
	padding-left: 3.5em;
	counter-reset: tty1ch-line;
}

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

.line-numbers .line-numbers-rows {
	position: absolute;
	top: 0;
	left: -3.5em;
	width: 2.7em;
	font-size: 100%;
	line-height: inherit;
	border-right: 1px solid var(--border, #232b27);
	pointer-events: none;
	user-select: none;
	-webkit-user-select: none;
}

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

.line-numbers-rows > span::before {
	content: counter( tty1ch-line );
	display: block;
	padding-right: 0.8em;
	text-align: right;
	color: var(--tty1ch-faint);
}

/* ---------------------------------------------------------------------------
 * print
 * ------------------------------------------------------------------------ */

@media print {
	pre[class*="language-"],
	code[class*="language-"] {
		text-shadow: none;
	}
}
