/* ============================================================
   全站视觉统一调优（unicorn-tune.css）
   - 统一标题/正文字号节奏
   - 图片自适应兜底，避免富文本大图把卡片撑破
   - 长文本折行，避免横向溢出显示不全
   加载顺序：置于 index.css 之后，页面内联 <style> 之前。
   ============================================================ */

/* ---- 正文基准 ---- */
body {
    font-size: 15px;
    line-height: 1.65;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* ---- 标题字号统一（中文阅读更协调） ---- */
h1, .h1 { font-size: 1.75rem; line-height: 1.3;  font-weight: 700; }
h2, .h2 { font-size: 1.5rem;  line-height: 1.32; font-weight: 700; }
h3, .h3 { font-size: 1.32rem; line-height: 1.38; font-weight: 700; }
h4, .h4 { font-size: 1.16rem; line-height: 1.42; font-weight: 600; }
h5, .h5 { font-size: 1.05rem; line-height: 1.45; font-weight: 600; }
h6, .h6 { font-size: .94rem;  line-height: 1.5;  font-weight: 600; }

/* 醒目引导文案与正文拉开层级但不喧宾夺主 */
.lead { font-size: 1.12rem; line-height: 1.6; }

p { line-height: 1.7; }
small { font-size: .85em; }

/* ---- 全站图片自适应兜底 ---- */
/* 所有 <img> 不得超出父容器宽度（防止后台编辑器上传大图把页面撑破） */
img {
    max-width: 100%;
}

/* 编辑器 / 富文本输出区域：强制等比缩放（含带 width/height 属性的图片）。
   注：不含 .modal-body/.footer，避免影响其中的固定尺寸二维码等图片。 */
.ck-content img,
.notice img,
.custom img,
.desc-content img,
.article-content img,
.article-order-content img,
.article-lock img,
.card-info img,
.buy-prompt img,
.alert img {
    max-width: 100% !important;
    height: auto !important;
}

/* 富文本中的媒体元素同样限宽 */
iframe, video, embed, object {
    max-width: 100%;
}
.ck-content iframe,
.desc-content iframe,
.article-content iframe,
.notice iframe,
.custom iframe {
    max-width: 100% !important;
}

/* 富文本表格限宽 + 单元格内容可折行，避免把卡片撑破 */
.ck-content table,
.desc-content table,
.article-content table,
.notice table,
.custom table {
    max-width: 100% !important;
}
.ck-content table td,
.ck-content table th,
.desc-content table td,
.desc-content table th {
    word-break: break-word;
}

/* ---- 长文本 / 长链接折行，防止“显示不完整” ---- */
h1, h2, h3, h4, h5, h6,
p, a, li, td, th,
blockquote, .card-title,
.navbar-text, .alert,
.badge, .btn {
    overflow-wrap: break-word;
}

/* 移动端输入框字号不小于 16px，避免 iOS 聚焦时自动放大页面 */
@media (max-width: 991.98px) {
    input:not([type='checkbox']):not([type='radio']),
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ---- 商品卡片细节 ---- */
/* 商品卡图片不因拉伸而变形（兜底） */
.goods-list .card-img-top {
    background-color: #fff;
}

/* 商品卡标题行高收敛，避免窄卡里显得过大 */
.goods-list .card-title {
    line-height: 1.4;
    letter-spacing: .01em;
}

/* 卡片价格区紧凑、对齐 */
.goods-list .goods-price {
    letter-spacing: -.01em;
}

/* ---- 文章/商品列表行：小屏上下留白克制 ---- */
@media (max-width: 575.98px) {
    .article-cover,
    .goods-list-thumb img {
        flex-basis: auto;
    }
}

/* ============================================================
   移动端体验优化
   - <992px  折叠菜单卡片化 / 大输入框兜底
   - <768px  顶栏收紧、分区留白、分类标签横向滚动
   - <576px  商品卡两列细节、按钮触达尺寸、页脚安全区
   ============================================================ */

/* ---- 折叠菜单（<992 导航展开即此形态）---- */
@media (max-width: 991.98px) {
    .header {
        padding: 12px 0;
    }

    .navbar .navbar-brand {
        font-size: 1.22rem;
        font-weight: 700;
        letter-spacing: .01em;
        color: #1f2937;
        max-width: 150px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        vertical-align: middle;
    }

    /* 折叠后的导航：卡片化浮层，避免直接贴在页面上方 */
    .navbar .navbar-collapse {
        margin-top: .6rem;
        padding: .75rem .9rem 1rem;
        background: #fff;
        border: 1px solid rgba(0, 0, 0, .06);
        border-radius: 1rem;
        box-shadow: 0 12px 28px rgba(0, 0, 0, .08);
    }

    .navbar .navbar-collapse .navbar-nav {
        width: 100%;
    }

    .navbar .navbar-collapse .navbar-nav .nav-item {
        width: 100%;
    }

    .navbar .navbar-collapse .navbar-nav .nav-link {
        padding: .6rem .85rem;
        border-radius: .65rem;
        font-weight: 500;
        color: #374151;
    }

    .navbar .navbar-collapse .navbar-nav .nav-link:hover {
        background: rgba(13, 110, 253, .06);
        color: #0d6efd;
    }

    .navbar .navbar-collapse .navbar-nav .nav-link.active {
        background: rgba(13, 110, 253, .08);
        color: #0d6efd;
    }

    /* 折叠菜单里的搜索框与按钮占满一行 */
    .navbar .navbar-collapse form.d-flex {
        width: 100%;
        margin: .4rem 0 .2rem;
    }

    .navbar .navbar-collapse form.d-flex .form-control {
        flex: 1 1 auto;
        min-width: 0;
    }

    /* 折叠菜单里的登录/注册按钮增大触达面积 */
    .navbar .navbar-collapse > .d-flex {
        flex-wrap: wrap;
        margin-top: .35rem;
    }

    .navbar .navbar-collapse > .d-flex .btn {
        padding: .5rem 1.1rem;
        min-height: 2.5rem;
    }
}

/* ---- 平板及以下：间距与滚动 ---- */
@media (max-width: 767.98px) {
    .category {
        padding: 1.6rem 0 1.2rem;
    }

    .category .separator {
        margin: 12px auto;
    }

    /* 分类 / 结果切换标签分行全部显示，不再横向滚动 */
    .category-menus,
    .article-cate-nav {
        margin-inline: -.25rem;
    }

    .category-menus ul.nav.nav-pills,
    .article-cate-nav,
    ul.nav.nav-pills {
        flex-wrap: wrap !important;
        justify-content: center !important;
        padding-bottom: .25rem;
        margin-bottom: .25rem;
    }

    .category-menus .nav-item,
    .article-cate-nav > .btn,
    ul.nav.nav-pills .nav-item,
    ul.nav.nav-pills > .btn {
        flex: 0 0 auto;
        white-space: nowrap;
        margin-bottom: .4rem;
    }

    /* 顶部公告 / 文章中心说明卡留白 */
    .notice .card {
        margin-top: .75rem !important;
        margin-bottom: .75rem;
    }
}

/* ---- 手机：商品两列网格、按钮触达、正文呼吸 ---- */
@media (max-width: 575.98px) {
    /* 商品网格间距收紧，一屏能看到更多，同时不糊在一起 */
    .goods-list .row {
        --bs-gutter-x: .85rem;
        --bs-gutter-y: .85rem;
    }

    /* 两列卡片内：价格/库存行允许换行，避免挤出卡片 */
    .goods-list .card-body .d-flex {
        flex-wrap: wrap;
        row-gap: .3rem;
        column-gap: .45rem;
    }

    .goods-list .card-body .d-flex .goods-stock {
        margin-left: auto;
    }

    /* 立即购买按钮统一触达高度、内容居中 */
    .goods-list .card .btn {
        min-height: 2.6rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* 正文与区块获得更宽松的左右留白 */
    .card-body {
        padding-left: 1.1rem;
        padding-right: 1.1rem;
    }

    /* 弹窗在小屏更宽松 */
    .modal-dialog {
        margin: .75rem;
    }

    /* 页脚 */
    .footer {
        padding: 1.5rem .9rem calc(1.5rem + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* iOS 全面屏底部安全区兜底 */
@supports (padding: max(0px)) {
    body {
        padding-bottom: max(0px, env(safe-area-inset-bottom, 0px));
    }
}
