/* ============================================================
   猫源码广告管理 - 前端样式（响应式自适应）
   ============================================================ */

/* 广告容器：Flex 网格布局，自动换行，居中 */
.mad-banner {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin: 0 auto;
    padding: 16px 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* 单个广告项 */
.mad-item {
    position: relative;
    box-sizing: border-box;
    flex: 1 1 calc(50% - 12px);       /* 桌面两列 */
    max-width: calc(50% - 12px);
    min-width: 240px;                  /* 过窄时自动换行成一列 */
    border: 2px solid #e8e8e8;
    padding: 10px;
    background: #fff;
    border-radius: 12px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.mad-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
    border-color: #cdcdcd;
}

/* 广告标签（左上角角标） */
.mad-label {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 2;
    background: rgba(0, 0, 0, .35);
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    line-height: 1;
    padding: 4px 7px;
    border-radius: 8px;
    pointer-events: none;
}

/* 广告链接 */
.mad-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

/* 图片广告：object-fit contain 保持比例不变形 */
.mad-item-image .mad-link {
    height: auto;
}

.mad-img {
    width: 100%;
    height: 100%;
    max-height: 90px;                  /* 限制高度，避免超高图撑爆布局 */
    object-fit: contain;
    border-radius: 8px;
}

/* 文字广告 */
.mad-text {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 50px;
    font-size: clamp(16px, 3vw, 26px); /* 随屏幕缩放 */
    font-weight: bold;
    color: #0f93fb;
    background: linear-gradient(135deg, #cef53e, #e0e0e0);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    word-break: break-word;
    letter-spacing: 1px;
}

/* HTML 广告：占满 */
.mad-item-html {
    display: block;
}
.mad-item-html .mad-link,
.mad-item-html > :not(.mad-label) {
    width: 100%;
}

/* 平板：仍两列 */
@media (max-width: 768px) {
    .mad-item {
        flex: 1 1 calc(50% - 12px);
        max-width: calc(50% - 12px);
        min-width: 0;
    }
}

/* 手机：一列，占满宽度 */
@media (max-width: 480px) {
    .mad-banner {
        gap: 8px;
        padding: 10px 0;
    }
    .mad-item {
        flex: 1 1 100%;
        max-width: 100%;
    }
    .mad-img {
        max-height: 70px;
    }
    .mad-text {
        min-height: 44px;
        font-size: 16px;
    }
}
