/* The research page (research.js): the latest paper, then every paper by
   year down a spine that a liquid bar runs along, each opening into its
   page over the content panel (paper.css). Cards take M3's large corners
   (16px), as the project tiles do, so a paper grows from its place as a
   project does from its tile. */

.research-page {
	container: research / inline-size;
}

.research-note {
	display: flex;
	align-items: center;
	gap: var(--s2);
	margin: 0 0 var(--s5);
	font-size: 13px;
	color: var(--muted);
}

.research-note[hidden] {
	display: none;
}

.research-note svg {
	flex: none;
	width: 16px;
	height: 16px;
}

.research-retry,
.research-reset {
	appearance: none;
	padding: 4px 12px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: none;
	color: var(--text);
	font: inherit;
	font-size: 13px;
}

.research-retry:hover,
.research-reset:hover {
	background: color-mix(in srgb, var(--text) 8%, transparent);
}

/* --- What every paper shows ---------------------------------------------- */

/* A figure from the paper, on the page's background its colours were
   checked against, outlined. */
.research-figure {
	display: block;
	border: 1px solid var(--hairline);
	border-radius: var(--s3);
	background: var(--bg);
	overflow: hidden;
}

.research-figure-empty {
	display: grid;
	place-items: center;
	color: var(--muted);
}

.research-figure-empty svg {
	width: 28px;
	height: 28px;
}

/* Facts set apart by dots; a line that wraps starts with a fact, its dot
   cut off in the band left of the text. */
.research-overline {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	margin-left: calc(-1 * var(--s5));
	font-size: 12px;
	line-height: 16px;
	letter-spacing: 0.5px;
	color: var(--muted);
	clip-path: inset(0 0 0 var(--s5));
}

.research-overline > * {
	position: relative;
	padding-left: var(--s5);
	white-space: nowrap;
}

.research-overline > ::before {
	content: "·";
	position: absolute;
	left: var(--s2);
}

.research-summary {
	color: var(--muted);
}

/* Words found, in the text colour on the secondary container, which the
   muted summary's own colour doesn't reach 4.5:1 on. */
.research-summary mark,
.research-title mark,
.research-lead-title mark {
	border-radius: 3px;
	background: var(--selected);
	box-shadow: 0 0 0 2px var(--selected);
	color: var(--text);
}

.research-authors {
	font-size: 13px;
	line-height: 20px;
}

/* Pressed, a paper gives a little and springs back, as a tile does
   (research.js sets the springs). */
:is(.research-lead, .research-item) {
	--underline-rest: transparent;
	position: relative;
	color: var(--text);
	transition: scale var(--spring-release-duration, 400ms) var(--spring-release, ease);
}

:is(.research-lead, .research-item):active {
	scale: 0.985;
	transition: scale var(--spring-press-duration, 150ms) var(--spring-press, ease);
}

:is(.research-lead, .research-item):hover {
	color: var(--text);
}

/* The M3 state layer, lighter than M3's 8% and 10% where the summary's
   muted text would otherwise drop under 4.5:1 (on the lead's surface,
   past 4%). */
:is(.research-lead, .research-item)::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	border-radius: inherit;
	background: currentColor;
	opacity: 0;
	transition: opacity 150ms var(--ease-effects);
	pointer-events: none;
}

.research-item:hover::before {
	opacity: 0.06;
}

.research-item:active::before {
	opacity: 0.1;
}

.research-lead:hover::before {
	opacity: 0.04;
}

.research-lead:active::before {
	opacity: 0.06;
}

:is(.research-lead, .research-item):focus-visible {
	outline-offset: 2px;
}

/* --- The latest paper ------------------------------------------------------ */

/* M3's filled card: its figure, big and moving, beside what it found. */
.research-lead-cell {
	margin-bottom: var(--s7);
}

.research-lead-cell[hidden] {
	display: none;
}

.research-lead {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--s5);
	padding: var(--s3) var(--s3) var(--s5);
	border-radius: var(--s4);
	background: var(--surface);
}

.research-lead-figure {
	height: clamp(200px, 30vw, 300px);
}

.research-lead-text {
	display: grid;
	align-content: center;
	gap: var(--s2);
	padding-inline: var(--s3);
}

.research-latest {
	color: var(--ink-accent);
	font-weight: 700;
}

.research-lead-title {
	margin-top: var(--s1);
	font-size: 24px;
	line-height: 32px;
	font-weight: 700;
	text-wrap: balance;
}

