/**
 * Madara Advanced Ad Inserter — frontend styles.
 */

.maai-ad {
	position: relative;
	margin: 12px 0;
	text-align: center;
	overflow: hidden;
}

.maai-ad__inner {
	display: inline-block;
	max-width: 100%;
}

.maai-ad__iframe {
	max-width: 100%;
	border: 0;
}

/* Banner */
.maai-ad--banner .maai-ad__inner {
	width: 100%;
}

/* Sticky */
.maai-ad--sticky {
	position: sticky;
	top: 80px;
	z-index: 90;
}

.maai-ad--sticky.maai-ad--placement-manga_reading {
	top: 60px;
}

/* Video */
.maai-ad--video .maai-ad__inner {
	width: 100%;
}

.maai-ad--video video,
.maai-ad--video iframe {
	width: 100%;
	max-width: 100%;
	height: auto;
	min-height: 180px;
}

/* Popup overlay */
.maai-popup-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.65);
	z-index: 99998;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.maai-popup-overlay[hidden] {
	display: none !important;
}

/* Original inline popup ad node — never show on screen */
.maai-ad--popup,
[data-maai-popup="1"] {
	display: none !important;
}

.maai-popup-box {
	position: relative;
	background: #fff;
	border-radius: 6px;
	padding: 16px;
	max-width: 90vw;
	max-height: 90vh;
	overflow: auto;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.maai-popup-close {
	position: absolute;
	top: 6px;
	right: 10px;
	background: transparent;
	border: 0;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	color: #333;
	padding: 4px 8px;
	z-index: 2;
}

.maai-popup-close:hover {
	color: #000;
}

/* Widget wrapper in Madara sidebars */
.widget.maai-widget .maai-ad {
	margin: 0;
}

/* Wall-style sticky (Madara footer wall ads compatibility) */
.maai-ad--sticky.maai-ad--placement-homepage {
	position: fixed;
	bottom: 0;
	left: 50%;
	transform: translateX(-50%);
	top: auto;
	z-index: 9990;
}

/* Responsive */
@media (max-width: 768px) {
	.maai-ad--sticky {
		position: relative;
		top: auto;
	}

	.maai-popup-box {
		max-width: 95vw;
		padding: 12px;
	}
}

/* ── Dark theme popup (manga reading pages) ── */
body.reading-manga .maai-popup-overlay,
body.text-ui-dark .maai-popup-overlay {
	background: rgba(0, 0, 0, 0.75);
}
body.reading-manga .maai-popup-box,
body.text-ui-dark .maai-popup-box {
	background: #1a1a2e;
	border: 1px solid rgba(72, 202, 228, 0.2);
	border-radius: 12px;
	box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}
body.reading-manga .maai-popup-close,
body.text-ui-dark .maai-popup-close {
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 50%;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-size: 18px;
	padding: 0;
	top: 8px;
	right: 12px;
}
body.reading-manga .maai-popup-close:hover,
body.text-ui-dark .maai-popup-close:hover {
	background: rgba(231, 76, 60, 0.3);
	border-color: rgba(231, 76, 60, 0.5);
	color: #e74c3c;
}
body.reading-manga .maai-popup-box .maai-ad__inner,
body.text-ui-dark .maai-popup-box .maai-ad__inner {
	display: block;
	width: 100%;
}
body.reading-manga .maai-popup-box .maai-ad__inner img,
body.text-ui-dark .maai-popup-box .maai-ad__inner img {
	max-width: 100%;
	height: auto;
	border-radius: 8px;
}

/* ── Native passthrough ads (v2.0.7) ──
 * Popup-type ads on reading pages, and any ad-network (script/ins/iframe)
 * code, render inline and run natively instead of being trapped in a JS
 * modal. This is what actually fires the network impression pixel and keeps
 * a stray close (x) button off the reading page.
 */
.maai-ad--native {
	display: block !important;
	overflow: visible;
	margin: 12px 0;
	text-align: center;
}

/* AquaReader reader body class — style any static house-ad modal to match the
 * dark reader UI (kept for parity with .reading-manga / .text-ui-dark). */
body.aqua-reader-page .maai-popup-overlay {
	background: rgba(0, 0, 0, 0.75);
}
body.aqua-reader-page .maai-popup-box {
	background: #1a1a2e;
	border: 1px solid rgba(72, 202, 228, 0.2);
	border-radius: 12px;
	box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}
body.aqua-reader-page .maai-popup-close {
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 50%;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-size: 18px;
	padding: 0;
	top: 8px;
	right: 12px;
}

/* Inline before/after-chapter promo button */
.aq-promo-inline {
	text-align: center;
	margin: 18px 0;
}
.aq-promo-inline__btn {
	display: inline-block !important;
	padding: 11px 28px;
	background: linear-gradient(135deg, #7c3aed, #4f46e5);
	color: #fff !important;
	font-weight: 700;
	font-size: 15px;
	border-radius: 10px;
	text-decoration: none !important;
	letter-spacing: .3px;
	transition: opacity .2s;
}
.aq-promo-inline__btn:hover { opacity: .85; color: #fff !important; }

/* Sitewide promo bar — fail-open: visible by default (no JS dependency to show).
   Naming avoids "ad/sw/banner"-style tokens that generic blocklists match. */
.aq-promo-bar {
	display: flex !important;
	position: fixed !important;
	bottom: 0 !important; left: 0 !important; right: 0 !important;
	z-index: 2147483000 !important; /* above any theme fixed bar (reader bottombar is 99999) */
	background: linear-gradient(135deg, #7c3aed, #4f46e5);
	padding: 10px 16px;
	align-items: center;
	justify-content: center;
	gap: 12px;
	box-shadow: 0 -2px 12px rgba(0,0,0,.35);
}
.aq-promo-bar__btn {
	color: #fff !important;
	font-weight: 700;
	font-size: 15px;
	text-decoration: none !important;
	letter-spacing: .3px;
}
.aq-promo-bar__btn:hover { opacity: .85; }
.aq-promo-bar__x {
	background: transparent;
	border: 1.5px solid rgba(255,255,255,.6);
	color: #fff;
	border-radius: 50%;
	width: 24px; height: 24px;
	line-height: 1;
	cursor: pointer;
	font-size: 16px;
	padding: 0;
	display: flex !important;
	align-items: center; justify-content: center;
	flex-shrink: 0;
}
.aq-promo-bar__x:hover { background: rgba(255,255,255,.2); }
