/* ============================================================
   迅必达前台 · 全站响应式契约（唯一真源）
   ------------------------------------------------------------
   规则：全站只允许三个结构性断点，各有唯一职责
     · 1200px —— 导航档（只切导航：桌面横向菜单 ↔ 汉堡抽屉，不碰任何栅格）
     · 900px  —— 布局档（多栏变单栏、表格重排入口、详情头部换行）
     · 560px  —— 手机档（触控尺寸、字号微调、卡片上图下文）
   两者之间、以及 900 以上，一律用 clamp() / auto-fit 做流体过渡，
   不允许再新增断点。site.css 里不写任何 @media（由 lint_responsive.py 门禁）。

   页面侧只允许使用骨架原子类（container / section / page-head / card-grid /
   mineral-list / layout-with-aside / panel / field-table / form-card /
   center-layout），因此规则天然覆盖每个页面，无需逐页适配。

   视觉语言沿用 site.css：同一套颜色、圆角、阴影、字重，只是"紧凑版"。
   验证：node scripts/audit_viewport_matrix.js（逐路由 × 逐宽度断言）
   ============================================================ */

/* ---------- 0. 移动端基线（微信内嵌 / iOS / Android WebView） ---------- */

/* 字体档（非布局断点）：移动端锁定 16px 基准，不跟随大屏流式曲线；
   这是全站唯一允许的 768 媒体查询，只写 font-size，由 lint_responsive.py 校验 */
@media (max-width: 768px) {
    html { font-size: 16px; }
}

html {
    /* 微信与部分安卓浏览器会强制放大正文字号，关闭后才能保证设计稿一致 */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    /* 微信底部工具栏/地址栏会压缩视口，dvh 比 vh 更贴合真实可视高度 */
    min-height: 100dvh;
}

/* iPhone 底部安全区（微信内尤其明显） */
.site-footer { padding-bottom: env(safe-area-inset-bottom); }

/* ---------- 1. 流体容器与节奏（大屏取值不变，只在窄屏收缩） ---------- */

.container { padding-inline: clamp(0.875rem, 3vw, 1.25rem); }

/* 1440 及以上仍是 4rem；1000 以下开始收紧，560 处约 2.75rem */
.section { padding-block: clamp(2.75rem, 5vw + 0.5rem, 4rem); }

.page-head {
    padding-block: clamp(1.25rem, 2.4vw + 0.4rem, 2rem) clamp(0.875rem, 1.6vw + 0.3rem, 1.25rem);
    padding-inline: 0;
}

.section-head {
    flex-wrap: wrap;
    row-gap: 0.5rem;
    margin-bottom: clamp(1.25rem, 2.5vw, 1.875rem);
}

.breadcrumb { overflow-wrap: anywhere; }

/* ---------- 2. 栅格：auto-fit 替代"档位跳变" ---------- */

/* 桌面仍是 2 列；容器窄于约 1130px 时自然降为 1 列，不出现挤压的中间态 */
.card-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 34rem), 1fr));
    gap: clamp(1rem, 1.8vw, 1.5rem);
}

/* 桌面仍是 3 列；平板 2 列、手机 1 列由容器宽度自然决定 */
.trust-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
    gap: clamp(1rem, 1.8vw, 1.5rem);
}

.mineral-list { gap: clamp(0.75rem, 1.4vw, 1.125rem); }

/* ---------- 3. 移动端导航抽屉 ---------- */

/* 桌面不渲染汉堡与抽屉（HTML 常驻，保证爬虫可抓全部栏目链接） */
.nav-toggle { display: none; }
.nav-drawer { display: none; }

.nav-toggle {
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.3125rem;
    width: 2.75rem;
    height: 2.75rem;
    margin-left: -0.5rem;
    padding: 0;
    border: 0;
    border-radius: 0.625rem;
    background: transparent;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background var(--ease);
}

