
/******************************************
* Modal Dialog
******************************************/

#modal {
	/* Underlay covers entire screen. */
	position: fixed;
	top: 0px;
	left: 0px;
	right:0px;
	bottom:0px;
	z-index: 1000;

	/* Flexbox centers the .modal-content vertically and horizontally */
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content:flex-start;

	/* Opacity updated by animations */
	opacity: 0;
	transition:opacity;
	transition-duration:180ms;
	transition-timing-function: ease;
}

#modal-underlay {
	/* underlay takes up the entire viewport. This is only
	required if you want to click to dismiss the popup */
	position: absolute;
	z-index: -1;
	top: 0px;
	bottom: 0px;
	left: 0px;
	right: 0px;
	background-color: #444;
	opacity: 0;
	transition:opacity;
	transition-duration:180ms;
	transition-timing-function: ease;
}

#modal-window {
	/* Sizing for visible dialog */
	width:600px;
	max-width:99vw;
	max-height:99vh;

	/* Scrolling behavior */
	display:flow-root;
	overflow-x:hidden;
	overflow-y:auto;
	overscroll-behavior:none;

	/* Display properties for visible dialog */
	position:relative;
	border: solid 1px var(--gray40);
	border-radius: 8px;
	box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.3);
	background-color: var(--page-background);
	padding: calc(var(--rhythm) * 2);
	line-height: 150%;
	margin-top:24px;

	opacity:0;
	transform:scale(0.8);
	transition:transform, opacity;
	transition-duration:180ms;
	transition-timing-function: ease
}

/* Enhanced Modals with Fixed Header/Footer */

#modal-window:has(#modal-body) {
	display:flex;
	flex-direction:column;
	padding: 0px;
}

#modal-header {
	padding-top: calc(var(--rhythm) * 1);
	padding: calc(var(--rhythm) * 2);
	border-bottom: solid 1px var(--gray20);
}

#modal-body {
	flex-grow:1;
	padding: calc(var(--rhythm) * 2);
	overflow-x:hidden;
	overflow-y:auto;
	overscroll-behavior:none;
}

#modal-header + #modal-body {
	padding-top: calc(var(--rhythm) * 1);
	background-color: var(--gray10);
}

#modal-footer {
	padding: calc(var(--rhythm) * 2);
	padding-bottom:12px;
	margin:0px;
	border-top:solid 1px var(--gray30);
	background-color: var(--gray20);
}

/* Additional Sizes */

#modal-window.large {
	width: clamp(480px, 96%, 1024px);}

#modal-window.huge {
	width:96%;
	height:96%;
}


/* Animations */

#modal.ready {
	opacity: 1;
	transition:opacity;
	transition-duration:180ms;
	transition-timing-function: ease
}

#modal.ready #modal-window {
	opacity:1;
	transform:scale(1);
	transition:transform, opacity;
	transition-duration:180ms;
	transition-timing-function: ease
}

#modal.ready #modal-underlay {
	opacity:0.7;
	transition:opacity;
	transition-duration:180ms;
	transition-timing-function: ease;
}

#modal .layout-title,
#modal #modal-title {
    font-weight:calc(var(--weight) + 100);
    font-size: calc(var(--rhythm) * 4);
    line-height:calc(var(--rhythm) * 5);
    margin-top:calc(var(--rhythm) * 1);
    margin-bottom:calc(var(--rhythm) * 3);
}


/* Alternate colors for dark mode */

@media (prefers-color-scheme: dark) {
	#modal-content {
		background-color:var(--gray20);
		border-color:var(--gray30);
		color: white;
	}
	
	#modal-underlay {
		background-color:black;
		opacity: 0.9;
	}
}
