:root {
	--active-text: ActiveText;
	--accent-color: LinkText;
	--accent-color: AccentColor;
	--accent-color-text: Canvas; /* Contrast from AccentColorText is too low */
	--border: ButtonBorder;
	--link-text: oklch(from LinkText l c h / 0.8);
	--canvas: Canvas;
	--canvas-text: CanvasText;
	--field: oklch(from lightgray l c h / 0.3);
	--secondary-canvas-text: #616161;
}

@media (prefers-color-scheme: dark) {
	:root {
		--border: Field;
		--field: darkgray;
		--field: Field;
		--link-text: LinkText;
		--link-text: AccentColor;
		--secondary-canvas-text: darkgray;
	}
}

html,
body {
	height: 100%;
}

body {
	background-color: var(--canvas);
	color: var(--canvas-text);
	margin: 0;
	display: flex;
	flex-flow: row nowrap;
	gap: 8px;
	justify-content: center;
}

body * {
	box-sizing: border-box;
}

nav.profile {
	display: flex;
	flex-flow: row nowrap;
	margin-bottom: 8px;
	height: fit-content;
	border-bottom: 2px solid var(--border);
}

nav.profile a {
	color: var(--secondary-canvas-text);
	text-decoration: none;
	font-weight: bold;
	text-align: center;
	padding-top: 1em;
	width: 100%;
	height: 47px;
}

nav.profile a:hover {
	background-color: var(--field);
}

/* Posts is "selected" by default */
nav.profile a:target,
nav.profile a#posts {
	color: var(--canvas-text);
	border-bottom: 3px solid var(--link-text);
}

/* when something other than Posts is selected */
a#posts:has(~ a:target) {
	color: var(--secondary-canvas-text);
	border-bottom: none;
}

main {
	width: 600px;
	border-left: 2px solid var(--field);
	border-right: 2px solid var(--field);
}

nav.meta,
footer {
	width: 330px;
	padding: 8px;
}

nav.meta {
	background-color: var(--canvas);
}

nav.meta .container {
	width: 200px;
	padding-top: 20px;
	float: right;
}

nav.meta .icon {
	width: 32px;
	color: var(--canvas-text);
}

nav.meta .logo {
	color: var(--canvas-text);
	text-decoration: none;
	display: flex;
	flex-flow: row nowrap;
	align-items: center;
}

nav.meta p.tagline,
nav.meta .program {
	font-size: 24px;
	font-weight: bold;
	margin-top: 12px;
	margin-bottom: 18px;
}

nav.meta .program {
	display: none;
	margin: 0;
	margin-left: 8px;
}

nav.meta .info {
	display: none;
	font-size: 14px;
	padding: 0;
}

nav.meta .locale {
	font-size: 14px;
	margin-top: 24px;
	display: flex;
	flex-flow: row nowrap;
	align-items: baseline;
}

nav.meta .locale select {
	color: var(--secondary-canvas-text);
	background-color: var(--canvas);
	border: none;
	border-radius: 8px;
	padding: 8px;
	cursor: pointer;
}

nav.meta .locale select:hover {
	background-color: oklch(from var(--secondary-canvas-text) l c h / 0.1)
}

nav.meta .locale button[type="submit"] {
	border: none;
	background-color: var(--canvas);
	color: var(--canvas-text);
	border-radius: 8px;
	padding: 8px;
	cursor: pointer;
}

nav.meta .locale button[type="submit"]:hover {
	background-color: oklch(from var(--secondary-canvas-text) l c h / 0.1)
}

nav.meta a.clients {
	background-color: var(--accent-color);
	color: var(--accent-color-text);
	text-decoration: none;
	padding: 8px 14px;
	border-radius: 10px;
	font-size: 14px;
}

nav.meta a.clients:hover {
	background-color: oklch(from var(--accent-color) l c h / 0.7);
}

footer {
	font-size: 14px;
	padding: 20px 10px 0 20px;
}

nav.info {
	color: GrayText; /* TODO: We want lower contrast here */
	padding: 8px;
	padding-left: 0;
}

nav.info ul {
	padding: 0;
	margin-top: 8px;
	display: flex;
	flex-flow: row wrap;
}

nav.info li {
	list-style: none;
}

nav.info li:not(:last-child)::after {
	content: " • ";
	white-space: pre;
}

nav.info a {
	text-decoration: none;
}

