/**
 * Portfolio GUI: one quiet page.
 *
 * A side panel that stays put on large screens and a column of sections
 * beside it, over a faint field of dots. Type and spacing do the work; there
 * are no cards. Every colour is declared once as a token, for the light
 * theme and again for the dark one.
 */

/* ───────────── tokens ───────────── */

#gui-view {
	--bg: #f6f6f3;
	--ink: #15181d;
	--soft: #5f6771;
	--rule: #d8dad5;
	--live: #0f7a4f;
	--grain: #cfd2cc;
	--wash: rgba(21, 24, 29, 0.045);
	--focus: #15181d;

	--syn-keyword: #a62a7a;
	--syn-string: #0f7a57;
	--syn-constant: #1f4fd1;
	--syn-entity: #8a4b00;

	--sans: 'Overpass', 'Helvetica Neue', Arial, sans-serif;
	--mono: 'Fira Code', 'SFMono-Regular', Consolas, monospace;

	background: var(--bg);
	color: var(--ink);
	font-family: var(--sans);
	font-size: 17.5px;
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
}

#gui-view[data-theme='dark'] {
	--bg: #15181d;
	--ink: #eef0f2;
	--soft: #99a2ac;
	--rule: #2c313a;
	--live: #57d39b;
	--grain: #39404a;
	--wash: rgba(255, 255, 255, 0.05);
	--focus: #57d39b;

	--syn-keyword: #f08bc4;
	--syn-string: #6edbb8;
	--syn-constant: #8fb1ff;
	--syn-entity: #f2c76b;
}

/* ───────────── base ───────────── */

#gui-view button {
	font: inherit;
	color: inherit;
}

#gui-view a {
	color: var(--ink);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

#gui-view :focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 3px;
	border-radius: 2px;
}

#gui-view section:focus-visible,
#gui-view .item:focus-visible {
	outline: none;
}

#gui-view .soft {
	color: var(--soft);
}

/* ───────────── the dot field ───────────── */

#gui-dots {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

#gui-scroll {
	position: absolute;
	inset: 0;
	overflow-y: auto;
}

/* ───────────── layout: side panel + sections ───────────── */

#gui-layout {
	display: grid;
	grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
	gap: clamp(32px, 6vw, 96px);
	max-width: 78rem;
	margin: 0 auto;
	padding: 0 clamp(20px, 5vw, 64px);
}

/* The side panel does not scroll away on large screens */
#gui-side {
	position: sticky;
	top: 0;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: 32px;
	height: 100vh;
	height: 100dvh;
	padding: clamp(48px, 11vh, 104px) 0 clamp(32px, 7vh, 72px);
}

/* The name always fits on one line */
#gui-side h1 {
	font-size: clamp(27px, 3.05vw, 42px);
	font-weight: 800;
	line-height: 1.1;
	letter-spacing: -0.035em;
	white-space: nowrap;
}

#gui-view #gui-side h1 a {
	text-decoration: none;
}

#gui-side .title {
	margin-top: 14px;
	font-size: 21px;
	font-weight: 600;
	letter-spacing: -0.01em;
}

#gui-side .tagline {
	max-width: 19rem;
	margin-top: 12px;
	color: var(--soft);
}

/* Section menu: a mark that lengthens for the section being read */
#gui-side nav {
	margin-top: clamp(28px, 7vh, 64px);
}

#gui-side nav ul {
	list-style: none;
}

#gui-view #gui-side nav a {
	display: inline-flex;
	align-items: center;
	gap: 16px;
	padding: 7px 0;
	color: var(--soft);
	font-size: 15.5px;
	font-weight: 700;
	text-decoration: none;
	transition: color 0.2s;
}

#gui-side nav .mark {
	width: 30px;
	height: 1.5px;
	background: currentColor;
	transition: width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#gui-view #gui-side nav a:hover,
#gui-view #gui-side nav a.is-current {
	color: var(--ink);
}

#gui-side nav a:hover .mark,
#gui-side nav a.is-current .mark {
	width: 68px;
}

.side-foot {
	font-size: 15.5px;
}

.side-foot p {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 22px;
}

.side-foot .tools {
	margin-top: 10px;
}

.side-foot button {
	padding: 0;
	border: 0;
	background: none;
	color: var(--soft);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
	cursor: pointer;
}

#gui-view .side-foot button:hover {
	color: var(--ink);
}

/* ───────────── sections ───────────── */

#gui-main {
	padding: clamp(48px, 11vh, 104px) 0 22vh;
	min-width: 0;
}

#gui-main section {
	scroll-margin-top: clamp(48px, 11vh, 104px);
}

#gui-main section + section {
	margin-top: clamp(80px, 15vh, 136px);
}

