/* The /projects/ page (templates/projects.html, js/projects.js): a bento grid
   of project cards. Each card sets --brand, which tints its header, its hover
   glow and its link hover colour. The micro-animations run while the card
   has .pj-play: on hover with a mouse, or while in view on touch screens. */

main:has(> .projects) {
	max-width: 64rem;
}

.projects {
	--pj-card: color-mix(in srgb, var(--bg-color) 30%, white);
	--pj-line: rgb(0 0 0 / 0.08);
	--pj-line-2: rgb(0 0 0 / 0.14);
	--pj-shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 8px 24px -12px rgb(0 0 0 / 0.14);
	--pj-shadow-hi: 0 2px 4px rgb(0 0 0 / 0.05), 0 22px 44px -18px rgb(0 0 0 / 0.28);
	--pj-spot: 16%;
	--pj-contain-bg: radial-gradient(100% 120% at 50% 0%, #ffffff, #eef1f7);
}

@media (prefers-color-scheme: dark) {
	.projects {
		--pj-card: color-mix(in srgb, var(--bg-color) 94%, white);
		--pj-line: rgb(255 255 255 / 0.07);
		--pj-line-2: rgb(255 255 255 / 0.14);
		--pj-shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px -12px rgb(0 0 0 / 0.6);
		--pj-shadow-hi: 0 2px 4px rgb(0 0 0 / 0.3), 0 22px 44px -18px rgb(0 0 0 / 0.85);
		--pj-spot: 22%;
		--pj-contain-bg: radial-gradient(100% 120% at 50% 0%, #1a2142, #0b0e19);
	}
}

.pj-intro h1 {
	margin: 0 0 0.6rem;
	letter-spacing: -0.02em;
}

.pj-intro p {
	margin: 0;
	max-width: 36rem;
	color: var(--fg-muted-5);
}

/* ---------- filter ---------- */

.pj-filter {
	display: inline-flex;
	position: relative;
	margin-top: 2rem;
	border: 1px solid var(--pj-line);
	border-radius: 999px;
	background: color-mix(in srgb, var(--fg-color) 5%, transparent);
	padding: 4px;
}

.pj-filter[hidden] {
	display: none;
}

.pj-filter button {
	position: relative;
	z-index: 1;
	cursor: pointer;
	margin: 0;
	box-shadow: none;
	border: 0;
	border-radius: 999px;
	background: none;
	padding: 0.55rem 0.95rem;
	color: var(--fg-muted-5);
	font: 600 0.85rem/1 inherit;
	font-family: inherit;
	transition: color 0.2s;
}

.pj-filter button:hover {
	background: none;
	color: var(--fg-color);
}

.pj-filter button[aria-pressed="true"] {
	color: var(--fg-color);
}

.pj-filter button:focus-visible {
	outline: 2px solid var(--accent-color);
	outline-offset: 1px;
}

.pj-filter button span {
	margin-left: 0.3rem;
	color: var(--fg-muted-4);
	font-weight: 500;
	font-variant-numeric: tabular-nums;
}

.pj-pill {
	position: absolute;
	top: 4px;
	bottom: 4px;
	left: 0;
	box-shadow: var(--pj-shadow);
	border-radius: 999px;
	background: var(--pj-card);
	width: 0;
	transition: transform 0.35s cubic-bezier(0.3, 1.3, 0.5, 1), width 0.35s cubic-bezier(0.3, 1.3, 0.5, 1);
}

/* ---------- grid + cards ---------- */

.pj-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	grid-auto-flow: dense;
	gap: 1rem;
	margin-top: 1.25rem;
}

.pj-filter[hidden] + .pj-grid {
	margin-top: 2.25rem;
}

.pj-card {
	--rx: 0deg;
	--ry: 0deg;
	--lift: 0px;
	--mx: 50%;
	--my: 50%;
	display: flex;
	position: relative;
	flex-direction: column;
	transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry)) translateY(var(--lift));
	transition: transform 0.25s ease-out, box-shadow 0.25s;
	margin: 0;
	box-shadow: var(--pj-shadow);
	border: 1px solid var(--pj-line);
	border-radius: 22px;
	background: var(--pj-card);
	overflow: hidden;
}

.pj-card[hidden] {
	display: none;
}

.pj-wide {
	grid-column: span 2;
}

