/**
 * 手机端：顶部品牌栏 + 右侧毛玻璃抽屉；≤1024px 隐藏底部五栏 Dock
 *
 * 注意：必须先写 .mobile-header / .mobile-drawer 等「默认 display:none」，
 * 再在文件末尾用 @media (max-width:1024px) 覆盖为 flex/block，否则层叠顺序
 * 会让窄屏仍保持 none，顶栏与抽屉整块消失。
 */

/* —— 顶部品牌栏 —— */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 1000;
  min-height: 72px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(15, 61, 36, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-sizing: border-box;
}

.mobile-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.mobile-logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  display: block;
}

.mobile-logo.is-placeholder {
  object-fit: contain;
  padding: 6px;
  background: rgba(255, 255, 255, 0.1);
}

.mobile-brand-text {
  min-width: 0;
  line-height: 1.1;
}

.mobile-site-name {
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(150px, 42vw);
}

.mobile-site-en {
  margin-top: 4px;
  font-size: 11px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.66);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(160px, 48vw);
}

.mobile-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.mobile-icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.18s ease, background 0.2s ease;
}

.mobile-icon-btn svg {
  display: block;
}

.mobile-workbench-btn {
  height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.18s ease, background 0.2s ease;
  box-sizing: border-box;
}

.mobile-menu-btn {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.22), transparent 35%),
    rgba(255, 255, 255, 0.1);
  color: #fff;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.18s ease, box-shadow 0.2s ease;
}

.mobile-menu-btn .mobile-menu-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

.mobile-menu-btn.is-open .mobile-menu-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.mobile-menu-btn.is-open .mobile-menu-bar:nth-child(2) {
  opacity: 0;
}
.mobile-menu-btn.is-open .mobile-menu-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.mobile-icon-btn:active,
.mobile-workbench-btn:active,
.mobile-menu-btn:active {
  transform: scale(0.96);
}

/* —— 遮罩 —— */
.mobile-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1090;
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
}

.mobile-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* —— 抽屉 ——（窄条：约 1/4 屏宽，略宽于文案；下限保证中文菜单不换行） */
.mobile-drawer {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: clamp(11.25rem, 25vw, 14rem);
  z-index: 1100;
  transform: translateX(100%);
  pointer-events: none;
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  box-sizing: border-box;
  background: linear-gradient(165deg, rgba(18, 58, 36, 0.92) 0%, rgba(12, 42, 28, 0.94) 45%, rgba(10, 36, 24, 0.96) 100%);
  backdrop-filter: blur(22px) saturate(1.25);
  -webkit-backdrop-filter: blur(22px) saturate(1.25);
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
}

.mobile-drawer.is-open {
  transform: translateX(0);
  pointer-events: auto;
}

.mobile-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 12px 10px 10px;
  gap: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mobile-drawer-title {
  font-size: 14px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.04em;
  min-width: 0;
  flex: 1;
}

.mobile-drawer-close {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s ease, transform 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-drawer-close:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.12);
}

.mobile-drawer-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 10px 20px;
}

/* 抽屉内主导航：覆盖历史全局 .nav-links 固定侧栏规则 */
.mobile-drawer .mobile-drawer-nav-list.nav-links {
  position: static !important;
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  min-width: 0 !important;
  height: auto !important;
  max-height: none !important;
  transform: none !important;
  visibility: visible !important;
  pointer-events: auto !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  gap: 10px !important;
  background: transparent !important;
  list-style: none;
  margin: 0;
}

.mobile-drawer .mobile-drawer-nav-list.nav-links::before {
  content: '';
  display: block;
  height: 3px;
  width: 56%;
  margin: 0 auto 6px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(201, 150, 42, 0.85),
    rgba(232, 184, 75, 0.95),
    rgba(201, 150, 42, 0.85),
    transparent
  );
  flex-shrink: 0;
}

.mobile-drawer .mobile-drawer-nav-list > li {
  width: 100%;
  list-style: none;
}

.mobile-drawer .mobile-drawer-nav-list > li > a.nav-top-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 11px 10px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-sizing: border-box;
  transition: background 0.2s ease, transform 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-drawer .mobile-drawer-nav-list > li > a.nav-top-link:active {
  transform: scale(0.98);
}

.mobile-drawer .mobile-drawer-nav-list > li > a.nav-top-link.active {
  background: rgba(201, 150, 42, 0.22);
  border-color: rgba(201, 150, 42, 0.45);
}

.mobile-drawer .nav-dd {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.mobile-drawer .nav-dd-hit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 11px 10px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  box-sizing: border-box;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
}

/* 覆盖 site-shell 里 .nav-dd-menu 的 absolute/fixed 层叠，子菜单必须在文档流内纵向展开 */
.mobile-drawer .nav-dd-menu {
  position: static !important;
  left: auto !important;
  top: auto !important;
  right: auto !important;
  transform: none !important;
  width: 100% !important;
  min-width: 0 !important;
  margin: 8px 0 0 !important;
  padding: 8px 0 !important;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  list-style: none;
  box-shadow: none !important;
  z-index: auto !important;
  opacity: 1 !important;
  visibility: visible !important;
  display: none !important;
  pointer-events: none;
}

.mobile-drawer .nav-dd.open .nav-dd-menu {
  display: block !important;
  pointer-events: auto !important;
}

.mobile-drawer .nav-dd-menu li {
  list-style: none;
  margin: 0;
}

.mobile-drawer .nav-dd-menu a {
  display: block;
  padding: 10px 10px;
  text-align: center;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.mobile-drawer .nav-dd-menu a:hover,
.mobile-drawer .nav-dd-menu a:active {
  background: rgba(255, 255, 255, 0.08);
}

body.mobile-drawer-open {
  overflow: hidden;
  touch-action: none;
}

@media (max-width: 1024px) {
  html {
    scroll-padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  }
  body.has-bottom-dock {
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  .site-bottom-dock {
    display: none !important;
  }
  .site-float-consult {
    bottom: calc(22px + env(safe-area-inset-bottom)) !important;
    right: max(16px, env(safe-area-inset-right)) !important;
  }
  #navbar.site-navbar-desktop {
    display: none !important;
  }
  .mobile-header {
    display: flex;
  }
  .mobile-drawer-backdrop {
    display: block;
  }
  .mobile-drawer {
    display: flex;
    flex-direction: column;
  }
}

@media (min-width: 1025px) {
  .mobile-header,
  .mobile-drawer-backdrop,
  .mobile-drawer {
    display: none !important;
  }
  #navbar.site-navbar-desktop {
    display: block;
  }
}
