html {
	margin: 0;
	padding: 0;
	//touch-action: pan-x pan-y;
}

body {
	font-family: sans-serif;
	background-color: #EEE;
	color: #000;
	margin: 0;
	line-height: 1.4;
	height: 100vh;
}

main {
	height: 100%;
	overflow-y: scroll;
	overflow-x: hidden;

	&.has-overlay {
		overflow: hidden;
	}
}

main.locked {
	margin: 16px;

	> button {
		width: 100%;
		height: 96px;
		font-size: 24px;
	}
}

.overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;

	background-color: rgba(0, 0, 0, 0.75);
	display: flex;
	align-items: center;
	justify-content: center;

	&.post-popup {
		align-items: normal;
	}

	&.image-popup > img {
		max-height: 100%;
		max-width: 100%;
	}
}

.spoiler, .nsfw {
	transition: 1s;
}

main:not(.unblur-all) {
	.spoiler:not(.unblur) {
		filter: blur(15px);
	}

	.nsfw:not(.unblur) {
		filter: blur(25px);
	}
}

.settings {
	margin: 16px;
	display: flex;
	flex-direction: column;

	> span.input-wrapper {
		margin: 4px;

		> * {
			padding: 4px;
		}

		&.checkbox {
			display: flex;
			align-items: center;
		}
	}
}

form.subreddit-picker {
	margin: 16px;
}

section.loading-indicator {
	margin: 16px;
}

article {
	box-sizing: border-box;
	background-color: #FFF;
	box-shadow: 0 0 16px rgba(0, 0, 0, 0.25);
	padding: 16px;
	margin: 16px;
	display: flex;
	flex-direction: column;
	content-visibility: auto;
	contain-intrinsic-height: auto 200px;
}

article > header {
	.metadata {
		font-size: 14px;
		display: flex;
		align-items: center;

		.subreddit-icon {
			border-radius: 100%;
			width: 24px;
			height: 24px;
		}

		.subreddit-name {
			font-weight: bold;
			margin: 0 4px;
		}

		.poster {
			color: #666;

			> a {
				color: #666 !important;
				margin: 0 4px;
				text-decoration: none;

				&:hover {
					text-decoration: underline;
				}

				&:visited {
					color: #666;
				}
			}
		}
	}

	h3 {
		max-width: 1000px;
		margin-top: 8px;
		overflow-wrap: break-word;

		a {
			text-decoration: none;
			color: #000 !important;
		}
	}
}

article > .source > pre {
	font-family: "Fira Code", monospace;
	font-size: 12px;
	margin: 0;
	max-height: 500px;
	overflow: auto;
}

article > .content {
	.media {
		display: flex;
		justify-content: center;
		flex-wrap: wrap;
	}

	img, video {
		max-height: max(60vh, 600px);
		max-width: 100%;
		height: auto;
	}

	.richtext-content {
		max-width: 700px;
	}
}

.richtext-content {
	overflow-wrap: break-word;

	.markdown-spoiler {
		transition: .5s;

		&.spoiled {
			cursor: pointer;
			filter: blur(5px);
		}
	}

	blockquote {
		border-left: 4px solid #CCC;
		padding-left: 8px;
		margin-left: 0;
	}

	> p:first-of-type {
		margin-top: 0;
	}

	> p:last-of-type {
		margin-bottom: 0;
	}

	ul {
		padding-left: 24px;
	}

	ol {
		padding-left: 32px;
	}

	img {
		max-height: 350px;
		max-width: 100%;
		width: auto;
	}

	li > p {
		margin: 0;
	}

	table {
		border-spacing: 0;
		border-collapse: collapse;

		td, th {
			padding: 8px;
			border: 1px solid #AAA;
		}

		.align-left {
			text-align: left;
		}
		.align-center {
			text-align: center;
		}
		.align-right {
			text-align: right;
		}

		tr:nth-child(odd) > td {
			background-color: #EEE;
		}

		tr:nth-child(even) > td, thead > tr > th {
			background-color: #FFF;
		}
	}
}

.overlay-post {
	min-height: 100%;
	width: 100%;
	max-width: 732px;
	background-color: white;
	overflow-y: scroll;

	> .close-button {
		height: 32px;
		border-radius: 0;
		border: none;
		width: 100%;
	}

	> article {
		box-shadow: none;
		margin: 0;
	}

	> section.comments {
		display: block;
	}
}

section.comments {
	margin-bottom: 64px;

	> .loading-comments {
		margin: 16px;
	}
}

.comment {
	padding: 8px;
	border-left: 4px solid white;

	> .header {
		display: flex;
		align-items: center;
		margin-bottom: 4px;

		> img {
			border-radius: 100%;
			width: 24px;
			height: 24px;
		}

		> .author {
			margin: 0 4px;
		}

		> .date {
			color: #666;
		}
	}
}

@media screen and (max-width: 450px) {
	article, .settings, form.subreddit-picker, section.loading-indicator {
		margin: 8px;
	}

	article {
		padding: 8px;
	}
}
