﻿/* /Tests/Layout */

/* control parameters:
	.fixed			- fixed layout, only full height of the viewport with separately scrollable Nav + Content, also hides full-opts elem
	.fixedFooter	- footer always visible, fixed at the bottom of the viewport
	.grid			- use grid instead of flex for main layout, stretches header & footer but breaks .fixed for some reason
	.show-nav		- on narrow screen it'll show the Navigation pane and hide Hamburge when set to html
	.sticky			- when subheader reaches the top of the viewport and sticks (detected in js), it shows bottom border & shadow
	.updn			- enabled the .scroll-dn / .scroll-up handling of the header, otherwise they're ignored
	.scroll-dn		- if js detects scrolling up, this will bring back the header into the view (slide in) alon with subheader below it
	.scroll-up		- if js detects scrolling dn, this will hide the header again (make it stick outside the view, moving subheader to the top)
*/

:root {
	--header-width: 100%;
	--header-height: 86px; /* initial value, will be adjusted on resize */
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}



html {
	min-height: 100vh;	/* NOTE: Stupid 100vh doesn't account for the horizontal scrollbar which may appear on narrow screen! */
}

	html.fixed {
		height: 100vh;
	}

html, body, #layContainer {
	margin: 0px !important; /* required as important to get rid of extra border */
	padding: 0px !important;
}

body, #layContainer {
	min-height: 100vh;
}

.fixed body, .fixed form, .fixed #layContainer {
	height: 100% !important;
	Xbackground: yellow;
}

#layContainer {
	height: 100%;
}
html:not(.grid) #layContainer {
		/* don't use flex because the header and footer will never extend horizontally beyond viewport width, use grid instead */
		display: flex; /* NOTE: this can't be applied to html as it will mess up Grids on the Home Page ! */
		flex-direction: column;
	}
html.grid #layContainer {
	display: grid;
	grid-template-rows: min-content 3fr min-content; /* Header, content, footer */
	Xbackground: #8f8;
}


header, footer {
	flex-shrink: 0;
	grid-column: 1 / -1; /* Span full width */
}

header {
	top: calc( -1 * var(--header-height)) !important; /* Aligns the sticky header with sticky top-XXX subheaders */
	transition: top 0.5s ease-in; /* Smooth slide down */
}

/* fixedFooter class at the root will make the footer stick to the bottom of the window at all times */
.fixedFooter #layContent {
	padding-bottom: calc( 2px + var( --footer-height, 16px ) ); /* It already takes into account actual --footer-height but we need extra padding above it */
}
.fixedFooter footer {
	position: fixed;
}


#main, #layContent {	/* original layout used id="main" now it's "layContent" */
	display: grid;
	grid-template-columns: min-content 1fr; /* Left column auto-sized, right column fills remaining width */
	grid-template-rows: auto 1fr; /* Top row auto-sized, bottom row takes remaining height */
	flex-grow: 1;
	height: 100%;		/* Ensure the main container fills the available height */
}

.fixed #layContent {
	overflow: hidden!important; /* hidden fixes content height to fit the window, without it the page stretches below window */
}

header, .top-left, .top-right {
	position: -webkit-sticky;
	position: sticky;
	top: 0;
}

.top-left, .top-right {
	Xmargin-bottom: 5px;

	grid-row: 1 / 2;
	transition: top 0.5s ease-in; /* Smooth slide down */
}
	.top-left::after, .top-right::after {
		display: none;
		content: '';
		position: absolute;
		bottom: 0;
		left: -5px;
		right: 0;
		height: 8px;	/* needed for the shadow to be visible */
		box-shadow: rgba(0,0,0,.5) 4px 3px 5px;	/* offset to the right so the shadow from right doesn't bleed to the left */
	}
.sticky .top-left::after, .sticky .top-right::after {
	display: block;	/* show the box-shadow defined above when the top bar stick to the window top */
	border-bottom: 1px solid black;
}

