/*
 * scmpc.github.io: the front panel of a hi-fi receiver.
 * Graphite panels, a vacuum fluorescent display and one red LED.
 *
 * Fonts: Martian Mono and Schibsted Grotesk, both under the SIL Open
 * Font License, see media/fonts/OFL-*.txt.
 */

@font-face {
	font-family: "Martian Mono";
	src: url("fonts/martian-mono.woff2") format("woff2");
	font-weight: 100 800;
	font-stretch: 75% 112.5%;
	font-display: swap;
}

@font-face {
	font-family: "Schibsted Grotesk";
	src: url("fonts/schibsted-grotesk.woff2") format("woff2");
	font-weight: 400 900;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Schibsted Grotesk";
	src: url("fonts/schibsted-grotesk-italic.woff2") format("woff2");
	font-weight: 400 900;
	font-style: italic;
	font-display: swap;
}

/* ------------------------------------------------------------------ */
/* Theme                                                                */
/* ------------------------------------------------------------------ */

:root {
	--mono: "Martian Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
	--sans: "Schibsted Grotesk", "Helvetica Neue", Helvetica, sans-serif;

	--bg: #0e0f10;
	--panel: #17191b;
	--panel-hi: #202326;
	--line: #2c3034;
	--ink: #e8e4dc;
	--muted: #9b978e;
	--link: #7af0d2;
	--accent: #7af0d2;
	--led: #ff4b33;
	--shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset,
		0 30px 60px -30px rgba(0, 0, 0, 0.8);
	--brush: rgba(255, 255, 255, 0.018);
	--grain: 0.07;

	/* the display is dark glass in both themes, like real hardware */
	--glass: #050c0b;
	--vfd: #6ff4d1;
	--vfd-dim: rgba(111, 244, 209, 0.16);
	--vfd-glow: 0 0 6px rgba(111, 244, 209, 0.55), 0 0 18px rgba(111, 244, 209, 0.25);

	color-scheme: dark;
}

@media (prefers-color-scheme: light) {
	:root {
		--bg: #d9d5cc;
		--panel: #ebe8e1;
		--panel-hi: #f6f4ef;
		--line: #c6c1b6;
		--ink: #1a1b1d;
		--muted: #5c5850;
		--link: #08705a;
		--accent: #0a7d65;
		--shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset,
			0 30px 60px -34px rgba(60, 50, 30, 0.45);
		--brush: rgba(0, 0, 0, 0.022);
		--grain: 0.05;
		color-scheme: light;
	}
}

/* ------------------------------------------------------------------ */
/* Base                                                                 */
/* ------------------------------------------------------------------ */

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

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-behavior: smooth;
	scroll-padding-top: 1.5rem;
}

body {
	margin: 0;
	padding: clamp(0.75rem, 3vw, 2.5rem);
	min-height: 100vh;
	background:
		radial-gradient(ellipse 80% 60% at 50% -10%, rgba(111, 244, 209, 0.07), transparent 70%),
		repeating-linear-gradient(0deg, var(--brush) 0 1px, transparent 1px 3px),
		var(--bg);
	color: var(--ink);
	font: 400 1.0625rem/1.65 var(--sans);
	font-kerning: normal;
}

/* film grain over everything, very faint */
body::before {
	content: "";
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 10;
	opacity: var(--grain);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
	mix-blend-mode: overlay;
}

a {
	color: var(--link);
	text-decoration-line: underline;
	text-decoration-thickness: 1px;
	text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent);
	text-underline-offset: 0.2em;
	transition: text-decoration-color 0.15s, color 0.15s;
}

a:hover {
	text-decoration-color: currentColor;
}

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

code {
	font: 0.86em/1 var(--mono);
	font-stretch: 100%;
	padding: 0.2em 0.45em;
	border: 1px solid var(--line);
	border-radius: 4px;
	background: var(--panel-hi);
	white-space: nowrap;
}

strong {
	font-weight: 650;
}

.skip {
	position: absolute;
	left: -999px;
	top: 1rem;
	z-index: 20;
	padding: 0.5rem 1rem;
	background: var(--accent);
	color: var(--glass);
	font-family: var(--mono);
}

.skip:focus {
	left: 1rem;
}

/* ------------------------------------------------------------------ */
/* Front panel                                                          */
/* ------------------------------------------------------------------ */

.panel {
	position: relative;
	max-width: 72rem;
	margin: 0 auto;
	padding: clamp(1.5rem, 4vw, 3rem);
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
	grid-template-areas:
		"brand display"
		"nav   nav";
	gap: 2rem 3rem;
	border: 1px solid var(--line);
	border-radius: 14px;
	background:
		repeating-linear-gradient(90deg, var(--brush) 0 1px, transparent 1px 2px),
		linear-gradient(180deg, var(--panel-hi), var(--panel) 40%);
	box-shadow: var(--shadow);
}