.pj-js .pj-card[data-detail] {
	cursor: pointer;
}

.pj-card.pj-hot {
	--lift: -4px;
	transition: transform 0.08s linear, box-shadow 0.25s;
	box-shadow: var(--pj-shadow-hi);
}

/* Cursor spotlight and border glow, in the project's colour. */
.pj-card::before,
.pj-card::after {
	position: absolute;
	inset: 0;
	opacity: 0;
	z-index: 3;
	transition: opacity 0.3s;
	pointer-events: none;
	content: "";
}

.pj-card::before {
	background: radial-gradient(420px circle at var(--mx) var(--my), color-mix(in srgb, var(--brand) var(--pj-spot), transparent), transparent 45%);
}

.pj-card::after {
	border-radius: inherit;
	background: radial-gradient(260px circle at var(--mx) var(--my), var(--brand), transparent 70%);
	padding: 1px;
	mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.pj-card.pj-hot::before,
.pj-card.pj-hot::after {
	opacity: 1;
}

.pj-top {
	display: grid;
	position: relative;
	place-items: center;
	background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--brand) 24%, var(--pj-card)), color-mix(in srgb, var(--brand) 10%, var(--pj-card)) 60%, var(--pj-card));
	height: 190px;
	overflow: hidden;
}

.pj-dots::after {
	position: absolute;
	inset: 0;
	background-image: radial-gradient(color-mix(in srgb, var(--fg-color) 10%, transparent) 1px, transparent 1px);
	background-size: 14px 14px;
	content: "";
	mask: linear-gradient(black, transparent);
}

.pj-has-banner {
	display: block;
	background: #0b0e19;
}

.pj-top img.pj-banner {
	position: absolute;
	inset: 0;
	transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
	margin: 0;
	box-shadow: none;
	border-radius: 0;
	background: none;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.pj-contain {
	background: var(--pj-contain-bg);
}

.pj-top.pj-contain img.pj-banner {
	object-fit: contain;
}

.pj-hot .pj-top img.pj-banner {
	transform: scale(1.04);
}

.pj-app {
	position: relative;
	z-index: 1;
	transition: transform 0.4s cubic-bezier(0.3, 1.4, 0.5, 1);
	box-shadow: 0 12px 30px -10px color-mix(in srgb, var(--brand) 75%, transparent), inset 0 0 0 1px var(--pj-line);
	border-radius: 21px;
	width: 84px;
	height: 84px;
	overflow: hidden;
}

.pj-app svg {
	display: block;
	width: 100%;
	height: 100%;
}

.pj-hot .pj-app {
	transform: translateY(-4px) scale(1.06);
}

.pj-body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 0.55rem;
	padding: 1rem 1.15rem 1.15rem;
}

.pj-head {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 0.15rem 0.6rem;
}

