/* ==========================================================================
   4fingers — System Builder
   A single long-running terminal session, not a "website with a dark theme".
   ========================================================================== */

@property --glow-blur {
	syntax: "<length>";
	inherits: true;
	initial-value: 4px;
}

:root {
	--black: oklch(12% 0.01 150);
	--black-soft: oklch(15% 0.015 150);

	--green-900: oklch(28% 0.09 150);
	--green-700: oklch(60% 0.15 150);
	--green-500: oklch(62% 0.19 150);
	--green-300: oklch(78% 0.19 150);
	--green-100: oklch(92% 0.1 150);

	--amber-500: oklch(75% 0.16 70);

	--text: var(--green-300);
	--text-dim: var(--green-700);
	--text-bright: var(--green-100);
	--border: color-mix(in oklch, var(--green-700) 45%, transparent);
	--surface: color-mix(in oklch, var(--green-900) 12%, var(--black));

	--font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
	--measure: 68ch;
	--space-1: 0.5rem;
	--space-2: 1rem;
	--space-3: 1.75rem;
	--space-4: 3rem;
	--space-5: 5rem;

	color-scheme: dark;
}

/* -------------------------------------------------------------------------
   Reset & base
   ------------------------------------------------------------------------- */

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	background: var(--black);
}

body {
	margin: 0;
	min-height: 100svh;
	background: var(--black);
	color: var(--text);
	font-family: var(--font-mono);
	font-size: 16px;
	line-height: 1.6;
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
	animation: crt-boot 0.7s ease-out;
}

/* The set switching on — a single power-on flicker, then it settles. */
@keyframes crt-boot {
	0% { filter: brightness(2.4) contrast(1.5); opacity: 0.3; }
	8% { filter: brightness(0.5) contrast(1.2); opacity: 1; }
	16% { filter: brightness(1.8); }
	28% { filter: brightness(0.85); }
	45% { filter: brightness(1.15); }
	100% { filter: brightness(1) contrast(1); }
}

h1, h2, h3, p {
	margin: 0;
}

a {
	color: inherit;
	text-decoration: none;
}

code {
	font-family: inherit;
}

::selection {
	background: var(--green-500);
	color: var(--black);
}

::-webkit-scrollbar {
	width: 12px;
	height: 12px;
}
::-webkit-scrollbar-track {
	background: var(--black);
}
::-webkit-scrollbar-thumb {
	background: var(--green-900);
	border: 3px solid var(--black);
	border-radius: 999px;
}
* {
	scrollbar-color: var(--green-900) var(--black);
	scrollbar-width: thin;
}

