/* 商城首页左侧广告位
 * 需求：【阳光优采平台】【商城】【共性】首页左侧增加"广告位"（广告位优化版）
 * 定位：页面左侧固定悬浮，参照右侧栏目悬浮固定模式（.side）
 * 数量：最多 5 个，由后端 getIndexLeftAdv 截断
 * 生效范围：主站 + 全部专区（渲染逻辑在 pages/js/common.js，页面容器在 pages/index/index.html）
 * 数据：首页广告图片 type=8（与首页飘窗 type=5 分开配置）
 *
 * 尺寸：广告位 260x120（按效果图 130x60 放大一倍）
 *      5 条之间不留间隙，整条是一条连续的竖条（投影/圆角挂在容器上）
 *      容器宽 1200 居中，故窄屏需逐级缩小，避免压住左侧内容
 *      （列宽上限：视口 >= 1200 + 2 * 广告位宽）
 */

.side-left-ad {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 260px;
    /* 高于首页飘窗 #bwphoto(z-index:99999)，避免飘窗漂过时压住广告位 */
    z-index: 100000;
    display: flex;
    flex-direction: column;
    /* 视口过矮（5条 x 120 = 600px）时滚动，不被裁掉 */
    max-height: 100vh;
    overflow-y: auto;
    scrollbar-width: none;
    /* 整条广告位共用一个圆角 + 投影（overflow 生效才能裁出圆角） */
    border-radius: 8px;
    box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.12);
}

.side-left-ad::-webkit-scrollbar {
    display: none;
}

/* 没有广告数据时容器为空，不占位 */
.side-left-ad:empty {
    display: none;
}

.side-left-ad-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 260px;
    height: 120px;
    overflow: hidden;
    background: #ffffff;
    transition: opacity 0.2s ease-in-out;
}

.side-left-ad-item:hover {
    opacity: 0.85;
}

.side-left-ad-item img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    /* 现代浏览器铺满裁切；IE11 不支持 object-fit，退化为 max-width/max-height 等比缩放 */
    object-fit: cover;
}

/* 视口 < 1720px：两侧留白不足 260px，逐级缩小 */
@media (max-width: 1720px) {
    .side-left-ad {
        width: 200px;
    }

    .side-left-ad-item {
        width: 200px;
        height: 92px;
    }
}

@media (max-width: 1560px) {
    .side-left-ad {
        width: 130px;
    }

    .side-left-ad-item {
        width: 130px;
        height: 60px;
    }
}

@media (max-width: 1460px) {
    .side-left-ad {
        width: 100px;
    }

    .side-left-ad-item {
        width: 100px;
        height: 46px;
    }
}

/* ==================================================================== *
 * 绍兴专区个性化：广告位固定在「分类推荐」模块左侧
 * 需求：【阳光优采平台】【绍兴专区】【个性化】广告位优化
 *  - 广告列放在分类推荐模块左侧的空白区，**不占内容宽度**，右侧内容位置保持不变
 *  - 广告列宽度与上方左侧分类面板一致（.banner-tab-left 为 240px）
 *  - 广告列右边缘距模块内容 16px，上端与模块内容顶部齐平
 *  - 单张广告图占位宽高比 2:1
 * 作用域：只在页面给 .classification 加了 has-side-left-ad 时生效（目前仅绍兴专区），
 *        主站与其他专区仍沿用上面的「左侧固定悬浮」样式。
 * ==================================================================== */

.classification.has-side-left-ad .classification-row {
    position: relative;
    display: flex;
    align-items: flex-start;
}

.classification.has-side-left-ad .classification-main {
    flex: 1;
    width: 0;
    min-width: 0;
}

/* 广告列：绝对定位到模块内容左侧的空白区（脱离文档流，不挤动右侧内容）
 * 宽度用变量控制，默认 320px：向右是内容（不动），向左是页面留白，所以放大只是往左长
 * 可用空间 = 视口留白 + 30px（广告右边缘比内容左边缘再往左 16px），超出时自动收窄 */
.classification.has-side-left-ad .side-left-ad {
    --ad-width: 320px;
    position: absolute;
    /* 上端与「分类推荐」标题下的横线（.mod-tt 的 border-bottom）齐平：
       .mod-tt 高 49px、margin-bottom 36px，广告锚在 .classification-row 顶部，
       所以要向上提 36px 才落到那条线上 */
    top: -36px;
    left: auto;
    right: calc(100% + 16px);
    transform: none;
    flex: none;
    width: min(var(--ad-width), calc((100vw - 1200px) / 2 + 30px));
    max-height: none;
    overflow: visible;
    border-radius: 0;
    box-shadow: none;
    gap: 16px;
}

/* 视口再窄就没有空白区可放，隐藏广告列（不挤动内容） */
@media (max-width: 1360px) {
    .classification.has-side-left-ad .side-left-ad {
        display: none;
    }
}

/* 单张广告：宽高比 2:1（padding-bottom 50% 兼容老浏览器） */
.classification.has-side-left-ad .side-left-ad-item {
    display: block;
    width: 100%;
    height: 0;
    padding-bottom: 50%;
    position: relative;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.classification.has-side-left-ad .side-left-ad-item img {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
}