.nav-toggle:hover { background: var(--primary-soft); }
.nav-toggle span {
    display: block;
    width: 1.125rem;
    height: 0.125rem;
    border-radius: 1px;
    background: var(--text);
    transition: background var(--ease);
}
.nav-toggle[aria-expanded="true"] { background: var(--primary-soft); }
.nav-toggle[aria-expanded="true"] span { background: var(--primary); }

.nav-drawer-panel {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 0 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(1.125rem) saturate(1.5);
    -webkit-backdrop-filter: blur(1.125rem) saturate(1.5);
    animation: drawerIn .2s ease-out;
}

@supports not (backdrop-filter: blur(1px)) {
    .nav-drawer-panel { background: #fff; }
}

.nav-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 3.875rem;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--border-faint);
}
.nav-drawer-title { font-size: var(--fs-body); font-weight: 700; color: var(--text); }
.nav-drawer-close {
    width: 2.75rem;
    height: 2.75rem;
    margin-right: -0.75rem;
    border: 0;
    border-radius: 0.625rem;
    background: transparent;
    color: var(--text-muted);
    font-size: var(--fs-body);
    line-height: 1;
    cursor: pointer;
    transition: background var(--ease), color var(--ease);
}
.nav-drawer-close:hover { background: var(--primary-soft); color: var(--primary); }

.nav-drawer-links {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem 0 1rem;
}
.nav-drawer-links a {
    display: flex;
    align-items: center;
    min-height: 3rem;
    padding: 0 0.875rem;
    border-left: 0.1875rem solid transparent;
    border-bottom: 1px solid var(--border-faint);
    color: var(--text);
    font-size: var(--fs-base);
    font-weight: 500;
    transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.nav-drawer-links a:active { background: var(--primary-soft); }
.nav-drawer-links a.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: var(--primary-soft);
    font-weight: 600;
}

.nav-drawer-actions {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-faint);
}
.nav-drawer-actions .btn { height: 2.75rem; }

body.nav-open { overflow: hidden; }

