$width: 1280px !default;
$mobile-limit: 1024px !default;
$mobile-width: 720px !default;
$very-small-limit: 560px !default;
$columns-gutter: 20px !default;
$footer-background: #666666 !default;
$footer-full-width-background: true !default;
$footer-color: white !default;
$footer-link-color: $link-color !default;
$sidebar-width: 280px !default;
$sidebar-max-width: $sidebar-width !default;
$sidebar-min-width: 0 !default;
$sidebar-position: left !default;
$sidebar-columns-gutter: $columns-gutter !default;

// custom media queries
// 	@media ($max-mobile-viewport) {}
//	@media ($min-desktop-viewport) {}
$max-mobile-viewport: "max-width: #{$mobile-limit}";
$min-desktop-viewport: "min-width: #{min-desktop-viewport($mobile-limit)}";

// set default box model to border-box
* {
	box-sizing: border-box;
	&::before, &::after {
		box-sizing: inherit;
	}
}

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

div#page {
	display: flex;
	min-height: 100vh;
	flex-direction: column;
}

div#page div#main-content-wrapper,
div#page main {
	flex: 1 0 auto;
	width: 100%;
}

.page-width,
.header-width,
.nav-width,
.footer-width {
	clear: both;
	max-width: $width;
	margin: 0 auto;
}

@if ($mobile-width) {
    .page-width,
    .footer-width {
		@media ($max-mobile-viewport) {
			max-width: $mobile-width;
        }
    }
}

div#header {
	width: 100%;
	position: relative;
	padding: 0 0.7em;
	& h1 {
		margin: 0;
	}
}

div#main-content-wrapper {
	position: relative;
	z-index: 100;
	@media screen and ($max-mobile-viewport) {
		position: static;
		z-index: 0;
	}
}

div#main-content {
	margin: 0;
	min-height: 300px;
}

.column {
	float: left;
	width: 50%;
}

#columns-wrapper {
	flex-grow: 1;
	max-width: 100%;
}

.central-content {
	display: flex;
	#sidebar {
		flex: 0 0 $sidebar-width;
		max-width: $sidebar-max-width;
		@if $sidebar-min-width != 0 {
			min-width: $sidebar-min-width;
		}
		@if $sidebar-position == right {
			order: 1;
		}
		@if $sidebar-position == left {
			margin-left: 0;
			margin-right: $sidebar-columns-gutter;
		} @else {
			margin-left: $sidebar-columns-gutter;
			margin-right: 0px;
		}
	}
}

@media screen and ($max-mobile-viewport) {
	#columns-wrapper {
		padding: 0 0.7em;
		max-width: 100%;
	}
	.column {
		float: none;
		width: auto;
	}

	.central-content {
		flex-direction: column;
		#sidebar {
			flex: 0 0 auto;
			max-width: 100%;
			// don't apply min-width on mobile
			@if $sidebar-min-width != 0 {
				min-width: 0;
			}
			margin: 0 0.7em;
			div.cell {
				margin-left: 0;
				margin-right: 0;
			}
		}
	}
}

#footer-wrapper {
	clear: both;
	margin-top: 1.5em;
	color: $footer-color;
	a {
		color: $footer-link-color;
	}
}

@if $footer-full-width-background {
	#footer-wrapper {
		padding: 0.7em 0 1.5em 0;
		background-color: $footer-background;
	}
} @else {
	#footer {
		padding: 0.7em 0.7em 1.5em 0.7em;
		background-color: $footer-background;
	}
}

@media screen and ($max-mobile-viewport) {
	.pk-desktop-only, .desktop-only {
		display: none !important;
	}
}

@media screen and ($min-desktop-viewport) {
	.pk-mobile-only, .mobile-only {
		display: none !important;
	}
}

@media not print {
	.pk-print-only {
		display: none !important;
	}
}

@media print {
	.pk-no-print {
		display: none !important;
	}
}

body.pk-mini-page {
	@if variable-exists(primary-color) {
		--primary-color: #{$primary-color};
	} @else {
		--primary-color: #ccc;
	}
	margin: 0;
	padding: 0;
	background: #F2F2F2;
	color: black;
	font-family: sans-serif;
	padding: 1em;
	main {
		background: white;
		max-width: 30em;
		margin: 4em auto;
		padding: 1em;
		text-align: center;
		border-bottom: 5px solid var(--primary-color);
	}
	.loader {
		margin: 2em auto;
		width: 40px;
		height: 30px;
		aspect-ratio: 1;
		--c: linear-gradient(var(--primary-color) 0 0);
		--r1: radial-gradient(farthest-side at bottom, var(--primary-color) 93%, var(--primary-color));
		--r2: radial-gradient(farthest-side at top   , var(--primary-color) 93%, var(--primary-color));
		background: var(--c), var(--r1), var(--r2), var(--c), var(--r1), var(--r2), var(--c), var(--r1), var(--r2);
		background-repeat: no-repeat;
		animation: l2 1s infinite alternate;
	}
	@keyframes l2 {
		0%,25% {
			background-size: 8px 0, 8px 4px, 8px 4px, 8px 0, 8px 4px, 8px 4px, 8px 0, 8px 4px, 8px 4px;
			background-position: 0 50%, 0 calc(50% - 2px), 0 calc(50% + 2px), 50% 50%, 50% calc(50% - 2px), 50% calc(50% + 2px), 100% 50%, 100% calc(50% - 2px), 100% calc(50% + 2px);
		}
		50% {
			background-size: 8px 100%, 8px 4px, 8px 4px, 8px 0, 8px 4px, 8px 4px, 8px 0, 8px 4px, 8px 4px;
			background-position: 0 50%, 0 calc(0% - 2px), 0 calc(100% + 2px), 50% 50%, 50% calc(50% - 2px), 50% calc(50% + 2px), 100% 50%, 100% calc(50% - 2px), 100% calc(50% + 2px);
		}
		75% {
			background-size: 8px 100%, 8px 4px, 8px 4px, 8px 100%, 8px 4px, 8px 4px, 8px 0, 8px 4px, 8px 4px;
			background-position: 0 50%, 0 calc(0% - 2px), 0 calc(100% + 2px), 50% 50%, 50% calc(0% - 2px), 50% calc(100% + 2px), 100% 50%, 100% calc(50% - 2px), 100% calc(50% + 2px);
		}
		95%,100% {
			background-size: 8px 100%, 8px 4px,  8px 4px, 8px 100%, 8px 4px, 8px 4px, 8px 100%, 8px 4px, 8px 4px;
			background-position: 0 50%, 0 calc(0% - 2px), 0 calc(100% + 2px), 50% 50%, 50% calc(0% - 2px), 50% calc(100% + 2px), 100% 50%, 100% calc(0% - 2px), 100% calc(100% + 2px);
		}
	}
}
