/*
 * WebPlus Dreamer 配置画布兼容样式（V4）
 *
 * 设计原则：
 * 1. 只有检测到 Dreamer 设计环境时，html 才会带 wp-dreamer-design 类；
 * 2. 正式展示页不命中本文件中的任何布局规则；
 * 3. 配置页中不用 CSS Grid 排列 frag 窗口，避免 Dreamer 注入的编辑辅助节点
 *    被 Grid 当作普通网格项目，造成空白单元、模块换行和配置框坐标错位；
 * 4. 不裁剪 frag 窗口，保证 Dreamer 原生虚线框与右上角工具栏可见。
 */

/* ---------- 配置页基础保护 ---------- */
html.wp-dreamer-design,
html.wp-dreamer-design body {
    overflow-x: visible !important;
}

html.wp-dreamer-design #container-1 .mod,
html.wp-dreamer-design #container-3 .mod,
html.wp-dreamer-design #container-1 .post,
html.wp-dreamer-design #container-3 .post,
html.wp-dreamer-design #container-1 [frag^="窗口"],
html.wp-dreamer-design #container-3 [frag^="窗口"],
html.wp-dreamer-design .quick-channel-list .links-wrap {
    overflow: visible !important;
}

/* 配置模式中禁止 hover 位移，否则 Dreamer 工具框按旧坐标绘制。 */
html.wp-dreamer-design .ind-main .post,
html.wp-dreamer-design .ind-main .post:hover,
html.wp-dreamer-design .quick-channel-list .links-wrap,
html.wp-dreamer-design .quick-channel-list .links-wrap:hover {
    transform: none !important;
    transition: none !important;
}

/* ---------- 顶部：科研新闻/通知公告 + 轮播/快捷通道 ---------- */
/*
 * Dreamer 会向容器内注入编辑辅助节点。配置页改用普通块级+浮动，
 * 只让真实业务模块参与两列排版，辅助节点不再占据 Grid 单元。
 */
html.wp-dreamer-design #container-1 .home-top-grid {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    align-items: initial !important;
}

html.wp-dreamer-design #container-1 .home-top-grid::after {
    display: block;
    clear: both;
    height: 0;
    content: "";
}

html.wp-dreamer-design #container-1 .home-top-grid > .home-news-column {
    display: block !important;
    float: left !important;
    width: calc(61.7% - 13px) !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
}

html.wp-dreamer-design #container-1 .home-top-grid > .home-side-stack {
    display: block !important;
    float: right !important;
    width: calc(38.3% - 13px) !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    align-self: auto !important;
    align-content: initial !important;
}

/* 左侧两个新闻窗口恢复普通上下流式排列。 */
html.wp-dreamer-design #container-1 .home-news-column > .post {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 0 26px !important;
}

html.wp-dreamer-design #container-1 .home-news-column > .post:last-of-type {
    margin-bottom: 0 !important;
}

html.wp-dreamer-design #container-1 .home-news-column > .post > .boxm {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
}

/* 右侧轮播和快捷通道恢复普通上下流式排列。 */
html.wp-dreamer-design #container-1 .home-side-stack > .home-feature,
html.wp-dreamer-design #container-1 .home-side-stack > .home-section-quick {
    display: block !important;
    float: none !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    overflow: visible !important;
}

html.wp-dreamer-design #container-1 .home-side-stack > .home-feature {
    height: 430px !important;
    min-height: 430px !important;
    margin-bottom: 26px !important;
}

/* 只裁剪轮播插件自己的画面，不裁剪 frag 窗口和 Dreamer 工具条。 */
html.wp-dreamer-design #container-1 .home-feature .post,
html.wp-dreamer-design #container-1 .home-feature .post .con,
html.wp-dreamer-design #container-1 .home-feature .post .con > div[frag="窗口内容"],
html.wp-dreamer-design #container-1 .home-feature .focus,
html.wp-dreamer-design #container-1 .home-feature .focus-box,
html.wp-dreamer-design #container-1 .home-feature .focus-container {
    width: 100% !important;
    height: 430px !important;
    min-height: 430px !important;
    box-sizing: border-box !important;
}

html.wp-dreamer-design #container-1 .home-feature .focus-box,
html.wp-dreamer-design #container-1 .home-feature .focus-container,
html.wp-dreamer-design #container-1 .home-feature .focus-item {
    overflow: hidden !important;
}

html.wp-dreamer-design #container-1 .home-feature .focus-item,
html.wp-dreamer-design #container-1 .home-feature .focus-item img,
html.wp-dreamer-design #container-1 .home-feature .focus-box img,
html.wp-dreamer-design #container-1 .home-feature .focus-container img {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
}

