/* =========================================================================
 * JEWEL MONSTER · 手机屏自适应（mobile.css v1）
 * 全站最后加载，覆盖同选择器。只做「手机端可用性与版式」，不动结构。
 * 断点：≤720px 手机 / ≤420px 小屏。平板(721-1024)沿用原有断点。
 * 注意：studio.html 是深色工作台主题，本表只做通用的点击区/输入/安全区，
 *      不翻它的配色，避免破坏深色 UI。
 * ========================================================================= */

/* ---------- 汉堡按钮：桌面/平板一律不显示（仅 ≤720 手机启用，见下方断点） ---------- */
.nav-burger { display: none; }

/* ---------- ≤720px：手机 ---------- */
@media (max-width: 720px) {
  /* 顶栏：压缩留白，品牌字缩小 */
  .topbar .wrap { padding-left: 12px; padding-right: 12px; min-height: 54px; gap: 8px; }
  .topbar .logo img { height: 30px !important; }
  .topbar .brand-text { font-size: 14px; line-height: 1.1; }
  .topbar .brand-text small { display: none; }

  /* 导航：手机端改为「汉堡按钮 + 上下拉面板」（做法同 QUANGINE 站）
     旧版把 6 个菜单压成纯图标横排、文字仅留给读屏 → 手机上根本认不出对应关系，已废弃 */
  .nav-burger {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
    width: 40px; height: 40px; padding: 0 9px; margin-left: 6px; flex: none;
    background: rgba(255, 255, 255, .10); border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 12px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .nav-burger span { display: block; width: 100%; height: 2px; background: #e9f4ee; border-radius: 2px; transition: .22s; }
  .nav-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .nav-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  .topbar .nav { display: none !important; }
  .topbar .nav.jm-open {
    display: flex !important; flex-direction: column; align-items: stretch; gap: 2px;
    position: absolute; top: 100%; left: 0; right: 0; z-index: 60;
    background: var(--jm-deep, #123f2b); border-top: 1px solid rgba(255, 255, 255, .10);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .32);
    padding: 10px 14px calc(16px + env(safe-area-inset-bottom));
    max-height: calc(100vh - 110px); overflow-y: auto; -webkit-overflow-scrolling: touch;
    animation: jmNavDrop .18s ease;
  }
  @keyframes jmNavDrop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
  .topbar .nav.jm-open a {
    display: flex !important; align-items: center; gap: 12px; width: 100%;
    min-height: 50px; padding: 10px 12px; margin: 0;
    font-size: 16px !important; color: var(--jm-on-dark, #e9f4ee) !important;
    background: transparent !important; border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .08); border-radius: 10px;
  }
  .topbar .nav.jm-open a:active { background: rgba(255, 255, 255, .10) !important; }
  /* 关键：解除旧版「文字视觉隐藏」，菜单文字在面板里必须可见 */
  .topbar .nav.jm-open a span {
    position: static !important; width: auto !important; height: auto !important;
    clip: auto !important; overflow: visible !important; white-space: nowrap !important;
    font-size: 15.5px !important; flex: 1 1 auto; text-align: left;
  }
  .topbar .nav.jm-open a .nav-i, .topbar .nav.jm-open a svg {
    width: 20px; height: 20px; flex: none; color: var(--jm-gold-2, #e3c573) !important;
  }
  /* 面板底部「下载APP / 珍享会员」文字行（由 nav-menu.js 克隆自顶栏图标按钮） */
  .topbar .nav.jm-open .jm-util {
    display: flex !important; align-items: center; gap: 10px; width: 100%;
    min-height: 46px; padding: 10px 12px; margin-top: 8px;
    font-size: 14.5px !important; color: var(--jm-on-dark-2, #bcd6c6) !important;
    background: transparent !important; border: 0; border-top: 1px solid rgba(255, 255, 255, .10);
    border-radius: 10px; text-decoration: none;
  }
  .topbar .nav.jm-open .jm-util svg { width: 18px; height: 18px; flex: none; color: var(--jm-gold-2, #e3c573) !important; }
  /* 顶栏 dl-btn 的 span 在 ≤720 被 chrome.css 设为 display:none，克隆到面板后必须解除 */
  .topbar .nav.jm-open .jm-util span,
  .topbar .nav.jm-open a.jm-util span {
    display: inline !important; position: static !important; width: auto !important; height: auto !important;
    clip: auto !important; overflow: visible !important; white-space: nowrap !important;
    font-size: 14.5px !important; flex: 1 1 auto; text-align: left;
  }

  /* 我的 / 语言：顶栏保留图标形态（面板内另有文字行） */
  .topbar .dl-btn { margin-left: auto !important; }
  .topbar .acct-btn { padding: 0 8px !important; min-height: 40px; font-size: 0; gap: 0; }
  .topbar .acct-btn svg { width: 20px; height: 20px; }
  .topbar .acct-btn span {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .topbar .lang-sel { font-size: 12px; padding: 6px 4px; min-height: 36px; max-width: 62px; }

  /* HERO：字号与留白收敛 */
  .hero { padding: 26px 0 20px !important; }
  .hero h1 { font-size: 26px !important; line-height: 1.25 !important; }
  .hero .lead, .hero p { font-size: 14.5px !important; line-height: 1.65 !important; }
  .pg-hero h1 { font-size: 24px !important; }
  .pg-hero .lead { font-size: 14.5px !important; }

  /* 通用块：左右留白统一，段间距收紧 */
  .wrap, .pg-block .wrap, section > .wrap { padding-left: 14px !important; padding-right: 14px !important; }
  .pg-block, section { padding-top: 20px !important; padding-bottom: 20px !important; }
  h2 { font-size: 20px !important; }
  h3 { font-size: 16.5px !important; }

  /* 栅格一律单列（卡片 / 会员档位 / 页脚 / 统计两列） */
  .acct-grid, .acct-tiers, .footer-grid, .cards, .grid-3, .grid-2, .grid-4,
  .benefit-grid, .maker-grid, .shop-grid, .story-grid {
    grid-template-columns: 1fr !important;
  }
  .acct-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .footer-grid { gap: 16px !important; }
  .footer-col a { padding: 5px 0; }

  /* ---------- 系统性栅格收敛（2026-10-20）----------
   * 全站扫描出 78 个设过 grid-template-columns 的类，其中 52 个此前在手机端
   * 完全没有收敛规则：固定 3/4 列的卡片墙被压成每列 ~90px，.recent-grid 是
   * repeat(8,1fr)（390px 屏每列仅 ~40px），.entry 是 repeat(6,1fr)。
   * 分三类处理：
   *   ① 卡片墙 → 2 列（手机上一列太长、三列太挤，两列最耐看）
   *   ② 步骤 / 档位 / 徽章 → 单列（文字要读全，不能横向挤）
   *   ③ 侧栏 / 双栏 → 纵向堆叠（236px 侧栏在手机上必须让位给内容）
   * 全部用 minmax(0,1fr) 而非 1fr，避免子元素 min-content 再次撑破视口。 */
  /* ① 卡片墙 → 2 列 */
  .cat-grid, .cats, .designer-grid, .inspo-grid, .feed-grid, .entry-grid, .brand-grid,
  .three, .c3, .quote-grid, .gw-grid, .ib-grid, .jm-imgband, .esh-row-grid, .esh-tiers-g,
  .gift-grid, .jewel-grid, .gallery-grid, .pg-gallery, .mk-grid, .sku-grid, .sku-row,
  .sf-pieces, .dsr-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  /* ② 步骤 / 档位 / 说明文字块 → 单列 */
  .c4, .pg-steps, .plan-grid, .gw-steps, .wx-row-items, .wx-tri8, .jm-check,
  .acct-ladder, .acct-benefits {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* 缩略图墙 8 列 → 4 列；入口格 6 列 → 3 列（保住关系，不再挤成一排像素） */
  .recent-grid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .entry { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  /* ③ 侧栏 / 双栏 → 堆叠 */
  .acct-shell, .studio-grid, .split, .collab, .mk-split, .esh-hero-in, .esh-topin,
  .wx-grid, .ho-grid, .sample-band, .press-item, .wx-band-cols, .collab-grid,
  .c2, .pg-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* 堆叠后这些块的间距/内边距要跟着收，否则手机上纵向拉得过长 */
  .acct-shell, .studio-grid, .split, .collab, .mk-split, .esh-hero-in, .esh-topin,
  .wx-grid, .ho-grid, .sample-band {
    gap: 14px !important; padding-left: 0 !important; padding-right: 0 !important;
  }
  .press-item { gap: 12px !important; }
  /* 五行日历必须保持 7 列（改了就不是日历），只缩字号与内距 */
  .wx-cal-grid, .wx-cal-dow { gap: 1px !important; }
  .wx-cal-grid > *, .wx-cal-dow > * { font-size: 11px !important; padding: 3px 1px !important; }

  /* 会员中心标签页：换行而不是横滑（8 个页签必须都能一眼看到） */
  .acct-tabs { flex-wrap: wrap !important; gap: 6px !important; overflow: visible !important; }
  .acct-tab { flex: 1 1 auto !important; min-height: 38px; padding: 8px 10px !important; font-size: 13px !important; }
  .acct-head { flex-direction: column; align-items: flex-start !important; gap: 12px; }
  .acct-head-acts { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  .acct-head-acts .btn, .acct-head-acts a { flex: 1 1 auto; min-height: 42px; }
  .acct-wallet-top { flex-direction: column; }
  .acct-member-top { flex-direction: column; }
  .acct-panel { padding: 14px; }

  /* 表单：16px 防止 iOS 聚焦自动放大；按钮满足 44px 点击区 */
  input, select, textarea, button { font-size: 16px !important; }
  .btn, .btn-primary, .btn-cream, .acct-mini { min-height: 44px; }
  .code-row { flex-wrap: nowrap; }
  .code-row input { flex: 1 1 auto; min-width: 0; }
  .code-row .btn { flex: 0 0 auto; white-space: nowrap; padding-left: 12px; padding-right: 12px; }
  .field { margin-bottom: 12px; }

  /* 社区头像圈里的字太小（实测 <11px），抬到 12px */
  .fc-ava, .fc-ava.mk { font-size: 12px !important; }

  /* 过小字号统一抬到 12px（时间戳 / meta / small 在手机上看不清） */
  small, .meta, .cm-meta, time, .foot-src, .acct-stat span, .pg-meta { font-size: 12px !important; }

  /* 按钮类点击区至少 40px（导航与「我的」键另有规则，不受影响） */
  a.btn:not(.acct-mini), .btn:not(.acct-mini) { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }

  /* 轮播箭头放大到 44px 点击区（圆点指示器保持原尺寸，属装饰件） */
  .jmc-arrow, .carousel-arrow, .spark-arrow { min-width: 44px !important; min-height: 44px !important; }

  /* 图片与媒体不溢出 */
  img, video, canvas, svg, table { max-width: 100% !important; }
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* 地址行 / 列表行在窄屏改为上下堆叠，避免右侧按钮被挤没 */
  .addr-row, .acct-row { flex-wrap: wrap; gap: 8px; }
  .addr-acts, .acct-row .acct-amt { margin-left: auto; }

  /* 刘海屏 / 手势条安全区 */
  .topbar { padding-top: env(safe-area-inset-top); }
  .footer { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* ---------- ≤420px：小屏再收紧 ---------- */
@media (max-width: 420px) {
  .topbar .wrap { padding-left: 8px; padding-right: 8px; gap: 4px; }
  /* 菜单已收进下拉面板，顶栏右侧空出来 → 品牌汉字恢复显示（≤420 原本隐藏，导致 390px 手机上只剩 JM 图标） */
  .topbar .brand-text { display: flex !important; font-size: 13px !important; }
  .topbar .nav a { min-width: 34px; padding: 0 4px; }
  .topbar .nav a svg { width: 19px; height: 19px; }
  .topbar .lang-sel { max-width: 62px; font-size: 12px; min-height: 36px; }
  .nav-burger { width: 38px; height: 38px; margin-left: 4px; }
  .hero h1 { font-size: 22px !important; }
  .pg-hero h1 { font-size: 21px !important; }
  .acct-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .acct-stat b { font-size: 17px; }
  .acct-stat span { font-size: 11.5px; }
  .acct-tab { font-size: 12px !important; padding: 7px 8px !important; }
  .acct-member-card b, .acct-wallet-bal b { font-size: 22px !important; }
  /* 卡片墙 2 列在 360px 级小屏收窄间距，避免卡片被挤成细条 */
  .cat-grid, .cats, .designer-grid, .inspo-grid, .feed-grid, .entry-grid, .brand-grid,
  .three, .c3, .quote-grid, .gw-grid, .ib-grid, .jm-imgband, .esh-row-grid, .esh-tiers-g,
  .gift-grid, .jewel-grid, .gallery-grid, .pg-gallery, .mk-grid, .sku-grid, .sku-row,
  .sf-pieces, .dsr-grid { gap: 10px !important; }
}

/* ---------- 防横向溢出兜底（手机全断点）----------
 * 长英文串 / 邮箱 / URL / 连续数字默认不断行，是「页面能左右滑」的常见根因。
 * 只作用于手机断点，桌面排版不受影响。 */
@media (max-width: 720px) {
  h1, h2, h3, h4, p, li, td, th, figcaption, .meta, small, label, .btn, a.btn {
    overflow-wrap: break-word; word-break: break-word;
  }
  /* 预格式化 / 代码块允许横滑，但不许把整页撑宽 */
  pre, code, kbd { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* 弹层（灯箱 / 模态）在手机上不能超出视口 */
  .lightbox, .modal, .lb-wrap, .jm-modal, .cm-modal {
    max-width: calc(100vw - 24px) !important;
  }
  .lightbox img, .lb-wrap img, .modal img { max-width: 100% !important; max-height: 70vh !important; object-fit: contain; }
}

/* ---------- 横屏矮屏：避免顶栏吃掉半屏 ---------- */
@media (max-height: 460px) and (orientation: landscape) {
  .topbar .wrap { min-height: 44px; }
  .hero { padding: 14px 0 !important; }
  .hero h1 { font-size: 20px !important; }
}

/* ---------- 减少动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 币种切换器：不能沿用语言器的 62px 上限 ---------- */
/* 语言器是「简/繁/EN」三字，币种值是「AUD$ AUD」这类四到七字，62px 会被切半成 "AUD$ A"，
   看起来像渲染坏了。这里单独放开宽度，并让数字部分等宽，切换时不会左右跳。 */
.topbar select.cur-sel {
  max-width: 96px;
  min-width: 66px;
  padding-right: 4px;
  font-variant-numeric: tabular-nums;
  text-align: left;
}

/* ---------- 390px 横向溢出（scrollWidth 443 > 390）根因修复 ---------- */
/* 1) 五行色带是 repeat(5, 1fr)，五列的 min-content 之和（每格 padding 20 + 最长的
      "Autumn" / "White" 之类的短词）超过容器 → 网格撑破 viewport。改成 minmax(0,1fr)
      允许压缩，并收字号。 */
@media (max-width: 560px) {
  .wx-five { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .wx-five-i { padding: 9px 4px; border-radius: 12px; border-top-width: 3px; }
  .wx-five-i b { font-size: 14px; }
  .wx-five-i span { font-size: 11px; }
  /* 「Spring · East」这行在 390 下会折成 4 行，把 Earth 那格拉得比邻居高一倍。
     窄屏只留「五行 + 颜色」，季节/方位在下面点开详解时照样能看到。 */
  .wx-five-i small { display: none; }
  /* 2) 旅程栏 .jny-s 是 flex:1 1 0 + min-width:96，四步最窄 384 + 间距 > 362 容器。
     窄屏直接不显示这条轨道——首访者还没进入流程，"5 steps · not entered yet"
     只是一块空进度条，占掉半屏还分散注意。桌面保留。 */
  .jny-wrap { display: none; }
  /* 结果路由四张卡压缩：原来一屏放不下，现在四张卡能连着看完 */
  .jw-who-g { gap: 10px; }
  .jw-who-c { padding: 14px; gap: 4px; }
  .jw-who-c b { font-size: 15px; }
  .jw-who-c span { font-size: 12.5px; line-height: 1.55; }
  /* 轨道已隐藏，那句「the rail above keeps the tally」就成了指向空气的注释，一并收掉 */
  #who .wx-src { display: none; }
  /* FAQ 按钮别在窄屏抢走标题的视觉重心 */
  #who .band-head .btn-cream { padding: 8px 14px; font-size: 13px; }
}

/* ---------- market 页顶部五行快捷条：三行文字全是 nowrap，把整块撑到 616px ---------- */
/* .esh-topquick 是隐式单列 grid（列宽 = max-content），子项 .esh-q 里 b/span/i 都
   white-space:nowrap 且没有 min-width:0 → flex 子项不肯收缩 → 列宽锁死在 616，
   反过来把父级 .wrap 也顶宽。允许收缩 + 省略号即可，信息不丢（桌面宽度够照常全显示）。 */
.esh-topquick { grid-template-columns: minmax(0, 1fr); }
.esh-q { min-width: 0; }
.esh-q b, .esh-q span, .esh-q i { min-width: 0; }
.esh-q b { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .esh-q { padding: 9px 11px; gap: 8px; border-left-width: 4px; }
  .esh-q b { font-size: 13px; }
  .esh-q span { display: none; }   /* 窄屏先让位给「五行 + 最低价」，描述文字收益最低 */
  .esh-q i { font-size: 12px; }
}

/* ---------- 旅程栏在所有内页都超宽（四步 × min-width:96 ≥ 384 > 362 容器） ----------
 * 首页那段已整块删掉（首屏当场兑现三样东西，不需要空进度条）；内页的轨道还有导航意义，
 * 所以不删，改成"轨道自身可横滑"：不撑页面、不缩字号，步进关系仍然一眼能看出来。 */
@media (max-width: 560px) {
  .jny-rail { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
  .jny-rail::-webkit-scrollbar { display: none; }
  .jny-s { flex: 0 0 auto; min-width: 92px; }
  .jny { padding: 14px 12px 12px; }
}