:focus-visible {
	outline: 2px solid var(--green-500);
	outline-offset: 3px;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.skip-link {
	position: absolute;
	left: var(--space-2);
	top: -3rem;
	background: var(--green-500);
	color: var(--black);
	padding: 0.5em 1em;
	font-weight: 600;
	transition: top 0.2s ease;
	z-index: 100;
}
.skip-link:focus {
	top: var(--space-2);
}

/* Faint CRT scanline texture — the terminal's own material, not a decoration
   borrowed from elsewhere. */
.crt-overlay {
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 50;
	background: repeating-linear-gradient(
		to bottom,
		oklch(0% 0 0 / 0.15) 0px,
		oklch(0% 0 0 / 0.15) 1px,
		transparent 1px,
		transparent 3px
	);
	mix-blend-mode: multiply;
	opacity: 0.35;
	animation: crt-flicker 6s steps(1, jump-none) infinite;
}

/* A CRT never holds perfectly still — a slow, low-amplitude jitter, not a strobe. */
@keyframes crt-flicker {
	0%, 92%, 100% { opacity: 0.35; }
	5% { opacity: 0.29; }
	34% { opacity: 0.39; }
	61% { opacity: 0.31; }
	78% { opacity: 0.37; }
}

/* -------------------------------------------------------------------------
   Top bar
   ------------------------------------------------------------------------- */

.topbar {
	position: sticky;
	top: 0;
	z-index: 40;
	padding: var(--space-2) var(--space-3);
	background: color-mix(in oklch, var(--black) 88%, transparent);
	backdrop-filter: blur(6px);
	border-bottom: 1px solid var(--border);
	font-size: 0.875rem;
}

.topbar__id {
	color: var(--text-dim);
	white-space: nowrap;
}

/* -------------------------------------------------------------------------
   Layout shell
   ------------------------------------------------------------------------- */

main {
	max-width: var(--measure);
	margin-inline: auto;
	padding: var(--space-5) var(--space-3) var(--space-4);
	display: flex;
	flex-direction: column;
	gap: var(--space-5);
}

.line {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0 0.6ch;
	font-size: 1rem;
	padding: 0.15em 0.4em;
	margin-inline: -0.4em;
	border-radius: 2px;
	transition: background-color 0.15s ease;
}

.line:hover {
	background: color-mix(in oklch, var(--green-900) 40%, transparent);
}

.prompt {
	color: var(--text-dim);
}

.cmd {
	color: var(--text-bright);
	font-weight: 500;
}

.cmd--static {
	color: var(--text-bright);
}

/* -------------------------------------------------------------------------
   Hero — the boot sequence
   ------------------------------------------------------------------------- */

.hero {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
}

.cmd--whoami {
	display: inline-block;
	overflow: hidden;
	white-space: nowrap;
	width: 6ch;
	animation: type-whoami 0.6s steps(6, end) forwards;
}

.cmd--mission {
	display: inline-block;
	overflow: hidden;
	white-space: nowrap;
	width: 16ch;
	animation: type-mission 1.1s steps(16, end) 1.5s forwards;
	animation-fill-mode: both;
	opacity: 0;
}

@keyframes type-whoami {
	from { width: 0; }
	to { width: 6ch; }
}
@keyframes type-mission {
	0% { width: 0; opacity: 1; }
	1% { opacity: 1; }
	100% { width: 16ch; opacity: 1; }
}

.caret,
.caret-static {
	display: inline-block;
	width: 0.55ch;
	align-self: center;
	background: var(--green-500);
	margin-left: 1px;
}
.caret {
	animation: caret-blink 1s step-end infinite, caret-reveal 0.1s linear 0.6s both;
}
.caret--2 {
	animation: caret-blink 1s step-end infinite, caret-reveal 0.1s linear 2.6s both;
}
.caret-static {
	animation: caret-blink 1s step-end infinite;
}
@keyframes caret-reveal {
	from { opacity: 0; }
	to { opacity: 1; }
}
@keyframes caret-blink {
	0%, 100% { opacity: 1; }
	50% { opacity: 0; }
}

.output {
	padding-left: 0.2ch;
	border-left: 1px solid var(--border);
	margin-left: 0.4ch;
	padding-left: 1.4ch;
	opacity: 0;
	transform: translateY(2px);
	animation: reveal 0.4s ease-out forwards;
}
.output--1 { animation-delay: 0.75s; }
.output--2 { animation-delay: 2.75s; }

@keyframes reveal {
	to { opacity: 1; transform: translateY(0); }
}

.output__title {
	color: var(--text-bright);
	font-size: 1.375rem;
	font-weight: 600;
	text-wrap: balance;
	letter-spacing: -0.02em;
}

.output__meta {
	margin-top: 0.35rem;
	color: var(--text-dim);
	font-size: 0.875rem;
}

.output--2 p {
	color: var(--text);
}

.hero__cta {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2);
	margin-top: var(--space-2);
	opacity: 0;
	animation: reveal 0.4s ease-out 3.35s forwards;
}

/* -------------------------------------------------------------------------
   Flags (buttons) — terminal selection, inverted on hover
   ------------------------------------------------------------------------- */

