/*
 * Look derived from Hermit-V2 (https://github.com/1bl4z3r/hermit-V2),
 * MIT License, Copyright (c) 2018-present, The Hermit-V2 Authors.
 */

:root {
	--bg: #494f5c;
	--bg-dark: #3b3e48;
	--text: #eee;
	--text-hover: #fff;
	--accent: #018472;
	--select: #7d828a;
	--scrollbar: #2c3e50;
	--scrollbar-thumb: #878787;
	--card-border: rgba(255, 255, 255, .15);
	--card-bg: rgba(255, 255, 255, .03);
	--term-bg: #33363f;
	--term-accent: #4cc2ae;
	--bar-h: 3.5rem;
	--fonts: "Trebuchet MS", Verdana, "Verdana Ref", "Segoe UI", Candara, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, sans-serif;
	--mono: ui-monospace, "Cascadia Code", "Fira Code", "JetBrains Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

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

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

html {
	background: var(--bg);
	line-height: 1.6;
	letter-spacing: .06em;
	scroll-behavior: smooth;
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	line-height: 1.5;
	color: var(--text);
	font-family: var(--fonts);
}

button {
	color: inherit;
	font: inherit;
}

img, svg, iframe { display: block; max-width: 100%; }

::selection { background: var(--select); }
::-webkit-scrollbar { width: 8px; height: 8px; background: var(--scrollbar); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); }
::-webkit-scrollbar-thumb:hover { background: var(--text); }

a {
	color: var(--text);
	text-decoration: none;
	transition: color .4s ease-out;
}

a:hover {
	color: var(--text-hover);
	text-shadow: 0 0 1px var(--text-hover);
}

blockquote {
	border-left: .25em solid;
	margin: 1em;
	padding: 0 1em;
	font-style: italic;
}

.icon {
	display: inline-block;
	vertical-align: -.125em;
	width: 1em;
	height: 1em;
}

.section-inner {
	margin: 0 auto;
	max-width: 1200px;
	width: 93%;
}

.thin {
	max-width: 720px;
	margin: auto;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.fade-in { animation: fadeIn 1s both; }
.fade-in.faster { animation-duration: .5s; }

@media (prefers-reduced-motion: reduce) {
	.fade-in { animation: none; }
	html { scroll-behavior: auto; }
}

/* ---------- Hero / top bar ---------- */

/*
 * The hero has three states, set on <html>:
 * - no class (no JS): full-height section, content below as usual
 * - .intro: full screen, page scroll locked until the first scroll gesture
 * - .compact: the same elements rearranged as a fixed bar at the top
 * main.js switches between .intro and .compact inside a View Transition,
 * which animates each element to its new position.
 */

#spotlight,
#hero {
	display: flex;
	min-height: 100vh;
	min-height: 100dvh;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	max-width: 93%;
	margin: auto;
	font-size: 1.5rem;
}

#hero { view-transition-name: hero; }

#home-title {
	margin: 0;
	font-size: 2em;
	text-align: center;
	view-transition-name: home-title;
}

#home-title a:hover { text-shadow: none; }

#home-subtitle {
	margin: 0 auto;
	padding-bottom: 1em;
	max-width: 90vw;
	min-height: 1.4em;
	line-height: 1.4;
	font-size: .7em;
	font-style: italic;
	opacity: .9;
	text-align: center;
	view-transition-name: home-subtitle;
}

/* Typewriter cursor, toggled by main.js */
#home-subtitle.typing::after,
#home-subtitle.typed::after {
	content: "";
	display: inline-block;
	width: .6em;
	height: 1.2em;
	margin-left: .1em;
	vertical-align: text-bottom;
	background: var(--accent);
}

#home-subtitle.typed::after { animation: blink 1s infinite; }

@keyframes blink { 50% { opacity: 0; } }

#home-links {
	display: flex;
	justify-content: center;
	gap: .4em;
	font-size: 1.4em;
	opacity: .8;
	view-transition-name: home-links;
}

/* In the intro the social links sit above the menu, as in Hermit */
#hero #home-nav { order: 1; }

#home-nav {
	opacity: .8;
	view-transition-name: home-nav;
}

#home-nav a {
	display: block;
	text-align: center;
	margin-top: .5em;
}

#home-nav a[hidden] { display: none; }

/* Scroll hint under the menu: appears after the intro, then pulses */
#scroll-hint {
	order: 2;
	margin-top: .6em;
	font-size: 1.4em;
	animation: fadeIn 1s 2.5s both, hint 2s 3.5s ease-in-out infinite;
}

#scroll-hint:hover { text-shadow: none; }

