.modal-overlay {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1000;
	background-color: rgba(255, 255, 255, 0.8);
	overflow: hidden;
	align-items: center;
	justify-content: center;
	padding: 20px;
	box-sizing: border-box;
}

.modal-overlay.is-open {
	display: flex;
}

/* ---------- Dialog container ---------- */
.modal {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 640px;
	max-height: calc(100% - 40px);
	background-color: #ffffff;
	box-shadow: 0px 0px 20px 3px rgba(163, 134, 47, 0.5);
	border-top: 5px solid #A3862F;
	box-sizing: border-box;
	overflow: hidden;
}

.modal.modal--sm { max-width: 400px; }
.modal.modal--lg { max-width: 960px; }
.modal.modal--full {
	max-width: none;
	width: calc(100% - 40px);
	height: calc(100% - 40px);
}

/* ---------- Header ---------- */
.modal-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	padding: 24px 28px 16px;
	border-bottom: 1px solid rgba(163, 134, 47, 0.35);
}

.modal-title {
	margin: 0;
	color: #A3862F;
	font-family: bBold, Georgia, serif;
	font-size: 2.4em;
	line-height: 0.9em;
	font-weight: normal;
}

.modal-subtitle {
	display: block;
	margin-top: 6px;
	color: #00245D;
	font-family: kBold, Arial, sans-serif;
	font-size: 1em;
}

.modal-close {
	flex-shrink: 0;
	background: none;
	border: none;
	padding: 0;
	margin: 0;
	color: #A3862F;
	font-size: 2em;
	line-height: 1em;
	cursor: pointer;
	transition: transform 0.5s;
}

.modal-close:hover,
.modal-close:focus-visible {
	transform: rotate(90deg);
	outline: none;
}

.modal-close:focus-visible {
	outline: 2px solid #A3862F;
	outline-offset: 4px;
}

/* ---------- Body ---------- */
.modal-body {
	flex: 1 1 auto;
	padding: 20px 28px;
	overflow-y: auto;
	overflow-x: hidden;
	color: #00245D;
	font-family: kReg, Arial, sans-serif;
	font-size: 1em;
	line-height: 1.5em;
	text-align: left;
}

.modal-body p {
	margin: 0 0 1em;
}

.modal-body p:last-child {
	margin-bottom: 0;
}

/* Optional media block (image above body) */
.modal-media {
	position: relative;
	width: 100%;
	height: 45%;
	min-height: 160px;
	background-color: #f4f1e8;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	box-shadow: 0px 0px 20px 3px rgba(163, 134, 47, 0.5);
}

/* ---------- Footer ---------- */
.modal-footer {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 12px;
	padding: 16px 28px 22px;
	border-top: 1px solid rgba(163, 134, 47, 0.35);
}

.modal-footer.modal-footer--split {
	justify-content: space-between;
}

/* ---------- Buttons ---------- */
.modal-btn {
	display: inline-block;
	padding: 10px 22px;
	font-family: kBold, Arial, sans-serif;
	font-size: 0.95em;
	letter-spacing: 0.03em;
	border: 1px solid #A3862F;
	border-radius: 0;
	cursor: pointer;
	transition: background-color 0.3s, color 0.3s;
	background-color: transparent;
	color: #A3862F;
}

.modal-btn:hover,
.modal-btn:focus-visible {
	background-color: #A3862F;
	color: #ffffff;
	outline: none;
}

.modal-btn--primary {
	background-color: #A3862F;
	color: #ffffff;
}

.modal-btn--primary:hover,
.modal-btn--primary:focus-visible {
	background-color: #00245D;
	border-color: #00245D;
}

.modal-btn--ghost {
	border-color: transparent;
	color: #00245D;
}

.modal-btn--ghost:hover,
.modal-btn--ghost:focus-visible {
	background-color: transparent;
	color: #A3862F;
}

.modal-btn--danger {
	border-color: #8B1E1E;
	color: #8B1E1E;
}

.modal-btn--danger:hover,
.modal-btn--danger:focus-visible {
	background-color: #8B1E1E;
	color: #ffffff;
}

/* ---------- Opening animation (fade only, no movement) ---------- */
.modal-overlay.is-open .modal {
	animation: modal-fade 0.25s ease-out;
}

@keyframes modal-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

/* ---------- Scroll lock ----------
   Applied to <html> so the page does not jump when the scrollbar
   disappears. --scrollbar-width is set by the script on open. */
html.modal-open {
	overflow: hidden;
}

html.modal-open body {
	padding-right: var(--scrollbar-width, 0px);
}

/* ---------- Responsive (mirrors team.css breakpoints) ---------- */
@media screen and (max-width: 900px) {
	.modal-title {
		font-size: 1.9em;
	}

	.modal-header,
	.modal-body,
	.modal-footer {
		padding-left: 20px;
		padding-right: 20px;
	}

	.modal-media {
		height: 35%;
	}
}

@media screen and (max-width: 500px) {
	.modal-overlay {
		padding: 0;
	}

	.modal {
		max-height: 100%;
		height: 100%;
		max-width: none;
		box-shadow: none;
	}

	.modal-footer {
		flex-direction: column-reverse;
		align-items: stretch;
	}

	.modal-footer .modal-btn {
		width: 100%;
		text-align: center;
	}
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
	.modal-overlay.is-open .modal,
	.modal-close {
		animation: none;
		transition: none;
	}
}