.flag {
	display: inline-flex;
	align-items: center;
	padding: 0.55em 1.1em;
	border: 1px solid var(--green-700);
	color: var(--green-300);
	font-weight: 500;
	white-space: nowrap;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.flag:hover,
.flag:focus-visible {
	background: var(--green-500);
	color: var(--black);
	border-color: var(--green-500);
}

.flag--primary {
	background: var(--green-900);
	border-color: var(--green-500);
	color: var(--green-100);
}
.flag--primary:hover,
.flag--primary:focus-visible {
	background: var(--green-500);
	color: var(--black);
}

/* -------------------------------------------------------------------------
   Panels
   ------------------------------------------------------------------------- */

.panel {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	scroll-margin-top: 5rem;
}

.panel__body {
	padding-left: 1.4ch;
	border-left: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	max-width: 62ch;
}

.file-heading {
	color: var(--text-bright);
	font-size: 1.5rem;
	font-weight: 600;
	letter-spacing: -0.02em;
	text-wrap: balance;
}

.panel p {
	color: var(--text);
}

/* -------------------------------------------------------------------------
   Process table
   ------------------------------------------------------------------------- */

.proc-table-wrap {
	overflow-x: auto;
	border: 1px solid var(--border);
	background: var(--surface);
	max-width: 100%;
	padding: 0.75rem;
}

.proc-table {
	border-collapse: collapse;
	width: 100%;
	min-width: 46rem;
	font-size: 0.9rem;
}

.proc-table th,
.proc-table td {
	text-align: left;
	padding: 0.55em 0.9em;
	white-space: nowrap;
}

.proc-table thead th {
	color: var(--text-dim);
	font-weight: 500;
	border-bottom: 1px solid var(--border);
	font-size: 0.8rem;
	letter-spacing: 0.02em;
}

.proc-table tbody tr + tr {
	border-top: 1px solid color-mix(in oklch, var(--border) 60%, transparent);
}

.proc-table tbody tr {
	transition: background-color 0.1s ease;
}

.proc-table tbody tr:hover {
	background: color-mix(in oklch, var(--green-900) 55%, transparent);
}

.proc-table__critical:hover {
	background: color-mix(in oklch, var(--amber-500) 14%, transparent);
}

.proc-table tbody td {
	color: var(--text);
}

.proc-table code {
	color: var(--text-bright);
}

.proc-table__critical td {
	color: var(--amber-500);
}
.proc-table__critical code {
	color: var(--amber-500);
}

.status-dot {
	display: inline-block;
	width: 0.5em;
	height: 0.5em;
	border-radius: 50%;
	background: var(--amber-500);
	margin-right: 0.6em;
	box-shadow: 0 0 var(--glow-blur) var(--amber-500);
	animation: pulse-glow 1.8s ease-in-out infinite;
}

@keyframes pulse-glow {
	0%, 100% { --glow-blur: 2px; }
	50% { --glow-blur: 9px; }
}

.proc-note {
	color: var(--text-dim);
	font-size: 0.9rem;
	max-width: 60ch;
}

.line--tight {
	margin-top: var(--space-1);
}

.cat-art {
	margin: 0;
	padding: var(--space-1) 0 var(--space-2);
	overflow-x: auto;
	color: var(--text-bright);
	font-size: 0.95rem;
	line-height: 1.4;
}

/* -------------------------------------------------------------------------
   Contact
   ------------------------------------------------------------------------- */

.contact-lede {
	color: var(--text-bright);
}

.contact-flags {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2);
	margin-top: var(--space-1);
}

.contact-hint {
	margin-top: var(--space-1);
	font-size: 0.85rem;
	color: var(--text-dim);
	opacity: 0.6;
	transition: opacity 0.2s ease;
}

.panel--contact:has(.contact-flags a:hover) .contact-hint,
.panel--contact:has(.contact-flags a:focus-visible) .contact-hint {
	opacity: 1;
	color: var(--green-500);
}

/* -------------------------------------------------------------------------
   Status bar footer
   ------------------------------------------------------------------------- */

.statusbar {
	position: sticky;
	bottom: 0;
	z-index: 40;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em 1.5em;
	align-items: center;
	padding: 0.6em var(--space-3);
	background: var(--green-500);
	color: var(--black);
	font-size: 0.8rem;
	font-weight: 500;
}

.statusbar__mid {
	flex: 1;
}

/* -------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------- */

@media (max-width: 640px) {
	main {
		padding: var(--space-4) var(--space-2) var(--space-4);
		gap: var(--space-4);
	}

	.topbar {
		padding: var(--space-1) var(--space-2);
		font-size: 0.8rem;
	}

	.output__title {
		font-size: 1.15rem;
	}

	.statusbar {
		font-size: 0.7rem;
	}

	.statusbar__right {
		flex-basis: 100%;
	}
}

/* -------------------------------------------------------------------------
   Motion preference
   ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	body,
	.crt-overlay,
	.cmd--whoami,
	.cmd--mission,
	.output,
	.hero__cta,
	.caret,
	.caret-static,
	.status-dot {
		animation: none !important;
		width: auto !important;
		opacity: 1 !important;
		transform: none !important;
		filter: none !important;
	}
	.crt-overlay {
		opacity: 0.35 !important;
	}
}
