/* A project's history (commits.js): its commits by day, and a commit with
   the files it changed and their diffs. */

.commit-day {
	margin: var(--s5) 0 var(--s2);
	font-size: 13px;
	font-weight: 400;
	color: var(--ink-quiet);
}

.commit-day:first-child {
	margin-top: 0;
}

/* A commit per row: its subject, who and when beneath it, and its short
   id at the end. */
.commit-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-areas: "subject sha" "by sha";
	align-items: center;
	column-gap: var(--s4);
	height: auto;
	min-height: 56px;
	padding-block: var(--s2);
}

.commit-subject {
	grid-area: subject;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Narrow, a subject takes two lines before it's cut. */
@container page (max-width: 599px) {
	.commit-subject {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		white-space: normal;
	}
}

/* A changed file's folder gives way before its name does. */
.diff-index .code-name {
	display: flex;
	min-width: 0;
}

.diff-dir,
.diff-name {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.diff-dir {
	flex: 0 1 auto;
	color: var(--ink-quiet);
}

.diff-name {
	flex: 0 0 auto;
	max-width: 100%;
}

.commit-by {
	grid-area: by;
	font-size: 12px;
	color: var(--ink-quiet);
}

.commit-sha {
	grid-area: sha;
	font: inherit;
	font-size: 12px;
	color: var(--ink-quiet);
}

.commit-more {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--s4);
	margin: var(--s5) 0 0;
	font-size: 13px;
	color: var(--ink-quiet);
}

/* A commit: its message, who and when, its ids, the files it changed, and
   the diff of each. */
.commit-title {
	margin: 0 0 var(--s3);
	font-size: 22px;
	line-height: 28px;
}

.commit-message {
	margin: 0 0 var(--s4);
	max-width: 80ch;
	white-space: pre-wrap;
	color: var(--ink-quiet);
}

.commit-meta {
	margin: 0 0 var(--s4);
	font-size: 13px;
	color: var(--ink-quiet);
}

.commit-meta span {
	color: var(--text);
}

.commit-ids {
	display: flex;
	flex-wrap: wrap;
	gap: var(--s2) var(--s6);
	margin: 0 0 var(--s5);
	font-size: 13px;
}

.commit-ids div {
	display: flex;
	align-items: center;
	gap: var(--s3);
}

.commit-ids dt {
	color: var(--ink-quiet);
}

.commit-ids dd {
	display: flex;
	align-items: center;
	gap: var(--s2);
	margin: 0;
	min-width: 0;
}

.commit-ids code,
.code-meta code {
	font: inherit;
	overflow-wrap: anywhere;
}

.diff-index {
	margin-bottom: var(--s5);
}

button.code-row {
	appearance: none;
	width: 100%;
	font: inherit;
	font-size: 14px;
	text-align: left;
}

.diff-plus {
	color: var(--ink-add);
}

.diff-minus {
	color: var(--ink-del);
}

/* Dark Everforest's red falls just short of 4.5:1 on the surface a file's
   head sits on; a quarter of the way to the text colour, it reaches 4.9. */
.diff-head .diff-minus {
	color: color-mix(in srgb, var(--ink-del) 75%, var(--text));
}

.diff-status {
	flex: none;
	font-size: 12px;
	color: var(--ink-quiet);
}

.diff-index .diff-status {
	width: 1.5em;
	text-align: center;
}

.diff-added {
	color: var(--ink-add);
}

.diff-deleted {
	color: var(--ink-del);
}

.diff-renamed,
.diff-copied {
	color: var(--ink-info);
}

.diff-modified,
.diff-type-changed {
	color: var(--ink-change);
}

/* A file's block rounds everything in it to its corners, so its head
   alone, when the file is folded or folding, keeps them too. It clips
   rather than hides, so the head can still stick. */
.diff-file {
	margin-top: var(--s4);
	border: 1px solid var(--hairline);
	border-radius: var(--s4);
	overflow: clip;
}

/* Each file's name stays in view while its changes scroll past, below the
   fade under the page's head. */
.diff-head {
	position: sticky;
	top: var(--s5);
	z-index: 1;
	display: flex;
	align-items: center;
	gap: var(--s3);
	min-height: 48px;
	padding: 0 var(--s4) 0 var(--s2);
	background: var(--surface);
	font-size: 13px;
}

.diff-path {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: anywhere;
}

.diff-counts {
	flex: none;
	font-variant-numeric: tabular-nums;
}

/* The size of each file's change as five small blocks, after forges. */
.diff-blocks {
	display: inline-flex;
	flex: none;
	gap: 2px;
}

.diff-block {
	width: 8px;
	height: 8px;
	border-radius: 2px;
	background: color-mix(in srgb, var(--text) 16%, transparent);
}

.diff-block.added {
	background: var(--green);
}

.diff-block.removed {
	background: var(--red);
}

.diff-head .icon-button {
	width: 32px;
	height: 32px;
	margin-left: calc(var(--s2) * -1);
}

.diff-head .icon-button svg {
	width: 18px;
	height: 18px;
}

.diff-index .file-icon {
	width: 16px;
	height: 16px;
}

.commit-load.loading {
	opacity: 0.7;
	pointer-events: none;
}

.diff-toggle {
	appearance: none;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--muted);
}

.diff-toggle:hover:not(:disabled) {
	background: color-mix(in srgb, var(--text) 8%, transparent);
}

.diff-toggle:disabled {
	opacity: 0.38;
}

.diff-toggle svg {
	width: 18px;
	height: 18px;
	transition: rotate 200ms cubic-bezier(0.2, 0, 0, 1);
}

.diff-toggle[aria-expanded="true"] svg {
	rotate: 90deg;
}

.diff-body[hidden] {
	display: none;
}

.diff-empty {
	margin: 0;
	padding: var(--s4);
	text-align: center;
	font-size: 13px;
	color: var(--ink-quiet);
}

.diff-scroll {
	overflow-x: auto;
}

/* Lines with their old and new numbers, which come from attributes so
   they never copy; added lines on a green wash and removed ones on red. */
.diff-table {
	min-width: 100%;
	border-collapse: collapse;
	font-family: var(--font-mono);
	font-size: 13px;
	line-height: 20px;
}

.diff-table td {
	padding: 0;
	vertical-align: top;
}

.diff-num {
	width: 1%;
	padding-inline: var(--s3) !important;
	color: var(--ink-quiet);
	text-align: right;
	user-select: none;
	--selection-line: none;
}

.diff-num::before {
	content: attr(data-n);
}

.diff-code {
	padding-inline: var(--s2) var(--s4) !important;
	white-space: pre;
	tab-size: 4;
}

.diff-sign {
	display: inline-block;
	width: 1.5ch;
	user-select: none;
	--selection-line: none;
}

.diff-add {
	background: color-mix(in srgb, var(--green) 14%, transparent);
}

.diff-add .diff-num {
	background: color-mix(in srgb, var(--green) 10%, transparent);
}

.diff-del {
	background: color-mix(in srgb, var(--red) 14%, transparent);
}

.diff-del .diff-num {
	background: color-mix(in srgb, var(--red) 10%, transparent);
}

.diff-hunk td {
	padding-block: var(--s1) !important;
	background: color-mix(in srgb, var(--blue) 10%, transparent);
	color: var(--ink-quiet);
}

.diff-hunk span {
	color: var(--text);
}

.diff-eof {
	color: var(--ink-quiet);
}

@media (prefers-reduced-motion: reduce) {
	.diff-toggle svg {
		transition: none;
	}
}