.pj-meta {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.projects .pj-body h2,
.projects .pj-d-title {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
	font-size: 1.08rem;
	letter-spacing: normal;
}

.pj-yr {
	color: var(--fg-muted-4);
	font-weight: 500;
	font-size: 0.8rem;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.pj-star {
	display: inline-flex;
	align-items: center;
	border-radius: 999px;
	background: rgb(240 165 0 / 0.14);
	padding: 0.1rem 0.45rem;
	color: #a86b00;
	font-weight: 650;
	font-size: 0.74rem;
	white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
	.pj-star {
		color: #ffc847;
	}
}

.pj-body p {
	margin: 0;
	color: var(--fg-muted-5);
	font-size: 0.92rem;
}

.pj-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin-top: auto;
	padding-top: 0.35rem;
}

.projects .pj-links a {
	position: relative;
	z-index: 4;
	transition: border-color 0.15s, color 0.15s, background-color 0.15s;
	border: 1px solid var(--pj-line-2);
	border-radius: 999px;
	padding: 0.32rem 0.7rem;
	color: var(--fg-color);
	font-weight: 600;
	font-size: 0.82rem;
	text-decoration: none;
}

.projects .pj-links a:hover {
	border-color: var(--brand);
	background: none;
	color: var(--brand);
}

.projects .pj-links a.pj-primary {
	border-color: var(--fg-color);
	background: var(--fg-color);
	color: var(--bg-color);
}

.projects .pj-links a.pj-primary:hover {
	border-color: var(--brand);
	background: var(--brand);
	color: #fff;
}

.projects .pj-links a:focus-visible {
	outline: 2px solid var(--brand);
	outline-offset: 2px;
}

/* "Details →", added by js/projects.js; shown on hover or keyboard focus. */
.projects .pj-hint {
	position: absolute;
	cursor: pointer;
	margin: 0;
	box-shadow: none;
	border: 0;
	border-radius: 999px;
	background: none;
	padding: 0.2rem 0.4rem;
	font-family: inherit;
	right: 1rem;
	bottom: 1.05rem;
	opacity: 0;
	z-index: 4;
	transform: translateX(-4px);
	transition: 0.25s;
	color: var(--brand);
	font-weight: 600;
	font-size: 0.78rem;
}

.pj-hot .pj-hint,
.projects .pj-hint:focus-visible {
	opacity: 1;
	transform: none;
}

.projects .pj-hint:focus-visible {
	outline: 2px solid var(--brand);
}

.projects .pj-more {
	justify-content: center;
	align-items: center;
	gap: 0.5rem;
	box-shadow: none;
	border-style: dashed;
	background: transparent;
	padding: 1.5rem;
	min-height: 220px;
	color: var(--fg-color);
	text-align: center;
	text-decoration: none;
	--brand: var(--accent-color);
}

.pj-more small {
	color: var(--fg-muted-4);
	font-weight: 500;
}

.pj-more svg {
	transition: transform 0.4s cubic-bezier(0.3, 1.4, 0.5, 1);
	fill: var(--fg-muted-5);
	width: 28px;
	height: 28px;
}

.pj-more.pj-hot svg {
	transform: rotate(-12deg) scale(1.15);
}

/* ---------- per-project micro-animations ---------- */

/* rllvm: a command types itself out over the banner. */
.pj-term {
	position: absolute;
	bottom: 0.8rem;
	left: 1rem;
	opacity: 0;
	z-index: 2;
	transform: translateY(6px);
	transition: 0.3s;
	border-radius: 8px;
	background: rgb(11 14 25 / 0.88);
	padding: 0.35rem 0.6rem;
	color: #e1e8ff;
	font: 600 0.78rem var(--font-monospace-code, ui-monospace), monospace;
	white-space: nowrap;
}

.pj-cmd {
	display: inline-block;
	vertical-align: bottom;
	width: 0;
	overflow: hidden;
}

.pj-out {
	opacity: 0;
	color: #f0a500;
}

.pj-play .pj-term {
	opacity: 1;
	transform: none;
}

.pj-play .pj-cmd {
	animation: pj-type 1.1s steps(var(--n)) 0.15s forwards;
}

.pj-play .pj-out {
	animation: pj-fade 0.3s 1.4s forwards;
}

@keyframes pj-type {
	to { width: calc(var(--n) * 1ch); }
}

@keyframes pj-fade {
	to { opacity: 1; }
}

/* Chromatron: a red, green and blue beam sweeps across the banner. */
.pj-sweep {
	position: absolute;
	inset: 0;
	opacity: 0;
	z-index: 1;
	mix-blend-mode: screen;
	background: linear-gradient(105deg, transparent 40%, rgb(255 60 80 / 0.35) 46%, rgb(40 255 140 / 0.35) 50%, rgb(60 110 255 / 0.35) 54%, transparent 60%);
	background-position: 120% 0;
	background-size: 250% 100%;
	pointer-events: none;
}

.pj-play .pj-sweep {
	animation: pj-sweep 1.6s cubic-bezier(0.3, 0.1, 0.3, 1) forwards;
}

@keyframes pj-sweep {
	0% { opacity: 1; background-position: 120% 0; }
	85% { opacity: 1; }
	100% { opacity: 0; background-position: -30% 0; }
}

/* Grammar-Mutator: two leaves swap places, a mutation. */
.pj-play .gm-a { animation: pj-swap-a 2.4s ease-in-out infinite; }
.pj-play .gm-b { animation: pj-swap-b 2.4s ease-in-out infinite; }
.pj-play .gm-root { transform-origin: 32px 15px; animation: pj-pulse 2.4s ease-in-out infinite; }

@keyframes pj-swap-a {
	0%, 15%, 90%, 100% { transform: none; }
	40%, 65% { transform: translate(35px, 0); }
}

@keyframes pj-swap-b {
	0%, 15%, 90%, 100% { transform: none; }
	40%, 65% { transform: translate(-35px, 0); }
}

@keyframes pj-pulse {
	0%, 100% { transform: scale(1); }
	40% { transform: scale(1.18); }
}

/* my-resume: the ring rides the timeline spine. */
.pj-play .rs-ring { animation: pj-ride 2.2s ease-in-out infinite; }

@keyframes pj-ride {
	0%, 100% { transform: translateY(0); }
	30% { transform: translateY(-14px); }
	70% { transform: translateY(14px); }
}

/* my-resume's mascot Duna (content/projects/duna.svg, from the my-resume
   site) sits beside the icon, breathing and blinking; on hover she waves. */
.pj-mascot {
	--coat: #9aa3ad;
	--stripe: #59626d;
	--light: #eceff2;
	--iris: #e3a72f;
	--nose: #e48b8b;
	--cat-edge: transparent;
	--cat-shadow: rgb(29 35 43 / 0.13);
	position: absolute;
	bottom: 10px;
	left: calc(50% + 54px);
	z-index: 1;
	width: 84px;
	transition: transform 0.4s cubic-bezier(0.3, 1.4, 0.5, 1);
}

@media (prefers-color-scheme: dark) {
	.pj-mascot {
		--cat-edge: rgb(255 255 255 / 0.2);
		--cat-shadow: rgb(0 0 0 / 0.35);
	}
}

.pj-mascot svg {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
}

.pj-mascot .cat-o {
	stroke: var(--cat-edge);
	stroke-width: 1.5;
	stroke-linejoin: round;
}

.pj-mascot .cat-ground {
	fill: var(--cat-shadow);
}

.pj-mascot .cat-tail {
	transform-origin: 92px 150px;
	animation: pj-wag 1.8s ease-in-out infinite;
}

.pj-mascot .cat-breath {
	transform-origin: 70px 182px;
	animation: pj-breathe 3s ease-in-out infinite;
}

.pj-mascot .cat-eye {
	transform-box: fill-box;
	transform-origin: center;
	animation: pj-cat-blink 4.5s infinite;
}

.pj-mascot .cat-wave,
.pj-mascot .cat-lids {
	display: none;
}

.pj-play .pj-mascot .cat-wave {
	display: inline;
	transform-origin: 88px 134px;
	animation: pj-wave 1.2s ease-in-out infinite;
}

.pj-play .pj-mascot .cat-paw-r {
	opacity: 0;
}

.pj-hot .pj-mascot {
	transform: translateY(-3px);
}

@keyframes pj-wag {
	50% { transform: rotate(10deg); }
}

@keyframes pj-breathe {
	50% { transform: scale(1.015, 0.99); }
}

@keyframes pj-cat-blink {
	0%, 93%, 100% { transform: scaleY(1); }
	96% { transform: scaleY(0.1); }
}

@keyframes pj-wave {
	0%, 100% { transform: rotate(-4deg); }
	50% { transform: rotate(14deg); }
}

/* cairn: the stones are stacked again, one at a time. */
.pj-play .st { animation: pj-drop 0.55s cubic-bezier(0.3, 1.5, 0.6, 1) backwards; }
.pj-play .st2 { animation-delay: 0.12s; }
.pj-play .st3 { animation-delay: 0.24s; }
.pj-play .st4 { animation-delay: 0.36s; }
.pj-play .st5 { animation-delay: 0.5s; }

@keyframes pj-drop {
	from { transform: translateY(-22px); opacity: 0; }
}

/* HTB: the cursor blinks and the flag goes up. */
.htb-cur { animation: pj-blink 1s steps(1) infinite; }
.htb-flag { transform: translateY(16px); transition: transform 0.7s cubic-bezier(0.3, 1.4, 0.5, 1) 0.15s; }
.pj-play .htb-flag { transform: none; }

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

/* ---------- detail sheet ---------- */

/* The theme's normalize makes dialogs position: absolute, which leaves a
   modal at the top of the document instead of over the viewport. */
.pj-dialog {
	position: fixed;
	inset: 0;
	margin: auto;
	height: fit-content;
	border: 0;
	background: none;
	padding: 0;
	width: 100%;
	max-width: min(100% - 2rem, 40rem);
	max-height: min(100% - 2rem, 46rem);
	overflow: visible;
	color: var(--fg-color);
}

.pj-dialog::backdrop {
	backdrop-filter: blur(6px);
	background: rgb(0 0 0 / 0.35);
}

.pj-sheet {
	display: flex;
	position: relative;
	flex-direction: column;
	box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.5);
	border: 1px solid var(--pj-line);
	border-radius: 24px;
	background: var(--pj-card);
	max-height: inherit;
	overflow: hidden;
}