/* four screws, because every front panel has them */
.panel::before {
	content: "";
	position: absolute;
	inset: 12px;
	pointer-events: none;
	--screw: radial-gradient(circle, var(--line) 0 2.5px, var(--muted) 3px 3.5px, transparent 4px);
	background:
		var(--screw) top left / 10px 10px no-repeat,
		var(--screw) top right / 10px 10px no-repeat,
		var(--screw) bottom left / 10px 10px no-repeat,
		var(--screw) bottom right / 10px 10px no-repeat;
	opacity: 0.6;
}

.brand {
	grid-area: brand;
	align-self: center;
}

.status {
	display: inline-flex;
	align-items: center;
	gap: 0.6em;
	margin: 0 0 1.25rem;
	font: 500 0.7rem/1 var(--mono);
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--muted);
}

.led {
	width: 0.6rem;
	height: 0.6rem;
	border-radius: 50%;
	background: var(--led);
	box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25), 0 0 10px var(--led);
	animation: pulse 2.4s ease-in-out infinite;
}

h1 {
	margin: 0;
	font: 650 clamp(3.25rem, 9vw, 6rem)/0.9 var(--mono);
	font-stretch: 112.5%;
	letter-spacing: -0.04em;
	color: var(--ink);
}

.tagline {
	max-width: 26ch;
	margin: 1.5rem 0 2rem;
	font-size: clamp(1.15rem, 2vw, 1.35rem);
	line-height: 1.45;
	color: var(--muted);
	text-wrap: balance;
}

.actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
}

.button {
	display: inline-flex;
	align-items: center;
	padding: 0.8rem 1.15rem;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: linear-gradient(180deg, var(--panel-hi), var(--panel));
	box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 2px 0 rgba(0, 0, 0, 0.25);
	color: var(--ink);
	font: 600 0.78rem/1 var(--mono);
	letter-spacing: 0.06em;
	text-transform: uppercase;
	text-decoration: none;
	transition: transform 0.12s, box-shadow 0.12s, border-color 0.15s;
}

.button:hover {
	border-color: var(--accent);
}

.button:active {
	transform: translateY(1px);
	box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

.button.primary {
	border-color: transparent;
	background: var(--vfd);
	color: var(--glass);
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2) inset, 0 0 24px rgba(111, 244, 209, 0.25);
}

/* ------------------------------------------------------------------ */
/* Vacuum fluorescent display                                           */
/* ------------------------------------------------------------------ */

.display {
	grid-area: display;
	position: relative;
	display: grid;
	gap: 1.4rem;
	padding: 1.6rem 1.6rem 1.2rem;
	border-radius: 10px;
	background:
		repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.35) 0 1px, transparent 1px 3px),
		radial-gradient(ellipse at 50% 0%, rgba(111, 244, 209, 0.08), transparent 70%),
		var(--glass);
	box-shadow:
		0 0 0 1px rgba(0, 0, 0, 0.6),
		0 0 0 6px color-mix(in srgb, var(--panel) 70%, #000),
		0 0 0 7px var(--line),
		inset 0 10px 30px rgba(0, 0, 0, 0.7);
	color: var(--vfd);
	font-family: var(--mono);
	overflow: hidden;
}

/* glass reflection */
.display::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(115deg, rgba(255, 255, 255, 0.07), transparent 35%);
	pointer-events: none;
}

