/* ============================================================
   麦德亚官网 · 移动端体验优化层 (mobile-optimize.css)
   叠加在 warm.css 之后，仅影响 <=640px；桌面端完全不生效。
   内容：吸底快捷条 / 双列紧凑卡 / 默认折叠 / 页脚手风琴 / 隐藏重复 CTA
   ============================================================ */

/* 吸底条、Toast 默认隐藏（脚本注入 DOM 后由媒体查询显示） */
.sn-mobar { display: none; }
.sn-toast {
  position: fixed; left: 50%; z-index: 1200;
  bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(12px);
  background: rgba(28, 25, 23, .96); color: #fff;
  padding: 10px 20px; border-radius: 999px; font-size: 14px; line-height: 1.4;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .3);
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease;
  max-width: calc(100vw - 40px); text-align: center;
}
.sn-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 折叠控制按钮、标签折叠：桌面隐藏 */
.sn-clist-more, .sn-tag-toggle { display: none; }
.sn-card-models { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sn-card-models.expanded { display: block; -webkit-line-clamp: unset; }

@media (max-width: 640px) {

  /* 修复：顶部 sticky header 在安卓/WebView 滚动时因半透明+模糊产生残影（表现为页面中部多出一条导航条）。
     与吸底条同类问题：背景改不透明、去 backdrop-filter、独立合成层。 */
  .sn-header {
    background: #ffffff !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
  }

  /* ---------- 1. 吸底快捷条 ---------- */
  body { padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }

  /* 悬浮顶/底按钮：窄屏保留且常驻可见，上移到吸底条上方，不与吸底条重叠 */
  .sn-jump {
    display: flex !important;
    right: 10px;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  .sn-jump-btn { width: 48px; height: 58px; }
  .sn-jump-btn svg { width: 40px; height: 40px; }
  .sn-jump-btn span { font-size: 14px; }
  /* 取消"到顶/到底自动隐藏单个按钮"，保证两个按钮始终可见 */
  .sn-jump-at-top #snJumpTop,
  .sn-jump-at-bottom #snJumpBottom { opacity: 1 !important; pointer-events: auto !important; }

  .sn-mobar {
    display: grid; grid-template-columns: repeat(2, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
    /* 用完全不透明实色，避免安卓 WebView 下半透明层 + backdrop-filter 在滚动时产生"左橙右灰"残影横条 */
    background: #1c1917;
    border-top: 1px solid #44403c;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, .28);
    /* 独立合成层，消除 fixed 元素在滚动中的拖影/重影 */
    -webkit-transform: translateZ(0); transform: translateZ(0);
    -webkit-backface-visibility: hidden; backface-visibility: hidden;
  }
  .sn-mobar > a {
    -webkit-appearance: none; appearance: none;
    border: 0; background: transparent; cursor: pointer;
    display: flex; flex-direction: row; align-items: center; justify-content: center;
    gap: 9px; min-height: 60px; padding: 8px 12px;
    color: #f5efe8; font-family: inherit; font-size: 15px; font-weight: 600; line-height: 1.2;
    text-decoration: none; position: relative; letter-spacing: .02em;
  }
  .sn-mobar > a:active { filter: brightness(1.1); }
  .sn-mobar > a + a::before {
    content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 1px; background: #44403c;
  }
  .sn-mobar .mb-ico { width: 22px; height: 22px; display: block; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .sn-mobar .mb-call { background: linear-gradient(135deg, #ea7c3f, #c2410c); color: #fff; }
  .sn-mobar .mb-call .mb-ico { fill: currentColor; stroke: none; }
  .sn-mobar .mb-products { color: #f5efe8; }
  .sn-mobar .mb-products .mb-ico { color: #fbbf24; }
  .sn-mobar .mb-label { white-space: nowrap; }

  /* ---------- 2. 各板块双列紧凑卡 ---------- */
  .sn-grid, .sn-grid-4, .sn-adv-grid, .sn-trust-grid,
  .sn-features, .sn-gallery, .sn-news-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
  }
  .sn-grid-5 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .sn-grid-5 > .sn-card { width: auto; max-width: none; }

  .sn-card { border-radius: 10px; }
  .sn-card img, .sn-grid-5 .sn-card img, .sn-news-grid .sn-card img {
    height: 116px; object-fit: cover;
  }
  .sn-card-body, .sn-grid-5 .sn-card-body { padding: 11px 12px 13px; }
  .sn-card-body h3, .sn-grid-5 .sn-card-body h3 {
    font-size: 14px; line-height: 1.35; margin: 0 0 5px;
  }
  .sn-card-body p, .sn-grid-5 .sn-card-body p {
    font-size: 12px; line-height: 1.5; margin: 0 0 8px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .sn-card-link { font-size: 12px; }
  .sn-card-models { font-size: 11px; padding: 5px 8px; margin-bottom: 8px; cursor: pointer; }

  .sn-adv, .sn-trust-card, .sn-feature-item { padding: 13px 10px; border-radius: 10px; }
  .sn-adv .sn-adv-num { font-size: 26px; }
  .sn-adv .sn-adv-num i { font-size: 14px; }
  .sn-adv h3, .sn-trust-card h3, .sn-feature-item h3 { font-size: 13px; margin: 5px 0 4px; }
  .sn-adv p, .sn-trust-card p, .sn-feature-item p {
    font-size: 11px; line-height: 1.45; margin: 0;
  }
  .sn-feature-item p {
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  }
  .sn-gallery img { width: 100%; height: auto; aspect-ratio: 575 / 440; }
  .sn-section-head { margin-bottom: 22px; }
  .sn-section-head p { font-size: 13px; }
  .sn-section { padding: 34px 0; }

  /* ---------- 3. 长列表 / 标签墙默认折叠 ---------- */
  .sn-clist.sn-collapsed > .sn-citem { display: none; }
  .sn-clist-more {
    display: block; width: 100%; margin: 12px 0 0; padding: 11px 14px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--accent);
    font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  }
  .sn-clist-more:active { background: #f5f0ea; }
  .sn-case-tags .sn-tag-more { display: none; }
  .sn-tag-toggle {
    display: inline-block; padding: 2px 9px; margin-left: 2px;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); color: var(--accent);
    font-family: inherit; font-size: 11px; line-height: 1.6; cursor: pointer;
  }
  .sn-case-tags.show-all .sn-tag-more { display: inline-block; }

  /* FAQ 保持折叠（details 原生折叠，此处兜底压缩间距） */
  .sn-faq { margin: 20px 0; }
  .sn-faq h2 { font-size: 22px; margin-bottom: 16px; }
  .sn-faq-item summary { padding: 13px 16px; font-size: 14px; }
  .sn-faq-a { padding: 0 16px 14px; font-size: 14px; }

  /* ---------- 4. 窄屏隐藏重复 CTA（吸底条已覆盖拨号/咨询） ---------- */
  .sn-hero-actions a[href^="tel:"],
  .sn-detail-hero .sn-hero-actions a[href^="tel:"],
  .sn-cta-band .sn-cta-btn { display: none !important; }
  .sn-hero-actions { gap: 10px; }
  .sn-hero-actions .sn-btn { padding: 13px 14px; font-size: 15px; }
  .sn-cta-band { padding: 24px 18px; border-radius: 14px; }
  .sn-cta-band h2 { font-size: 20px; }
  .sn-cta-band p { font-size: 14px; }

  /* ---------- 5. 页脚多栏改手风琴 ---------- */
  .sn-footer { margin-top: 40px; }
  .sn-footer-grid { grid-template-columns: 1fr; gap: 0; padding: 22px 0 12px; }
  .sn-footer-grid > div { border-bottom: 1px solid #38332f; }
  .sn-footer-grid > div:first-child { padding-bottom: 16px; }
  .sn-footer-grid > div.sn-acc > h4 {
    position: relative; margin: 0; padding: 13px 30px 13px 0;
    font-size: 15px; color: #fff; cursor: pointer; list-style: none;
  }
  .sn-footer-grid > div.sn-acc > h4::after {
    content: "+"; position: absolute; right: 4px; top: 50%;
    transform: translateY(-50%); color: #fbbf24; font-size: 20px; font-weight: 400;
  }
  .sn-footer-grid > div.sn-acc.open > h4::after { content: "\2212"; }
  .sn-footer-grid > div.sn-acc .sn-acc-body { display: none; padding: 0 0 14px; }
  .sn-footer-grid > div.sn-acc.open .sn-acc-body { display: block; }
  .sn-footer-grid > div.sn-acc .sn-acc-body a { padding: 5px 0; }
  .sn-footer-bottom { font-size: 12px; padding: 16px 0 8px; }

  /* ---------- 6. 联系页在小屏进一步压缩 ---------- */
  .sn-contact-card { padding: 20px 16px; }
  .sn-map-wrap iframe { height: 260px; }
  .sn-map-bar { gap: 8px; }
  .sn-map-addr { font-size: 13px; }
  .sn-page-hero { padding: 38px 0; }
  .sn-page-hero h1 { font-size: 27px; }

  /* ---------- 7. 配色方案 A · 暖橙通透（仅 <=640px 生效） ----------
     主色 #e8622a / 悬停 #d4541a / 点缀金 #f0a429 / 页面底 #faf7f2 */
  :root {
    --accent: #e8622a;
    --accent-hover: #d4541a;
  }
  /* 主按钮：主色→亮橙，去掉深砖橙收尾，更通透 */
  .sn-btn-primary {
    background: linear-gradient(115deg, #f0a429, #e8622a 58%, #d4541a);
    box-shadow: 0 12px 30px rgba(232, 98, 42, .34), inset 0 1px 0 rgba(255, 255, 255, .28);
  }
  .sn-btn-primary:hover {
    background: linear-gradient(115deg, #f7b45a, #f0a429 45%, #e8622a);
    box-shadow: 0 18px 38px rgba(232, 98, 42, .42);
  }
  /* 顶部 eyebrow 圆点 / 标题渐变字 */
  .sn-hero-eyebrow .sn-dot { background: #f0a429; box-shadow: 0 0 0 4px rgba(240, 164, 41, .22); }
  .sn-hero h1 em { background: linear-gradient(100deg, #f0a429 12%, #e8622a 88%); -webkit-background-clip: text; background-clip: text; }
  /* 描边按钮 hover */
  .sn-btn-ghost:hover { border-color: #f0a429; color: #f7b45a; }
  /* 装饰线：章节标题 / 优势卡 / FAQ 标题 */
  .sn-section-head h2::after,
  .sn-faq h2::after { background: linear-gradient(90deg, var(--accent), #f0a429); }
  .sn-adv::before { background: linear-gradient(90deg, var(--accent), #f0a429 55%, var(--green)); }
  /* logo 标 / 作者头像 */
  .sn-logo-mark { background: linear-gradient(135deg, var(--accent), #f0a429); }
  .sn-author-avatar { background: linear-gradient(135deg, var(--accent), #f0a429); }
  /* Hero 边框光晕 */
  .sn-hero-frame::before { background: linear-gradient(130deg, rgba(240, 164, 41, .38), rgba(63, 122, 94, .30)); }
  /* 面包屑 / 页脚链接 hover */
  .sn-page-hero .sn-crumb a:hover,
  .sn-footer-contact a:hover { color: #f7b45a; }
  /* CTA band：整体换暖橙通透渐变 */
  .sn-cta-band {
    background: linear-gradient(118deg, #a83a0e 0%, #e8622a 46%, #ef7a35 78%, #b4471a 100%);
    box-shadow: 0 22px 48px rgba(168, 58, 14, .28);
  }
  /* 悬浮"顶"按钮 */
  .sn-jump-top { background: linear-gradient(135deg, rgba(240, 164, 41, .78), rgba(232, 98, 42, .78)); box-shadow: 0 8px 22px rgba(232, 98, 42, .38); }
  /* 吸底条一键拨号键同步新主色 */
  .sn-mobar .mb-call { background: linear-gradient(135deg, #f0a429, #e8622a); }
  .sn-mobar .mb-products .mb-ico { color: #f0a429; }

  /* 体验优化：去掉移动端默认蓝色点击高亮与蓝色聚焦框，统一暖橙反馈 */
  a, button, .sn-copy-btn, .sn-mobar > a, .sn-jump-btn {
    -webkit-tap-highlight-color: transparent;
  }
  .sn-copy-btn:focus, .sn-copy-btn:focus-visible,
  .sn-mobar > a:focus, .sn-btn:focus {
    outline: 2px solid var(--accent, #e8622a);
    outline-offset: 2px;
    background: #faf3ec !important;
    color: var(--accent, #e8622a) !important;
  }

  /* ========== 8. 体验优化 P0：图片淡入占位 ========== */
  .sn-carousel img, .sn-card img, .sn-hero-frame img,
  .sn-gallery img, .sn-contact-qr img {
    background: #f0ece6;
    transition: opacity .45s ease;
  }
  /* 轮播首图立即显示；懒加载图加载完成后由 JS 补 .sn-img-loaded 淡入 */

  /* ========== 9. 体验优化 P1：触摸热区 ≥44px ========== */
  .sn-nav a, .sn-footer a, .sn-case-tag, .sn-tag-toggle,
  .sn-card-link, .sn-carousel-arrow {
    min-height: 44px; display: inline-flex; align-items: center;
  }
  .sn-nav a { padding: 10px 8px; }
  .sn-carousel-arrow { min-width: 44px; justify-content: center; }
  /* 轮播圆点保持细条视觉（原 26x5 / 移动 18x5），不用 min-width 撑成白方块；
     用透明伪元素扩大点击热区，既保证 44px 可点又不改变外观 */
  .sn-carousel-dots { gap: 14px; }
  .sn-carousel-dots button { position: relative; min-width: 0; min-height: 0; display: block; }
  .sn-carousel-dots button::after {
    content: ''; position: absolute; left: 50%; top: 50%;
    width: 44px; height: 44px; transform: translate(-50%, -50%);
  }
  .sn-map-actions .sn-btn { min-height: 44px; display: inline-flex; align-items: center; }

  /* ---- 联系页一键复制条（按钮由 JS 注入） ---- */
  .sn-copy-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 4px; }
  .sn-copy-btn {
    -webkit-appearance: none; appearance: none;
    min-height: 46px; border: 1px solid var(--border, #e7e5e4); border-radius: 10px;
    background: var(--surface, #fff); color: var(--accent, #e8622a);
    font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 7px;
  }
  .sn-copy-btn:active { background: #faf3ec; transform: scale(.98); }
  .sn-copy-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

  /* ========== 10. 体验优化 P2：微动效与排版细节 ========== */
  /* 卡片入场淡入上移（配合 reveal.js，额外补一层 transform 平滑） */
  .sn-card, .sn-adv, .sn-trust-card, .sn-feature-item {
    transition: transform .28s ease, box-shadow .28s ease, opacity .4s ease;
  }
  .sn-card:active { transform: scale(.985); }
  /* 展开按钮 / 手风琴展开更顺 */
  .sn-clist-more, .sn-tag-toggle { transition: background .2s ease, color .2s ease; }
  .sn-footer-grid > div.sn-acc > h4 { transition: color .2s ease; }
  .sn-footer-grid > div.sn-acc .sn-acc-body {
    animation: snAccordionIn .26s ease both;
  }
  @keyframes snAccordionIn {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  /* FAQ 展开平滑（details 原生，补内容淡入） */
  .sn-faq details[open] .sn-faq-a { animation: snFaqIn .28s ease both; }
  @keyframes snFaqIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  /* 吸底条入场：改为纯透明度淡入。原 translateY 位移动画在安卓 WebView 滚动时会留下横条残影 */
  .sn-mobar { animation: snBarIn .32s ease both; }
  @keyframes snBarIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
  /* 按钮点按涟漪感（轻微缩放） */
  .sn-btn:active { transform: scale(.97); }
  .sn-btn { transition: transform .12s ease, box-shadow .2s ease; }
  /* 统一圆角阴影 */
  .sn-card, .sn-adv, .sn-trust-card, .sn-feature-item,
  .sn-contact-card, .sn-cta-band { box-shadow: 0 4px 16px rgba(41, 37, 36, .06); }
  /* 正文行高字号微调，移动端更易读 */
  .sn-sub, .sn-section-head p, .sn-hero-trust span { line-height: 1.75; }
}

/* 尊重系统"减少动态效果"偏好 */
@media (max-width: 640px) and (prefers-reduced-motion: reduce) {
  .sn-mobar, .sn-footer-grid > div.sn-acc .sn-acc-body,
  .sn-faq details[open] .sn-faq-a { animation: none !important; }
  .sn-card, .sn-adv, .sn-btn, .sn-carousel img { transition: none !important; }
}
