/* =========================================================
   Header / primary navigation.
   Desktop: horizontal nav with hover dropdown.
   Mobile: side drawer with accordion.
   ========================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: rgba(255, 255, 255, 0.52);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  transition: background var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.site-header.is-scrolled {
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.05), 0 2px 8px rgba(15, 23, 42, 0.03);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-header {
    background: rgba(255, 255, 255, 0.92);
  }
  .site-header.is-scrolled {
    background: rgba(255, 255, 255, 0.96);
  }
}
.site-header > .container {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 72px;
}

/* ---- Logo ---- */
.logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: var(--fw-extrabold);
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--color-text-strong);
  text-decoration: none;
  flex-shrink: 0;
}
.logo__img {
  display: block;
  height: 36px;
  width: auto;
  user-select: none;
  -webkit-user-drag: none;
}
/* 页脚是深色底，原 logo 图为「红 icon + 黑色 云梦 字标」，
   文字部分会糊在深底里。这里整体反相成白色 logo，保证可读。 */
.footer-brand .logo__img {
  filter: brightness(0) invert(1);
  height: 32px;
}
@media (max-width: 539px) {
  .logo__img { height: 32px; }
}
.logo .mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  background:
    linear-gradient(135deg, #146EF5 0%, #00B8D9 60%, #A7E92F 120%);
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(20, 110, 245, 0.35);
}
.logo .mark::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.92);
}
.logo .mark::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 12px; height: 12px;
  transform: translate(-50%, -50%);
  border-radius: 3px;
  background:
    conic-gradient(from 230deg, #146EF5, #00B8D9, #A7E92F, #146EF5);
}
.logo .word { display: inline-block; }
.logo .word .alt { color: var(--color-primary); }
.logo small { display: block; font-size: 11px; font-weight: var(--fw-medium); color: var(--color-muted); letter-spacing: 0.16em; text-transform: uppercase; line-height: 1; margin-top: 4px; }

/* ---- Primary nav ---- */
.primary-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: 64px;
  flex: 1;
}
.primary-nav > .nav-item {
  position: relative;
  padding: 0;
}
.primary-nav .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 11px;
  font-size: 14px;
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  transition: color var(--dur-fast) var(--ease-out);
}
.primary-nav .nav-link:hover { color: var(--color-primary-strong); }
.primary-nav .nav-item[aria-current="page"] > .nav-link { color: var(--color-primary-strong); }
.primary-nav .dropdown a[aria-current="page"] {
  background: var(--color-primary-soft);
  color: var(--color-primary-strong);
}
.primary-nav .nav-link .chevron {
  width: 14px; height: 14px;
  transition: transform var(--dur-fast) var(--ease-out);
}
.primary-nav .nav-item.has-dropdown:hover > .nav-link .chevron,
.primary-nav .nav-item.is-open > .nav-link .chevron { transform: rotate(180deg); }

/* ---- Nav hover hint (desktop) — 单行说明，挂到 body + fixed 定位，避免被顶栏/首屏裁切 ---- */
@media (min-width: 1024px) {
  .site-header,
  .site-header > .container,
  .primary-nav,
  .primary-nav > .nav-item {
    overflow: visible;
  }

  .nav-hint {
    position: fixed;
    margin: 0;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: var(--fw-medium);
    line-height: 1.35;
    letter-spacing: 0.01em;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    background: rgba(10, 12, 16, 0.6);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    user-select: none;
    cursor: default;
    transform: translateX(-50%) translateY(6px);
    transition:
      opacity var(--dur-fast) var(--ease-out),
      transform var(--dur-fast) var(--ease-out),
      visibility var(--dur-fast) linear;
    transition-delay: 0s, 0s, 0s;
    z-index: calc(var(--z-sticky) + 30);
  }
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .nav-hint {
      background: #0a0c10;
      border-color: transparent;
    }
  }

  .nav-hint.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    transition-delay: 0.14s, 0.14s, 0.14s;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-hint {
    transition: none;
  }
  .nav-hint.is-visible {
    transition-delay: 0s;
  }
}

/* ---- Dropdown ---- */
.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 270px;
  background: var(--color-surface);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 8px 12px 12px;
  opacity: 0;
  transform: translateY(4px);
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), visibility var(--dur-fast) linear;
  z-index: var(--z-dropdown);
}
/* 透明桥接区：鼠标从一级项移入二级菜单时不断开 hover */
.dropdown::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -10px;
  height: 10px;
}
.primary-nav .has-dropdown:hover .dropdown,
.primary-nav .has-dropdown:focus-within .dropdown,
.primary-nav .is-open .dropdown {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s, 0s, 0s;
}
.dropdown a {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  color: var(--color-text);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
.dropdown a:hover { color: var(--color-primary-strong); }
.dropdown a strong { font-size: 15px; font-weight: var(--fw-strong); }
.dropdown a span { font-size: 13px; color: var(--color-muted); line-height: 1.5; }
.dropdown a:hover span { color: var(--color-text); }

/* ---- Right zone: lang + cta ---- */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  overflow: visible;
  flex-shrink: 0;
}
/* Ultron AutoTranslate 挂载点（ctype="languages"）— 预留「简体中文」宽度，避免与登录重叠 */
.lang-switch[ctype="languages"] {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
  flex: 0 0 auto;
  width: 142px;
  min-width: 142px;
  max-width: 142px;
  min-height: 40px;
  overflow: visible;
  isolation: isolate;
}
.header-right .btn--secondary,
.header-right .btn--sm,
.header-right .nav-toggle {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.lang-switch {
  position: relative;
}
.lang-switch button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 13px;
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
}
.lang-switch button:hover { color: var(--color-primary-strong); }
.lang-switch ul {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 140px;
  background: var(--color-surface);
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  list-style: none;
  padding: 8px 6px 6px;
  margin: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), visibility var(--dur-fast) linear;
  z-index: var(--z-dropdown);
}
.lang-switch ul::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -10px;
  height: 10px;
}
.lang-switch:hover ul,
.lang-switch:focus-within ul,
.lang-switch.is-open ul {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
.lang-switch li { margin: 0; }
.lang-switch a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 13px;
  text-decoration: none;
}
.lang-switch a:hover, .lang-switch a[aria-current="true"] { background: var(--color-primary-soft); color: var(--color-primary-strong); }

