* {
	box-sizing: border-box;
	image-rendering: pixelated;
}

html,
body {
	display: flex;
	flex-flow: column;
	height: 100%;
	margin: 0;
	font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}

body>div {
	display: flex;
	flex-flow: column;
	flex: 1 1 auto;
	height: calc(100% - 48px);
	background-image: url("background.png");
	background-size: cover;
}

nav {
	display: flex;
	flex-flow: row;
	flex-wrap: wrap;

	&>a {
		box-sizing: border-box;
		width: 80px;
		/* 32px * 2.5 = 80px */
		margin: 3px 1px;
		padding: 4px 2px;
		display: flex;
		flex-flow: column;
		align-items: center;
		color: #ffffff;
		font-size: 11px;
		text-decoration: none;
		text-shadow: 1px 1px 2px black;
		letter-spacing: 0.5px;
		border: 1px solid transparent;

		&:visited {
			color: #dddddd;
		}

		&:hover {
			background-color: #88bbff44;
			border: 1px solid #88bbff88;
		}

		&>p {
			text-align: center;
			margin: 0;
			margin-top: 2px;
		}

		&>img {
			filter: drop-shadow(1px 1px 2px #00000044);
		}
	}
}

@media screen and (min-width: 1024px) {
	body>div {
		flex-flow: row;
	}

	nav {
		flex-flow: column;
		flex-wrap: wrap;
		/* this has to be defined here too for some reason, thank you css */
	}
}

nav>a>img,
footer>a>img {
	width: 32px;
	height: 32px;
}

main {
	left: 0;
	right: 0;
	width: 100%;
	display: flex;
	flex-flow: row;
	flex-wrap: wrap;
	justify-content: space-evenly;
	overflow-y: auto;
}

@media screen and (min-width: 1024px) {
	main {
		/*width: 848px;  1024px - (2 * (80px + 2 * 4px)) = 848px */
		padding: 0;
	}
}

/* for firefox scrollbars :/
 * it is shit but can't get closer than that :P
 * detecting if firefox: https://stackoverflow.com/a/32455002
 * scrollbar css for firefox: https://stackoverflow.com/a/54101063
 */
@supports (-moz-appearance: none) {
	main {
		scrollbar-color: #567df0 #aabbff;
	}
}

aside {
	position: fixed;
	left: 0px;
	top: 0px;
	width: 0px;
	height: 0px;


	& button {
		border: 2px outset #eedd88;
		border-radius: 2px;
		background-color: #ddcc88;
		text-shadow: -1px 0 #ffffff44, 0 1px #ffffff44, 1px 0 #ffffff44, 0 -1px #ffffff44;
	}
}

/* https://stackoverflow.com/a/67476494 */
::-webkit-scrollbar-button:vertical:start:increment,
::-webkit-scrollbar-button:vertical:end:decrement,
::-webkit-scrollbar-button:horizontal:start:increment,
::-webkit-scrollbar-button:horizontal:end:decrement {
	display: none;
}

/* this selector is required for some reason so we just tell it to fuck off */
::-webkit-scrollbar {
	opacity: 0;
}

::-webkit-scrollbar-track {
	border-radius: 2px;
	border-left: 2px outset #ccddff;
	border-right: 2px outset #ccddff;
	background-color: #aabbff;
}

::-webkit-scrollbar-button,
::-webkit-scrollbar-thumb {
	border-radius: 2px;
	border: 2px outset #88aaff;
	background-color: #567df0;

	&:hover,
	&:hover {
		border-color: #aabbff;
		background-color: #88aaff;
	}

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

details {
	height: max-content;
	width: max-content;
	border: 2px outset #88aaff;
	border-radius: 2px;
	margin: 8px;
	padding: 4px;
	background-color: #567df0;

	&.popup {
		position: fixed;
		left: 50vw;
		top: 50vh;
		transform: translate(-50%, -50%);

		& div {
			padding: 4px;
			display: flex;
			flex-direction: column;
			align-items: center;

			& small {
				opacity: 0.5;
			}
		}
	}

	&>div {
		border: 2px inset #88aaff;
		background-color: #ffffff;
	}

	&:target {
		border-color: #ccddff;
		background-color: #aabbff;

		& {
			border-color: #ccddff;
		}
	}

	&>summary {
		margin-right: 2px;
		margin-left: 4px;

		&::marker {
			margin-right: 8px;
		}

		&>span {
			display: inline-flex;
			width: calc(100% - 18px);
			font-size: 13px;
			padding-left: 4px;
			padding-bottom: 4px;

			&>span:not(:has(img)) {
				flex: 1 1 auto;
				margin-right: 8px;
				text-overflow: ellipsis;
				text-wrap: nowrap;
				font-weight: bold;
				vertical-align: middle;
			}

			&>span:has(img) {
				display: flex;
				width: 70px;
				height: 20px;
				justify-content: space-between;

				&>img {
					width: 20px;
					height: 20px;
					text-align: center;
					vertical-align: text-top;
					font-size: 16px;
					font-weight: bold;
					border-radius: 3px;
					color: white;
					border: 2px outset #666666;
					background-color: #444444;
				}
			}
		}
	}
}

/* for some reason we have to reduce the width of this
 * by 2 pixels or else the marker causes it to wrap
 * detecting if firefox: https://stackoverflow.com/a/32455002
 */
@supports (-moz-appearance: none) {
	details>summary>span {
		width: calc(100% - 20px);
	}
}

img[src="windowButtonMinimize.png"] {
	border: 2px outset #66ff66;
	background-color: #24d424;
}

img[src="windowButtonMaximise.png"] {
	border: 2px outset #dddd33;
	background-color: #cccc1f;
}

img[src="windowButtonClose.png"] {
	border: 2px outset #ff8866;
	background-color: #ed4f3e;
}

iframe {
	display: block;
	border: none;
}

.markdown {
	padding: 4px;
	overflow-y: scroll;

	& code {
		background-color: #eee;
		border: 1px solid #ddd;
		border-radius: 3px;
	}

	& small {
		opacity: 0.666;
	}
}

.subtextStructureDialect {
	background-image: url("windows/starryBackground.png");
	background-repeat: repeat;
	padding: 12px;

	&:not(textarea) {
		color: #ffff00;
		/* TODO: verify if this is a good idea */
		text-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black;
	}

	& img,
	& textarea {
		box-shadow: 0px 0px 4px 2px #ffffff44;
	}

	& textarea {
		word-break: break-all;
		color: #ffffff;
		background-color: #000000;
	}

	& hr {
		border-top: 1px solid #ff0000;
		border-bottom: 1px solid #880000;
		box-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black;
	}
}

.spreadsheet {
	text-wrap: nowrap;
	overflow: auto;

	& table {
		width: 100%;
		border-spacing: 0px;
		border: 1px solid #333333;
	}

	& tr {
		width: 100%;

		&:nth-child(2n + 1) td {
			background-color: #dddddd;
		}
	}

	& th {
		background-color: #666666;
		color: #ffffff;
		border-left: 2px solid #444444;
		border-bottom: 2px solid #444444;
		border-top: 2px solid #444444;
		padding: 2px 4px;
		text-align: left;

		&:last-child {
			border-right: 2px solid #444444;
		}
	}

	& td {
		border-left: 2px solid #888888;
		border-bottom: 2px solid #888888;
		padding: 2px 4px;

		&:last-child {
			border-right: 2px solid #888888;
		}
	}
}

.tabmenu {
	& section {
		width: 100%;
		height: 100%;
		display: flex;
		flex-wrap: wrap;
		align-content: flex-start;
		border: black solid 1px;
	}

	& input[type="radio"] {
		display: none;

		&:checked+label {
			background-color: #ffffff;
			border-bottom: none;
			border-top: #888888 solid 2px;

			&>span {
				border-right: #888888 solid 2px;
				border-left: #888888 solid 2px;
			}
		}
	}

	& label {
		display: inline-block;
		box-sizing: border-box;
		height: 30px;
		cursor: pointer;
		border-top: #444444 solid 2px;
		border-bottom: #888888 solid 2px;
		background-color: #eeeeee;
		text-align: center;

		&[for="tab1"] {
			width: 56px;
		}

		&[for="tab2"] {
			width: 100px;
		}

		&[for="tab3"] {
			width: 90px;
		}

		&>span {
			display: inline-block;
			height: 100%;
			width: 100%;
			padding: 4px;
			border-right: #444444 solid 2px;
			border-left: #666666 solid 2px;
		}
	}

	& .tab-content {
		display: none;
	}

	& #tab1:checked~#content1,
	& #tab2:checked~#content2,
	& #tab3:checked~#content3 {
		display: block;
		border-bottom: #888888 solid 2px;
		border-right: #888888 solid 2px;
		border-left: #888888 solid 2px;
		width: 100%;
		height: 266px;
	}
}

.decors {
	background: linear-gradient(135deg, #ff8844, #ff0088, #00bbff, #00ffff);
	padding: 8px;

	&>h2 {
		margin-bottom: 8px;
		text-shadow: -1px 0 #ffffff44, 0 1px #ffffff44, 1px 0 #ffffff44, 0 -1px #ffffff44;
	}

	&>a {
		text-decoration: none;

		&>img {
			box-shadow: 0px 0px 4px 2px #ffffff44;
			width: 88px;
			height: 31px;
			box-sizing: content-box;
		}
	}
}

.mailer>form {
	&>img {
		margin-left: 8px;
	}

	&>div {
		width: 100%;
		height: 24px;

		&>label {
			display: inline-block;
			width: 65px;
			height: 24px;
			text-align: end;
			vertical-align: middle;
			padding-right: 3px;

			background: linear-gradient(#eeeeee, #cccccc);
			border: 2px outset #999999;
			border-top-left-radius: 10px;
			border-bottom-left-radius: 10px;
		}

		&>input {
			width: 260px;
			height: 24px;
			padding-left: 2px;
			background: linear-gradient(#dddddd, #eeeeee);
			border-radius: 10px;
			border-top-left-radius: 0px;
			border-bottom-left-radius: 0px;
			vertical-align: middle;

			&:focus {
				outline: none;
			}

			&:disabled {
				background: linear-gradient(#eeeeee, #f7f7f7);
				border-top: 2px solid #aaaaaa;
				border-left: 2px solid #aaaaaa;
				border-bottom: 2px solid #cccccc;
				border-right: 2px solid #cccccc;
				color: #aaaaaa;
			}
		}

		&:has(label[for="body"]) {
			margin-top: 10px;
		}

		&>label[for="body"] {
			border-top-right-radius: 10px;
			border-bottom-left-radius: 0px;
			text-align: center;
		}
	}

	&>div,
	&>textarea,
	&>button {
		display: block;
		margin: auto;
		margin-top: 5px;
		width: 330px;
	}

	&>textarea {
		height: 113px;
		padding: 4px;
		resize: none;

		border: 2px inset #999999;
		background: linear-gradient(#dddddd, #eeeeee);
		border-bottom-left-radius: 10px;
		border-top-right-radius: 10px;

		&:focus {
			outline: none;
		}
	}

	&>button {
		width: 48px;
		margin-right: 8px;
		background: linear-gradient(#eeeeee, #cccccc);
		border: 2px inset #999999;
		border-bottom-right-radius: 7px;
		border-bottom-left-radius: 7px;
	}
}

#mailSubmitted:not(:target) {
	display: none;
}

footer {
	display: flex;
	flex-flow: row;
	flex: 0 1 40px;
	box-sizing: border-box;
	padding: 2px;
	background-color: #bbbbbb;
	border: 2px outset #dddddd;

	&>a {
		height: 40px;
		box-sizing: border-box;
		padding: 2px;
		margin-right: 4px;
		background-color: #bbbbbb;
		border: 2px outset #dddddd;
		border-radius: 2px;

		&:visited {
			background-color: #aaaaaa;
			border: 2px outset #bbbbbb;
		}

		&:hover {
			background-color: #cccccc;
			border: 2px outset #eeeeee;
		}
	}
}
