/**
 * Quiz & Ads Manager - ad containers, rewarded loader and fallback popup.
 */

/* ---------------------------------------------------------------
   Display ad containers
   --------------------------------------------------------------- */

.adunit {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 250px;
	margin: 0 auto 30px;
}

.ad-skeleton {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 300px;
	height: 250px;
	transform: translate(-50%, -50%);
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 37%, #f0f0f0 63%);
	background-size: 400% 100%;
	animation: qam-shimmer 1.4s ease infinite;
}

@keyframes qam-shimmer {
	0% {
		background-position: 100% 0;
	}

	100% {
		background-position: -100% 0;
	}
}

.ad-label {
	display: none;
	margin-bottom: 5px;
	color: #888;
	font-size: 12px;
	text-align: center;
}

.ad-box {
	position: relative;
	z-index: 1;
}

.adnotes {
	margin-top: auto;
	padding-top: 20px;
	color: #6b7280;
	font-size: 12px;
	text-align: center;
}

/* ---------------------------------------------------------------
   Full screen loader shown while the rewarded ad is requested

   Markup, whatever the style:

     <div class="qam-loader qam-loader--spinner">
       <div class="qam-loader-spinner"><span></span><span></span><span></span></div>
       <div class="qam-loader-text">...</div>
     </div>

   Colours come from the settings as custom properties, so a preset and a
   hand written style both read the same three values.
   --------------------------------------------------------------- */

.qam-loader {
	--qam-loader-bg: rgba(255, 255, 255, 0.96);
	--qam-loader-accent: #72c3c1;
	--qam-loader-text: #111819;
	--qam-loader-track: rgba(0, 0, 0, 0.08);

	position: fixed;
	top: 0;
	left: 0;
	z-index: 999999;
	display: flex;
	flex-direction: column;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	background-color: var(--qam-loader-bg);
	transition: opacity 0.5s ease;
}

.qam-loader.is-hiding {
	opacity: 0;
}

.qam-loader-text {
	width: 100%;
	max-width: 22em;
	margin-bottom: 30px;
	padding: 0 20px;
	box-sizing: border-box;
	color: var(--qam-loader-text);
	font-size: 20px;
	font-weight: bold;
	line-height: 1.35;
	text-align: center;
}

/* The spans are only used by the styles that need them. */
.qam-loader-spinner span {
	display: none;
}

/* ---- 1. spinner (default) ---- */

.qam-loader--spinner .qam-loader-spinner {
	width: 60px;
	height: 60px;
	margin-bottom: 20px;
	border: 8px solid var(--qam-loader-track);
	border-top-color: var(--qam-loader-accent);
	border-radius: 50%;
	animation: qam-spin 1.1s linear infinite;
}

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

/* ---- 2. dots ---- */

.qam-loader--dots .qam-loader-spinner {
	display: flex;
	gap: 12px;
	margin-bottom: 26px;
}

.qam-loader--dots .qam-loader-spinner span {
	display: block;
	width: 16px;
	height: 16px;
	background-color: var(--qam-loader-accent);
	border-radius: 50%;
	animation: qam-bounce 1.2s ease-in-out infinite;
}

.qam-loader--dots .qam-loader-spinner span:nth-child(2) {
	animation-delay: 0.15s;
}

.qam-loader--dots .qam-loader-spinner span:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes qam-bounce {
	0%, 60%, 100% {
		transform: translateY(0);
		opacity: 0.55;
	}
	30% {
		transform: translateY(-14px);
		opacity: 1;
	}
}

/* ---- 3. bars ---- */

.qam-loader--bars .qam-loader-spinner {
	display: flex;
	align-items: flex-end;
	gap: 7px;
	height: 46px;
	margin-bottom: 26px;
}

.qam-loader--bars .qam-loader-spinner span {
	display: block;
	width: 10px;
	height: 100%;
	background-color: var(--qam-loader-accent);
	border-radius: 3px;
	transform-origin: bottom;
	animation: qam-equalise 1s ease-in-out infinite;
}

