/* kc-mobile-global-fixes.css - 全局移动端修复 */

/* ===== 576px～768px：内容区左右边距统一为 12px ===== */
@media screen and (min-width: 577px) and (max-width: 768px) {
    .content-container.site-container,
    .site-container,
    .site-header-row-layout-contained,
    .site-footer-row-layout-contained,
    .entry-hero-layout-contained,
    .alignfull > .wp-block-cover__inner-container,
    .alignwide > .wp-block-cover__inner-container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

/* ===== 通用页面修复 ===== */
@media (max-width: 768px) {
    /* 1. 基础修复：防止水平滚动 */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
        position: relative;
    }
    
    /* 2. 修复所有WordPress容器 */
    .container,
    .site-container,
    .site-content,
    .content-area,
    .site-main,
    .entry-content,
    .wp-site-blocks {
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    /* 3. 修复页头（所有页头版本）
     * 学苑/课程/课时 independent 容器：左 padding 0（Logo 贴汉堡避让区），右 16px
     */
    .kc-header-container-independent {
        padding-left: 0 !important;
        padding-right: 16px !important;
        max-width: 100vw !important;
    }
    .site-header,
    #masthead {
        padding-left: 16px !important;
        padding-right: 16px !important;
        max-width: 100vw !important;
    }
    
    /* 4. 内容区域不再强制 16px，避免全宽区块（如分类卡片、our-philosophy）出现白边 */
    
    /* 5. 修复所有固定宽度布局 */
    [class*="width-"],
    [class*="max-width"],
    .kc-course-header-independent {
        max-width: 100vw !important;
    }
}

/* ===== iPad Pro / iOS Chrome 页脚下方空白修复 ===== */
/* 仅学苑模板 + 平板/手机（≤1024px）：100dvh 与可视高度一致。公共页不设 100dvh，避免短内容时页脚下白边 */
@media (max-width: 1024px) {
    html:has(body.page-template-page-template-sp-learning-center),
    body.page-template-page-template-sp-learning-center,
    body.page-template-page-template-sp-learning-center .site,
    body.page-template-page-template-sp-learning-center .site-inner,
    body.page-template-page-template-sp-learning-center #wrapper {
        min-height: 100vh !important;
        min-height: 100dvh !important;
    }
}

/* 公共页页脚白条 / body outer chrome：kc-init.php wp_body_open 内联，此处不再重复 */

/* ===== 移动端：.sp-photo-strip 四图横向滚动（固定高度，不依赖 Kadence ratio） ===== */
@media (max-width: 768px) {
    /* 含该列的 Row 给最小高度，避免 grid 行高为 0 */
    .kb-row-layout-wrap:has(.sp-photo-strip) {
        min-height: 320px !important;
    }
    /* 列：固定高度 + 纵向 flex，内层占满 */
    .sp-photo-strip {
        display: flex !important;
        flex-direction: column !important;
        height: 320px !important;
    }
    /* 内层：占满列高并横向滚动 */
    .sp-photo-strip .kt-inside-inner-col {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        gap: 1rem;
        flex: 1 1 0 !important;
        min-height: 0 !important;
    }
    /* 每张图卡片：固定 240×320 */
    .sp-photo-strip .kt-inside-inner-col > .wp-block-kadence-image {
        flex: 0 0 240px !important;
        width: 240px !important;
        height: 320px !important;
    }
    /* ratio 盒填满卡片高度 */
    .sp-photo-strip .kb-is-ratio-image {
        height: 100% !important;
        padding-bottom: 0 !important;
        position: relative !important;
        overflow: hidden !important;
    }
    .sp-photo-strip .kb-is-ratio-image .kb-img {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
}