/**
 * Sagebrush Advocates — Modal Stylesheet
 * Dark + Cinematic Edition
 *
 * @package Sagebrush_Advocates
 */

/* ============================================================
   MODAL OVERLAY + WRAPPER
   ============================================================ */

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

	/* Hidden state */
	visibility: hidden;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sa-modal.is-open {
	visibility: visible;
	opacity: 1;
	pointer-events: auto;
}

/* Backdrop */
.sa-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.88);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	cursor: pointer;
}

/* ============================================================
   MODAL CONTAINER
   ============================================================ */

.sa-modal__container {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 500px;
	max-height: calc(100dvh - 2rem);
	overflow-y: auto;

	/* Appearance */
	background: #111111;
	border: 1px solid #242424;
	border-radius: 6px;

	/* Top accent line: animated gradient */
	border-top: none;

	/* Entry animation */
	transform: translateY(32px) scale(0.96);
	transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);

	/* Scrollbar */
	scrollbar-width: thin;
	scrollbar-color: #2a2a2a transparent;
}

.sa-modal__container::before {
	content: '';
	display: block;
	height: 3px;
	background: linear-gradient(90deg, #6B1212, #8B1A1A 40%, #C8A84B 70%, #E0C06A);
	border-radius: 6px 6px 0 0;
}

.sa-modal__container::-webkit-scrollbar { width: 5px; }
.sa-modal__container::-webkit-scrollbar-track { background: transparent; }
.sa-modal__container::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 3px; }

.sa-modal.is-open .sa-modal__container {
	transform: translateY(0) scale(1);
}

/* ============================================================
   CLOSE BUTTON
   ============================================================ */

.sa-modal__close {
	position: absolute;
	top: 1.125rem;
	right: 1.125rem;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	background: transparent;
	border: 1px solid #2a2a2a;
	border-radius: 50%;
	color: #666666;
	cursor: pointer;
	transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.sa-modal__close:hover {
	background: #1e1e1e;
	border-color: #3a3a3a;
	color: #ffffff;
	transform: rotate(90deg);
}

.sa-modal__close:focus-visible {
	outline: 2px solid #C8A84B;
	outline-offset: 2px;
}

/* ============================================================
   MODAL HEADER
   ============================================================ */

.sa-modal__header {
	padding: 2.25rem 2.25rem 0;
	padding-right: 3.5rem; /* space for close btn */
}

.sa-modal__eyebrow {
	font-family: 'Inter', sans-serif;
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: #C8A84B;
	margin: 0 0 0.6rem;
	line-height: 1;
}

.sa-modal__title {
	font-family: 'Oswald', 'Impact', sans-serif;
	font-size: clamp(1.5rem, 4vw, 2rem);
	font-weight: 800;
	line-height: 1.0;
	letter-spacing: -0.015em;
	text-transform: uppercase;
	color: #ffffff;
	margin: 0 0 0.7rem;
}

.sa-modal__desc {
	font-size: 0.85rem;
	line-height: 1.65;
	color: #888888;
	margin: 0;
}

/* ============================================================
   MODAL DIVIDER (auto inserted via CSS)
   ============================================================ */

.sa-modal__body {
	padding: 1.75rem 2.25rem;
}

.sa-modal__body::before {
	content: '';
	display: block;
	height: 1px;
	background: #1e1e1e;
	margin: 0 -2.25rem 1.75rem;
}

/* ============================================================
   SUCCESS STATE
   ============================================================ */

.sa-modal__success {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 0.875rem;
	padding: 0.5rem 0;
	animation: sa-modal-success-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.sa-modal__success[hidden] { display: none !important; }

.sa-success-icon { flex-shrink: 0; }

.sa-modal__success h3 {
	font-family: 'Oswald', 'Impact', sans-serif;
	font-size: 1.4rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: -0.01em;
	color: #ffffff;
	margin: 0;
}

.sa-modal__success p {
	font-size: 0.875rem;
	line-height: 1.65;
	color: #888888;
	margin: 0;
	max-width: 300px;
}

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

/* ============================================================
   DISCLAIMER
   ============================================================ */

.sa-modal__disclaimer {
	border-top: 1px solid #1a1a1a;
	padding: 1rem 2.25rem 1.75rem;
	font-size: 0.66rem;
	line-height: 1.55;
	color: #444444;
	margin: 0;
}

/* ============================================================
   BODY SCROLL LOCK
   ============================================================ */

body.sa-modal-open {
	overflow: hidden;
	/* Prevent layout shift on scrollbar hide */
	padding-right: var(--scrollbar-width, 0px);
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
	.sa-modal,
	.sa-modal__container {
		transition: opacity 0.1s ease, visibility 0.1s ease !important;
		transform: none !important;
	}
	.sa-modal__success { animation: none !important; }
	.sa-modal__close:hover { transform: none !important; }
}

/* ============================================================
   RESPONSIVE — Mobile sheet
   ============================================================ */

@media (max-width: 599px) {
	.sa-modal {
		align-items: flex-end;
		padding: 0;
	}

	.sa-modal__container {
		max-width: 100%;
		max-height: 94dvh;
		border-radius: 14px 14px 0 0;
		transform: translateY(100%);
	}

	.sa-modal__container::before {
		border-radius: 14px 14px 0 0;
	}

	.sa-modal.is-open .sa-modal__container {
		transform: translateY(0);
	}

	.sa-modal__header {
		padding: 2rem 1.5rem 0;
		padding-right: 3.25rem;
	}

	.sa-modal__body {
		padding: 1.5rem;
	}

	.sa-modal__body::before {
		margin-left: -1.5rem;
		margin-right: -1.5rem;
	}

	.sa-modal__disclaimer {
		padding: 1rem 1.5rem 2rem;
	}
}