.research-lead .research-summary {
	font-size: 15px;
	line-height: 24px;
}

.research-cta {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: var(--s2);
	color: var(--accent);
	font-size: 14px;
	line-height: 20px;
}

.research-cta svg {
	width: 16px;
	height: 16px;
	transition: translate 250ms cubic-bezier(0.2, 0, 0, 1);
}

.research-lead:hover .research-cta svg {
	translate: 4px 0;
}

@container research (min-width: 760px) {
	.research-lead {
		grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
		padding: var(--s3) var(--s5) var(--s3) var(--s3);
	}

	.research-lead-figure {
		height: clamp(240px, 26vw, 320px);
	}

	.research-lead-text {
		padding: var(--s4) 0;
	}

	.research-lead-title {
		font-size: 28px;
		line-height: 36px;
	}
}

/* --- Search and topics ------------------------------------------------------- */

.research-tools {
	display: grid;
	gap: var(--s4);
	margin-bottom: var(--s5);
}

.research-tools[hidden] {
	display: none;
}

/* M3's search bar: 56px, fully rounded, on the highest surface, the
   search icon leading and clearing trailing. */
.research-search {
	display: flex;
	align-items: center;
	gap: var(--s1);
	max-width: 520px;
	height: 56px;
	padding: 0 var(--s1) 0 var(--s4);
	border-radius: 28px;
	background: var(--surface);
	box-shadow: inset 0 0 0 1px var(--hairline);
	transition: box-shadow 150ms var(--ease-effects);
}

.research-search:focus-within {
	box-shadow: inset 0 0 0 2px var(--accent);
}

.research-search > svg {
	flex: none;
	width: 20px;
	height: 20px;
	color: var(--muted);
}

.research-search input {
	flex: 1 1 auto;
	min-width: 0;
	height: 100%;
	padding: 0 var(--s2);
	border: 0;
	background: none;
	color: var(--text);
	font: inherit;
	font-size: 16px;
	outline: none;
}

.research-search input::placeholder {
	color: var(--muted);
	opacity: 1;
}

.research-search input::-webkit-search-cancel-button {
	display: none;
}

.research-search-clear[hidden] {
	display: none;
}

/* M3's filter chips: 32px, 8px corners, outlined, and, chosen, in the
   secondary container with a check that grows in. */
.research-topic-chips {
	display: flex;
	flex-wrap: wrap;
	gap: var(--s2);
}

.research-chip {
	display: inline-flex;
	align-items: center;
	height: 32px;
	padding: 0 var(--s4);
	border: 1px solid var(--border);
	border-radius: var(--s2);
	background: none;
	color: var(--muted);
	font: inherit;
	font-size: 14px;
	line-height: 20px;
	letter-spacing: 0.1px;
	transition:
		background-color 200ms var(--ease-effects),
		border-color 200ms var(--ease-effects),
		color 200ms var(--ease-effects),
		padding 250ms cubic-bezier(0.2, 0, 0, 1);
}

.research-chip svg {
	width: 0;
	height: 18px;
	margin-right: 0;
	opacity: 0;
	transition:
		width 250ms cubic-bezier(0.2, 0, 0, 1),
		margin-right 250ms cubic-bezier(0.2, 0, 0, 1),
		opacity 150ms var(--ease-effects);
}

.research-chip:hover {
	background: color-mix(in srgb, var(--text) 8%, transparent);
	color: var(--text);
}

.research-chip[aria-pressed="true"] {
	padding-left: var(--s2);
	border-color: transparent;
	background: var(--selected);
	color: var(--text);
}

.research-chip[aria-pressed="true"] svg {
	width: 18px;
	margin-right: var(--s2);
	opacity: 1;
}

.research-count {
	margin: 0 0 var(--s4);
	font-size: 13px;
	line-height: 20px;
	color: var(--muted);
}

.research-empty {
	display: grid;
	justify-items: start;
	gap: var(--s3);
	padding: var(--s5) 0 var(--s7);
}

.research-empty[hidden],
.research-page .empty-state[hidden],
.research-count[hidden] {
	display: none;
}

.research-empty p {
	margin: 0;
	color: var(--muted);
}

/* --- Every paper, by year ------------------------------------------------------- */

/* The years stand in a column of their own, each staying in view while
   its papers pass, beside the spine the papers hang from. */