.qam-loader--bars .qam-loader-spinner span:nth-child(2) {
	animation-delay: 0.18s;
}

.qam-loader--bars .qam-loader-spinner span:nth-child(3) {
	animation-delay: 0.36s;
}

@keyframes qam-equalise {
	0%, 100% {
		transform: scaleY(0.3);
	}
	50% {
		transform: scaleY(1);
	}
}

/* ---- 4. pulse ---- */

.qam-loader--pulse .qam-loader-spinner {
	position: relative;
	width: 72px;
	height: 72px;
	margin-bottom: 26px;
}

.qam-loader--pulse .qam-loader-spinner span {
	display: block;
	position: absolute;
	inset: 0;
	border: 4px solid var(--qam-loader-accent);
	border-radius: 50%;
	opacity: 0;
	animation: qam-ripple 1.6s ease-out infinite;
}

.qam-loader--pulse .qam-loader-spinner span:nth-child(2) {
	animation-delay: 0.5s;
}

.qam-loader--pulse .qam-loader-spinner span:nth-child(3) {
	animation-delay: 1s;
}

@keyframes qam-ripple {
	0% {
		transform: scale(0.35);
		opacity: 0.9;
	}
	100% {
		transform: scale(1);
		opacity: 0;
	}
}

/* ---- 5. progress ---- */

.qam-loader--progress .qam-loader-spinner {
	position: relative;
	width: 220px;
	max-width: 70vw;
	height: 6px;
	margin-bottom: 26px;
	overflow: hidden;
	background-color: var(--qam-loader-track);
	border-radius: 999px;
}

.qam-loader--progress .qam-loader-spinner span:first-child {
	display: block;
	position: absolute;
	top: 0;
	left: 0;
	width: 40%;
	height: 100%;
	background-color: var(--qam-loader-accent);
	border-radius: 999px;
	animation: qam-slide 1.4s ease-in-out infinite;
}

@keyframes qam-slide {
	0% {
		transform: translateX(-100%);
	}
	100% {
		transform: translateX(250%);
	}
}

/* ---- 6. custom: no animation, only the layout and the colours ---- */

.qam-loader--custom .qam-loader-spinner {
	margin-bottom: 26px;
}

/* A visitor who asked for less motion gets the text, not the animation. */
@media (prefers-reduced-motion: reduce) {
	.qam-loader .qam-loader-spinner,
	.qam-loader .qam-loader-spinner span {
		animation: none !important;
	}

	.qam-loader--dots .qam-loader-spinner span,
	.qam-loader--bars .qam-loader-spinner span,
	.qam-loader--pulse .qam-loader-spinner span {
		opacity: 1;
		transform: none;
	}
}

/* ---------------------------------------------------------------
   Fallback popup
   --------------------------------------------------------------- */

.qam-popup-overlay {
	position: fixed;
	inset: 0;
	z-index: 999998;
	display: none;
	box-sizing: border-box;
	align-items: center;
	justify-content: center;
	padding: 16px;
	overflow-y: auto;
	background: rgba(15, 23, 42, 0.62);
	-webkit-backdrop-filter: blur(7px);
	backdrop-filter: blur(7px);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

html.qam-popup-open,
html.qam-popup-open body {
	overflow: hidden;
}

.qam-popup-overlay .qam-popup {
	box-sizing: border-box;
	width: 100%;
	max-width: 520px;
	margin: auto;
	padding: 32px 28px 28px;
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 16px;
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25), 0 4px 15px rgba(0, 0, 0, 0.08);
	text-align: center;
	animation: qam-popup-in 0.35s ease-out;
}

.qam-popup-overlay .qam-popup * {
	box-sizing: border-box;
}

