/* What a project's code and history views share (ui.js): the head with
   where the view is and what it holds, the branch or tag button, rows of
   files, notes, the outlined button, and the loading placeholder. */

/* Where the view is (its branch or tag, and the path) and what it holds
   (counts and actions), on one row, or two when the page is narrow. */
.code-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--s2) var(--s4);
	min-height: 40px;
	margin-bottom: var(--s3);
}

.code-where {
	display: flex;
	flex: 1 1 320px;
	align-items: center;
	gap: var(--s3);
	min-width: 0;
}

.code-ref:empty {
	display: none;
}

.code-about {
	display: flex;
	flex: 0 1 auto;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: var(--s2) var(--s3);
	margin-left: auto;
	min-width: 0;
}

/* On narrow pages what the view holds takes a row of its own, its facts
   at the start and its actions after them, wrapping as they must. */
@container page (max-width: 599px) {
	.code-about {
		flex: 1 1 100%;
		justify-content: space-between;
		margin-left: 0;
	}
}

/* M3's outlined menu button for the branch or tag: 32px, 8px corners, an
   icon before the name and a chevron after, which turns while open. */
.ref-button,
.loc-chip {
	appearance: none;
	position: relative;
	display: inline-flex;
	flex: none;
	align-items: center;
	gap: var(--s2);
	height: 32px;
	max-width: 240px;
	padding: 0 var(--s2) 0 var(--s3);
	border: 1px solid var(--border);
	border-radius: var(--s2);
	background: none;
	color: var(--text);
	font: inherit;
	font-size: 13px;
	white-space: nowrap;
}

.loc-chip {
	padding-right: var(--s3);
	max-width: none;
}

.ref-button svg,
.loc-chip svg {
	width: 16px;
	height: 16px;
	flex: none;
	color: var(--ink-quiet);
}

.ref-name {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ref-button svg:last-child {
	transition: rotate 250ms cubic-bezier(0.2, 0, 0, 1);
}

.ref-button[aria-expanded="true"] svg:last-child {
	rotate: 180deg;
}

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

html.custom-cursor :is(.ref-button, .loc-chip):hover:not(:focus-visible, :active) {
	background: none;
}

.loc-chip[aria-expanded="true"] {
	background: var(--selected);
}

.repo-path {
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	gap: var(--s2);
	min-width: 0;
	overflow-x: auto;
	scrollbar-width: none;
	font-size: 15px;
	white-space: nowrap;
	color: var(--ink-quiet);
}

.repo-path::-webkit-scrollbar {
	display: none;
}

.repo-path [aria-current="page"] {
	color: var(--text);
}

.code-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--s1) 0;
	margin: 0;
	font-size: 13px;
	color: var(--ink-quiet);
}

.code-meta > span {
	white-space: nowrap;
}

.code-meta > span + span::before {
	content: "·";
	margin: 0 var(--s2);
}

.code-meta > .loc-chip {
	margin-right: var(--s3);
}

.code-actions {
	flex-wrap: wrap;
	display: flex;
	flex: none;
}

.code-actions:empty {
	display: none;
}

/* A folder: one 40px row per entry, folders first. */
.code-list {
	margin: 0;
	padding: 0;
	list-style: none;
	border: 1px solid var(--hairline);
	border-radius: var(--s4);
	overflow: hidden;
}

.code-list li + li {
	border-top: 1px solid var(--hairline);
}

.code-row {
	position: relative;
	display: flex;
	align-items: center;
	gap: var(--s3);
	height: 40px;
	padding: 0 var(--s4);
	border: 0;
	background: none;
	color: var(--text);
	font-size: 14px;
}

.code-row svg {
	width: 18px;
	height: 18px;
	flex: none;
	color: var(--muted);
}

.code-name {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.code-up {
	color: var(--ink-quiet);
}

.code-size {
	flex: none;
	font-size: 12px;
	color: var(--ink-quiet);
	font-variant-numeric: tabular-nums;
}

/* The M3 state layer. */
.code-row::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background: currentColor;
	opacity: 0;
	transition: opacity 150ms cubic-bezier(0.34, 0.8, 0.34, 1);
	pointer-events: none;
}

.code-row:hover::before {
	opacity: 0.08;
}

/* Files that aren't shown, and paths that lead nowhere. */
.code-note {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--s4);
	padding: var(--s7) var(--s5);
	border: 1px solid var(--hairline);
	border-radius: var(--s4);
	text-align: center;
	color: var(--ink-quiet);
}

.code-note p {
	margin: 0;
}

/* Paths in a note keep the page's font, not the browser's monospace. */
.code-note code {
	font: inherit;
}

/* M3's outlined button. */
.code-download {
	appearance: none;
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: var(--s2);
	height: 40px;
	padding: 0 var(--s5) 0 var(--s4);
	border: 1px solid var(--border);
	border-radius: 20px;
	background: none;
	color: var(--text);
	font: inherit;
	font-size: 14px;
}

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

.code-download svg {
	width: 18px;
	height: 18px;
}

.code-skeleton {
	display: flex;
	flex-direction: column;
	gap: var(--s3);
	padding: var(--s4);
	border: 1px solid var(--hairline);
	border-radius: var(--s4);
}

.code-skeleton .skeleton:nth-child(odd) {
	width: 55%;
}

.code-skeleton .skeleton:nth-child(3n) {
	width: 35%;
}

@media (prefers-reduced-motion: reduce) {
	.code-row::before {
		transition: none;
	}
}
