@charset "utf-8";
/**
 * 弹窗广告 - 前台样式
 * 适配电脑端与手机端
 */

/* ========== 遮罩层 ========== */
.popupad-mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 999998;
    opacity: 0;
    visibility: hidden;
    transition: opacity .28s ease, visibility .28s ease;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.popupad-mask.popupad-show {
    opacity: 1;
    visibility: visible;
}

/* ========== 弹窗主体 ========== */
.popupad-box {
    position: fixed;
    z-index: 999999;
    box-sizing: border-box;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
    overflow: hidden;
    max-width: 92vw;
    opacity: 0;
    visibility: hidden;
    transition: opacity .28s ease, transform .28s ease, visibility .28s ease;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.popupad-box.popupad-show {
    opacity: 1;
    visibility: visible;
}

.popupad-content {
    position: relative;
    line-height: 0;
    font-size: 0;
}

.popupad-content iframe {
    border: 0;
    display: block;
    max-width: 100%;
}

/*
 * 弹窗为 shrink-to-fit 容器，内部百分比 max-width 无法可靠解析，
 * 在图片原始宽度超过弹窗上限（尤其手机端）时会溢出被裁切。
 * 因此改用视口单位兜底，与 .popupad-box 的 max-width 保持一致。
 */
.popupad-img {
    display: block;
    max-width: 100%;
    max-width: 92vw;   /* 兜底：不依赖容器百分比 */
    height: auto;
    border: 0;
}

.popupad-link {
    display: block;
    text-decoration: none;
}

/* ========== 关闭按钮 ========== */
.popupad-close {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    width: 28px;
    height: 28px;
    padding: 0;
    line-height: 26px;
    text-align: center;
    font-size: 22px;
    color: #fff;
    background: rgba(0, 0, 0, .5);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background .2s ease, transform .2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.popupad-close:hover {
    background: rgba(0, 0, 0, .72);
}

.popupad-close:active {
    transform: scale(.9);
}

/* ========== 广告字标 ========== */
.popupad-label {
    position: absolute;
    z-index: 1;
    display: inline-block;
    padding: 2px 7px;
    font-size: 12px;
    line-height: 1.6;
    color: #fff;
    background: rgba(0, 0, 0, .55);
    border-radius: 3px;
    pointer-events: none;
}

.popupad-label-tl { top: 6px; left: 6px; }
.popupad-label-tr { top: 6px; right: 6px; }
.popupad-label-bl { bottom: 6px; left: 6px; }
.popupad-label-br { bottom: 6px; right: 6px; }

/* 右上角显示字标时，为关闭按钮让位 */
.popupad-label-tr { padding-right: 40px; }

/* ========== 风格 1：居中弹窗 ========== */
.popupad-style-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(.92);
}

.popupad-style-center.popupad-show {
    transform: translate(-50%, -50%) scale(1);
}

/* ========== 风格 2：顶部横幅 ========== */
.popupad-style-topbar {
    top: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    transform: translateY(-100%);
}

.popupad-style-topbar.popupad-show {
    transform: translateY(0);
}

.popupad-style-topbar .popupad-close {
    top: 8px;
    right: 8px;
}

/* ========== 风格 3：底部横幅 ========== */
.popupad-style-bottombar {
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    transform: translateY(100%);
}

.popupad-style-bottombar.popupad-show {
    transform: translateY(0);
}

/* ========== 风格 4-7：四角悬浮 ========== */
.popupad-style-tr,
.popupad-style-tl,
.popupad-style-br,
.popupad-style-bl {
    max-width: 90vw;
}

.popupad-style-tr {
    top: 16px;
    right: 16px;
    transform: translateY(-16px);
    opacity: 0;
}

.popupad-style-tr.popupad-show {
    transform: translateY(0);
}

.popupad-style-tl {
    top: 16px;
    left: 16px;
    transform: translateY(-16px);
    opacity: 0;
}

.popupad-style-tl.popupad-show {
    transform: translateY(0);
}

.popupad-style-br {
    bottom: 16px;
    right: 16px;
    transform: translateY(16px);
    opacity: 0;
}

.popupad-style-br.popupad-show {
    transform: translateY(0);
}

.popupad-style-bl {
    bottom: 16px;
    left: 16px;
    transform: translateY(16px);
    opacity: 0;
}

.popupad-style-bl.popupad-show {
    transform: translateY(0);
}

/* ========== 风格 8：侧边滑入 ========== */
.popupad-style-slide {
    top: 50%;
    right: 0;
    border-radius: 10px 0 0 10px;
    transform: translate(100%, -50%);
}

.popupad-style-slide.popupad-show {
    transform: translate(0, -50%);
}

/* 无遮罩时悬浮可点击关闭热区扩大 */
.popupad-nomask .popupad-close {
    width: 32px;
    height: 32px;
    line-height: 30px;
}

/* ========== 手机端适配 ========== */
@media screen and (max-width: 768px) {
    .popupad-box {
        max-width: 94vw;
        border-radius: 8px;
    }

    /* 手机端弹窗上限为 94vw，图片/iframe 同步放宽 */
    .popupad-img,
    .popupad-content iframe {
        max-width: 94vw;
    }

    /* 居中弹窗在手机上略微上移，避免遮挡底部内容 */
    .popupad-style-center {
        top: 46%;
    }

    /* 横幅类风格在手机上不占满高度，限制最大高度 */
    .popupad-style-topbar,
    .popupad-style-bottombar {
        max-height: 40vh;
        overflow-y: auto;
    }

    .popupad-style-tr,
    .popupad-style-tl {
        top: 8px;
        right: 8px;
        left: auto;
    }

    .popupad-style-br,
    .popupad-style-bl {
        bottom: 8px;
        right: 8px;
        left: auto;
    }

    .popupad-style-slide {
        top: auto;
        bottom: 8px;
        right: 8px;
        left: auto;
        transform: translateY(20px);
        border-radius: 8px;
        max-width: 88vw;
    }

    .popupad-style-slide.popupad-show {
        transform: translateY(0);
    }

    /* 手机上关闭按钮加大，方便点击 */
    .popupad-close {
        width: 30px;
        height: 30px;
        line-height: 28px;
        font-size: 24px;
    }

    .popupad-label {
        font-size: 11px;
        padding: 1px 5px;
    }
}

/* 小屏手机 */
@media screen and (max-width: 360px) {
    .popupad-box {
        max-width: 96vw;
    }
}

/* 尊重系统的"减少动态效果"设置 */
@media (prefers-reduced-motion: reduce) {
    .popupad-mask,
    .popupad-box {
        transition: opacity .01ms ease !important;
    }
}
