/* A project's own page (page.js), grown from its tile (morph.js): its top
   app bar and tabs over the views, which are its overview (overview.css),
   and its code and history (code.css, commits.css). */

/* Set on the page and its cover every frame of the container transform
   (morph.js). Registered as not inherited, so changing them restyles
   only the element itself, not everything the page holds. */
@property --page-fill {
	syntax: "<number>";
	inherits: false;
	initial-value: 1;
}

@property --hero-fill {
	syntax: "<number>";
	inherits: false;
	initial-value: 1;
}

/* Text on the page (a project's, a research paper's, or the research
   listing's) meets WCAG's 4.5:1. The site's accent and muted colours do (theme.css), and so do
   dark Everforest's other accents; light Everforest's don't on its
   background, so there they give way to the text colour, and the meaning
   stays with words, signs and washes. */
:is(.project-page, .paper-page, .research-page) {
	--ink-accent: var(--accent);
	--ink-add: var(--green);
	--ink-del: var(--red);
	--ink-info: var(--blue);
	--ink-change: var(--yellow);
	--ink-quiet: var(--muted);
	/* What's selected (the open file, the shown form of a Markdown file)
	   sits on Everforest's bg_green, M3's secondary container. */
	--selected: #3c4841;
	/* Syntax, after Everforest's Vim colour scheme (highlight.js), with
	   comments in grey2 rather than grey1 for contrast. */
	--syntax-comment: var(--ink-quiet);
	--syntax-string: var(--green);
	--syntax-number: var(--purple);
	--syntax-keyword: var(--red);
	--syntax-storage: var(--orange);
	--syntax-type: var(--yellow);
	--syntax-function: var(--green);
	--syntax-constant: var(--aqua);
	--syntax-preproc: var(--purple);
	--syntax-operator: var(--orange);
	--syntax-variable: var(--blue);
	--syntax-tag: var(--orange);
	--syntax-attribute: var(--aqua);
	--syntax-key: var(--green);
	--syntax-heading: var(--red);
}

html[data-theme="light"]:not([data-browser="ladybird"]) :is(.project-page, .paper-page, .research-page) {
	--selected: #f3f5d9;
	--ink-add: var(--text);
	--ink-del: var(--text);
	--ink-info: var(--text);
	--ink-change: var(--text);
	--syntax-comment: var(--ink-quiet);
	--syntax-string: var(--text);
	--syntax-number: var(--text);
	--syntax-keyword: var(--text);
	--syntax-storage: var(--text);
	--syntax-type: var(--text);
	--syntax-function: var(--text);
	--syntax-constant: var(--text);
	--syntax-preproc: var(--text);
	--syntax-operator: var(--text);
	--syntax-variable: var(--text);
	--syntax-tag: var(--text);
	--syntax-attribute: var(--text);
	--syntax-key: var(--text);
	--syntax-heading: var(--text);
}

/* Laid over the whole content panel, under the panel's shading
   (layout.css). Opening, its colour turns from the tile's to the page's as
   it grows (morph.js): a project tile's surface, or nothing, for a paper
   listed without a fill of its own (--tile-fill). */
:is(.project-page, .paper-page) {
	position: absolute;
	inset: 0;
	z-index: 1;
	display: flex;
	flex-direction: column;
	background: color-mix(in srgb, var(--bg) calc(var(--page-fill, 1) * 100%), var(--tile-fill, var(--surface)));
	color: var(--text);
}

/* As the window springs past the panel's size it carries the page up and
   to the left a few pixels, past the panel's top left edges; its colour
   reaches on past the page's own right and bottom edges, so the panel
   stays covered there rather than showing the list behind. Only the
   window (morph.js) shows it, and only while it's bigger than the page. */
:is(.project-page, .paper-page).moving {
	box-shadow: 0 0 0 32px color-mix(in srgb, var(--bg) calc(var(--page-fill, 1) * 100%), var(--tile-fill, var(--surface)));
}

/* The tile's copy, riding the start and end of the container transform
   (morph.js). */
.page-ghost,
.page-ghost-container {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 3;
	pointer-events: none;
}

.page-ghost {
	list-style: none;
}

/* Where the tile sits in a container its styles ask about, the copy sits
   in a stand-in of the same width (morph.js). */
.page-ghost-container {
	height: 0;
}

