html, body {
	margin: 0;
	padding: 0;
	overflow: hidden;
	display: flex;
	justify-content: center;
	align-items: center;
	height: 100%;
}

@font-face {
    font-family: 'Zrnic';
    src: url('fonts/zrnic.otf') format('opentype'),
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

.grid {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	grid-template-rows: auto 1fr auto;
	align-items: center;
	justify-items: center;
	width: 100%;
	height: 100vh;
	padding: 1rem;
	box-sizing: border-box;
}

.site-header {
	grid-column: 1 / -1;
	font-family: 'Zrnic', sans-serif;
	font-size: 1.25rem;
	text-align: center;
	padding: 0.5rem 0;
}

.site-footer {
	grid-column: 1 / -1;
	font-family: 'Zrnic', sans-serif;
	font-size: 1rem;
	text-align: center;
	padding: 0.5rem 0;
	opacity: 0.5;
}

.canvas-wrap {
	display: flex;
	justify-content: center;
	align-items: center;
}

canvas {
	max-height: 70vh !important;
	max-width: 50vw !important;
	width: auto !important;
	height: auto !important;
	aspect-ratio: 820 / 720;
}

.link {
	font-family: 'Zrnic', sans-serif;
	text-decoration: none;
	color: inherit;
	font-size: 1.75rem;
	margin: 0.5rem 2rem 0.5rem 2rem;
	position: relative;
}

.link::after {
	content: "";
	position: absolute;
	bottom: -2px;
	left: 50%;
	width: 0;
	height: 2.5px;
	background: currentColor;
	transition: width 0.3s ease, left 0.3s ease;
}

.link:hover::after {
	width: 100%;
	left: 0;
}

.menu {
	display: flex;
	flex-direction: column;
	align-items: center;
}

.submenu {
	display: flex;
	flex-direction: column;
	align-items: center;
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.4s ease;
}

.menu.open .submenu {
	max-height: 12rem;
}

.submenu-item {
	font-family: 'Zrnic', sans-serif;
	text-decoration: none;
	color: inherit;
	font-size: 1.2rem;
	padding: 0.4rem 0;
	opacity: 0;
	transform: translateY(-8px);
	transition: opacity 0.5s ease, transform 0.5s ease;
}

.menu.open .submenu-item:nth-child(1) { opacity: 1; transform: translateY(0); transition-delay: 0.05s; }
.menu.open .submenu-item:nth-child(2) { opacity: 1; transform: translateY(0); transition-delay: 0.1s; }
.menu.open .submenu-item:nth-child(3) { opacity: 1; transform: translateY(0); transition-delay: 0.15s; }

.theme-toggle {
	position: fixed;
	top: 1.5rem;
	right: 1.5rem;
	width: 44px;
	height: 24px;
	z-index: 10;
	cursor: pointer;
}

.theme-toggle input {
	display: none;
}

.theme-toggle .slider {
	position: absolute;
	inset: 0;
	background: color-mix(in srgb, currentColor 20%, transparent);
	border-radius: 12px;
	transition: background 0.3s;
}

.theme-toggle .slider::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	background: var(--knob-bg, #fff);
	border-radius: 50%;
	transition: transform 0.3s;
}

.theme-toggle input:checked + .slider::after {
	transform: translateX(20px);
}

@media (max-width: 820px) and (max-aspect-ratio: 5/4) {

	.grid {
		grid-template-columns: 1fr;
		grid-template-rows: auto 1fr 28vh 1fr auto;
		align-content: center;
	}

	.site-header { order: -1; }
	.site-footer { order: 3; }

	.structure-menu {
		order: 0;
		align-self: end;
		flex-direction: column-reverse;
	}

	.structure-menu .submenu-item {
		transform: translateY(8px);
	}

	.structure-menu .submenu-item:nth-child(1) { transition-delay: 0s; }
	.structure-menu .submenu-item:nth-child(2) { transition-delay: 0.05s; }
	.structure-menu .submenu-item:nth-child(3) { transition-delay: 0.1s; }

	.structure-menu.open .submenu-item:nth-child(1) { transition-delay: 0.15s; }
	.structure-menu.open .submenu-item:nth-child(2) { transition-delay: 0.1s; }
	.structure-menu.open .submenu-item:nth-child(3) { transition-delay: 0.05s; }

	.structure-menu .link::after {
		bottom: auto;
		top: -2px;
	}

	.canvas-wrap {
		order: 1;
		overflow: hidden;
	}

	.flow-menu {
		order: 2;
		align-self: start;
	}

	canvas {
		max-width: 90vw !important;
		max-height: 40vh !important;
	}
}

@media (max-width: 820px) and (max-aspect-ratio: 5/4) and (min-aspect-ratio: 2/3) {
	.grid {
		grid-template-columns: 1fr;
		grid-template-rows: auto 1fr 28vh 1fr auto;
		align-content: center;
	}
}

.menu.open > .link::after {
	width: 100%;
	left: 0;
}

@media (hover: none) {
	.link:hover::after {
		width: 0;
		left: 50%;
	}
}
