$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: 300px !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%;
}

div#header,
div#nav,
div#footer,
div#main-content-wrapper,
.page-width {
	clear: both;
	max-width: $width;
	margin: 0 auto;
}

@if ($mobile-width) {
    div#footer,
    div#main-content-wrapper,
    .page-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;
	padding: 0;
	@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;
		}
		div.cell {
			@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;
	}
}
