:root {
	--bg: #07070f;
	--panel: #0c0c1a;
	--border: #55361c;
	--fg: #c8c8ff;
	--dim: #6a6a9a;
	--accent: #d9884a;
	--accent2: #5ee1ff;
	--green: #7dff9b;
	--pink: #ff7bd5;
	--glow: 0 0 5px rgba(217, 136, 74, 0.35);
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	min-height: 100%;
	background: var(--bg);
	color: var(--fg);
	font-family: "Cascadia Mono", "JetBrains Mono", "Fira Code", Consolas, "Courier New", monospace;
	font-size: 14px;
	line-height: 1.45;
}

body {
	background:
		radial-gradient(ellipse at top, #1e120a 0%, transparent 60%),
		radial-gradient(ellipse at bottom, #0b1a2a 0%, transparent 60%),
		var(--bg);
	background-attachment: fixed;
}

/* CRT scanlines + vignette over everything */
body::after {
	content: "";
	position: fixed;
	inset: 0;
	pointer-events: none;
	background:
		repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px),
		radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.6) 100%);
	z-index: 100;
	animation: flicker 6s infinite;
}

@keyframes flicker {
	0%, 97%, 100% { opacity: 1; }
	98% { opacity: 0.85; }
	99% { opacity: 0.95; }
}

::selection { background: var(--accent); color: var(--bg); }

a { color: var(--accent2); text-decoration: none; }
a:hover { color: var(--pink); text-shadow: 0 0 6px var(--pink); }

.dim { color: var(--dim); }
.small { font-size: 12px; }

/* starfield */
.stars {
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 0;
}
.stars i {
	position: absolute;
	width: 2px;
	height: 2px;
	background: #fff;
	border-radius: 50%;
	animation: twinkle 3s infinite ease-in-out;
}
@keyframes twinkle {
	0%, 100% { opacity: 0.15; }
	50% { opacity: 0.9; }
}

/* layout */
.layout {
	position: relative;
	z-index: 1;
	display: grid;
	grid-template-columns: 200px minmax(0, 820px) 200px;
	justify-content: center;
	gap: 18px;
	padding: 28px 16px 60px;
}

.side { display: flex; flex-direction: column; gap: 16px; }

.moon {
	margin: 0;
	color: #fff0e0;
	text-shadow: 0 0 8px #d9a57a, 0 0 18px #a8622c;
	font-size: 13px;
	line-height: 1.1;
	text-align: center;
}

.box {
	background: rgba(12, 12, 26, 0.85);
	border: 1px solid var(--border);
	padding: 8px 10px 10px;
	box-shadow: 0 0 0 1px #000, 4px 4px 0 #000;
}
.box p { margin: 6px 0 0; }
.box-title {
	color: var(--accent);
	text-shadow: var(--glow);
	border-bottom: 1px dashed var(--border);
	padding-bottom: 4px;
	margin-bottom: 4px;
}

.nav, .updates { list-style: none; margin: 0; padding: 0; }
.nav li::before { content: "> "; color: var(--dim); }
.nav li:hover::before { color: var(--pink); }
.updates li { margin-top: 6px; }

