/* 1. Modal styles */
.modal-container {
	position: fixed;
	display: none;
	inset: 0;
	z-index: 100;
	background-color: rgb(0 0 0 / 85%);
}

.modal-container.show-modal {
	display: block;
}

.modal {
	display: flex;
	gap: 1rem;
	color: var(--white);
	padding: 1rem 0;
	width: 97%;
	height: auto;
	max-width: 100%;
	background-color: rgb(0 0 0 / 80%);
	border-radius: 0.25rem;
	box-shadow: 0 0 10px rgb(255 255 255 / 25%);
	position: absolute;
	overflow: hidden; /* Prevent content from spilling outside modal */
	top: 50%; /* Center vertically */
	left: 50%; /* Center horizontally */
	transform: translate(-50%, -50%); /* Center modal on screen */
	animation-name: modalopen;
	animation-duration: 300ms;
}

.modal .modal-image {
	display: block;
	width: auto;
	height: auto;
	max-width: 90vw;
	max-height: 80vh;
	object-fit: contain;
}

.modal.landscape,
.modal.square,
.modal.portrait {
	flex-direction: column;
	align-items: center;
}

.modal.landscape .modal-image,
.modal.square .modal-image {
	height: auto;
	max-height: 80vh;
}

.modal.square .modal-image {
	width: 70vw;
}

.modal.landscape .modal-image {
	width: 70vw;
}

.modal.portrait .modal-image {
	height: 80vh;
	width: auto;
	max-width: 60vw;
}

.modal-buttons {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	align-items: end;
	gap: 1rem;

	button {
		cursor: pointer;
		font-size: 0.875rem;
		padding: 0.375em 0.75em;
		border-radius: 0.25rem;
		border: 1px solid transparent;
		transition:
			background-color 300ms ease,
			border 300ms ease,
			color 300ms ease;
	}
}

.modal-buttons .modal-save {
	color: var(--white);
	background-color: var(--primary);
	border: 1px solid transparent;
}

.modal-buttons button:hover {
	color: var(--dark-gray);
	background-color: var(--accent-3);
	border: 1px solid transparent;
}

.modal-buttons button:focus,
.modal-buttons button:active {
	color: var(--dark-gray);
	background-color: var(--accent-3);
	border: 1px solid var(--white);
	outline: transparent;
}

.modal .nav {
	font-size: 2rem;
	line-height: 1;
	color: var(--white);
	position: absolute;
	top: 50%;
	transform: translateY(-50%); /* Vertically center nav button */
	padding: 0.125rem 0.5rem 0.5rem;
	background: rgb(0 0 0 / 50%);
	z-index: 10;
}

.modal .prev,
.modal .next {
	background-color: var(--primary-dark-1);
	border: 1px solid transparent;
	transition:
		background-color 300ms ease,
		border 300ms ease,
		color 300ms ease;
}

.modal .prev {
	left: 0.5rem;
}

.modal .next {
	right: 0.5rem;
}

.modal .prev:hover,
.modal .next:hover {
	color: var(--dark-gray);
	background-color: var(--accent-3);
	border: 1px solid var(--white);
}

.modal .prev:disabled,
.modal .next:disabled {
	color: #777;
	background-color: #aaa;
	cursor: not-allowed;
}

.modal .prev:disabled:hover,
.modal .next:disabled:hover,
.modal .prev:disabled:active,
.modal .next:disabled:active {
	color: #777;
	background-color: #aaa;
	border: 1px solid transparent;
}

.close-btn {
	cursor: pointer;
	font-size: 0.75rem;
	line-height: 1;
	background-color: var(--primary);
	color: var(--white);
	opacity: 0.75;
	padding: 0;
	border: 1px solid var(--white);
	border-radius: 0.25rem;
	position: absolute;
	top: 0.75rem;
	right: 1.25rem;
	z-index: 10;
	transition:
		color 300ms ease,
		opacity 300ms ease,
		background-color 300ms ease;

	&:hover {
		color: var(--dark-gray);
		opacity: 1;
		background-color: var(--accent-3);
	}
}

@keyframes modalopen {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

/* 2. Mobile first media queries */
@media (width >= 525px) {
	.modal.portrait .modal-image {
		max-width: 70vw;
	}
}

@media (width >= 670px) {
	.modal.square .modal-image {
		max-width: 60vw;
	}
}

@media (width >= 950px) {
	.modal.square .modal-image {
		max-width: 90vw;
	}
}
