/* #region reset.css */
/* https://www.youtube.com/watch?v=eWmDW4zEXt4 */
/* https://youtube.com/shorts/2lyDv0wOQuQ */

/* Element includes padding & border in size dimensions */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	color-scheme: dark light;
}

body {
	min-height: 100vh;
	margin: 0;
}

/* This allows querying a container by its inline size, which is equivalent to
 * width in a standard horizontal writing mode. */
/* See https://css-tricks.com/almanac/properties/c/container-type/ */
header,
main,
footer,
section,
article {
	container-type: inline-size;
}

/* Keep break lines ~equal width */
h1,
h2,
h3,
h4,
h5,
h6 {
	text-wrap: balance;
}

p,
li,
figcaption {
	@supports (text-wrap: pretty) {
		/* Prevents orphan words, i.e. single word at end */
		text-wrap: pretty;
	}
	max-width: 80ch;
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
li,
figcaption {
	width: fit-content;
	margin-left: auto;
	margin-right: auto;
}

img,
picture,
svg,
video {
	display: block;
	max-width: 100%;
}

button,
input,
select,
textarea {
	font: inherit;
}
/* #endregion */

/* Main Styles */
* {
	transition: background 0.3s, color 0.3s;
}

:root {
	--bg-color: #F4F4F6;
	--primary-color: #28282C;
	--accent-color: #61FFCA;
}

body {
	background: var(--bg-color);
	color: var(--primary-color);
	text-align: center;
	display: grid;
	grid-template-columns: 1fr 4fr 1fr;
	grid-template-rows: 100px 100% max-content;
	grid-template-areas:
		"header	header	header"
		"nav	main	."
		"footer	footer	footer";
	& header {
		grid-area: header;
	}
	& nav {
		grid-area: nav;
	}
	& main {
		grid-area: main;
	}
	& footer {
		grid-area: footer;
	}
}

a {
	color: #4C4CFB;
}

button {
	border: 2px outset grey;
	border-radius: 5px;
	margin: 15px 5px 0 5px;
	/* Default light mode ButtonFace value in Firefox */
	/* ButtonFace: #E9E9ED */
	background-color: #E9E9ED;
	/* Default light mode ButtonText value in Firefox */
	/* ButtonText: #000000 */
	color: black;
	cursor: pointer;

	&:active {
		border-style: inset;
	}
}

div.buttons,
div.inputs {
	font-size: 0;
	/* Hide whitespace between buttons */

	& button,
	input {
		/* Reset font-size after above rule */
		font-size: 1rem;
	}
}

input {
	border: 2px inset grey;
	border-radius: 5px;
	margin: 0 5px;
	/* Default light mode Field value in Firefox */
	/* Field: #FFFFFF */
	background-color: white;
	/* Default light mode FieldText value in Firefox */
	/* FieldText: #000000 */
	color: black;
}

footer {
	align-content: center;
	padding-bottom: 10px;
	margin-top: 30px;

	/* License */
	& img.cc-icon {
		display: inline;
		max-width: 1em;
		max-height: 1em;
		margin-left: 0.25em;
	}
}

div.error:popover-open {
	/* min-width: calc(fit-content + 50px); */
	min-height: 100px;
	padding: 0 25px;
	display: flex;
	/* Ensure spans stack on top rather than side-by-side */
	flex-direction: column;
	/* Center vertically */
	justify-content: center;
	border-color: var(--accent-color);

	&::backdrop {
		backdrop-filter: brightness(0.5);
	}

	& > span.hint {
		font-size: 12px;
		font-style: italic;
		margin-top: 10px;
	}
}

button.change-theme {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 10px;
	background-color: #C9C9CD;
	color: var(--primary-color);
	border: none;
	cursor: pointer;
	gap: 10px;

	&:hover {
		background-color: #AFAFB5;

		& > span {
			background-image: url(assets/moon-solid.svg);
		}
	}

	& > span {
		width: 20px;
		height: 20px;
		background-image: url(assets/sun-solid.svg);
		background-repeat: no-repeat;
		background-position: center;
		background-size: contain;
	}
}

/* Dark Mode */
[data-theme="dark"] {
	--bg-color: #28282C;
	--primary-color: #F4F4F6;

	button.change-theme {
		background-color: #19191B;

		&:hover {
			background-color: #353539;

			& > span {
				background-image: url(assets/sun-solid-white.svg);
			}
		}

		& > span {
			background-image: url(assets/moon-solid-white.svg);
		}
	}

	a {
		color: LinkText;
	}

	input {
		/* Default dark mode Field value in Firefox */
		/* Field: #2B2A33 */
		background-color: #2B2A33;
		/* Default dark mode FieldText value in Firefox */
		/* FieldText: #FBFBFE */
		color: #FBFBFE;
	}

	button {
		/* Default dark mode ButtonFace value in Firefox */
		/* ButtonFace: #2B2A33 */
		background-color: #2B2A33;
		/* Default dark mode ButtonText value in Firefox */
		/* ButtonText: #FBFBFE */
		color: #FBFBFE;
	}
}