/* The page's head: the way back and where the page sits, with the tabs
   beside them on one row, or under them on narrow pages, where M3 puts
   them. It has no fill of its own; content scrolling under it fades out
   over the views' 24px top margin rather than being cut off (--fade,
   page.js). */
.page-top {
	display: flex;
	flex: none;
	flex-wrap: wrap;
	align-items: center;
}

@property --fade {
	syntax: "<length>";
	inherits: false;
	initial-value: 0px;
}

.page-top.scrolled + .page-scroll {
	-webkit-mask-image: linear-gradient(to bottom, transparent, #000 var(--fade));
	mask-image: linear-gradient(to bottom, transparent, #000 var(--fade));
}

/* M3's small top app bar: 64px tall, the navigation icon leading with its
   glyph on the content's edge, then the way back to Projects. */
.page-bar {
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	gap: var(--s1);
	min-width: 0;
	height: 64px;
	padding: 0 var(--s4) 0 calc(var(--page-pad) - var(--s2));
}

.page-back {
	color: var(--text);
}

.page-crumbs {
	display: flex;
	align-items: center;
	gap: var(--s2);
	min-width: 0;
	font-size: 16px;
	line-height: 24px;
	white-space: nowrap;
	color: var(--muted);
}

.page-crumbs [aria-current] {
	overflow: hidden;
	text-overflow: ellipsis;
	color: var(--text);
}

/* M3's primary tabs: title-small labels (14/20) in on-surface-variant,
   the open one in the primary colour over a 3px indicator as wide as its
   label and at least 24px. Fixed tabs share
   the widest one's width. Beside the bar they take its height and end on
   the content's edge; under it, M3's 48px, starting on that edge. */
.page-tabs {
	padding-right: calc(var(--page-pad) - var(--s4));
}

.page-tab-list {
	position: relative;
	display: inline-grid;
	grid-auto-columns: 1fr;
	grid-auto-flow: column;
}

/* The cursor's highlight wraps the label in a pill with room either side
   (cursor.js), rather than the whole tab. */
.page-tab {
	--cursor-pad: 6px 12px;
	--cursor-radius: 999px;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	height: 64px;
	padding: 0 var(--s4);
	border: 0;
	background: none;
	color: var(--muted);
	font-size: 14px;
	line-height: 20px;
	letter-spacing: 0.1px;
	white-space: nowrap;
}

.page-tab:hover,
.page-tab:focus-visible {
	color: var(--text);
}

.page-tab[aria-current="page"] {
	color: var(--ink-accent);
}

/* The state layer: the same pill around the label as the cursor's, held
   or hovered, rather than the whole tab. */
.page-tab > span {
	position: relative;
}

.page-tab > span::before {
	content: "";
	position: absolute;
	inset: -6px -12px;
	border-radius: 999px;
	background: currentColor;
	opacity: 0;
	transition: opacity 150ms var(--ease-effects);
	pointer-events: none;
}

.page-tab:hover > span::before {
	opacity: 0.08;
}

.page-tab:active > span::before {
	opacity: 0.12;
}

.page-tab:focus-visible {
	outline-offset: -3px;
}

/* The indicator, drawn over the tabs' foot (tab-indicator.js). */
.page-tab-indicator {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	overflow: visible;
	color: var(--ink-accent);
	pointer-events: none;
}

/* Each view lays out against the page's own size (code.css), and a view
   leaving is placed in it (.page-view-leaving). */
.page-scroll {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	padding: 0 var(--page-pad) var(--s7);
	overflow: auto;
	overscroll-behavior: contain;
	container: page / size;
}

.page-view[hidden] {
	display: none;
}

/* A view leaving for another tab, held in place over the one coming in
   (page.js). */
.page-view-leaving {
	position: absolute;
	overflow: clip;
	pointer-events: none;
}

@media (max-width: 719px) {
	.page-tabs {
		flex-basis: 100%;
		padding: 0 var(--page-pad);
	}

	.page-tab-list {
		margin-left: calc(var(--s4) * -1);
	}

	.page-tab {
		height: 48px;
	}
}

/* Under tabs, views start a step down from them. */
.project-page:has(.page-tabs) .page-view {
	padding-top: var(--s5);
}

/* Its scrollbar waits until the page has arrived (scrollbars.js draws over
   scroll containers only). */
html.custom-scrollbars :is(.project-page, .paper-page).moving .page-scroll {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.page-tab > span::before {
		transition: none;
	}
}