.chain {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	font-size: clamp(0.62rem, 1.2vw, 0.78rem);
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

.node {
	padding: 0.45em 0.7em;
	border: 1px solid var(--vfd-dim);
	border-radius: 4px;
	text-shadow: var(--vfd-glow);
	white-space: nowrap;
}

.node.core {
	border-color: var(--vfd);
	box-shadow: 0 0 12px rgba(111, 244, 209, 0.3), inset 0 0 12px rgba(111, 244, 209, 0.15);
	text-transform: none;
	letter-spacing: 0.04em;
	font-weight: 600;
}

.wire {
	position: relative;
	flex: 1;
	height: 1px;
	min-width: 1.5rem;
	background: repeating-linear-gradient(90deg, var(--vfd-dim) 0 4px, transparent 4px 7px);
}

/* a packet travels from left to right */
.wire::after {
	content: "";
	position: absolute;
	top: -2px;
	left: 0;
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: var(--vfd);
	box-shadow: var(--vfd-glow);
	animation: travel 2.6s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.wire + .node.core + .wire::after {
	animation-delay: 1.3s;
}

.meter {
	display: grid;
	grid-template-columns: repeat(36, 1fr);
	align-items: end;
	gap: 3px;
	height: 4.5rem;
}

.meter i {
	display: block;
	height: 100%;
	background: repeating-linear-gradient(0deg, var(--vfd) 0 3px, transparent 3px 5px);
	opacity: 0.85;
	filter: drop-shadow(0 0 3px rgba(111, 244, 209, 0.6));
	transform-origin: bottom;
	transform: scaleY(0.3);
	/* pseudo-random rhythm from each bar's index */
	animation: level calc(0.9s + mod(var(--i) * 173ms, 700ms)) ease-in-out infinite alternate;
	animation-delay: calc(var(--i) * -211ms);
}

/* the top segments of the loudest bars glow red, like a peak light */
.meter i:nth-child(7n + 3) {
	background:
		linear-gradient(0deg, transparent 82%, var(--led) 82%) ,
		repeating-linear-gradient(0deg, var(--vfd) 0 3px, transparent 3px 5px);
	-webkit-mask: repeating-linear-gradient(0deg, #000 0 3px, transparent 3px 5px);
	mask: repeating-linear-gradient(0deg, #000 0 3px, transparent 3px 5px);
}

.readout {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding-top: 0.9rem;
	border-top: 1px solid var(--vfd-dim);
	font-size: 0.66rem;
	letter-spacing: 0.18em;
	opacity: 0.75;
	text-shadow: var(--vfd-glow);
}

.readout span:first-child {
	animation: blink 4s steps(1) infinite;
}

/* ------------------------------------------------------------------ */
/* Section selector                                                     */
/* ------------------------------------------------------------------ */

nav {
	grid-area: nav;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	padding-top: 1.75rem;
	border-top: 1px solid var(--line);
}

nav a {
	padding: 0.55rem 0.85rem;
	border: 1px solid var(--line);
	border-radius: 6px;
	color: var(--muted);
	font: 500 0.7rem/1 var(--mono);
	letter-spacing: 0.14em;
	text-transform: uppercase;
	text-decoration: none;
	transition: color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

nav a:hover {
	color: var(--accent);
	border-color: var(--accent);
	box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* ------------------------------------------------------------------ */
/* Content: a spec sheet with labels on the left                       */
/* ------------------------------------------------------------------ */

main {
	max-width: 72rem;
	margin: clamp(2.5rem, 6vw, 4.5rem) auto 0;
	padding: 0 clamp(0.25rem, 2vw, 3rem);
	display: grid;
	grid-template-columns: 13rem minmax(0, 46rem);
	column-gap: 3rem;
}

main > * {
	grid-column: 2;
	margin: 0 0 1.1rem;
}

main > h2 {
	grid-column: 1;
	margin: 0;
	padding-top: 2.2rem;
	border-top: 1px solid var(--line);
	color: var(--muted);
	font: 600 0.72rem/1.4 var(--mono);
	letter-spacing: 0.2em;
	text-transform: uppercase;
}

main > h2::before {
	content: "";
	display: inline-block;
	width: 0.5rem;
	height: 0.5rem;
	margin-right: 0.7rem;
	border-radius: 50%;
	background: var(--accent);
	box-shadow: 0 0 8px var(--accent);
	vertical-align: 0.05em;
}

main > h2 + * {
	padding-top: 2rem;
	border-top: 1px solid var(--line);
}

main > h2:first-child,
main > h2:first-child + * {
	border-top: 0;
	padding-top: 0;
}

main > h2 + ul {
	padding-top: 2rem;
}

main p {
	text-wrap: pretty;
}

main > p:first-of-type {
	font-size: 1.2rem;
	line-height: 1.55;
}

/* Features become a grid of lit indicators */
#features + ul {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
	gap: 0.75rem;
	padding-left: 0;
	list-style: none;
}

#features + ul li {
	position: relative;
	padding: 1rem 1rem 1rem 2.4rem;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--panel);
	line-height: 1.45;
}

#features + ul li::before {
	content: "";
	position: absolute;
	left: 1rem;
	top: 1.35rem;
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
	background: var(--accent);
	box-shadow: 0 0 8px var(--accent);
}

/* Requirements read like a spec sheet, with dotted leaders */
#requirements + p + ul {
	padding-left: 0;
	list-style: none;
}

#requirements + p + ul li {
	display: flex;
	align-items: baseline;
	gap: 0.6rem;
	padding: 0.3rem 0;
	font-family: var(--mono);
	font-size: 0.85rem;
	color: var(--muted);
}

#requirements + p + ul li a {
	display: flex;
	flex: 1;
	align-items: baseline;
	gap: 0.6rem;
	color: var(--ink);
	text-decoration: none;
}