html.wp-dreamer-design #container-1 .home-feature img {
    object-fit: cover !important;
}

html.wp-dreamer-design #container-1 .post-11 .focus-title-bar {
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    margin-left: 0 !important;
}

html.wp-dreamer-design #container-1 .post-11 .focus-pagination {
    right: 14px !important;
}

/* 快捷通道配置页不用 Grid，避免编辑辅助节点占据卡片位置。 */
html.wp-dreamer-design #container-1 .quick-channel-list {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
}

html.wp-dreamer-design #container-1 .quick-channel-list::after {
    display: block;
    clear: both;
    height: 0;
    content: "";
}

html.wp-dreamer-design #container-1 .quick-channel-list > .links-wrap {
    display: block !important;
    float: left !important;
    width: calc(50% - 6px) !important;
    height: 58px !important;
    min-height: 58px !important;
    line-height: 58px !important;
    margin: 0 12px 12px 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

html.wp-dreamer-design #container-1 .quick-channel-list > .links-wrap:nth-of-type(2n) {
    margin-right: 0 !important;
}

html.wp-dreamer-design #container-1 .quick-channel-list > .links-wrap > div,
html.wp-dreamer-design #container-1 .quick-channel-list > .links-wrap a {
    height: 58px !important;
    line-height: 58px !important;
}

/* ---------- 下部：学术之窗、学术活动、社会服务 ---------- */
html.wp-dreamer-design #container-3 .home-content-grid {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    align-items: initial !important;
}

html.wp-dreamer-design #container-3 .home-content-grid::after {
    display: block;
    clear: both;
    height: 0;
    content: "";
}

/* 只选择真实的三个业务卡片；Dreamer 注入的其他直接子节点不会被分配列宽。 */
html.wp-dreamer-design #container-3 .home-content-grid > .home-section-card {
    display: block !important;
    float: left !important;
    width: calc((100% - 52px) / 3) !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 26px 0 0 !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    grid-column: auto !important;
}

html.wp-dreamer-design #container-3 .home-content-grid > .home-section-service {
    width: calc((100% - 52px) / 3) !important;
    max-width: none !important;
    margin-right: 0 !important;
    grid-column: auto !important;
}

html.wp-dreamer-design #container-3 .home-content-grid > .home-section-card > .post {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
}

/* ---------- 配置画布较窄时改为单列，避免模块与工具框互相遮挡 ---------- */
@media screen and (max-width: 1100px) {
    html.wp-dreamer-design #container-1 .home-top-grid > .home-news-column,
    html.wp-dreamer-design #container-1 .home-top-grid > .home-side-stack,
    html.wp-dreamer-design #container-3 .home-content-grid > .home-section-card,
    html.wp-dreamer-design #container-3 .home-content-grid > .home-section-service {
        float: none !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    html.wp-dreamer-design #container-1 .home-top-grid > .home-news-column,
    html.wp-dreamer-design #container-3 .home-content-grid > .home-section-card {
        margin-bottom: 26px !important;
    }

    html.wp-dreamer-design #container-1 .home-feature .post,
    html.wp-dreamer-design #container-1 .home-feature .post .con,
    html.wp-dreamer-design #container-1 .home-feature .post .con > div[frag="窗口内容"],
    html.wp-dreamer-design #container-1 .home-feature .focus,
    html.wp-dreamer-design #container-1 .home-feature .focus-box,
    html.wp-dreamer-design #container-1 .home-feature .focus-container,
    html.wp-dreamer-design #container-1 .home-side-stack > .home-feature {
        height: 360px !important;
        min-height: 360px !important;
    }
}

@media screen and (max-width: 767px) {
    html.wp-dreamer-design #container-1 .quick-channel-list > .links-wrap {
        float: none !important;
        width: 100% !important;
        margin-right: 0 !important;
    }

    html.wp-dreamer-design #container-1 .home-feature .post,
    html.wp-dreamer-design #container-1 .home-feature .post .con,
    html.wp-dreamer-design #container-1 .home-feature .post .con > div[frag="窗口内容"],
    html.wp-dreamer-design #container-1 .home-feature .focus,
    html.wp-dreamer-design #container-1 .home-feature .focus-box,
    html.wp-dreamer-design #container-1 .home-feature .focus-container,
    html.wp-dreamer-design #container-1 .home-side-stack > .home-feature {
        height: 260px !important;
        min-height: 260px !important;
    }
}