@keyframes qam-popup-in {
	from {
		opacity: 0;
		transform: translateY(20px) scale(0.97);
	}

	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

.qam-popup-overlay .qam-popup-title {
	margin: 0 0 18px;
	padding: 0;
	color: #111827;
	font-size: 24px;
	font-weight: 800;
	line-height: 1.3;
	text-transform: uppercase;
}

.qam-popup-overlay .qam-popup-subtitle {
	margin: 0 0 28px;
	padding: 0;
	color: #1f2937;
	font-size: 18px;
	line-height: 1.45;
}

.qam-popup-overlay .qam-popup-btn {
	display: flex;
	gap: 14px;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 64px;
	margin: 0;
	padding: 12px 20px;
	background: #0a3cff;
	border: 0;
	border-radius: 8px;
	color: #ffffff;
	font-family: inherit;
	font-size: 20px;
	font-weight: 600;
	letter-spacing: 0.3px;
	line-height: 1.2;
	text-transform: uppercase;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background-color 0.2s ease, transform 0.15s ease;
}

.qam-popup-overlay .qam-popup-btn:hover {
	background: #0830d6;
	transform: translateY(-1px);
}

.qam-popup-overlay .qam-popup-btn:focus-visible {
	outline: 3px solid #93c5fd;
	outline-offset: 2px;
}

.qam-popup-overlay .qam-popup-btn:disabled {
	opacity: 0.85;
	transform: none;
	cursor: default;
}

.qam-popup-overlay .qam-popup-btn-icon {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	background: #ffffff;
	border-radius: 50%;
}

.qam-popup-overlay .qam-popup-btn-icon svg {
	width: 20px;
	height: 20px;
	margin-left: 3px;
	fill: #0a3cff;
}

.qam-popup-overlay .qam-popup-btn-spinner {
	display: none;
	flex: 0 0 auto;
	width: 26px;
	height: 26px;
	border: 3px solid rgba(255, 255, 255, 0.35);
	border-top-color: #ffffff;
	border-radius: 50%;
	animation: qam-spin 0.8s linear infinite;
}

.qam-popup-overlay .qam-popup.is-loading .qam-popup-btn-icon {
	display: none;
}

.qam-popup-overlay .qam-popup.is-loading .qam-popup-btn-spinner {
	display: block;
}

.qam-popup-overlay .qam-popup-note {
	margin: 22px 0 0;
	padding: 0;
	color: #6b7280;
	font-size: 16px;
	line-height: 1.4;
}

@media (prefers-reduced-motion: reduce) {
	.qam-popup-overlay .qam-popup {
		animation: none;
	}
}

@media (max-width: 480px) {
	.qam-popup-overlay {
		/* Leave room for the bottom anchor ad. */
		padding: 12px 12px 96px;
	}

	.qam-popup-overlay .qam-popup {
		padding: 26px 18px 22px;
		border-radius: 14px;
	}

	.qam-popup-overlay .qam-popup-title {
		font-size: 20px;
	}

	.qam-popup-overlay .qam-popup-subtitle {
		margin-bottom: 22px;
		font-size: 16px;
	}

	.qam-popup-overlay .qam-popup-btn {
		gap: 12px;
		min-height: 58px;
		font-size: 17px;
	}

	.qam-popup-overlay .qam-popup-btn-icon {
		width: 38px;
		height: 38px;
	}

	.qam-popup-overlay .qam-popup-note {
		font-size: 14px;
	}
}

/* ---- Fallback popup close button ---- */

.qam-popup-overlay .qam-popup {
	position: relative;
}

.qam-popup-overlay .qam-popup-close {
	position: absolute;
	top: 10px;
	right: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	background: transparent;
	border: 0;
	border-radius: 50%;
	color: #6b7280;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.qam-popup-overlay .qam-popup-close:hover {
	background: #f3f4f6;
	color: #111827;
}

.qam-popup-overlay .qam-popup-close:focus-visible {
	outline: 3px solid #93c5fd;
	outline-offset: 2px;
}

.qam-popup-overlay .qam-popup-close svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.25;
	stroke-linecap: round;
}

/* Keep the title clear of the close button. */
.qam-popup-overlay .qam-popup-close ~ .qam-popup-title {
	padding-right: 36px;
	padding-left: 36px;
}
