/**
 * modal.css
 *
 * Reusable modal module.
 */

body.has-open-modal {
	overflow: hidden;
}

.modal[hidden] {
	display: none;
}

.modal {
	position: fixed;
	inset: 0;
	z-index: 999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
}

.modal--backdrop {
	position: absolute;
	inset: 0;
	background: rgba(148, 59, 37, 0.18);
}

.modal--dialog {
	position: relative;
	width: min(100%, 58rem);
	max-height: calc(100vh - 2rem);
	overflow: auto;
	padding: 1.5rem;
	border: 1px solid var(--color-brown);
	border-radius: 1rem;
	background: var(--color-white);
	box-shadow: 0 2rem 3rem rgba(148, 59, 37, 0.15);
}

.modal--header {
	margin-bottom: 1.5rem;
}

.modal--controls {
	position: sticky;
	top: -1.5rem;
	z-index: 4;
	display: flex;
	justify-content: flex-end;
	gap: 0.5rem;
	margin: -1.5rem -1.5rem 1rem;
	padding: 1.5rem 1.5rem 0.875rem;
	background: linear-gradient(to bottom, var(--color-white) 0%, var(--color-white) 82%, rgba(255, 255, 255, 0) 100%);
}

.modal--close,
.modal--nav {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	border: 0;
	border-radius: var(--radius-pill);
	background: var(--color-brown);
	color: var(--color-white);
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
}

.modal--icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
	line-height: 1;
}

.modal--closeIcon {
	position: relative;
	display: block;
	width: 1rem;
	height: 1rem;
}

.modal--closeStroke {
	position: absolute;
	inset: 50% auto auto 50%;
	width: 100%;
	height: 2px;
	background: currentColor;
	border-radius: 999px;
	transform-origin: center;
}

.modal--closeStroke:first-child {
	transform: translate(-50%, -50%) rotate(45deg);
}

.modal--closeStroke:last-child {
	transform: translate(-50%, -50%) rotate(-45deg);
}

.modal--nav[disabled] {
	opacity: 0.35;
	cursor: not-allowed;
}

.modal--layout {
	display: grid;
	gap: 1.5rem;
}

.modal--content {
	display: grid;
	gap: 1.25rem;
}

.modal--contentMain {
	min-height: 0;
}

.modal--title {
	margin: 0;
	font-size: var(--font-size-page-title);
	line-height: var(--line-title);
	color: var(--color-brown);
}

.modal--meta {
	margin: 0;
	display: grid;
	gap: 0.875rem;
}

.modal--metaRow {
	display: grid;
	gap: 0.25rem;
}

.modal--metaLabel,
.modal--metaValue {
	margin: 0;
	font-size: var(--font-size-body);
	line-height: var(--line-body);
}

.modal--metaLabel {
	color: var(--color-brown);
	text-transform: capitalize;
}

.modal--metaValue {
	color: var(--color-body-text);
}

.modal--body {
	max-width: 26rem;
}

.modal--actions {
	margin: 0;
}

.modal--gallery {
	display: grid;
	gap: 1rem;
}

.modal--thumbs {
	display: flex;
	gap: 0.75rem;
	overflow-x: auto;
	overflow-y: hidden;
	padding-right: 0.25rem;
	padding-bottom: 0.25rem;
	flex-wrap: nowrap;
	-webkit-overflow-scrolling: touch;
}

.modal--thumb {
	flex: 0 0 auto;
	padding: 0;
	border: 1px solid transparent;
	border-radius: 0.5rem;
	background: transparent;
	cursor: pointer;
}

.modal--thumb.is-active {
	border-color: var(--color-brown);
}

.modal--thumbImage {
	width: 4.75rem;
	height: 4.75rem;
	object-fit: cover;
	border-radius: 0.5rem;
}

.modal--viewer {
	display: flex;
	align-items: stretch;
	justify-content: center;
	padding: 0.875rem;
	border-radius: 0.75rem;
	background: var(--color-card-bg);
}

.modal--slide {
	display: none;
	margin: 0;
	width: 100%;
}

.modal--slide.is-active {
	display: flex;
	align-items: center;
	justify-content: center;
}

.modal--slideImage {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	border-radius: 0.875rem;
}

@media screen and (min-width: 900px) {
	.modal--dialog {
		display: flex;
		flex-direction: column;
		height: min(calc(100vh - 2rem), 43rem);
		max-height: min(calc(100vh - 2rem), 43rem);
		overflow: hidden;
	}

	.modal--header {
		flex: 0 0 auto;
	}

	.modal--controls {
		top: 0;
		margin: 0 0 1rem;
		padding: 0 0 1rem;
	}

	.modal--layout {
		grid-template-columns: minmax(0, 18rem) minmax(0, 1fr);
		align-items: stretch;
		min-height: 0;
		flex: 1 1 auto;
	}

	.modal-layoutNoGallery {
		grid-template-columns: 1fr;
	}

	.modal--content {
		grid-template-rows: minmax(0, 1fr) auto;
		min-height: 0;
	}

	.modal--contentMain {
		overflow-y: auto;
		padding-right: 0.5rem;
	}

	.modal--gallery {
		grid-template-columns: auto minmax(0, 1fr);
		align-items: stretch;
		min-height: 0;
	}

	.modal--thumbs {
		flex-direction: column;
		height: 100%;
		align-self: stretch;
		overflow-y: auto;
		overflow-x: hidden;
		padding-right: 0.5rem;
		padding-bottom: 0;
	}

	.modal--viewer {
		height: 100%;
		min-height: 0;
		overflow: hidden;
	}

	.modal--slide,
	.modal--slide.is-active {
		height: 100%;
	}

	.modal--slideImage {
		max-width: 100%;
		max-height: 100%;
		width: auto;
		height: auto;
		object-fit: contain;
	}
}