nav.info a:hover {
	text-decoration: underline;
}

input[type="search"] {
	height: 44px;
	width: 100%;
	padding: 8px;
	padding-left: 42px; /* search icon */
	border: none;
	border-radius: 8px;
	font-size: medium;
	background-color: var(--field);
}

form {
	position: relative;
}

search .icon {
	position: absolute;
	top: 13px;
	left: 13px;
	width: 18px;
	z-index: 1;
	color: var(--secondary-canvas-text);
}

a {
	color: var(--link-text);
}

a:active {
	color: var(--active-text);
}

img {
	background-color: var(--field);
	border: 1px solid lightgray; /* TODO: ??? */
}

.banner-placeholder {
	background-color: var(--field);
	width: 600px;
	height: 150px;
}

img.avatar {
	box-sizing: content-box;
	border-radius: 50%;
	border-color: var(--canvas);
	border-width: 2px;
}

section.profile {
	padding: 0 16px;
}

section.profile img.avatar {
	margin-left: -6px;
	margin-top: -46px;
}

header.profile {
	display: flex;
	flex-flow: row nowrap;
	gap: 12px;
	margin-bottom: 6px;
}

.horizontal header.profile {
	gap: 6px;
}

.profile .separator {
	color: var(--secondary-canvas-text);
	user-select: none;
}

/* Profile view */
header.profile h1 {
	margin: 0;
}

/* Post view */
header.profile h2 {
	margin: 0;
	font-size: 1em;
}

h2 {
	display: flex;
	flex-flow: row nowrap;
	gap: 4px;
}

/* Post view */
header.profile .user {
	display: flex;
	flex-flow: column nowrap;
	gap: 4px;
}

header.profile a {
	color: var(--canvas-text);
	text-decoration: none;
}

header.profile .handle {
	color: var(--secondary-canvas-text);
	font-weight: normal;
}

article.no-posts {
	display: flex;
	flex-flow: column nowrap;
	justify-content: center;
	align-items: center;
	padding: 44px;
	color: var(--secondary-canvas-text);
	font-size: 17px;
}

article.no-posts .icon {
	border-radius: 50%;
	overflow: visible;
	padding: 20px;
	width: 96px;
	background-color: var(--field);
}

article.post {
	padding: 0 16px;
	padding-bottom: 8px;
}

/* Simple post view */
article.post .horizontal {
	display: flex;
	flex-flow: row nowrap;
	gap: 8px;
}

article.post .horizontal > :first-child {
	display: flex;
	flex-flow: column nowrap;
}

article.post .thread-line {
	margin: 0 auto;
	width: 2px;
	/* for some reason this stretches past the bottom, but that's perfect! */
	height: calc(100% - 45px);
	flex-grow: 2;
	background-color: var(--border);
}

blockquote {
	margin: 0;
	margin-bottom: 16px;
	white-space: pre;
	text-wrap: wrap;
}

blockquote a {
	text-decoration: none;
}

blockquote a:hover {
	text-decoration: underline;
}

.primary blockquote {
	font-size: 18.75px;
}

section.embeds {
	border: 1px solid var(--border);
	border-radius: 12px;
	overflow: hidden;
}

section.embeds a {
	text-decoration: none;
}

section.embeds:has(a:hover) {
	border-width: 1px;
	border-color: var(--secondary-canvas-text);
}

section.embeds img,
section.embeds video {
	max-width: 100%;
	border: none;
}

section.embeds h3,
section.embeds p {
	margin: 0;
	padding: 0 12px;
	color: var(--canvas-text);
	font-size: 14px;
}

section.embeds h3 {
	font-size: 15px;
	padding-top: 8px;
	padding-bottom: 4px;
}

section.embeds p {
	padding-bottom: 8px;
}

section.embeds p.subtext {
	font-size: small;
	padding: 8px 12px 12px 12px; /* only top is shorter */
	color: var(--secondary-canvas-text);
	border-top: 1px solid var(--border);
}

section.embeds a:hover p.subtext {
	color: var(--canvas-text);
}

aside.pinned {
	padding-bottom: 4px;
	color: var(--secondary-canvas-text);
}

aside.stats {
	display: flex;
	flex-flow: row nowrap;
	justify-content: space-between;
	padding: 8px;
	gap: 10px;
}

aside.stats .data {
	font-weight: bold;
}

aside.stats,
aside.time {
	border-bottom: 1px solid var(--border);
}

