/* ==========================================================================
   AF Modal – native <dialog> styling
   ========================================================================== */

.af-modal {
	position: relative;
	width: min(820px, 92vw);
	max-height: 88vh;
	padding: 0;
	border: none;
	border-radius: 8px;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
	overflow: hidden;
	background: #fff;
	color: #111;
}

/* When open, lay the dialog out as a column so only the content scrolls
   while the rounded corners + close button stay fixed. */
.af-modal[open] {
	display: flex;
	flex-direction: column;
	animation: af-modal-in 0.25s ease;
}

.af-modal::backdrop {
	background: rgba(0, 0, 0, 0.55);
	backdrop-filter: blur(2px);
}

@keyframes af-modal-in {
	from { opacity: 0; transform: translateY(12px) scale(0.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
	.af-modal[open] { animation: none; }
}

/* Close button */
.af-modal__close {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 2;
	width: 40px;
	height: 40px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: none;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.06);
	color: #111;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.af-modal__close:hover { background: rgba(0, 0, 0, 0.12); }
.af-modal__close:focus-visible { outline: 2px solid #e6002f; outline-offset: 2px; }

/* Content */
.af-modal__content {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 56px clamp(20px, 4vw, 48px) 48px;
}

.af-modal__title {
	margin: 0 0 1rem;
	font-size: clamp(24px, 3vw, 36px);
	font-weight: 900;
	line-height: 1.1;
}

.af-modal__body {
	font-size: 17px;
	line-height: 1.6;
}

.af-modal__body img { max-width: 100%; height: auto; }
.af-modal__body > :first-child { margin-top: 0; }
.af-modal__body > :last-child { margin-bottom: 0; }

.af-modal__error {
	padding: 1rem;
	color: #b00020;
	font-weight: 600;
}

/* Loader */
.af-modal__loader {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.7);
	z-index: 1;
}

/* The [hidden] attribute must win over display:flex above, otherwise the
   loader never toggles off (a class-level `display` beats the UA `hidden`
   rule). */
.af-modal__loader[hidden] {
	display: none;
}

.af-modal__spinner {
	width: 36px;
	height: 36px;
	border: 3px solid rgba(0, 0, 0, 0.15);
	border-top-color: #e6002f;
	border-radius: 50%;
	animation: af-modal-spin 0.8s linear infinite, af-modal-fade 0.2s ease 0.15s both;
}

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

@keyframes af-modal-spin {
	to { transform: rotate(360deg); }
}

/* Lock body scroll while open (belt-and-braces; <dialog> mostly handles it). */
body:has(.af-modal[open]) {
	overflow: hidden;
}