#gui-main h2 {
	margin-bottom: 18px;
	font-size: clamp(25px, 2.6vw, 31px);
	font-weight: 800;
	line-height: 1.15;
	letter-spacing: -0.02em;
}

#gui-main p + p,
#gui-main p + dl,
#gui-main dl + p {
	margin-top: 16px;
}

/* Label and value pairs */
.facts {
	display: grid;
}

.facts > div {
	display: grid;
	grid-template-columns: 7.5rem 1fr;
	gap: 16px;
	padding: 6px 0;
}

.facts.is-ruled > div {
	padding: 14px 0 12px;
	border-top: 1px solid var(--rule);
}

.facts dt {
	color: var(--soft);
}

.facts dd {
	min-width: 0;
	overflow-wrap: anywhere;
}

/* Rows that open in place */

.item {
	border-top: 1px solid var(--rule);
	scroll-margin-top: 24px;
}

.item h3 {
	font: inherit;
}

#gui-view .row {
	display: grid;
	grid-template-columns: minmax(7rem, 12rem) 1fr auto;
	gap: 4px 20px;
	align-items: baseline;
	width: 100%;
	padding: 16px 0 14px;
	border: 0;
	background: none;
	text-align: left;
	cursor: pointer;
	transition:
		padding-left 0.25s cubic-bezier(0.2, 0.8, 0.2, 1),
		background-color 0.2s;
}

#gui-view .row:hover,
.item.is-open .row {
	padding-left: 12px;
	background: var(--wash);
}

.row b {
	font-weight: 700;
	overflow-wrap: anywhere;
}

.row span {
	color: var(--soft);
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.row i {
	padding-right: 12px;
	color: var(--soft);
	font-style: normal;
	white-space: nowrap;
}

/* The opened part grows from nothing to its own height */
.more {
	display: grid;
	grid-template-rows: 0fr;
	transition: grid-template-rows 0.38s cubic-bezier(0.3, 0, 0.2, 1);
}

.item.is-open > .more {
	grid-template-rows: 1fr;
}

.more-inner {
	min-height: 0;
	overflow: hidden;
}

.more-inner {
	padding: 0 12px;
	opacity: 0;
	transition: opacity 0.3s;
}

.item.is-open .more-inner {
	padding-top: 6px;
	padding-bottom: 26px;
	opacity: 1;
}

.more-inner > * + * {
	margin-top: 12px;
}

#gui-view .bullets {
	padding-left: 20px;
}

#gui-view .bullets li + li {
	margin-top: 8px;
}

.links {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 24px;
}

#gui-view .link {
	padding: 0;
	border: 0;
	background: none;
	font-weight: 700;
	text-decoration: underline;
	text-decoration-thickness: 1.5px;
	text-underline-offset: 0.22em;
	cursor: pointer;
}

/* The main thing to do with a project */
#gui-view .link.is-primary {
	padding: 7px 16px 5px;
	border-radius: 999px;
	background: var(--ink);
	color: var(--bg);
	text-decoration: none;
}

#gui-view .link.is-primary svg {
	width: 13px;
	height: 13px;
	margin-left: 3px;
	vertical-align: -1px;
}

#gui-view .link.is-primary:hover {
	background: var(--live);
}

.links {
	align-items: center;
}

.plain-item + .plain-item {
	margin-top: 28px;
}

.plain-item h3 {
	font-size: inherit;
	font-weight: 700;
}

.plain-item p {
	margin-top: 8px;
}

.colophon {
	margin-top: clamp(80px, 15vh, 136px);
	max-width: 30rem;
	font-size: 15px;
	color: var(--soft);
}

/* A project's how-to steps */
.guide-title {
	margin-top: 1rem;
	font-weight: 600;
}

.guide {
	margin: 0.4rem 0 1rem 1.2rem;
	padding: 0;
}

.guide li {
	margin: 0.45rem 0;
	padding-left: 0.2rem;
}

.guide pre {
	margin-top: 0.4rem;
	padding: 10px 12px;
	border-radius: 6px;
	background: var(--wash);
	font-size: 13px;
	line-height: 1.55;
	overflow-x: auto;
	white-space: pre;
}

/* The page as the server wrote it, before the script takes over (and for
   visitors without scripts): plain but tidy. */
#gui-main article:not(.item) + article:not(.item) {
	margin-top: 24px;
}

#gui-main article > h3 {
	font-size: inherit;
	font-weight: 700;
}

#gui-main section > dl > dt {
	margin-top: 10px;
	color: var(--soft);
}

/* ───────────── small screens: one column ───────────── */

