.layout {
	min-height: 100dvh;
	width: 100dvw;
	overflow-x: clip;
	display: grid;
	grid-template-columns: minmax(12rem, auto) 1fr;
}

.skipnav {
	position: fixed;
	top: 0;
	left: 0;
	background: black;
	color: white;
	border-bottom-right-radius: 0.375rem;
	padding: 0.5rem 0.75rem;
	transform: translateY(-100%);
	transition: transform 0.3s ease-in-out;
	z-index: 2147483647;

	&:focus-within {
		transform: translateY(0);
	}
}

.sidenav {
	min-width: 14rem;
	height: calc(100dvh - var(--sb-header-height));
	position: sticky;
	top: var(--sb-header-height);
	left: 0;
	display: flex;
	flex-direction: row;
	padding: .5rem .5rem 1.5rem 1.5rem;
	transition: transform 0.3s ease-in-out;
	overflow-y: auto;
}

:global(div._e + main) {
	grid-column-start: span 2;
}

@media screen and (max-width: 1100px) {
	.layout {
		grid-template-columns: 1fr;
	}

	.sidenav {
		position: fixed;
		left: 0;
		top: 0;
		height: 100dvh;
		z-index: 51;
		width: min(20rem, 70dvw);
		background: var(--sb-background-color);
		animation: contentHide 300ms ease-out forwards;

		&[data-expanded] {
			animation: contentShow 300ms ease-out;
		}
	}
}

.sidenav-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	background: rgba(0, 0, 0, 0.4);
	backdrop-filter: blur(2px);
	z-index: 50;
	animation: overlayHide 250ms ease forwards;

	&[data-expanded] {
		animation: overlayShow 250ms ease;
	}
}

.sidenav-content {
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
}

.sidenav-header {
	width: 100%;
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	align-items: center;
}

.logo-link {
	text-decoration: none;
	color: var(--sb-heading-color);
	font-family: var(--sb-font-headings);
	font-size: 1.25em;
}

.section-trigger {
	appearance: none;
	background: unset;
	border: unset;
	cursor: var(--sb-button-cursor);
	transition-property: opacity;
	transition-timing-function: var(--sb-transition-timing);
	transition-duration: 0.15s;
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: .5rem;
	width: 100%;

	&:hover,
	&:focus {
		user-select: none;
		opacity: 0.8;
	}

	&:not(:hover)[data-expanded] svg {
		opacity: 0;
	}

	svg {
		transition-property: transform, opacity;
		transition-timing-function: var(--sb-transition-timing);
		transition-duration: 0.15s;
	}

	h2,
	h3,
	h4,
	h5,
	h6 {
		display: inline;
	}

	h2 {
		color: var(--sb-heading-color);
		font-weight: 500;
		font-size: 0.9rem;
	}

	h3,
	h4,
	h5,
	h6 {
		font-size: 0.9rem;
		font-weight: 500;
	}

	&:has(h2) {
		margin-bottom: 1rem;
	}

	&[data-expanded] {
		svg {
			transform: rotateX(180deg);
		}
	}
}

.section-content {
	animation: sectionHide .15s var(--sb-transition-timing);
	overflow: hidden;

	&[data-expanded] {
		animation: sectionShow .15s var(--sb-transition-timing);
	}
}

@keyframes sectionShow {
	from {
		opacity: 0;
		height: 0;
	}

	to {
		opacity: 1;
		height: var(--kb-collapsible-content-height);
	}
}

@keyframes sectionHide {
	from {
		opacity: 1;
		height: var(--kb-collapsible-content-height);
	}

	to {
		opacity: 0;
		height: 0;
	}
}

.sidenav-links {
	width: 100%;
	color: var(--sb-text-color);
	padding-bottom: 1rem;

	& ul {
		list-style-type: none;
		padding: 0;
	}

	& > ul {
		display: flex;
		flex-direction: column;
		gap: 1rem;

		ul {
			padding-left: .5rem;
			display: flex;
			flex-direction: column;

			ul {
				border-left: 1px solid
					color-mix(in hsl, var(--sb-decoration-color) 15%, transparent);
			}
		}
	}

	li {
		list-style-type: none;
	}

	.sidenav-link {
		display: flex;
		width: 100%;
		color: var(--sb-text-color);
		text-decoration: none;
		outline: none;
		padding: 0.5rem;
		border-radius: var(--sb-border-radius);
		font-size: 0.85rem;
		transition-property: background-color, color;
		transition-timing-function: var(--sb-transition-timing);
		transition-duration: 0.15s;
		line-height: 1.5rem;
		justify-content: space-between;
		align-items: center;

		&:hover,
		&:focus-visible {
			color: var(--sb-heading-color);
			background: color-mix(
				in hsl,
				var(--sb-link-underline-color) 20%,
				transparent
			);
		}

		&.active {
			color: var(--sb-active-link-color);
		}

		.status-new,
		.status-updated,
		.status-next,
		.status-custom {
			display: inline-flex;
			align-items: center;
			font-size: 0.7rem;
			padding: .2rem .35rem;
			line-height: 1;
			font-weight: 600;
			text-transform: uppercase;
			border-radius: .25rem;
		}

		.status-new {
			background: var(--sb-active-link-color);
			color: white;
		}

		.status-updated {
			background: oklch(66.6% 0.179 58.318);
			color: white;
		}

		.status-next {
			background: color-mix(in hsl, var(--sb-decoration-color) 40%, black);
			color: color-mix(in hsl, var(--sb-decoration-color) 10%, white);
		}

		.status-custom {
			background: var(---bg);
			color: var(---fg);
		}
	}
}

@media screen and (max-width: 1100px) {
	.sidenav-links {
		& li > ul {
			padding-top: 0.5rem;
		}
	}
}

@keyframes overlayShow {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}
@keyframes overlayHide {
	from {
		opacity: 1;
	}
	to {
		opacity: 0;
	}
}

@keyframes contentShow {
	from {
		opacity: 0;
		transform: translateX(-100%);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}
@keyframes contentHide {
	from {
		opacity: 1;
		transform: translateX(0);
	}
	to {
		opacity: 0;
		transform: translateX(-100%);
	}
}