.pj-dialog[open] .pj-sheet {
	animation: pj-rise 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

@keyframes pj-rise {
	from { transform: translateY(24px) scale(0.97); opacity: 0; }
}

.pj-sheet .pj-top {
	flex: none;
	height: 220px;
}

.pj-scroll {
	padding: 1.25rem 1.5rem 1.5rem;
	overflow: auto;
}

.projects .pj-sheet .pj-d-title {
	font-size: 1.5rem;
	letter-spacing: -0.01em;
}

.pj-sheet .pj-kicker {
	margin: 0.2rem 0 1rem;
	color: var(--fg-muted-4);
	font-size: 0.85rem;
}

.pj-sheet p {
	margin: 0 0 0.9rem;
	color: var(--fg-muted-5);
}

.pj-sheet img.pj-shot {
	display: block;
	margin: 0 0 1rem;
	box-shadow: none;
	border: 1px solid var(--pj-line);
	border-radius: 14px;
	width: 100%;
	height: auto;
}

.pj-facts {
	display: grid;
	gap: 0.45rem;
	margin: 0 0 1rem;
	padding: 0;
	list-style: none;
}

.pj-facts li {
	display: flex;
	gap: 0.6rem;
	margin: 0;
	color: var(--fg-muted-5);
	font-size: 0.92rem;
}

.pj-facts li::before {
	flex: none;
	margin-top: 0.55rem;
	border-radius: 50%;
	background: var(--brand);
	width: 6px;
	height: 6px;
	content: "";
}

.pj-parts {
	display: grid;
	gap: 0.5rem;
}

.pj-parts > div {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	border-radius: 14px;
	background: color-mix(in srgb, var(--fg-color) 4%, transparent);
	padding: 0.7rem 0.8rem;
}

.pj-parts b {
	display: block;
}

.pj-parts span {
	color: var(--fg-muted-5);
	font-size: 0.85rem;
}

.pj-parts .pj-links {
	flex-wrap: nowrap;
	margin: 0 0 0 auto;
	padding: 0;
}

.projects .pj-close {
	position: absolute;
	top: 0.8rem;
	right: 0.8rem;
	z-index: 5;
	backdrop-filter: blur(6px);
	cursor: pointer;
	margin: 0;
	box-shadow: none;
	border: 0;
	border-radius: 50%;
	background: rgb(0 0 0 / 0.45);
	padding: 0;
	width: 34px;
	height: 34px;
	color: #fff;
	font-size: 1rem;
	line-height: 34px;
}

::view-transition-group(*) {
	animation-duration: 0.38s;
	animation-timing-function: cubic-bezier(0.2, 0.9, 0.3, 1);
}

@media (max-width: 760px) {
	.pj-grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.pj-wide {
		grid-column: auto;
	}

	.pj-top {
		height: 160px;
	}

	.pj-filter:not([hidden]) {
		display: flex;
		width: 100%;
	}

	.pj-filter button {
		flex: 1;
		padding-inline: 0.3rem;
	}

	/* The sheet becomes a bottom sheet. */
	.pj-dialog {
		margin: auto 0 0;
		max-width: 100%;
		max-height: 88vh;
	}

	.pj-sheet {
		border-radius: 24px 24px 0 0;
	}

	.pj-parts > div {
		flex-wrap: wrap;
	}

	.pj-parts .pj-links {
		margin: 0;
	}

	@keyframes pj-rise {
		from { transform: translateY(100%); }
	}
}

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

	.pj-card {
		transform: none !important;
	}

	.htb-flag {
		transform: none;
	}

	.pj-play .pj-cmd {
		width: auto;
	}

	.pj-play .pj-out {
		opacity: 1;
	}

	.pj-play .pj-mascot .cat-wave {
		transform: rotate(8deg);
	}
}

/* Inline code in the summaries: keep the theme's chip, drop its red. */
.projects code:not(pre code) {
	color: inherit;
}

.projects .pj-close:focus {
	outline: none;
}

.projects .pj-close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}
