/* =====================================================================
   mobile.css —— 门户移动端适配（PC 端零影响）
   ---------------------------------------------------------------------
   契约：本文件所有规则 100% 位于 @media 内
         → 视口 ≥768px 时本文件贡献 0 条声明，PC / 展厅大屏渲染与引入前逐像素一致。

   断点：
     B1  ≤767px                       移动模式总开关（布局范式 + 字号体系 + 滚动解禁）
     B2  ≤640px                       主流手机竖屏数值微调
     B3  ≤380px                       小屏数值微调
     B4  (max-height:480px) and (orientation:landscape)  横屏守卫，并入 B1 同组

   规范：
     · 字号一律 clamp(px下限, 视口系数vw, px上限)，禁止无下限纯 vw
     · 全局硬底线 10px；可点击元素文字 ≥14px；触控目标 ≥44×44px
     · 布局范式在移动档内恒定（单列纵向流式），B2 / B3 只调数值
     · 不引入框架、不改 DOM 顺序、不改配置 JSON、不改 JS 逻辑
   ===================================================================== */

/* ---------------------------------------------------------------------
   B1 + B4：移动模式总开关
   --------------------------------------------------------------------- */
@media (max-width: 767px),
       (max-height: 480px) and (orientation: landscape) {

  /* ---------- 1) 解禁纵向滚动 + 流式容器 ---------- */
  html, body {
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }
  body { display: block; }

  /* 场景覆盖层打开时仍锁定底层滚动（保持原行为） */
  body.scene-open { overflow: hidden; }

  .nav-container {
    /* 用 100% 而非 100vw：避免移动端横向滚动条 */
    width: 100%;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;          /* 规避地址栏伸缩导致的 100vh 跳动 */
    overflow: visible;
    /* 底部留白 = 浮窗高 128px + 偏移 12px，保证滚到底时最后一条不被浮窗遮挡 */
    padding:
      calc(env(safe-area-inset-top) + 12px)
      16px
      calc(env(safe-area-inset-bottom) + 140px);
  }

  /* 整页背景层仍铺满整个容器高度 */
  .portal-bg { inset: 0; }

  /* ---------- 2) 品牌区 / 主标题回到文档流 ---------- */
  .brand-header {
    /* 用 relative 而非 static：保持文档流的同时让 z-index 生效，
       否则会被门户整页底图（absolute; z-index:0）压在下面。
       必须同时重置 PC 的 top/left —— relative 下它们依然会生效产生偏移 */
    position: relative;
    z-index: 40;
    top: auto;
    left: auto;
    width: auto;
    height: 44px;
  }
  .brand-logo .logo-mark {
    width: 26px;
    height: 26px;
    font-size: 12px;
    border-radius: 6px;
  }
  .brand-logo .logo-text {
    font-size: clamp(12px, 3.3vw, 14px);
  }

  .brand-title {
    position: relative;      /* 流式 + 恢复层级，浮于门户底图之上 */
    z-index: 40;
    left: auto;              /* 重置 PC 的 left:50% / top:12.8% */
    top: auto;
    transform: none;
    text-align: left;
    white-space: normal;         /* 长标题允许折行 */
    letter-spacing: 0.04em;
    font-size: clamp(17px, 5.1vw, 22px);
    margin: 16px 0 20px;
  }

  /* ---------- 3) 卡片：五槽位绝对定位 → 单列条目 ---------- */
  /* 注：必须用 position:relative（而非 static）—— .ui-content / .card-bg / ::before
     均为 absolute 定位，需要卡片本身作为定位基准，否则会脱离卡片铺满整屏 */
  .nav-container .screen-link,
  .nav-container .screen-link:hover,
  .nav-container .screen-link.is-auto-open {
    position: relative;
    top: auto;
    left: auto;
    transform: none;             /* 取消 rotateY 透视，正面可读 */
    width: 100%;
    max-width: 560px;
    height: 96px;
    margin: 0 auto 12px;
  }

  .nav-container .ui-content {
    align-items: flex-start;
    text-align: left;
    padding: 0 16px;
  }

  .nav-container .ui-subtext {
    /* 缺陷 A 修复：触屏无 hover，代号改为常驻可见 */
    opacity: 0.8;
    transform: none;
    font-size: clamp(10px, 2.6vw, 12px);
    letter-spacing: 2px;
  }

  .nav-container .site-name {
    font-size: clamp(15px, 4.1vw, 18px);
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(0, 243, 255, 0.6);
  }

  /* 布局模板变体的移动端字号 */
  .nav-container .screen-link.layout-compact .site-name {
    font-size: clamp(14px, 3.7vw, 16px);
  }
  .nav-container .screen-link.layout-emphasis .site-name {
    font-size: clamp(17px, 4.6vw, 20px);
  }

  /* 模块 LOGO 徽标：左上 → 右上（文字左对齐，不碰撞） */
  .nav-container .card-logo {
    top: 10px;
    right: 12px;
    left: auto;
    width: 28px;
    height: 28px;
  }

  /* HUD 准星角标收小 */
  .nav-container .screen-link::before { background-size: 10px 10px; }

  /* 激光扫描线：卡片变矮后原 keyframes（-50px → 280px）会直接飞出卡片 */
  .nav-container .ui-content::before { animation-name: radarSweepMobile; }

  .nav-container .screen-link.is-error .ui-content::after { font-size: 12px; }

  /* ---------- 4) 数字人浮窗 / 演示控制条 ---------- */
  .dh-stage {
    width: 96px;
    height: 128px;
    gap: 6px;
    border-radius: 16px;
    /* 修正：字幕改到浮窗上方，必须解除 overflow:hidden 否则被裁掉 */
    overflow: visible;
    right: calc(env(safe-area-inset-right) + 12px);
    bottom: calc(env(safe-area-inset-bottom) + 12px);
  }
  .dh-avatar { width: 52px; height: 52px; font-size: 16px; }
  .dh-name { font-size: 12px; letter-spacing: 1px; }
  .dh-tip { font-size: 10px; }
  /* 语音字幕（滚动气泡）的浮窗外定位样式见 assets/css/digital-human.css 的移动端块 */

  .portal-controls {
    left: calc(env(safe-area-inset-left) + 12px);
    bottom: calc(env(safe-area-inset-bottom) + 12px);
    gap: 8px;
  }
  .portal-controls button {
    min-height: 44px;            /* 触控目标下限 */
    padding: 10px 14px;
  }

  /* ---------- 5) 场景覆盖层（触屏可用性修复） ---------- */
  #sceneOverlay {
    width: 100%;
    height: 100vh;
    height: 100dvh;
  }

  /* 缺陷 B 修复：控制条常驻可见，关闭按钮可点 */
  .scene-chrome { opacity: 1; pointer-events: auto; }
  #sceneClose {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 13px;
    letter-spacing: 2px;
  }
  #sceneLabel { font-size: 13px; letter-spacing: 2px; }
  .scene-hint { font-size: 10px; }
  .scene-loading-text { font-size: 12px; }
  /* 右下角退出热区收小，避免误触 */
  .scene-exit-hotspot { width: 96px; height: 96px; }

  /* ---------- 6) 追问框（预留组件） ---------- */
  .end-qa-frame {
    width: 88vw;
    padding: 24px 16px;
  }
  .end-qa-kicker {
    font-size: 11px;
    margin-bottom: 12px;
  }
  .end-qa-title {
    font-size: clamp(18px, 5.2vw, 24px);
    letter-spacing: 0;
  }
  .end-qa-list {
    margin: 20px 0 0;
    gap: 12px;
  }
  .end-qa-list li { font-size: clamp(14px, 4vw, 18px); }
}

/* 移动版激光扫描关键帧：与 96px 卡片高度匹配 */
@keyframes radarSweepMobile {
  0%   { transform: translateY(-16px); opacity: 0; }
  12%  { opacity: 1; }
  80%  { transform: translateY(96px);  opacity: 1; }
  92%  { transform: translateY(96px);  opacity: 0; }
  100% { transform: translateY(96px);  opacity: 0; }
}

/* ---------------------------------------------------------------------
   B2：主流手机竖屏微调（≤640px）
   --------------------------------------------------------------------- */
@media (max-width: 640px) {
  .nav-container .screen-link { height: 92px; }
}

/* ---------------------------------------------------------------------
   B3：小屏手机微调（≤380px）—— 只收数值，不改范式
   --------------------------------------------------------------------- */
@media (max-width: 380px) {
  .nav-container {
    padding-left: 14px;
    padding-right: 14px;
  }
  .nav-container .screen-link {
    height: 88px;
    margin-bottom: 10px;
  }
}