@keyframes hint {
	0%, 100% { opacity: .3; transform: translateY(0); }
	50% { opacity: .9; transform: translateY(.3em); }
}

html.compact #scroll-hint { display: none; }

html.intro { overflow: hidden; }

html.compact #hero {
	position: fixed;
	z-index: 10;
	top: 0;
	left: 0;
	right: 0;
	flex-direction: row;
	justify-content: flex-start;
	gap: 1.2em;
	min-height: var(--bar-h);
	max-width: none;
	margin: 0;
	padding: 0 max(3.5%, calc((100% - 1200px) / 2));
	font-size: 1rem;
	background: var(--bg-dark);
	box-shadow: 1px 2px 3px rgba(0, 0, 0, .45);
}

html.compact #home-title { font-size: 1.45em; }

html.compact #home-subtitle { display: none; }

html.compact #hero #home-nav {
	order: 0;
	display: flex;
	gap: .8em;
	font-size: 1.1em;
}

html.compact #home-nav a { margin: 0; }

html.compact #home-links {
	margin-left: auto;
	font-size: 1.3em;
}

/* Content: hidden behind the intro, fades in when the bar takes over */
html.intro .site-main,
html.intro #site-footer {
	opacity: 0;
	transform: translateY(2em);
}

html.compact .site-main,
html.compact #site-footer {
	transition: opacity .6s ease-out .15s, transform .6s ease-out .15s;
}

html.compact .site-main { padding-top: var(--bar-h); }

html.compact .site-main section { scroll-margin-top: calc(var(--bar-h) + 1em); }

::view-transition-group(*) {
	animation-duration: .55s;
	animation-timing-function: cubic-bezier(.4, 0, .2, 1);
}

/* The menu changes shape (column <-> row): swap it instead of cross-fading */
::view-transition-old(home-nav) { animation-duration: .15s; }
::view-transition-new(home-nav) { animation-delay: .3s; animation-duration: .25s; }

@media (max-width: 420px) {
	html.compact #hero { gap: .8em; }
	html.compact #home-title { font-size: 1.25em; }
	html.compact #hero #home-nav { font-size: 1em; gap: .6em; }
	html.compact #home-links { font-size: 1.15em; gap: .3em; }
}

@media (prefers-reduced-motion: reduce) {
	#scroll-hint { animation: none; opacity: .6; }
	html.compact .site-main,
	html.compact #site-footer { transition: none; }
}

/* ---------- Main ---------- */

.site-main section { margin-top: 3em; }

.site-main section > h2 {
	display: inline-block;
	padding-bottom: .15em;
	border-bottom: 2px solid var(--accent);
}

.content a {
	word-wrap: break-word;
	box-shadow: inset 0 -4px 0 var(--accent);
	transition: box-shadow .3s ease;
}

.content a:hover { box-shadow: inset 0 calc(-1.5em - 5px) 0 var(--accent); }

.content ul {
	padding: 0;
	margin-left: 1.8em;
}

@media (min-width: 1800px) { .thin { max-width: 960px; } }

/* ---------- Projects ---------- */

.projects-featured {
	display: grid;
	gap: 1.2em;
	margin-top: 1.2em;
}

.projects-secondary {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 1em;
	margin-top: 1.2em;
}

/* Desktop: all secondary projects on one row, in more compact cards */
@media (min-width: 800px) {
	.projects-secondary {
		grid-template-columns: repeat(4, 1fr);
		gap: .8em;
	}

	.projects-secondary .project-card {
		padding: 1em 1.1em;
		font-size: .9em;
	}
}

/* Set --frame on a card (style="--frame: #c0392b") to color its border */
.project-card {
	border: 1px solid var(--frame, var(--card-border));
	border-radius: 8px;
	padding: 1.2em 1.4em;
	background: var(--card-bg);
	transition: border-color .2s ease-out, box-shadow .2s ease-out;
}

.project-card:hover {
	border-color: var(--frame, var(--accent));
	box-shadow: 0 0 0 1px var(--frame, var(--accent));
}

.project-card.featured {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 1.2em;
	padding: 1.6em 1.8em;
	overflow: hidden;
}

.project-card-body {
	position: relative;
	z-index: 1;
	flex: 1;
	min-width: 0;
}

.project-card h3,
.project-card h4 {
	margin: 0 0 .4em;
	line-height: normal;
}

.project-card p {
	margin: 0;
	opacity: .85;
	font-size: .95em;
}

.project-card.featured p { font-size: 1em; }

.project-source {
	display: inline-block;
	margin-top: .6em;
	font-size: .8em;
	opacity: .75;
	transition: color .2s ease-out;
}