/* ---- Mobile toggle ---- */
.nav-toggle {
  display: none;
  width: 44px; height: 44px;
  align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
}
.nav-toggle svg { width: 20px; height: 20px; }
.nav-toggle .icon-close { display: none; }
.nav-open .nav-toggle .icon-menu { display: none; }
.nav-open .nav-toggle .icon-close { display: block; }

/* ---- Drawer（挂载在 body 下，避免被首屏/产品区 z-index 盖住）---- */
.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(11, 18, 32, 0.35);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out), visibility var(--dur-fast) linear;
}
body.nav-open .nav-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.nav-drawer {
  position: fixed;
  inset: 72px 0 0 0;
  background: var(--color-bg);
  z-index: 9999;
  transform: translateX(100%);
  transition: transform var(--dur-base) var(--ease-out);
  overflow: hidden;
  display: none;
  -webkit-overflow-scrolling: touch;
}
.nav-drawer .container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-drawer .drawer-section { margin-bottom: 24px; flex-shrink: 0; }
.nav-drawer .drawer-section h5 {
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--color-muted);
  margin-bottom: 8px; font-weight: var(--fw-semibold);
}
.nav-drawer .drawer-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px;
  font-size: 16px;
  font-weight: var(--fw-semibold);
  color: var(--color-text-strong);
  border-bottom: 1px solid var(--color-divider);
  text-decoration: none;
}
.nav-drawer .drawer-link--indent {
  padding-left: 28px;
  font-size: 14px;
  font-weight: var(--fw-medium);
  color: var(--color-text);
}
.nav-drawer details > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px;
  font-size: 16px;
  font-weight: var(--fw-semibold);
  color: var(--color-text-strong);
  border-bottom: 1px solid var(--color-divider);
}
.nav-drawer details > summary::-webkit-details-marker { display: none; }
.nav-drawer details > summary::after {
  content: ""; width: 14px; height: 14px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='none' stroke='%230B1220' stroke-width='2' stroke-linecap='round' d='M4 6l4 4 4-4'/></svg>") no-repeat center/contain;
  transition: transform var(--dur-fast) var(--ease-out);
}
.nav-drawer details[open] > summary::after { transform: rotate(180deg); }
.nav-drawer details[open] { padding-bottom: 8px; }
.nav-drawer details a.sub {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 24px;
  color: var(--color-text);
  font-size: 14px;
  font-weight: var(--fw-medium);
  border-bottom: 1px solid var(--color-divider);
  text-decoration: none;
}
.nav-drawer details a.sub small { color: var(--color-muted); font-size: 12px; }
.nav-drawer .drawer-cta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
  padding-top: 24px;
  flex-shrink: 0;
}
.nav-drawer .drawer-cta .btn--block,
.nav-drawer .drawer-cta .consult-popover--drawer {
  width: 100%;
}

@media (max-width: 1023px) {
  .primary-nav { display: none; }
  .site-header > .container { gap: 12px; }
  .header-right .lang-switch[ctype="languages"] {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    min-height: 36px;
  }
  .header-right { gap: 14px; min-width: 0; }
  /* 移动端顶栏只保留语言 + 菜单，登录/咨询放抽屉 */
  .header-right .btn--secondary,
  .header-right > .btn--sm,
  .header-right > .consult-popover {
    display: none;
  }
  .header-right .lang-switch[ctype="languages"] {
    margin-inline-end: 2px;
  }
  .site-header > .container {
    position: relative;
    z-index: calc(var(--z-sticky) + 2);
  }
  .nav-toggle {
    display: inline-flex;
    flex-shrink: 0;
    margin-left: 0;
    position: relative;
    z-index: calc(var(--z-sticky) + 3);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
  }
  .logo { flex-shrink: 0; }
  /* 关闭时 translateX(100%) 仍可能挡住右侧汉堡按钮，须禁用 pointer-events */
  .nav-drawer {
    display: block;
    pointer-events: none;
  }
  body.nav-open .nav-drawer {
    transform: translateX(0);
    pointer-events: auto;
  }
  body.nav-open { overflow: hidden; }
  body.nav-open .site-header {
    z-index: 10000;
  }
}

@media (max-width: 539px) {
  .header-right { gap: 16px; }
  .header-right .lang-switch[ctype="languages"] {
    width: 108px;
    min-width: 108px;
    max-width: 108px;
  }
}