/* 88x31-ish buttons */
.buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.btn88 {
	width: 88px; height: 31px;
	display: flex; flex-direction: column; justify-content: center; align-items: center;
	font-size: 9px; line-height: 1.1; text-transform: uppercase;
	background: linear-gradient(#33200f, #1a0f06);
	border: 1px solid var(--accent);
	color: var(--fg);
	image-rendering: pixelated;
}
.btn88 b { color: var(--accent2); font-size: 11px; }
.btn88.alt { border-color: var(--accent2); background: linear-gradient(#0a2230, #050c14); }
.btn88.alt b { color: var(--pink); }
.btn88.alt2 { border-color: var(--pink); background: linear-gradient(#2a0f2a, #0d0410); }
.btn88.alt2 b { color: var(--green); }
.btnimg {
	display: block;
	max-width: 100%;
	height: auto;
	image-rendering: pixelated;
	border: 1px solid var(--border);
	background: #000;
}
.btnimg.sm { width: 88px; height: auto; }

/* main content box */
.main {
	min-height: calc(100vh - 110px);
	padding: 10px 16px 16px;
	border-color: var(--accent);
	box-shadow: 0 0 0 1px #000, 0 0 30px rgba(217, 136, 74, 0.15), 6px 6px 0 #000;
}
.main .box-title { margin-bottom: 12px; }

#content .line { white-space: pre-wrap; word-break: break-word; min-height: 1.45em; }
#content pre { margin: 0; font: inherit; }

/* text colours used by script output */
.c-accent { color: var(--accent); text-shadow: var(--glow); }
.c-cyan { color: var(--accent2); }
.c-green { color: var(--green); }
.c-pink { color: var(--pink); }
.c-err { color: #ff6b8b; }
.ascii { color: var(--accent); text-shadow: 0 0 6px rgba(217, 136, 74, 0.4); line-height: 1.1; }

/* images embedded in blog posts */
.blogimg {
	display: block;
	max-width: 100%;
	height: auto;
	border: 1px solid var(--border);
	background: #000;
	margin: 4px 0;
}

/* blog markdown bits */
.blog-h { color: var(--accent2); }
.blog-quote { color: var(--dim); border-left: 2px solid var(--border); padding-left: 8px; }
.blog-li { padding-left: 1em; }
.blog-hr { border-top: 1px dashed var(--border); margin: 6px 0; }
#content code { color: var(--green); background: rgba(125, 255, 155, 0.10); padding: 0 3px; }
#content pre.blog-code {
	margin: 4px 0;
	padding: 6px 8px;
	background: rgba(0, 0, 0, 0.35);
	border: 1px solid var(--border);
	overflow-x: auto;
	white-space: pre;
}
#content pre.blog-code code { background: transparent; padding: 0; }

/* footer marquee */
.footer {
	position: fixed;
	left: 0; right: 0; bottom: 0;
	z-index: 2;
	padding: 5px 0;
	background: rgba(7, 7, 15, 0.9);
	border-top: 1px solid var(--border);
	overflow: hidden;
}
.marquee { display: block; white-space: nowrap; }
.marquee span { display: inline-block; padding-left: 100%; animation: marquee 28s linear infinite; }
.marquee b { color: var(--green); }
@keyframes marquee { to { transform: translateX(-100%); } }

@media (max-width: 1100px) {
	.layout { grid-template-columns: minmax(0, 1fr); }
	.side { flex-direction: row; flex-wrap: wrap; }
	.side .box, .moon { flex: 1 1 180px; }
	.side.left { order: -1; }
	.main { min-height: 0; }
}

@media (max-width: 640px) {
	html, body { font-size: 13px; }
	.layout { gap: 12px; padding: 12px 8px 48px; }
	.side { gap: 10px; }
	.moon { display: none; }
	.side .box { flex: 1 1 140px; }

	/* nav becomes a row of tappable chips */
	.nav { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
	.nav li::before { content: none; }
	.nav a { display: block; padding: 6px 10px; border: 1px solid var(--border); background: rgba(217, 136, 74, 0.08); }
	.side.left .box:first-of-type { flex-basis: 100%; }

	.main { padding: 10px; }

	/* keep wide ascii art from blowing out the layout */
	#content pre { overflow-x: auto; }
	#content .line:has(.ascii) { white-space: pre; overflow-x: auto; }
	.ascii { font-size: 9px; }
}

/* github contribution heatmap */
.gh-wrap { overflow-x: auto; }
.gh {
	display: grid;
	grid-template-columns: 26px max-content;
	grid-template-rows: 14px auto;
	gap: 4px 6px;
	margin-top: 6px;
}
.gh-months { grid-column: 2; grid-row: 1; position: relative; }
.gh-months span { position: absolute; font-size: 10px; color: var(--dim); }
.gh-days {
	grid-column: 1; grid-row: 2;
	display: grid;
	grid-template-rows: repeat(7, 10px);
	gap: 2px;
	font-size: 10px; color: var(--dim); text-align: right;
}
.gh-days span { line-height: 10px; }
.gh-grid {
	grid-column: 2; grid-row: 2;
	display: grid;
	grid-auto-flow: column;
	gap: 2px;
}
.gh-cell { width: 10px; height: 10px; border-radius: 2px; }
.gh-cell.l0 { background: #16251c; }
.gh-cell.l1 { background: #1e4a2c; }
.gh-cell.l2 { background: #2f7a45; }
.gh-cell.l3 { background: #4fbf6f; }
.gh-cell.l4 { background: #7dff9b; box-shadow: 0 0 6px rgba(125, 255, 155, 0.55); }
.gh-legend { display: flex; align-items: center; gap: 2px; margin-top: 8px; }
.gh-legend .gh-cell { width: 8px; height: 8px; }

/* compact sidebar heatmap */
.gh-mini {
	display: grid;
	grid-auto-flow: column;
	gap: 1px;
	margin-top: 6px;
}
.gh-mini .gh-cell { width: 5px; height: 5px; border-radius: 1px; }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; }
}