@media (max-width: 960px) {
	#gui-layout {
		grid-template-columns: minmax(0, 1fr);
		gap: 0;
	}

	#gui-side {
		position: static;
		height: auto;
		padding: 56px 0 8px;
	}

	#gui-side h1 {
		font-size: min(40px, 8.6vw);
	}

	/* Everything is one scroll away, so the menu is not needed */
	#gui-side nav {
		display: none;
	}

	.side-foot {
		margin-top: 4px;
	}

	#gui-main {
		padding-top: 56px;
	}

	/* Section headings stay in view while their section is read */
	#gui-main h2 {
		position: sticky;
		top: 0;
		z-index: 1;
		margin: 0 -20px 6px;
		padding: 12px 20px 10px;
		font-size: 22px;
		background: color-mix(in srgb, var(--bg) 88%, transparent);
		backdrop-filter: blur(8px);
		-webkit-backdrop-filter: blur(8px);
		color: var(--ink);
	}

	/* Leave room for the sticky heading when a row is scrolled to */
	.item {
		scroll-margin-top: 64px;
	}

	#gui-view .row {
		grid-template-columns: 1fr auto;
	}

	.row span {
		grid-column: 1 / -1;
		grid-row: 2;
	}

	.facts > div {
		grid-template-columns: 6rem 1fr;
	}
}

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

/* ───────────── pointer: a circle on desktop ─────────────
   Drawn by portfolio-cursor.js: a ring that follows the mouse with no easing (so
   it never trails) and grows smoothly over anything clickable. The system cursor
   is hidden only once that script is running, so without it the normal cursor
   remains. Touch screens never get it. */

#gui-view.has-cursor,
#gui-view.has-cursor * {
	cursor: none !important;
}

#gui-cursor {
	position: fixed;
	left: 0;
	top: 0;
	z-index: 1000;
	pointer-events: none;
	will-change: transform;
}

#gui-cursor::before,
#gui-cursor::after {
	content: '';
	position: absolute;
	left: 0;
	top: 0;
	border-radius: 50%;
	transform: translate(-50%, -50%);
	transition: opacity 0.2s ease;
}

/* The ring, with a faint halo in the page colour so it reads over text and dots */
#gui-cursor::before {
	width: 30px;
	height: 30px;
	border: 1px solid var(--ink);
	box-shadow: 0 0 0 1px color-mix(in srgb, var(--bg) 70%, transparent);
	transition:
		width 0.32s cubic-bezier(0.22, 1, 0.36, 1),
		height 0.32s cubic-bezier(0.22, 1, 0.36, 1),
		background-color 0.32s ease,
		opacity 0.2s ease;
}

/* The centre dot: only over something clickable. In the accent green rather
   than the text colour, with a page-coloured edge, so it reads over link text. */
#gui-cursor::after {
	width: 8px;
	height: 8px;
	background: var(--live);
	box-shadow: 0 0 0 2px var(--bg);
	opacity: 0;
}

#gui-cursor.is-active::before {
	width: 68px;
	height: 68px;
	background-color: color-mix(in srgb, var(--ink) 8%, transparent);
}

#gui-cursor.is-active::after {
	opacity: 1;
}

/* A press tightens the ring a little */
#gui-cursor.is-down::before {
	width: 24px;
	height: 24px;
}

#gui-cursor.is-active.is-down::before {
	width: 56px;
	height: 56px;
}

#gui-cursor.is-hidden::before,
#gui-cursor.is-hidden::after {
	opacity: 0;
}

@media print {
	#gui-cursor {
		display: none;
	}
}

/* ───────────── print: the same page, everything open ───────────── */

@media print {
	html,
	body {
		height: auto !important;
		overflow: visible !important;
		background: #fff !important;
	}

	#terminal-view,
	#gui-dots,
	#gui-side nav,
	.side-foot .tools,
	.colophon {
		display: none !important;
	}

	#gui-view,
	#gui-view[data-theme] {
		display: block !important;
		position: static !important;
		--bg: #fff;
		--ink: #000;
		--soft: #444;
		--rule: #bbb;
		--live: #000;
		--wash: transparent;
		font-size: 11pt;
	}

	#gui-scroll {
		position: static;
		overflow: visible;
	}

	#gui-layout {
		display: block;
		padding: 0;
	}

	#gui-side {
		position: static;
		height: auto;
		padding: 0 0 18pt;
	}

	#gui-main {
		padding: 0;
	}

	#gui-main section + section {
		margin-top: 22pt;
	}

	/* Rows are printed open */
	.more {
		grid-template-rows: 1fr !important;
	}

	.more-inner {
		padding: 2pt 0 10pt !important;
		opacity: 1 !important;
	}

	#gui-view .row {
		padding: 8pt 0 2pt !important;
		background: none !important;
	}

	.item {
		break-inside: avoid;
	}

	#gui-main h2 {
		break-after: avoid;
	}

	#gui-main a[href^='http']::after,
	.side-foot a[href^='http']::after {
		content: ' (' attr(href) ')';
		overflow-wrap: anywhere;
	}
}
