@import 'reset.css';

* {
	box-sizing: border-box;
}

:root {
	/* System font stacks from https://gist.github.com/don1138/5761014 */
	--font-stack-serif: 'Palatino Linotype', Palatino, Palladio, 'URW Palladio L', 'Book Antiqua', Baskerville,
		'Bookman Old Style', 'Bitstream Charter', 'Nimbus Roman No9 L', Garamond, 'Apple Garamond',
		'ITC Garamond Narrow', 'New Century Schoolbook', 'Century Schoolbook', 'Century Schoolbook L', Georgia, serif;
	--font-stack-sans: 'IBM Plex Sans', system-ui, Segoe UI, Helvetica, Roboto, sans-serif;
	--font-stack-mono: 'IBM Plex Mono', monospace;

	--clr-yellow-30: #866b00;
	--clr-yellow-50: #d5b712;
	--clr-yellow-60: oklch(0.81 0.18 91);
	--clr-yellow-base: var(--clr-yellow-60);

	--clr-red-30: #a22205;
	--clr-red-40: #b7391d;
	--clr-red-60: #fb4444;
	--clr-red-base: var(--clr-red-30);

	--clr-gray-0: #000000;
	--clr-gray-10: #100e06;
	--clr-gray-20: #242021;
	--clr-gray-25: #302b2c;
	--clr-gray-80: #e6e5e4;
	--clr-gray-90: #f2f1f0;
	--clr-gray-95: #fcfcfc;
	--clr-gray-100: #ffffff;

	--clr-lighter-10: hsla(0, 0%, 100%, 0.08);
	--clr-lighter-20: hsla(0, 0%, 100%, 0.2);
	--clr-lighter-30: hsla(0, 0%, 100%, 0.4);
	--clr-lighter-40: hsla(0, 0%, 100%, 0.7);
	--clr-lighter-50: hsla(0, 0%, 100%, 0.93);

	--clr-darker-10: hsla(0, 0%, 0%, 0.05);
	--clr-darker-20: hsla(0, 0%, 0%, 0.17);
	--clr-darker-30: hsla(0, 0%, 0%, 0.35);
	--clr-darker-40: hsla(0, 0%, 0%, 0.65);
	--clr-darker-50: hsla(0, 0%, 0%, 0.93);

	--font-size-0: 0.85em;
	--font-size-10: 1em;
	--font-size-20: 1.2em;
	--font-size-30: calc(4em / 3);
	--font-size-40: calc(5em / 3);
	--font-size-50: calc(6em / 3);

	--line-height: calc(1.5 / 0.875); /* 24px for base font size */

	--reading-width-narrow: 65ch;
	--reading-width-wide: 75ch;
}

.🌞,
.🌒 .inverted {
	--text-primary: var(--clr-darker-50);
	--text-secondary: var(--clr-darker-40);
	--text-tertiary: var(--clr-darker-30);
	--text-inverted: var(--clr-lighter-50);
	--theme-primary: var(--clr-red-base);
	--theme-primary-bg: var(--clr-red-30);
	--theme-primary-text: var(--clr-red-30);
	--theme-accent-bg: var(--clr-yellow-50);
	--theme-accent-text: var(--clr-yellow-30);
	--layer-bg: #fbf9f4;
	--layer-container: rgba(255, 255, 255, 0);
	--layer-container-hover: rgba(255, 255, 255, 0.25);
	--layer-highlight: var(--clr-gray-80);
	--clr-scrollbar: var(--clr-darker-20);
	--divider: var(--clr-darker-20);
	--container-border: 1px solid var(--divider);
	--nav-collapsed: var(--text-secondary);
}

.🌒,
.🌞 .inverted {
	--text-primary: var(--clr-lighter-50);
	--text-secondary: var(--clr-lighter-40);
	--text-tertiary: var(--clr-lighter-30);
	--text-inverted: var(--clr-darker-50);
	--theme-primary: var(--clr-yellow-base);
	--theme-primary-bg: var(--clr-yellow-60);
	--theme-primary-text: var(--clr-yellow-60);
	--theme-accent-bg: var(--clr-red-40);
	--theme-accent-text: var(--clr-red-60);
	--layer-bg: var(--clr-gray-10);
	--layer-container: oklch(0.25 0 0 / 0.1);
	--layer-container-hover: var(--clr-gray-25);
	--layer-highlight: var(--clr-gray-20);
	--clr-scrollbar: var(--clr-lighter-20);
	--divider: var(--clr-lighter-10);
	--container-border: 1px solid var(--divider);
	--nav-collapsed: var(--layer-container);
}