#requirements + p + ul li a::after {
	content: "";
	flex: 1;
	border-bottom: 1px dotted var(--line);
	transform: translateY(-0.25em);
}

#requirements + p + ul li a:hover {
	color: var(--link);
}

/* Distribution list */
#installation ~ ul li {
	padding: 0.25rem 0;
}

#installation ~ ul li::marker {
	color: var(--accent);
}

#installation ~ ul li a {
	font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* News: entries in a log                                               */
/* ------------------------------------------------------------------ */

.post {
	position: relative;
	margin: 0 0 1.75rem;
	padding: 0 0 0 1.4rem;
	border-left: 1px solid var(--line);
}

.post::before {
	content: "";
	position: absolute;
	left: -4px;
	top: 0.45rem;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--panel);
	border: 1px solid var(--muted);
}

main > .post:first-of-type::before {
	background: var(--led);
	border-color: var(--led);
	box-shadow: 0 0 10px var(--led);
}

.post time {
	display: block;
	color: var(--muted);
	font: 500 0.7rem/1.4 var(--mono);
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

.post h3 {
	margin: 0.35rem 0 0.6rem;
	font-size: 1.2rem;
	font-weight: 650;
	line-height: 1.3;
	letter-spacing: -0.01em;
	text-wrap: balance;
}

.post p,
.post ul {
	margin: 0 0 0.75rem;
}

.post ul {
	padding-left: 1.1rem;
}

.post li::marker {
	color: var(--accent);
}

.older summary {
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
	margin-bottom: 1.5rem;
	padding: 0.6rem 0.9rem;
	border: 1px solid var(--line);
	border-radius: 6px;
	color: var(--muted);
	font: 500 0.7rem/1 var(--mono);
	letter-spacing: 0.14em;
	text-transform: uppercase;
	cursor: pointer;
	list-style: none;
}

.older summary::-webkit-details-marker {
	display: none;
}

.older summary::before {
	content: "+";
	font-size: 0.9rem;
	color: var(--accent);
}

.older[open] summary::before {
	content: "\2212";
}

.older summary:hover {
	color: var(--accent);
	border-color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Footer                                                               */
/* ------------------------------------------------------------------ */

footer {
	max-width: 72rem;
	margin: 4rem auto 0;
	padding: 1.75rem clamp(0.25rem, 2vw, 3rem) 0.5rem;
	border-top: 1px solid var(--line);
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0.5rem 2rem;
	color: var(--muted);
	font: 400 0.72rem/1.6 var(--mono);
	letter-spacing: 0.03em;
}

footer p {
	margin: 0;
}

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

@keyframes pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.35; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25), 0 0 2px var(--led); }
}

@keyframes travel {
	0% { left: 0; opacity: 0; }
	15% { opacity: 1; }
	85% { opacity: 1; }
	100% { left: calc(100% - 5px); opacity: 0; }
}

@keyframes level {
	0% { transform: scaleY(0.12); }
	35% { transform: scaleY(0.55); }
	70% { transform: scaleY(0.32); }
	100% { transform: scaleY(0.88); }
}

@keyframes blink {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.45; }
}

/* one orchestrated entrance */
/* movement only: if the animation never runs, nothing stays hidden */
@keyframes rise {
	from { transform: translateY(14px); }
	to { transform: none; }
}

.brand > *,
.display,
nav {
	animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.brand > :nth-child(2) { animation-delay: 0.06s; }
.brand > :nth-child(3) { animation-delay: 0.12s; }
.brand > :nth-child(4) { animation-delay: 0.18s; }
.display { animation-delay: 0.22s; }
nav { animation-delay: 0.3s; }

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

	html {
		scroll-behavior: auto;
	}

	.meter i {
		transform: scaleY(calc(0.25 + mod(var(--i) * 0.37, 0.6)));
	}
}

/* ------------------------------------------------------------------ */
/* Narrow screens                                                       */
/* ------------------------------------------------------------------ */

@media (max-width: 60rem) {
	.panel {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas: "brand" "display" "nav";
	}

	main {
		grid-template-columns: minmax(0, 1fr);
	}

	main > *,
	main > h2 {
		grid-column: 1;
	}

	main > h2 {
		padding-top: 2.5rem;
		margin-bottom: 1rem;
	}

	main > h2 + *,
	main > h2 + ul {
		padding-top: 1rem;
		border-top: 0;
	}

	.meter {
		height: 3.25rem;
	}
}

@media (max-width: 30rem) {
	.chain .wire {
		min-width: 0.75rem;
	}

	.readout span:nth-child(2) {
		display: none;
	}
}
