/*!
 * 子比广告位插件 - 前台样式
 *
 * 书写顺序约定：通用基类写在最前，修饰类（--float_left / --bottom_bar / --popup）
 * 写在后面。两者优先级相同时由书写顺序决定胜负，把基类写在后面会静默盖掉修饰类。
 */

/* ===== 基础结构（通用） ===== */

.zad-slot {
	position: relative;
	display: block;
	box-sizing: border-box;
	overflow: hidden;
	line-height: 0;
}

.zad-slot * {
	box-sizing: border-box;
}

.zad-slot__inner {
	position: relative;
	display: block;
}

.zad-slot__media {
	display: block;
	margin: 0;
}

.zad-slot__img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	border: 0;
}

.zad-slot__link {
	display: block;
	line-height: 0;
	text-decoration: none;
	outline: none;
}

/* 「广告」标识：默认压在右下角，不遮挡主视觉。 */
.zad-slot__tag {
	position: absolute;
	right: 6px;
	bottom: 6px;
	z-index: 2;
	padding: 0 6px;
	font-size: 11px;
	line-height: 18px;
	color: #fff;
	background: rgba(0, 0, 0, 0.45);
	border-radius: 3px;
	pointer-events: none;
}

/* 关闭按钮 */
.zad-slot__close {
	position: absolute;
	top: 4px;
	left: 4px;
	z-index: 6;
	width: 22px;
	height: 22px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.5);
	color: #fff;
	font-size: 15px;
	line-height: 20px;
	text-align: center;
	cursor: pointer;
	opacity: 0.75;
	transition: opacity 0.2s ease;
}

.zad-slot__close:hover,
.zad-slot__close:focus {
	opacity: 1;
}

/* 文字广告 */
.zad-slot--text .zad-slot__inner {
	line-height: 1.6;
	text-align: left;
}

.zad-slot__text {
	display: block;
	padding: 10px 12px;
	color: inherit;
	text-decoration: none;
	line-height: 1.6;
}

.zad-slot__text-title {
	display: block;
	font-weight: 600;
}

/* 文字广告：标题改为行内，让「广告」标识跟标题排在同一行 */
.zad-slot--text .zad-slot__text-title {
	display: inline;
}

.zad-slot__text-desc {
	display: block;
	margin-top: 4px;
	font-size: 0.85em;
	opacity: 0.72;
}

/* 文字广告的标识改成行内小尾巴，避免压住标题。 */
.zad-slot--text .zad-slot__tag {
	position: static;
	display: inline-block;
	margin: 0 0 0 8px;
	padding: 0 4px;
	color: rgba(128, 138, 157, 0.9);
	background: transparent;
	border: 1px solid currentColor;
	vertical-align: 1px;
}

/* ===== 设备显隐 ===== */

@media (max-width: 768px) {
	.zad-hide-mobile {
		display: none !important;
	}
}

@media (min-width: 769px) {
	.zad-hide-pc {
		display: none !important;
	}
}

/* 被用户关掉之后 */
.zad-slot.zad-closed {
	display: none !important;
}

/* ===== 信息流广告的插入包裹层 =====
   子比的 .posts-row 可能是 grid 或 flex 布局，普通 div 只占一格。
   这里强制占满整行，广告才会像一条独立的卡片那样横跨列表。 */

.zad-loop-banner,
.zad-loop-feed {
	width: 100%;
	flex: 0 0 100%;
	grid-column: 1 / -1;
	clear: both;
}

/* ===== 修饰类：悬浮 / 吸底 ===== */

.zad-slot--float_left,
.zad-slot--float_right {
	position: fixed;
	z-index: 98;
	overflow: visible;
}

.zad-slot--bottom_bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 97;
	width: 100%;
	overflow: visible;
}

/* ===== 修饰类：弹窗 ===== */

.zad-popup {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 99990;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.zad-popup[hidden] {
	display: none;
}

/* 弹窗打开时锁住页面滚动，避免背景跟着滑 */
html.zad-popup-open,
html.zad-popup-open body {
	overflow: hidden;
}

.zad-popup__layer {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	background: rgba(0, 0, 0, 0.65);
}

.zad-popup__box {
	position: relative;
	z-index: 1;
	width: 100%;
	max-height: 86vh;
	overflow: auto;
	background: #fff;
	border-radius: 10px;
	box-shadow: 0 12px 48px rgba(0, 0, 0, 0.28);
}

.zad-popup__close {
	position: absolute;
	top: -14px;
	right: -14px;
	z-index: 3;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #2b2b2b;
	color: #fff;
	font-size: 20px;
	line-height: 30px;
	text-align: center;
	cursor: pointer;
}

/* 弹窗内部不要再叠加外边距（0-2-0 优先级，与书写顺序无关）。 */
.zad-popup .zad-slot {
	margin: 0;
	border-radius: 0;
}

.zad-popup .zad-slot__close {
	display: none;
}

/* 弹窗内部图片上下留白由容器控制 */
.zad-popup__box .zad-slot__img {
	width: 100%;
}

/* ===== 夜间模式适配（兼容常见写法） ===== */

body.dark-theme .zad-popup__box,
[data-theme="dark"] .zad-popup__box,
[data-color-scheme="dark"] .zad-popup__box {
	background: #1f1f1f;
	color: #dcdcdc;
}

body.dark-theme .zad-slot--text .zad-slot__inner,
[data-theme="dark"] .zad-slot--text .zad-slot__inner,
[data-color-scheme="dark"] .zad-slot--text .zad-slot__inner {
	color: #dcdcdc;
}

body.dark-theme .zad-slot__text-title,
[data-theme="dark"] .zad-slot__text-title {
	color: #eaeaea;
}
