/**
 * Promo Popup Block Styles
 *
 * The block renders a native <dialog>, so it stays display:none from the
 * browser's own stylesheet until view.js calls showModal(). Nothing here sets
 * display on the closed dialog for that reason.
 *
 * @package AusQual
 */

dialog.ausqual-promo-popup {
	width: min(900px, calc(100% - 32px));
	max-height: calc(100vh - 32px);
	max-height: calc(100dvh - 32px);
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: 12px;
	background: var(--wp--preset--color--base, #fff);
	color: var(--wp--preset--color--fertiliser, #1F2828);
	box-shadow: 0 24px 60px rgba(0, 62, 51, 0.3);
	overflow: auto;
}

dialog.ausqual-promo-popup::backdrop {
	background: rgba(31, 40, 40, 0.75);
}

dialog.ausqual-promo-popup[open] {
	animation: ausqual-promo-popup-in 0.3s ease-out;
}

dialog.ausqual-promo-popup[open]::backdrop {
	animation: ausqual-promo-popup-fade 0.3s ease-out;
}

/* Scroll lock while the popup is open. */
body.ausqual-promo-popup-open {
	overflow: hidden;
}

.ausqual-promo-popup__card {
	position: relative;
	display: flex;
	flex-direction: column;
}

/* Banner image across the top, kept at its own aspect ratio. */
.ausqual-promo-popup__media {
	background: var(--wp--preset--color--light-bg, #F4F7F4);
}

.ausqual-promo-popup__img {
	display: block;
	width: 100%;
	height: auto;
}

/* Image-only popups: the whole picture is the enrol link. */
.ausqual-promo-popup__media-link {
	display: block;
}

.ausqual-promo-popup__media-link:focus-visible {
	outline: 3px solid var(--wp--preset--color--grains, #FFD861);
	outline-offset: -3px;
}

.ausqual-promo-popup__content {
	display: flex;
	flex-direction: column;
	gap: 16px;
	padding: 40px 48px 48px;
}

.ausqual-promo-popup__heading {
	margin: 0;
	font-size: clamp(1.875rem, 1.4rem + 1.6vw, 2.875rem);
	line-height: 1.15;
	color: var(--wp--preset--color--fertiliser, #1F2828);
}

.ausqual-promo-popup__subheading {
	margin: 0;
	font-size: 1.25rem;
	line-height: 1.5;
	color: var(--wp--preset--color--muted, #686868);
}

.ausqual-promo-popup__body {
	margin-top: 8px;
}

.ausqual-promo-popup__body > * {
	margin-top: 0;
}

.ausqual-promo-popup__body > * + * {
	margin-top: 16px;
}

.ausqual-promo-popup__close {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(31, 40, 40, 0.08);
	color: var(--wp--preset--color--fertiliser, #1F2828);
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.ausqual-promo-popup__close:hover {
	background: rgba(31, 40, 40, 0.16);
}

/* Over the banner image the button needs a solid background to read. */
.ausqual-promo-popup--has-image .ausqual-promo-popup__close {
	background: rgba(255, 255, 255, 0.92);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.ausqual-promo-popup--has-image .ausqual-promo-popup__close:hover {
	background: #fff;
}

.ausqual-promo-popup__close:focus-visible {
	outline: 2px solid var(--wp--preset--color--grains, #FFD861);
	outline-offset: 2px;
}

.ausqual-promo-popup__close svg {
	width: 20px;
	height: 20px;
}

@keyframes ausqual-promo-popup-in {
	from {
		opacity: 0;
		transform: translateY(16px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes ausqual-promo-popup-fade {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@media (max-width: 640px) {
	.ausqual-promo-popup__content {
		padding: 28px 24px 28px;
	}
}

@media (prefers-reduced-motion: reduce) {
	dialog.ausqual-promo-popup[open],
	dialog.ausqual-promo-popup[open]::backdrop {
		animation: none;
	}
}