.🌞,
.🌒,
.inverted {
	--text-link: var(--theme-primary);
	--text-link-hover: var(--theme-accent-text);
	color: var(--text-primary);
}

/*    TYPOGRAPHY    */

html {
	font-family: var(--font-stack-sans);
	font-feature-settings: 'liga';
	font-weight: 400;
	font-size: 16px; /* Used as basis for spacing throughout the app. */
	line-height: var(--line-height);
}

html,
body {
	background-color: var(--layer-bg);
}

.app {
	font-size: 0.875rem; /* 14px on most monitors. */
}

h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child,
h5:first-child,
h6:first-child,
p:first-child {
	margin-top: 0;
}

h1,
h2 {
	font-weight: 300;
}

h1 {
	font-size: var(--font-size-50);
	line-height: 1.4;
}

h2 {
	font-size: var(--font-size-30);
	line-height: 1.5;
}

blockquote {
	margin: 0;
	padding-left: 1rem;
	border-left: 4px solid var(--divider);
	font-style: italic;
	font-size: 1.1em;
	font-family: var(--font-stack-serif);
}

blockquote > * + *,
article > * + *,
section > * + *,
figure > * + *,
footer > * + * {
	--spacing: 1em;
	margin-top: var(--spacing);
}

blockquote:not(.extract-text) em {
	font-style: normal;
}

hr {
	color: var(--divider);
	margin: calc(1em * var(--line-height) - 1px) 0 0 0;
	padding-top: calc(1em * var(--line-height));
	border-style: solid;
	border-bottom: none;
	border-left: none;
	border-right: none;
}

ul {
	list-style-type: circle;
}

table {
	border-collapse: collapse;
}

tr:not(:first-child) {
	border-top: 1px solid var(--divider);
}

th,
td {
	padding: 0.5rem 0.25rem;
}

th {
	text-align: left;
	font-weight: normal;
	color: var(--text-secondary);
	vertical-align: bottom;
	white-space: nowrap;
	padding-top: 0;
}

td {
	vertical-align: baseline;
}

strong {
	font-weight: 500;
}

button.link {
	appearance: none;
	background: none;
	border: none;
	outline: none;
	padding: 0;
	margin: 0;
}

a,
.link {
	color: var(--text-link);
	text-decoration: none;
	transition: color 0.33s;
}

a:hover,
.link:hover {
	color: var(--text-link-hover);
	cursor: pointer;
	text-decoration: underline;
}

a,
.link,
.text-mono,
pre,
code,
kbd,
samp {
	font-family: var(--font-stack-mono);
	/* The monospace fonts tend to be optically larger for a given font size. */
	font-size: 0.933em;
	line-height: calc((1.5 / 0.875) / 0.933);
}

pre {
	overflow-x: auto;
}

small,
.small {
	font-size: var(--font-size-0);
}

.caption {
	font-size: var(--font-size-0);
	color: var(--text-secondary);
}

.text-mono a,
.text-mono .link {
	font-size: 1em;
	/* Avoid compounding ensmallnesses. */
}

.markdown-block > *:first-child {
	margin-top: 0;
}

.markdown-block > *:last-child {
	margin-bottom: 0;
}

/*    CONTROLS    */

.input--radio {
	white-space: nowrap;
}

select {
	background-color: var(--layer-bg);
	border-radius: 0;
	font-size: var(--font-size-0);
	font-family: var(--font-stack-mono);
	border: 1px solid var(--text-secondary);
	padding: 0.25em 0.5em;
	/* -webkit-appearance: none;
	-moz-appearance: none;
	appearance: none; */
}

select:focus {
	outline: none;
	border-color: var(--theme-primary);
	box-shadow: 0 0 2px var(--theme-primary);
	color: var(--theme-primary-text);
}

/*    HELPERS    */

.inherit {
	all: inherit;
	color: currentColor;
}

.text-inverted {
	color: var(--text-inverted) !important;
}

.theme-primary {
	color: var(--theme-primary-text);
}

.text-secondary {
	color: var(--text-secondary);
}

.text-tertiary {
	color: var(--text-tertiary);
}

.center {
	text-align: center;
}

.right {
	text-align: right;
}

