/* ------------------------------------------------------------------
   luketongue.com — one stylesheet, no build step.

   One type size everywhere (14px / 22px). Every row of the page sits on
   the same 12-column grid with a 22px gutter, so the gutter, the line
   height and the page padding are all the same unit.
   Black on white; white on black when the visitor prefers dark mode.
   ------------------------------------------------------------------ */

@font-face {
	font-family: "Inter";
	font-style: normal;
	font-weight: 350;
	font-display: swap;
	src: url("/resources/fonts/inter-350.woff2") format("woff2");
}

:root {
	color-scheme: light dark;
	--unit: 22px;
	--n-col: 3em;
	--bg: #fff;
	--bg-rgb: 255, 255, 255;
	--fg: #000;
	--muted: rgba(0, 0, 0, 0.5);   /* #808080 on white, 3.9:1 — labels only */
	--rule: rgba(0, 0, 0, 0.15);
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #000;
		--bg-rgb: 0, 0, 0;
		--fg: #fff;
		--muted: rgba(255, 255, 255, 0.55);   /* #8c8c8c on black, 5.1:1 */
		--rule: rgba(255, 255, 255, 0.2);
	}
}

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

html {
	background-color: var(--bg);
	-webkit-text-size-adjust: 100%;
}

body,
h1,
h2,
p,
ul,
li {
	margin: 0;
	padding: 0;
	font: inherit;
}

ul {
	list-style: none;
}

body {
	font-family: "Inter", Helvetica, Arial, sans-serif;
	font-weight: 350;
	font-size: 14px;
	line-height: var(--unit);
	color: var(--fg);
	background-color: var(--bg);
	padding: 0 var(--unit);
	min-height: 100vh;
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
}

a {
	color: inherit;
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
	text-underline-offset: 3px;
}

a:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

/* The grid. Three layouts share one gutter:
   - phones  (<600px): a narrow N. track + 5 columns
   - tablets (600-839px): a 6em N. track + 2fr 1fr 1fr, so the header fits one line
   - desktop (840px+): a 6em N. track + 11 columns */
.g {
	display: grid;
	grid-template-columns: var(--n-col) repeat(5, minmax(0, 1fr));
	column-gap: var(--unit);
	align-items: baseline;
}

.g > *,
.c-index__row > * {
	min-width: 0;
	overflow-wrap: anywhere;
}

/* Header: stuck to the top with a solid background so rows slide beneath it.
   Phones: name and role down the left, the two links stacked on the Type column. */
.c-head {
	position: sticky;
	top: 0;
	z-index: 2;
	padding: var(--unit) 0;
	background-color: var(--bg);
}

.c-head__name { grid-column: 1 / 5; grid-row: 1; white-space: nowrap; }
.c-head__role { grid-column: 1 / 5; grid-row: 2; white-space: nowrap; }
.c-head__nav  { grid-column: 5 / 7; grid-row: 1 / 3; align-self: start; display: flex; flex-direction: column; }

.c-head__nav a {
	white-space: nowrap;
}

/* Work index: a numbered table on the grid, centred between header and footer
   when the window is taller than the page */
.c-index {
	margin: auto 0;
	padding: calc(var(--unit) * 2) 0;
}

.c-index__labels {
	color: var(--muted);
}

.c-index__row {
	display: grid;
	grid-template-columns: var(--n-col) repeat(5, minmax(0, 1fr));
	column-gap: var(--unit);
	align-items: baseline;
}

.c-index__row:hover {
	text-decoration: none;
}