.research-index {
	--years: 0px;
	--spine: 0px;
	position: relative;
	padding-bottom: var(--s7);
}

.research-index[hidden] {
	display: none;
}

.research-index::before {
	content: "";
	position: absolute;
	top: var(--s3);
	bottom: var(--s7);
	left: var(--spine);
	width: 1px;
	background: var(--hairline);
}

/* The bar on it (tab-indicator.js), as tall as the paper pointed at. */
.research-indicator {
	position: absolute;
	top: 0;
	left: calc(var(--spine) - 1px);
	width: 4px;
	height: 100%;
	overflow: visible;
	color: var(--ink-accent);
	pointer-events: none;
}

.research-year {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	margin-bottom: var(--s5);
	padding: 0;
}

.research-year[hidden] {
	display: none;
}

.research-year-label {
	margin: 0 0 var(--s2) var(--s5);
	font-size: 14px;
	line-height: 20px;
	letter-spacing: 0.1px;
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}

.research-entries {
	display: grid;
	gap: var(--s2);
	margin: 0;
	padding: 0 0 0 var(--s4);
	list-style: none;
}

.research-entry[hidden] {
	display: none;
}

/* M3's list item, three lines and more, led by the paper's figure. On
   narrow pages the title stands beside the figure and the rest runs the
   full width under them, rather than in a sliver beside it. */
.research-item {
	display: grid;
	grid-template-columns: 88px minmax(0, 1fr);
	grid-template-areas:
		"figure title"
		"overline overline"
		"summary summary"
		"meta meta";
	align-items: start;
	gap: var(--s1) var(--s4);
	padding: var(--s3);
	border-radius: var(--s4);
}

.research-item .research-figure {
	grid-area: figure;
	height: 64px;
	margin-bottom: var(--s2);
}

.research-item-text {
	display: contents;
}

.research-item .research-overline {
	grid-area: overline;
}

.research-item .research-title {
	grid-area: title;
	align-self: center;
}

.research-item .research-summary {
	grid-area: summary;
}

.research-item .research-meta {
	grid-area: meta;
}

.research-title {
	font-size: 16px;
	line-height: 24px;
	font-weight: 700;
	text-wrap: pretty;
}

.research-item .research-summary {
	display: -webkit-box;
	font-size: 14px;
	line-height: 20px;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	overflow: hidden;
}

.research-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--s2) var(--s3);
	margin-top: var(--s1);
}

.research-topics {
	display: flex;
	flex-wrap: wrap;
	gap: var(--s1);
}

.research-topics span {
	padding: 0 var(--s2);
	border: 1px solid var(--hairline);
	border-radius: var(--s1);
	font-size: 12px;
	line-height: 20px;
	color: var(--muted);
}

@container research (min-width: 640px) {
	.research-index {
		--years: 72px;
		--spine: calc(var(--years) + var(--s5));
	}

	.research-year {
		grid-template-columns: var(--years) minmax(0, 1fr);
		column-gap: var(--s5);
	}

	.research-year-label {
		position: sticky;
		top: var(--s4);
		align-self: start;
		margin: var(--s3) 0 0;
		font-size: 28px;
		line-height: 36px;
		letter-spacing: 0;
		text-align: right;
	}

	.research-entries {
		padding-left: var(--s5);
	}

	.research-item {
		grid-template-columns: 184px minmax(0, 1fr);
		grid-template-areas: none;
		gap: var(--s5);
	}

	.research-item .research-figure {
		grid-area: auto;
		height: 116px;
		margin-bottom: 0;
	}

	.research-item-text {
		display: grid;
		gap: var(--s1);
		min-width: 0;
	}

	.research-item :is(.research-overline, .research-title, .research-summary, .research-meta) {
		grid-area: auto;
	}

	.research-item .research-title {
		align-self: auto;
	}

	.research-title {
		font-size: 18px;
		line-height: 26px;
	}

	.research-item .research-summary {
		-webkit-line-clamp: 2;
		line-clamp: 2;
	}
}

@media (prefers-reduced-motion: reduce) {
	:is(.research-lead, .research-item),
	:is(.research-lead, .research-item):active,
	:is(.research-lead, .research-item)::before,
	.research-cta svg,
	.research-search,
	.research-chip,
	.research-chip svg {
		transition: none;
	}

	:is(.research-lead, .research-item):active {
		scale: none;
	}
}