/* Ensure that fixed layout ignores scrolling above */
.updn.scroll-up:not(.fixed) header {
	top: 0!important;
	transition: top 0.5s ease-out; /* Smooth slide down */
}

.updn.scroll-up:not(.fixed) .top-left, .updn.scroll-up:not(.fixed) .top-right {
	top: var(--header-height);
	transition: top 0.5s ease-out; /* Smooth slide down */
}

.top-left {
	grid-column: 1 / 2;
}

.top-right {
	grid-column: 2 / 3;
}

#Print {	/* Create PDF and Print buttons on the top-right */
	float: right;
	padding: 2px 4px 1px 10px;
}

.bottom-left, .bottom-right {
	grid-row: 2 / 3;
	Xoverflow: auto; /* Adds scrollbars if content overflows, even if not fixed because it impacts the width of left column */
}
.fixed .bottom-left, .fixed .bottom-right {
	overflow: auto; /* Adds scrollbars if content overflows */
}

.bottom-left {
	grid-column: 1 / 2;
	min-width: 200px;	/* to prevent resizing when Navigation is loaded */
}

.bottom-right {
	grid-column: 2 / 3;
	/* this is used for Tabs inside so make sure tabs take up top line while content takes the rest */
	display: flex;
	flex-direction: column;
}

#close-nav, #hamburger-menu {
	display: none;
	font-size: 2em;
	background: none;
	border: none;
	cursor: pointer;
	margin: -6px 0;
	vertical-align: -1px;
	color: gray;
}
#close-nav {
	position: absolute;
	top: 4px;
	left: 0;
}

/* Optional styles for a responsive footer on narrow screens (768 => 1000) */
@media (max-width: 1000px) {
	#layContent {
		grid-template-columns: 1fr; /* Collapse into a single column */
	}

	.top-left, .top-right {
		grid-column: 1 / 2; /* Stack navigation and content vertically */
	}

	.bottom-left, .bottom-right {
		grid-column: 1 / 2; /* Stack navigation and content vertically */
	}

	.top-left, .bottom-left {
		display: none;
	}
	.show-nav .top-left, .show-nav .bottom-left {
		display: block;
	}


	.show-nav #layContent {
		grid-template-columns: auto 1fr; /* Expand again into separate columns */
	}

		.show-nav #layContent .top-right, .show-nav #layContent .bottom-right {
			grid-column: 2 / 3;
		}

	.top-left #close-nav, .top-right #hamburger-menu {
		display: inline-block;
	}

	.show-nav #layContent .top-right #hamburger-menu {
		display: none;
	}
}

.fixed #full-opts {
	display: none; /* hide it when Fixed mode as it has no effect in that case, only enable it in Full layout */
}

/* TODO: these are non-Layout cosmetic definitions, move them elsewhere, Common.css perhaps ? */
header, .top-left, .top-right {
	background: #e0e0e0;
	z-index: 9999;
}

footer {
	margin-top: 2px;
	bottom: 0px;
	width: 100%;
}

.top-left {
	text-align: center;
}

div.Head {	/* don't use h2 for these because other css rules mess it up - conflict */
	display: inline-block;	/* to allow hamburger menu next to it */
	font-size: 160%;
	font-weight: bold;
	white-space: nowrap;
}


@media print {
	@page {
		/* Default Size - Letter: 740x980, Legal: 740x1268, A4: 718x1047 */
		size: 900px auto; /* Set the page width to 1000px */
		Xmargin: 1in; /* Adjust margins as needed */
	}

	body {
		width: 900px;
	}

	/* NOTE: When printing a fixed content, make sure it's not showing a scroll bar in the printout */
	.fixed #layContent, .fixed .bottom-left, .fixed .bottom-right {
		overflow: visible !important;
	}

	header {
		margin-bottom: -10px;
	}

	#layBanner, footer {
		background: none;
	}
}