.c-index__row:hover .c-index__project,
.c-index__row:focus-visible .c-index__project {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.c-index__n       { grid-column: 1 / 2; color: var(--muted); }
.c-index__project { grid-column: 2 / 5; transition: color 0.3s; }

/* While one row is hovered or focused, the other project names drop to grey */
.c-index ul:hover .c-index__row:not(:hover) .c-index__project,
.c-index ul:focus-within .c-index__row:not(:focus-within) .c-index__project {
	color: var(--muted);
}
.c-index__design  { display: none; color: var(--muted); }
.c-index__type    { grid-column: 5 / 7; color: var(--muted); }
.c-index__site    { display: none; color: var(--muted); }

.c-index__row:hover .c-index__n,
.c-index__row:hover .c-index__design,
.c-index__row:hover .c-index__type,
.c-index__row:hover .c-index__site {
	color: var(--fg);
}

/* Footer: stuck to the bottom with a solid background */
.c-foot {
	position: sticky;
	bottom: 0;
	z-index: 2;
	padding: var(--unit) 0;
	background-color: var(--bg);
	color: var(--muted);
}

.c-foot__a { grid-column: 1 / 5; }
.c-foot__b { grid-column: 5 / 7; visibility: hidden; }

/* Back to top only when there is somewhere to go (class set by script) */
.is-scrollable .c-foot__b {
	visibility: visible;
}

/* Wash: the hovered site's screenshot blown up and blurred behind the whole
   page, under a scrim in the page colour so the text stays legible */
.c-wash {
	position: fixed;
	inset: 0;
	z-index: 0;
	overflow: hidden;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.7s ease;
	/* Keep the wash on its own compositor layer so Safari fades it rather
	   than painting the blur late and popping it in */
	will-change: opacity;
	transform: translateZ(0);
}

.c-wash.is-visible {
	opacity: 1;
	transition-delay: 0.15s;   /* let the bars clear first */
}

.c-wash__img {
	position: absolute;
	inset: -10%;
	width: 120%;
	height: 120%;
	object-fit: cover;
	filter: blur(48px) saturate(1.3);
	opacity: 0;
	transition: opacity 0.7s ease;
	will-change: opacity, filter;
	transform: translateZ(0);
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
}

.c-wash__img.is-front {
	opacity: 1;
}

.c-wash::after {
	content: "";
	position: absolute;
	inset: 0;
	background-color: var(--bg);
	opacity: 0.7;
}

/* Content sits above the wash; the sticky bars go clear while it shows.
   The bar and wash fades must not overlap or the bars read as a band:
   on the way in the bars clear in 0.15s before the wash starts, and on the
   way out they stay clear until the wash has fully gone. */
.c-head,
.c-foot {
	transition: background-color 0.2s ease 0.7s;
}

.c-index {
	position: relative;
	z-index: 1;
}

.is-washed .c-head,
.is-washed .c-foot {
	background-color: rgba(var(--bg-rgb), 0);
	transition: background-color 0.15s ease 0s;
}

@media (hover: none), (pointer: coarse) {
	.c-wash {
		display: none;
	}
}

/* Hover preview: a fixed box moved by JS, hidden on touch devices */
.c-preview {
	position: fixed;
	top: 0;
	left: 0;
	width: 400px;
	aspect-ratio: 16 / 10;
	z-index: 10;
	pointer-events: none;
	opacity: 0;
	scale: 0.96;
	transform: translate3d(-9999px, -9999px, 0);
	transition: opacity 0.2s, scale 0.3s ease-out;
	will-change: transform;
	background-color: var(--bg);
	border: 1px solid var(--rule);
	overflow: hidden;
}

.c-preview.is-visible {
	opacity: 1;
	scale: 1;
}

/* Two images stacked; the front one fades in over the other on each change */
.c-preview__img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity 0.4s ease;
}

.c-preview__img.is-front {
	opacity: 1;
}

@media (hover: none), (pointer: coarse) {
	.c-preview {
		display: none;
	}
}

/* Tablet: four columns, header on one line */
@media (min-width: 600px) {
	:root {
		--n-col: 6em;
	}

	.g,
	.c-index__row {
		grid-template-columns: var(--n-col) minmax(0, 2fr) minmax(0, 1.25fr) minmax(0, 1fr);
	}

	.c-head__name { grid-column: 1 / 2; }
	.c-head__role { grid-column: 2 / 3; grid-row: 1; }
	.c-head__nav  { grid-column: 3 / 5; grid-row: 1; align-self: baseline; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }

	@supports (grid-template-columns: subgrid) {
		.c-head__nav { grid-template-columns: subgrid; }
		.c-head__nav a:nth-child(1) { grid-column: 1 / 2; }
		.c-head__nav a:nth-child(2) { grid-column: 2 / 3; }
	}

	.c-index__row > *,
	.c-index__labels > * {
		white-space: nowrap;   /* the longest names overrun into the gutter rather than wrap */
	}

	.c-index__n       { grid-column: 1 / 2; }
	.c-index__project { grid-column: 2 / 3; }
	.c-index__design  { grid-column: 3 / 4; display: block; }
	.c-index__type    { grid-column: 4 / 5; }
	.c-index__site    { display: none; }

	.c-foot__a { grid-column: 1 / 3; }
	.c-foot__b { grid-column: 4 / 5; }
}

/* Desktop: twelve columns */
@media (min-width: 840px) {
	.g,
	.c-index__row {
		grid-template-columns: var(--n-col) repeat(11, minmax(0, 1fr));
	}

	.c-head__name { grid-column: 1 / 2; }
	.c-head__role { grid-column: 2 / 8; }
	.c-head__nav  { grid-column: 8 / 13; }

	@supports (grid-template-columns: subgrid) {
		.c-head__nav a:nth-child(1) { grid-column: 1 / 3; }
		.c-head__nav a:nth-child(2) { grid-column: 3 / 6; }
	}

	.c-index__n       { grid-column: 1 / 2; }
	.c-index__project { grid-column: 2 / 5; }
	.c-index__design  { grid-column: 5 / 8; }
	.c-index__type    { grid-column: 8 / 10; }
	.c-index__site    { grid-column: 10 / 13; display: block; }

	.c-foot__a { grid-column: 1 / 5; }
	.c-foot__b { grid-column: 10 / 13; }
}

@media (prefers-reduced-motion: reduce) {
	.c-preview,
	.c-preview__img,
	.c-wash,
	.c-wash__img,
	.c-head,
	.c-foot,
	.c-index__project {
		transition: none;
	}

	.c-preview {
		scale: 1;
	}
}

.u-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}
