/* =========================================
   H5 顶栏 + 移动菜单抽屉（Figma 629:3219 / Navi_m 423:2518）
   仅 max-width: 768px，与 PC .header 完全隔离
   ========================================= */

@media (max-width: 768px) {
  #header-placeholder .header {
    display: none !important;
  }

  /* 固定顶栏容器（占位 + 内嵌 nav 同区域） */
  #header-m-placeholder {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    display: block;
    width: 100%;
    height: calc(0.8rem + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 0.16rem 0;
    box-sizing: border-box;
    pointer-events: none;
  }

  #header-m-placeholder:not(.is-i18n-ready) .header-m,
  #mobile-menu-placeholder:not(.is-i18n-ready) .mobile-menu {
    visibility: hidden;
  }

  #header-m-placeholder .header-m {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    position: relative;
    pointer-events: auto;
  }

  body > #header-m-placeholder + main {
    padding-top: calc(0.8rem + env(safe-area-inset-top));
  }

  .header-m__brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    height: 0.48rem;
    line-height: 0;
  }

  .header-m__logo {
    display: block;
    height: 0.48rem;
    width: auto;
    max-width: 1.8rem;
    max-height: none;
  }

  .header-m__menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    line-height: 0;
    cursor: pointer;
  }

  .header-m__menu-img {
    display: block;
    height: 0.36rem;
    width: auto;
    max-width: none;
  }

  /* ---------- 移动菜单 ---------- */
  .mobile-menu {
    position: fixed;
    inset: 0;
    z-index: 2000;
    pointer-events: none;
  }

  .mobile-menu[hidden] {
    display: none !important;
  }

  .mobile-menu.is-open {
    pointer-events: auto;
  }

  .mobile-menu__backdrop {
    position: absolute;
    inset: 0;
    background: transparent;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .mobile-menu.is-open .mobile-menu__backdrop {
    opacity: 1;
  }

  .mobile-menu__panel {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      'header'
      'nav'
      'lang';
    width: 100%;
    max-width: 3.9rem;
    height: 100%;
    min-height: -webkit-fill-available;
    padding: env(safe-area-inset-top) 0 0;
    background: rgba(17, 17, 17, 0.8);
    backdrop-filter: blur(0.15rem);
    -webkit-backdrop-filter: blur(0.15rem);
    transform: translateX(100%);
    transition: transform 0.35s ease;
    will-change: transform;
    overflow: hidden;
    box-sizing: border-box;
  }

  .mobile-menu.is-open .mobile-menu__panel {
    transform: translateX(0);
  }

  @media (prefers-reduced-motion: reduce) {
    .mobile-menu__panel {
      transition: none;
    }
  }

  /* 抽屉顶栏（对齐 H5 header-m 间距） */
  .mobile-menu__header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 0.8rem;
    margin: 0;
    padding: 0 0.16rem;
    box-sizing: border-box;
  }

  .mobile-menu__brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    height: 0.48rem;
    line-height: 0;
  }

  .mobile-menu__logo {
    display: block;
    height: 0.48rem;
    width: auto;
    max-width: 1.8rem;
    max-height: none;
  }

  .mobile-menu__close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    line-height: 0;
    cursor: pointer;
  }

  .mobile-menu__close-img {
    display: block;
    height: 0.35rem;
    width: auto;
    max-width: none;
  }

  .mobile-menu__nav {
    grid-area: nav;
    min-height: 0;
    margin-top: 0.24rem;
    padding: 0 0.24rem 0.16rem;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .mobile-menu__list {
    display: flex;
    flex-direction: column;
    gap: 0.16rem;
    width: 100%;
  }

  .mobile-menu__item {
    padding-bottom: 0.16rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  }

  .mobile-menu__item:last-child {
    border-bottom: 0;
  }

  .mobile-menu__link {
    display: flex;
    flex-direction: column;
    gap: 0.02rem;
    color: var(--color-white);
    overflow-wrap: break-word;
    word-break: normal;
  }

  .mobile-menu__link-en {
    font-family: var(--font-en);
    font-size: 0.24rem;
    font-weight: 500;
    line-height: 0.24rem;
  }

  .mobile-menu__link-zh {
    font-family: var(--font-zh);
    font-size: 0.16rem;
    font-weight: 400;
    line-height: 0.24rem;
  }

  .mobile-menu__link--active {
    position: relative;
  }

  .mobile-menu__link--active::before {
    content: '';
    position: absolute;
    left: -0.15rem;
    top: 50%;
    width: 0.03rem;
    height: 0.5rem;
    background: #fff;
    transform: translateY(-50%);
    pointer-events: none;
  }

  .mobile-menu__lang {
    grid-area: lang;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.16rem;
    margin: 0;
    padding: 0.32rem 0.24rem calc(0.48rem + env(safe-area-inset-bottom));
  }

  .mobile-menu__lang-option {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    font-family: var(--font-zh);
    font-size: 0.16rem;
    line-height: 0.18rem;
    color: var(--color-white);
    opacity: 0.4;
    cursor: pointer;
    overflow-wrap: break-word;
    word-break: normal;
  }

  .mobile-menu__lang-option--active {
    font-weight: 500;
    opacity: 1;
  }

  body.mobile-menu-open {
    overflow: hidden;
  }
}

@media (min-width: 769px) {
  .header-m,
  .mobile-menu,
  #header-m-placeholder,
  #mobile-menu-placeholder {
    display: none !important;
  }
}