@keyframes drawerIn {
    from { opacity: 0; transform: translateY(-0.5rem); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 4. 结构断点：≤900 ---------- */

@media (max-width: 1200px) {
    /* 只负责导航：桌面 7 个栏目 + 品牌 + 两个按钮实测需要 1166px，
       低于 1200 必须切抽屉，否则整页会出现横向滚动 */
    .nav-toggle { display: inline-flex; }
    .nav-drawer { display: block; position: fixed; inset: 0; z-index: 120; }
    .nav-drawer[hidden] { display: none; }

    .main-nav { display: none; }

    .site-header .container { gap: 0.75rem; }
    .brand { flex: 1 1 auto; min-width: 0; }
    .brand-text { min-width: 0; }
    .brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

@media (max-width: 900px) {
    /* 多栏 → 单栏（.layout-even 是 .layout-with-aside 的等比变体，要一起压平） */
    .layout-with-aside,
    .layout-with-aside.layout-even,
    .home-duo,
    .center-layout,
    .auth-split { grid-template-columns: 1fr; }
    .auth-split { max-width: 32rem; }
    .auth-side { padding: 1.75rem 1.5rem; }
    .center-nav { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .center-nav a {
        white-space: nowrap;
        border-left: 0;
        border-bottom: 0.1875rem solid transparent;
        min-height: 2.75rem;
        display: inline-flex;
        align-items: center;
    }
    .center-nav a.active { border-left: 0; border-bottom-color: var(--primary); }

    .metrics { grid-template-columns: repeat(2, 1fr); }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 1.5rem; }

    .hero { padding: 4rem 0 6.5rem; }
    .hero h1 { font-size: var(--fs-icon); }

    /* 详情页头部按钮换行，避免标题被挤成三行 */
    .detail-head-top { flex-wrap: wrap; }
    .detail-head, .panel, .form-card, .center-panel { padding: 1.375rem 1.25rem; }
}

/* ---------- 5. 手机精修：≤560 ---------- */

@media (max-width: 560px) {
    /* 顶部信息条：只保留服务热线与联系方式 */
    .topbar .container { justify-content: flex-start; }
    .topbar .topbar-brand { display: none; }

    .site-header .container { height: 3.875rem; gap: 0.5rem; }
    .brand-sub { display: none; }
    .header-actions { gap: 0.5rem; }
    .header-actions .btn { height: 2.75rem; padding: 0 0.75rem; font-size: var(--fs-chip); }
    #navUserCenter { display: none; }

    /* 触控底线 44px */
    .btn, .btn-sm, .filter-select, .filter-input, .input,
    .toolbar-sorts a, .chip, .fav-btn { min-height: 2.75rem; }
    .btn-sm { padding: 0 0.875rem; }
    .pager a, .pager span { min-width: 2.75rem; height: 2.75rem; }
    /* 首屏热门矿种胶囊：手机上按触控底线撑开（一行放不下会自然换行） */
    .hero-tags a {
        display: inline-flex;
        align-items: center;
        min-height: 2.75rem;
        padding: 0 0.875rem;
    }
    .footer-grid a { padding: 0.375rem 0; }

    /* 首屏 */
    .hero { padding: 3rem 0 5.5rem; }
    .hero h1 { font-size: var(--fs-section); }
    .hero p.lead { font-size: var(--fs-body-sm); margin-bottom: 1.5rem; }
    .hero .eyebrow { font-size: var(--fs-caption); padding: 0.25rem 0.75rem; }
    .hero-search input { height: 3.125rem; font-size: var(--fs-body-sm); padding: 0 1rem; }
    .hero-search button { padding: 0 1.125rem; font-size: var(--fs-body-sm); white-space: nowrap; }

    /* 数据条 2×2 */
    .stat-strip { margin-top: -2.875rem; }
    .stat-strip .container {
        grid-template-columns: repeat(2, 1fr);
        padding: 1.125rem 0.75rem;
        gap: 0.5rem;
        border-radius: 0.875rem;
    }
    .stat-num { font-size: var(--fs-error); }
    .stat-item + .stat-item::before { display: none; }

    .section-title { font-size: var(--fs-metric); }
    .section-title::after { margin-top: 0.5625rem; }
    .page-title { font-size: var(--fs-price); }

    /* 卡片改上图下文（列表页与首页栅格统一） */
    .mineral-card { grid-template-columns: 1fr; min-height: 0; }
    .mineral-cover { height: 9.5rem; }
    .mineral-body { padding: 0.9375rem 1rem 0.875rem; }
    .price-num { font-size: var(--fs-brand); }

    /* 筛选栏纵向堆叠 */
    .filter-card { padding: 1rem 1rem 0.875rem; }
    .filter-row { flex-direction: column; align-items: stretch; }
    .filter-item.grow { flex: 1 1 auto; }
    .filter-select { width: 100%; }
    .filter-note { font-size: var(--fs-caption); }

    /* 详情页字段表：标签上 / 值下，去掉 th 固定宽度 */
    .field-table, .field-table tbody, .field-table tr, .field-table th, .field-table td {
        display: block;
        width: auto;
    }
    .field-table tr {
        padding: 0.6875rem 0;
        border-bottom: 1px solid var(--border-faint);
    }
    .field-table th, .field-table td { border: 0; padding: 0; }
    .field-table th {
        background: none;
        font-size: var(--fs-caption);
        color: var(--text-faint);
        margin-bottom: 0.125rem;
    }
    .field-table td { font-size: var(--fs-body-sm); color: var(--text); }
    .field-table tr:last-child { border-bottom: 0; padding-bottom: 0; }

    .detail-title { font-size: var(--fs-brand); }
    .detail-head, .panel, .form-card, .center-panel { padding: 1.125rem; }
    .attach-item { flex-wrap: wrap; }
    .attach-name { flex: 1 1 100%; }

    .footer-grid { grid-template-columns: 1fr; gap: 1.25rem; }
    .footer-bottom { flex-direction: column; gap: 0.25rem; }

    .locked { padding: 2rem 1.125rem; }
    .locked-actions .btn { flex: 1 1 auto; }

    .article-content { font-size: var(--fs-small); line-height: 1.85; }
}