aside.stats.profile {
	justify-content: unset;
	padding: 8px 0;
	border-bottom: none;
}

aside.stats .label,
aside.time .label {
	color: var(--secondary-canvas-text);
}

aside.stats a,
aside.time a,
.profile a.time {
	color: var(--secondary-canvas-text);
	text-decoration: none;
}

aside.stats.profile a {
	color: var(--canvas-text);
}

aside.stats a:hover,
a.time:hover {
	text-decoration: underline;
}

aside.post.stats {
	position: relative;
}

aside.post.stats .item {
	display: flex;
	flex-flow: row nowrap;
	align-items: center;
	color: var(--secondary-canvas-text);
	margin-right: 44px;
}

aside.post.stats .item:last-of-type {
	margin-right: 0;
	margin-left: auto;
}

aside.post.stats .icon {
	height: 1.2rem;
}

aside.post.stats .value {
	margin-left: 8px;
}

aside.post.stats details > summary {
	border-radius: 4px;
	padding: 4px 4px 0 4px;
	list-style: none;
	cursor: pointer;
}

aside.post.stats details > summary::-webkit-details-marker {
	display: none;
}

aside.post.stats details > summary:hover,
aside.post.stats details[open] > summary {
	background-color: var(--field);
}

aside.post.stats details > menu {
	position: absolute;
	right: 0;
	background: var(--canvas);
	border: 1px solid var(--border);
	border-radius: 8px;
}

/*
MARK: - Size Queries
*/

@media (max-width: 1300px) {
	/* Medium layout (left bar to bottom) */

	nav.meta {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		width: unset;
		border-top: 2px solid var(--border);
	}

	nav.meta .container {
		width: 100%;
		float: unset;
		padding: 8px;
		gap: 8px;
		display: flex;
		flex-flow: row nowrap;
		align-items: center;
	}

	nav.meta .logo {
		flex-grow: 2;
		order: 0;
	}

	nav.meta .program {
		display: inline;
	}

	nav.meta .tagline {
		display: none;
	}

	nav.meta .info {
		order: 1;
	}

	nav.meta .locale {
		margin: 0;
		order: 2;
	}

	nav.meta .clients {
		order: 3;
	}

	main {
		/* shift the main content more toward the center, now that the left bar is gone */
		margin-left: 64px;
	}

	footer {
		width: 280px;
	}
}

option.thin,
.clients.thin {
	display: none;
}

@media (max-width: 1100px) {
	/* small layout (right bar to bottom) */

	nav.meta .info {
		display: unset;
	}

	nav.meta .info ul {
		margin: 0;
	}

	nav.meta .locale select {
		/* FIXME: Compute server-side the width to use here; should be equal to the current locale name. For now, this is roughly the width of the string "English" */
		max-width: 68px; /* poor-woman's shrinkwrap; manually set the widest that text can be */
	}

	/* Shows the "short version" of the locale list */
	option.thin {
		display: initial;
	}

	/* Hides the "long version of the locale list, and other elements */
	option.thick,
	footer {
		display: none;
	}

	main {
		margin-left: 0;
	}
}

@media (max-width: 780px) {
	/* minimal layout (no page margins) */

	main,
	.banner-placeholder {
		width: 100%;
		border: none;
	}

	/* Shows the "short version" of the "Join" button */
	.clients.thin {
		display: initial;
	}

	/* Hides the "long version of the "Join" button */
	.clients.thick {
		display: none;
	}
}

@media (max-width: 600px) {
	/* tiny layout (no logo) */

	nav.meta .program {
		display: none;
	}
}

@media (max-width: 410px) {
	/* smol layout (locale selection only is automatic or URL query) */

	nav.meta .locale {
		display: none;
	}
}

@media (max-width: 290px) {
	/* itty bitty layout (vertical nav) */

	nav.meta .logo,
	nav.meta .info li::after,
	nav.profile {
		display: none;
	}

	section.profile {
		/* Profile still needs its bottom border, tho profile is gone */
		border-bottom: 2px solid var(--border);
	}

	nav.meta .info {
		flex-grow: 2;
	}

	nav.meta .info ul {
		display: initial; /* un-flex */
	}

	article.post .horizontal,
	header.profile,
	header.profile h2 {
		flex-direction: column;
	}

	aside.stats {
		flex-wrap: wrap;
	}
}
