/* Home page terminal, rendered inside Duckquill's .crt container
   (templates/shortcodes/terminal.html). The output <pre> inherits the CRT
   colour, glow and flicker; the prompt line copies them. */
#terminal {
	cursor: text;
}

#terminal-output {
	padding-block-end: 0.5rem;
	height: 12rem;
	overflow-y: auto;
	overflow-wrap: anywhere;
	white-space: pre-wrap;
	scrollbar-color: color-mix(in srgb, var(--accent-color) 40%, transparent) transparent;
	scrollbar-width: thin;
}

/* Focusable so keyboard users can scroll it; inset because .scanlines clips overflow. */
#terminal-output:focus-visible {
	outline: 0.125rem solid currentColor;
	outline-offset: -0.375rem;
}

.terminal-line {
	display: block;
}

#terminal-output a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

.terminal-prompt {
	--text-shadow-1: hsl(from var(--accent-color) h s l / 0.5);
	--text-shadow-2: hsl(from var(--accent-color) h calc(s * 2) l);
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
	padding: 0 1rem 1rem;
	color: var(--accent-color);
	font-family: var(--font-monospace-code);
	text-shadow:
		var(--text-shadow-1) 0 0 0.25rem,
		var(--text-shadow-2) 0 0 0.75rem;
}

.terminal-prompt label {
	flex-shrink: 0;
	cursor: text;
}

#terminal-input {
	flex: 1;
	margin: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	padding: 0;
	min-width: 0;
	color: inherit;
	font: inherit;
	/* 16px or more stops iOS Safari zooming in on focus. */
	font-size: max(1rem, 16px);
	text-shadow: inherit;
	caret-color: currentColor;
}

#terminal-input:focus-visible {
	outline-color: currentColor;
	outline-offset: 0.25rem;
}

/* Lift the text to at least 50% lightness so the light theme's dark accent
   stays readable on the near-black screen; the dark accent is unchanged.
   Guarded because with var() an unsupported colour would fall back to the
   page text colour instead of the accent. */
@supports (color: hsl(from red h s max(l, 50))) {
	#terminal-output,
	.terminal-prompt {
		color: hsl(from var(--accent-color) h s max(l, 50)) !important;
	}
}
