html,
body {
	/* System font stacks swiped from https://systemfontstack.com/ */
	--font-family-sans: -apple-system, BlinkMacSystemFont, avenir next, avenir,
		segoe ui, helvetica neue, Cantarell, Ubuntu, roboto, noto, helvetica, arial,
		sans-serif;
	--font-family-serif: Iowan Old Style, Apple Garamond, Baskerville,
		Times New Roman, Droid Serif, Times, Source Serif Pro, serif,
		Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
	--font-family-monospace: Menlo, Consolas, Monaco, Liberation Mono,
		Lucida Console, monospace;
	font-family: var(--font-family-sans);
}

/*
GRID PAGE
*/

.p-main-page {
	padding: 3rem 1.5rem;
	display: flex;
	flex-direction: column;
	gap: 2rem;
	background: #dddddd;
}

.p-main-page h1 {
	font-size: 3rem;
	font-family: var(--font-family-serif);
}

.grid {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	justify-content: center;
}

.grid-item {
	background: white;
	border-radius: 6px;
	border: 1px solid #dddddd;
	display: flex;
	flex-direction: column;
	height: auto;
	overflow: hidden;
	position: relative;
	text-decoration: none;
	width: 124px;
}

.grid-item:focus {
	outline: 3px solid dodgerblue;
}

.grid-item .label {
	color: #333;
	display: flex;
	flex-direction: column;
	flex-grow: 1;
	font-family: var(--font-family-serif);
	font-size: 0.75rem;
	justify-content: center;
	line-height: 1.2;
	padding: 0.75rem 0.75rem 1.25rem 0.75rem;
	text-align: center;
}

.grid-item img {
	aspect-ratio: 1.2;
	border-radius: 8px;
	border: 4px solid white;
	display: block;
	object-fit: cover;
	object-position: center center;
}

/*
ENTRY PAGE
*/

#p-entry-page {
	/* TODO: this should set in some parsed data, and passed to the page template.
	   Cover media will NOT all be square. */
	--cover-aspect: 1;
	--entry-page-max-width: max(75vh, 580px);
	padding: 1rem;
}

#p-entry-page .back {
	display: block;
	position: absolute;
	top: 0.5rem;
	left: 0.5rem;
	color: dodgerblue;
	text-decoration: none;
	border-radius: 16px;
	overflow: hidden;
	padding: 0.5rem 1rem 0.5rem 0.8rem;
	background: white;
}

#p-entry-page .back:focus {
	outline: 3px solid dodgerblue;
}

#p-entry-page main {
	margin: auto;
	display: flex;
	flex-direction: column;
	gap: 2rem;
}

#p-entry-page .cover-container {
	align-items: center;
	aspect-ratio: var(--cover-aspect);
	display: flex;
	flex-direction: column;
	justify-content: center;
	margin: 0 auto;
	max-width: var(--entry-page-max-width);
	width: 100%;
	--cover-height-relative: calc(100% / var(--cover-aspect));
	--cover-offset: calc(var(--cover-height-relative) / 2);
	/* Space so the image starts perfectly centered in the page */
	margin-top: max(3rem, calc(-4rem + 50vh - var(--cover-offset)));
}

#p-entry-page .cover-container img {
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 16px;
}

#p-entry-page .cover-container video {
	border-radius: 16px;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
}

#p-entry-page .cover-container audio {
	border-radius: 16px;
	width: 100%;
}

#p-entry-page .contents {
	display: flex;
	flex-direction: column;
	gap: 1.5rem;

	width: 100%;
	max-width: var(--entry-page-max-width);
	margin: 0 auto;
}

#p-entry-page .contents .markdown-content {
	padding-bottom: max(8rem, 20vh);
}

#p-entry-page .header {
	display: grid;
	gap: 2rem;
	flex-wrap: wrap;
	align-items: center;
	/* grid-template-columns: auto 1fr auto; */
	grid-template-areas: "title title" "leftside rightside";
}

@media (min-width: 600px) {
	#p-entry-page .header {
		grid-template-columns: 1fr 3fr 1fr;
		grid-template-areas: "leftside title rightside";
	}
}

.g-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

#p-entry-page .header .leftside-link {
	grid-area: leftside;
}

#p-entry-page .header .rightside-link {
	grid-area: rightside;
	text-align: right;
}

#p-entry-page .header a {
	color: dodgerblue;
	text-decoration: none;
	border-radius: 16px;
	overflow: hidden;
	padding: 0.5rem 1rem 0.5rem 0.8rem;
	background: white;
}

#p-entry-page .header-text {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	grid-area: title;
}

#p-entry-page .header-text p {
	color: #999;
	text-align: center;
	font-size: 0.875rem;
}

#p-entry-page .header-text h1 {
	font-size: 1.125rem;
	text-align: center;
	font-family: var(--font-family-serif);
}

/*
MARKDOWN CONTENT
*/

.markdown-content {
	position: relative;
	margin: 0 auto;
	max-width: 32em;
	line-height: 1.5;
	color: #333;
	font-family: var(--font-family-serif);
	font-size: 1.125rem;
	display: flex;
	flex-direction: column;
	gap: 1.2rem;
}

.markdown-content img {
	display: block;
	max-width: 100%;
	height: auto;
}

.markdown-content pre {
	background: #eee;
	padding: 1em;
	font-size: 0.875rem;
	border: 1px solid lightgray;
	border-radius: 16px;
	white-space: pre-wrap;
	font-family: var(--font-family-monospace);
}

/* TODO: refine styles for code, generated for now */

.markdown-content code {
	background: #f5f5f5;
	padding: 0.2rem 0.4rem;
	border-radius: 6px;
	font-family: var(--font-family-monospace);
	font-size: 0.9rem;
}

.markdown-content a {
	color: dodgerblue;
}

.markdown-content blockquote {
	padding-left: 1.2rem;
	padding-top: 0.2rem;
	padding-bottom: 0.2rem;
	border-left: 1px solid lightgray;
	color: #555;
}

.markdown-content blockquote p {
	margin: 1rem 0;
}

/* TODO: add styles for all headings */

.markdown-content h2 {
	font-size: 1.5rem;
}

/* TODO: refine styles for lists, generated for now */

.markdown-content ul {
	padding-left: 1.5rem;
	list-style-type: disc;
}

.markdown-content ol {
	padding-left: 1.5rem;
	list-style-type: decimal;
}

.markdown-content li {
	margin: 0.5rem 0;
}