.themey {
	background-color: var(--theme-primary-bg);
	color: var(--text-inverted);

	--layer-highlight: var(--theme-primary-bg);
	--text-link: var(--text-inverted);
	--text-link-hover: var(--text-inverted);
}

/* https://stackoverflow.com/questions/26032089/in-html-how-can-i-have-text-that-is-only-accessible-for-screen-readers-i-e-fo#:~:text=visibility%3A%20hidden%3B%20and%2For,want%20read%20by%20screen%20readers. */
.screenreader {
	position: absolute !important; /* Outside the DOM flow */
	height: 1px;
	width: 1px; /* Nearly collapsed */
	overflow: hidden;
	left: -10000px;
	clip-path: rect(1px, 1px, 1px, 1px); /* All other browsers */
	clip: rect(1px, 1px, 1px, 1px); /* All other browsers */
}

/*    COMPONENTS    */
.spaces-list {
	--spacing: 1em;
	list-style-type: none;
	margin-bottom: 0;
	margin-left: calc(-1 * var(--spacing));
	display: flex;
	flex-wrap: wrap;
	max-width: 100%;
}

.spaces-list > li {
	margin-left: var(--spacing);
}

.linked-list {
	--separation: 0.5rem;
	position: relative;
	list-style-position: inside;
	list-style-type: none;
	color: var(--text-secondary);
}

.linked-list * {
	display: inline;
}

.linked-list > li:not(:last-child) {
	margin-right: var(--separation);
}

.linked-list > li + li::before {
	content: '/';
	color: var(--text-tertiary);
	margin-right: var(--separation);
}

.topic {
	color: var(--text-secondary);
	text-transform: uppercase;
	white-space: nowrap;
}

.topic::before {
	content: '#';
	opacity: 0.5;
	display: inline-block;
	margin-right: 2px;
}

/*    LAYOUT    */
html,
body,
.app {
	height: 100%;
}

.app {
	--padding: 2rem;
}

.layout {
	display: flex;
	position: relative;
	align-items: flex-start;
}

.layout > * {
	padding: var(--padding);
	overflow-x: hidden;
}

.layout__index {
	max-height: 100vh;
}

.layout__panel:empty {
	display: none;
}

@media screen and (max-width: 650px) {
	.layout {
		--padding: 1rem;
		align-items: stretch;
		max-height: 100%;
		height: 100%;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
	}

	.layout__index,
	.layout__gallery,
	.layout__panel {
		width: 100vw;
		min-width: 100vw;
		height: 100%;
		overflow-y: auto;
		position: relative;
		scroll-snap-align: start;
	}

	.layout__index {
		padding-top: 0;
		margin-top: var(--padding);
		height: calc(100% - var(--padding));
	}
}

@media screen and (min-width: 700px) {
	.layout__index {
		flex: 2 1 0;
		min-width: 200px;
		max-height: 100vh;
		position: sticky;
		top: 0;
		overflow-y: auto;
	}

	.layout__gallery {
		flex: 2 1 var(--reading-width-narrow);
		position: sticky;
		top: 0;
		max-height: 100vh;
		overflow-y: auto;
		padding-right: calc(var(--padding) / 2 + 5px);
		margin-right: calc(var(--padding) / 2 - 5px);
	}

	.layout__panel {
		flex: 1 1 var(--reading-width-narrow);
		min-height: 100vh;
		border-left: 2px solid var(--theme-primary-text);
		max-width: var(--reading-width-wide);
	}
}

@media screen and (min-width: 700px) and (max-width: 1350px) {
	.layout {
		--index-width: 1.5rem;
	}

	.layout__index {
		position: fixed;
		min-width: 0;
		flex: 0 0 auto;
		top: 0;
		left: 0;
		bottom: 0;
		width: 0;
		padding-right: 0;
		padding-left: var(--index-width);
		background-color: var(--nav-collapsed);
		transition: width 0.5s, background-color 0.5s, padding 0.5s;
		z-index: 1;
		border-right: 1px solid var(--divider);
	}

	.layout__index > * {
		opacity: 0;
		transition: opacity 0.5s;
	}

	.layout__index:hover,
	.layout__index:only-child {
		width: 225px;
		background-color: var(--layer-bg);
		padding-right: var(--padding);
		border-right: 1px solid var(--divider);
	}

	.layout__index:hover > *,
	.layout__index:only-child > * {
		opacity: 1;
	}

	.layout__index:only-child {
		width: 100%;
		border-right: none;
	}

	.layout__gallery {
		margin-left: var(--index-width);
	}
}
