/* =========================================================================
   mobile.css — 手机端紧凑版式（对齐参考站的「一行 4 个方块」布局）
   -------------------------------------------------------------------------
   为什么单独一个文件、并且放在 app.css / fx.css 之后加载：
     fx.css 里已经有一个 @media (max-width:640px) 块（.cat-card .thumb{height:88px}、
     .hero-stat{min-width:88px} 等）。同特异性下「后加载的胜出」，如果把这些覆盖写进
     app.css，会被 fx.css 反向盖掉。按层叠顺序单独成文件最稳，也方便日后整体回滚。
   三条硬目标：
     1. 顶部导航 103px → 单行 ~50px
     2. Hero 702px → ~280px，把首屏让给商品
     3. 分类 / 商品 / 热销统一 4 列方块，缩略图正方形完整显示，徽章不再压图
   ========================================================================= */

@media (max-width: 640px) {

  /* ------------------------------------------------------------ 顶部导航 */
  .topbar {
    border-bottom-width: 2px;
  }

  /* 上一版把品牌、跑马灯、登录按钮硬挤进一行，跑马灯只剩 152px（实测），
     10 个字就被裁掉，用户看到的结论是「通告不显示」。这里改成两排：
       第 1 排 品牌 + 登录/注册
       第 2 排 跑马灯整行通栏（order:9 把它顶到第二排）
     代价只有 24px 高度，换来的是公告真的读得完。 */
  .topbar-inner {
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 6px 10px 7px;
    min-height: 0;
  }

  .brand {
    gap: 6px;
    font-size: 13px;
    flex: 1 1 auto;
    min-width: 0;
  }

  .brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    box-shadow: 2px 2px 0 var(--primary-ink);
  }

  .brand-mark .icon {
    width: 14px;
    height: 14px;
  }

  .brand small {
    display: none;
  }

  /* 通栏第二排。flex:1 0 100% 让它整行占满，不再和品牌抢宽度；
     order:9 把它排到品牌与按钮之后 —— 不加这个，wrap 后它会插到第一排中间。 */
  .marquee {
    order: 9;
    flex: 1 0 100%;
    flex-basis: 100%;
    min-width: 0;
    max-width: 100%;
    height: 24px;
    padding: 0 9px;
    gap: 6px;
    border-width: 1.5px;
    border-radius: 8px;
  }

  .marquee > .icon {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
  }

  .marquee-track {
    font-size: 11.5px;
  }

  /* 手机上跑马灯要真的跑起来，但时长不在这里定：app.js 按「一份文字的宽度 / 34px/s」
     算出 --marq-dur 后统一写死，桌面和手机同一套速度。这里再写 animation 简写会把它盖掉。 */

  .userbar {
    margin-left: 0;
    flex: 0 0 auto;
    gap: 5px;
  }

  .userbar .btn-sm {
    height: 26px;
    min-height: 26px;
    padding: 0 9px;
    font-size: 11.5px;
    border-width: 1.5px;
    box-shadow: 2px 2px 0 var(--primary-ink);
  }

  /* ------------------------------------------------------------ Hero 压缩 */
  .page {
    padding: 10px 10px 36px;
  }

  .hero {
    padding: 8px 9px 9px;
    margin-bottom: 10px;
    border-width: 2px;
    border-radius: 11px;
    box-shadow: 3px 3px 0 var(--primary-ink);
  }

  .hero::after {
    display: none;   /* 右下角装饰大圆，窄屏上没有存在感，白占绘制 */
  }

  /* 徽章与标题并排成一行。原来白吃两行高度，原因有两个：
       ① .hero-badge 自带 margin-bottom:16px，是独立一行；
       ② fx.css:26 的 .fx-blur 是 display:block，把「买卡密，」和「不用等」拆成了两行。 */
  .hero-badge {
    display: inline-flex;
    vertical-align: middle;
    margin: 0 6px 0 0;
    padding: 0 6px;
    font-size: 9px;
    line-height: 1.75;
    letter-spacing: .04em;
    border-width: 1px;
  }

  .hero-badge .icon {
    width: 10px;
    height: 10px;
  }

  .hero h1 {
    display: inline-block;
    vertical-align: middle;
    font-size: 16px;
    line-height: 1.3;
    margin: 0;
  }

  .hero h1 .fx-blur,
  .hero h1 .fx-grad {
    display: inline;
  }

  /* fx.css 的渐变头两个色号是 #6366F1 / #8B5CF6，压在靛蓝 hero 上几乎看不见；
     小字号下更糊。手机端换一套亮色，保持流动动画不变。 */
  .hero h1 .fx-grad {
    background-image: linear-gradient(96deg, #FDE68A 0%, #A7F3D0 28%, #BAE6FD 58%, #FDE68A 100%);
  }

  /* 营销文案整段收起：手机端要两行 ~34px，同样的信息在商品卡与常见问题里都有 */
  .hero p {
    display: none;
  }

  /* 4 个数据块：原来 flex-wrap 在 390px 下换行成 3+1，占掉 ~150px */
  .hero-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    margin: 7px 0 0;
  }

  .hero-stat {
    min-width: 0;
    padding: 2px 1px 3px;
    border-width: 1px;
    border-radius: 6px;
    text-align: center;
    backdrop-filter: none;
  }

  .hero-stat b {
    font-size: 12px;
    line-height: 1.25;
  }

  .hero-stat span {
    display: block;
    font-size: 8.5px;
    letter-spacing: 0;
    text-transform: none;
  }

  /* 5 个按钮挤成一行。用 grid-auto-flow:column 而不是 repeat(5)，
     这样「节日活动」被 hidden 掉时只会有 4 格、不会右边空一格。 */
  .hero-actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 4px;
    margin-top: 6px;
  }

  .hero-actions .btn {
    height: 27px;
    min-height: 27px;
    padding: 0 1px;
    font-size: 10px;
    white-space: nowrap;
    border-width: 1.5px;
    border-radius: 7px;
    box-shadow: 2px 2px 0 rgba(15, 15, 60, .45);
  }

  .search {
    margin-top: 6px;
    padding: 0 3px 0 8px;
    border-width: 2px;
    box-shadow: 2px 2px 0 rgba(15, 15, 60, .45);
  }

  .search .icon {
    width: 14px;
    height: 14px;
  }

  .search input {
    height: 30px;
    font-size: 11px;
  }

  /* 装饰性滚动 chip 条：aria-hidden，纯装饰，移动端整块不要 */
  .hero-loop {
    display: none;
  }

  /* ------------------------------------------------------------ 段落标题 */
  .section-head {
    margin-bottom: 7px;
    align-items: baseline;
  }

  .section-head h2 {
    font-size: 15px;
  }

  .section-head .sub {
    font-size: 10.5px;
  }

  .tabs {
    gap: 5px;
    padding: 1px 0 7px;
    margin: 0 0 9px;
  }

  .tab {
    min-height: 28px;
    padding: 3px 11px;
    font-size: 11.5px;
    border-width: 1.5px;
  }

  /* ------------------------------------------------- 分类卡 / 热销卡：4 列 */
  .cat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 12px;
  }

  .cat-card {
    gap: 3px;
    padding: 4px;
    min-height: 0;
    border-width: 2px;
    border-radius: 9px;
    box-shadow: 2px 2px 0 var(--primary-ink);
  }

  .cat-card:hover {
    transform: none;
    box-shadow: 2px 2px 0 var(--primary-ink);
  }

  /* 4 列宽度下（约 77px）放不下 38px 图标 + 图片，图标让位给缩略图 */
  .cat-card .cat-icon {
    display: none;
  }

  .cat-card .cat-name {
    font-size: 10.5px;
    line-height: 1.25;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-all;
  }

  .cat-card .cat-meta {
    font-size: 9.5px;
    line-height: 1.3;
    text-align: center;
  }

  /* 「框框遮挡」根治：
     原来 .cat-tag 是 position:absolute; top:-10px，正好压在 <img> 顶部。
     移动端改为流内小胶囊、order:3 排到卡片最底部，图像区域完全不重叠。 */
  .cat-card .cat-tag {
    position: static;
    order: 3;
    align-self: center;
    margin-top: 1px;
    padding: 0 4px;
    border-width: 1px;
    border-radius: 5px;
    /* 4 列卡片内容宽约 76px：9px 字号排 8 个汉字要 72px，加上 padding 和边框
       刚好超一点点，会被挤成「可用活动金额购 / 买」—— 第二行孤零零一个「买」
       字，卡片还因此高低不齐。压到 8px + nowrap 让它稳定占一行。 */
    font-size: 8px;
    line-height: 1.6;
    letter-spacing: 0;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
  }

  /* ------------------------------------------------- 商品列表：4 列方块卡 */
  .sub-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .sub-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    padding: 4px;
    border-width: 2px;
    border-radius: 9px;
  }

  .sub-item:hover {
    transform: none;
    box-shadow: none;
  }

  .sub-item .sub-main {
    width: 100%;
  }

  .sub-item .sub-name {
    font-size: 10.5px;
    line-height: 1.25;
    gap: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-all;
  }

  /* 卡宽只有 ~87px，描述和库存徽章会把文字挤成一行一个字，全部收起。
     缺货状态由 .is-out 的透明度 + 按钮文案「已售罄」表达，信息不丢。 */
  .sub-item .sub-desc,
  .sub-item .badge {
    display: none;
  }

  .sub-item .sub-price {
    font-size: 12px;
    line-height: 1.2;
  }

  .sub-item .sub-price small {
    font-size: 9px;
  }

  .sub-item .btn {
    grid-column: auto;
    width: 100%;
    height: 24px;
    min-height: 24px;
    padding: 0 1px;
    font-size: 10px;
    border-width: 1.5px;
    border-radius: 6px;
    box-shadow: 2px 2px 0 var(--primary-ink);
  }

  /* ------------------------------------------------- 缩略图下的下载胶囊 */
  /* 4 列后卡片只有 ~87px 宽，胶囊必须跟着缩：
     去掉图标、字号降到 9px，一排两个字刚好放下。 */
  .dl-chip {
    gap: 0;
    padding: 0 5px;
    border-width: 1px;
    border-radius: 5px;
    font-size: 9px;
    line-height: 1.5;
  }

  .dl-chip .icon {
    display: none;
  }

  .cat-card .dl-chip {
    align-self: center;
    margin-top: 1px;
  }

  /* 有下载地址的规格多一颗胶囊、没填的少一颗，四列并排时商品名会一高一低错位。
     给缩略图这一列固定留出一行胶囊位（14px + 3px 间距），
     不管有没有下载地址，四张卡的缩略图、商品名、买按钮都会落在同一条线上。 */
  .sub-item .sub-thumb {
    display: grid;
    grid-template-rows: auto 14px;
    row-gap: 3px;
    justify-items: center;
    align-content: start;
  }

  /* ------------------------------------------------------------ 面板收紧 */
  .panel {
    border-radius: 11px;
  }

  .panel-head {
    padding: 7px 9px;
  }

  .panel-head h3 {
    font-size: 12.5px;
    gap: 5px;
  }

  .panel-head .sub {
    display: none;
  }

  .panel-body {
    padding: 7px;
  }

  .list-row {
    padding: 7px 9px;
  }

  .list-row .t {
    font-size: 12px;
  }

  .list-row .s {
    font-size: 11px;
  }

  /* 页脚：四列在手机上折成两列，第四条说明通栏放最后一行 */
  .footer {
    margin-top: 22px;
    font-size: 11.5px;
  }

  .footer-nav {
    padding: 18px 14px 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 14px;
  }

  .footer-col h4 {
    margin-bottom: 6px;
    font-size: 12px;
  }

  .footer-col h4 .icon {
    width: 13px;
    height: 13px;
  }

  /* 手指点击要求：纵向给足 32px 以上，否则一行行挤在一起容易点错 */
  .footer-col button {
    padding: 7px 0;
    font-size: 12px;
    min-height: 32px;
  }

  .footer-about {
    grid-column: 1 / -1;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
  }

  .footer-about .footer-name { font-size: 13px; }

  .footer-line,
  .footer-note { font-size: 11px; }

  .footer-bar {
    padding: 10px 14px 18px;
    gap: 6px;
    font-size: 11px;
  }

  /* 手机端同样改成「图标 + 客服」胶囊，只缩尺过尺寸，不要还原成正方形 */
  .float-btn {
    min-width: 46px;
    padding: 6px 9px 5px;
    right: 12px;
    bottom: 14px;
    border-radius: 13px;
    gap: 2px;
    box-shadow: 3px 3px 0 var(--primary-ink);
  }
  .float-btn .icon { width: 19px; height: 19px; }
  .float-btn .fb-txt { font-size: 10.5px; letter-spacing: .04em; }
}

/* ------------------------------------------------------------------ 缩略图 */
@media (max-width: 640px) {
  /* 正方形满宽 + contain：完整显示原图，不再被裁掉半边 */
  .cat-card .thumb,
  .cat-card .thumb.is-hot,
  .sub-item .thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    border-width: 1.5px;
    border-radius: 7px;
  }

  .cat-card .thumb img,
  .cat-card .thumb.is-hot img,
  .sub-item .thumb img {
    object-fit: contain;
  }

  /* hot 位的渐变遮罩是为 cover 裁切设计的，contain 下会糊成一条灰带 —— 关掉 */
  .thumb.is-hot::after {
    display: none;
  }

  .thumb .thumb-fallback .icon {
    width: 42%;
    height: 42%;
  }
}

/* 超窄屏（≤360px）再压一档 */
@media (max-width: 360px) {
  .hero h1 { font-size: 14px; }
  .hero-badge { font-size: 8px; padding: 0 5px; }
  .hero-actions .btn { font-size: 9px; }
  .cat-grid,
  .sub-list { gap: 5px; }
  .cat-card .cat-name,
  .sub-item .sub-name { font-size: 10px; }
}