.project-source:hover { color: var(--frame, var(--accent)); }

.project-source + .project-source { margin-left: 1.2em; }

/*
 * Screenshot in a featured card, fading into the card.
 * Mobile: banner on top fading downwards. Desktop: on the right side
 * (left with .shot-left) fading towards the text.
 * --shot-pos on the card picks the visible part (default: top).
 */
.project-shot {
	order: -1;
	width: calc(100% + 3.6em);
	max-width: none;
	height: 180px;
	margin: -1.6em -1.8em 0;
	object-fit: cover;
	object-position: var(--shot-pos, center top);
	opacity: .85;
	transition: opacity .2s ease-out;
	-webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent);
	mask-image: linear-gradient(to bottom, #000 40%, transparent);
}

.project-card:hover .project-shot { opacity: 1; }

@media (min-width: 800px) {
	.project-card.featured:has(.project-shot) { min-height: 13em; }

	.project-card.featured:has(.project-shot) .project-card-body { max-width: 55%; }

	.project-card.shot-left:has(.project-shot) .project-card-body { margin-left: auto; }

	.project-shot {
		position: absolute;
		top: 0;
		right: 0;
		width: 50%;
		height: 100%;
		margin: 0;
		-webkit-mask-image: linear-gradient(to right, transparent, rgba(0, 0, 0, .5) 35%, #000 75%);
		mask-image: linear-gradient(to right, transparent, rgba(0, 0, 0, .5) 35%, #000 75%);
	}

	.shot-left .project-shot {
		right: auto;
		left: 0;
		-webkit-mask-image: linear-gradient(to left, transparent, rgba(0, 0, 0, .5) 35%, #000 75%);
		mask-image: linear-gradient(to left, transparent, rgba(0, 0, 0, .5) 35%, #000 75%);
	}
}

/* ---------- Mastodon feed (terminal) ---------- */

.term {
	margin-top: 1.2em;
	border: 1px solid var(--card-border);
	border-radius: 8px;
	overflow: hidden;
	background: var(--term-bg);
	font-family: var(--mono);
	font-size: .85em;
	letter-spacing: 0;
}

.term-bar {
	display: flex;
	align-items: center;
	gap: 1em;
	padding: .5em 1em;
	background: var(--bg-dark);
	border-bottom: 1px solid var(--card-border);
	font-size: .9em;
	opacity: .7;
}

.term-dots { display: flex; gap: .4em; }

.term-dots i {
	width: .7em;
	height: .7em;
	border-radius: 50%;
	background: var(--select);
}

.term-dots i:first-child { background: var(--accent); }

.term-body { padding: 1em 1.2em; }

.term-body p { margin: 0; }

.term-cursor {
	display: inline-block;
	width: .6em;
	height: 1.1em;
	vertical-align: text-bottom;
	background: var(--accent);
	animation: blink 1s infinite;
}

.toot { margin: 0 0 1.2em; }

.toot-meta { opacity: .75; }

.toot-meta a { color: var(--term-accent); }

.toot-meta a:hover { color: var(--text-hover); }

/* Toot text, indented under its header like command output */
.toot-text {
	margin-top: .3em;
	padding-left: 1em;
	border-left: 2px solid var(--card-border);
	overflow-wrap: anywhere;
}

.toot-text p + p { margin-top: .6em; }

.toot-text a { text-decoration: underline; text-decoration-color: var(--accent); }

.toot-text summary { cursor: pointer; opacity: .8; }

.toot-text details[open] summary { margin-bottom: .4em; }

@media (prefers-reduced-motion: reduce) {
	.term-cursor { animation: none; }
}

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

#site-footer {
	text-align: center;
	font-size: .8em;
	margin-top: 64px;
	margin-bottom: 2em;
}

#site-footer p { margin: 0; }

/* ---------- 404 ---------- */

#spotlight.error-404 {
	flex-direction: row;
	line-height: normal;
}

.img-404 svg {
	width: 180px;
	height: auto;
}

.banner-404 { margin-left: 2em; }

.banner-404 h1 {
	font-size: 3em;
	margin: .5rem 0;
}

.banner-404 p { margin-top: 0; }

.btn-404 a {
	display: inline-flex;
	align-items: center;
	gap: .5em;
	font-size: .8em;
	border: 2px solid var(--text);
	border-radius: 5px;
	padding: 5px;
	transition-property: color, border-color;
}

.btn-404 a:hover { border-color: var(--text-hover); }

@media (max-width: 760px) {
	#spotlight.error-404 {
		flex-direction: column;
		text-align: center;
	}

	.banner-404 { margin: 0; }
}
