/* ============================================================
   博邦编程 · 四系统统一导航（共享样式，唯一真相）
   ============================================================
   这个文件是导航外观的唯一来源。四个系统都通过
     <link rel="stylesheet" href="<gateway>/branding/bb-nav.css">
   引入，不允许各自的样式再覆盖尺寸、间距、圆角、颜色。

   对齐规格（与博识基准一致）：
     导航条    高 56 / sticky / 白底 + 1px #e6e9ee 底边 / 左右 52 内边距
     品牌方块  28x28 / 圆角 8 / 内容区左起 52
     竖线      1x20 / 左右各 12 → x=161
     切换器    18px 图标 + 14px/500 文字 + 12px 箭头 / 内边距 6 8 / 圆角 7
     导航项    14px/400 / 内边距 7 11 / 圆角 7 / 间距 2 / 高 34
     选中态    accent 文字 + accent 8% 浅底 + 圆角 7
     注册按钮  34 高 / 内边距 0 16 / 圆角 8 / 白字

   断点（三档，全站唯一）：
     >1024   完整
     ≤1024   内边距收成 32
     ≤768    导航项收进菜单，只留 品牌 + 切换器图标 + 右侧操作
     ≤560    只留 logo 与右侧操作

   字体：不加载 webfont。三个系统都回落系统字体，度量天然一致；
   如果将来某个系统要上 webfont，必须四个一起加，否则缩放时字宽不同。
   ============================================================ */

.bb-nav-bar {
  --bb-accent: #0b7165;
  --bb-accent-soft: color-mix(in srgb, var(--bb-accent) 9%, #fff);
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 52px;
  background: #fff;
  border-bottom: 1px solid #e6e9ee;
  font-family: Inter, -apple-system, BlinkMacSystemFont, system-ui,
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 20px;
  color: #1e242d;
  box-sizing: border-box;
}
.bb-nav-bar *,
.bb-nav-bar *::before,
.bb-nav-bar *::after { box-sizing: border-box; }

/* 导航里的所有 SVG 一律按块级处理。
   不写的话，各系统自己的 reset 会决定 svg 是 inline 还是 block：
   博识的 Tailwind reset 设了 block，博创那边没有，于是切换器箭头
   作为 inline 元素受基线影响，往下偏了 3px —— 两端看起来就不一样。 */
.bb-nav-bar svg { display: block; flex: none; }

/* ---------- 组件本体 ---------- */
/* <bb-nav> 是 flex 行里的一个项。自定义元素默认 display:inline 且 min-width:auto，
   不显式声明的话它不会收缩 —— 窄屏时会把右侧操作区顶出可视范围
   （博识/博创被 overflow-x:hidden 截断，博弈整页横向滚动）。 */
bb-nav { display: block; flex: 1 1 auto; min-width: 0; }

.bb-nav { display: flex; align-items: center; height: 56px; min-width: 0; flex: 1 1 auto; }

.bb-nav__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  width: 97px;            /* 固定宽度：保证竖线永远落在 x=161 */
  text-decoration: none;
  color: inherit;
}
.bb-nav__mark {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #0b7165;
  display: grid;
  place-items: center;
}
.bb-nav__mark svg { width: 16px; height: 16px; color: #fff; display: block; }
.bb-nav__brandname {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: #1e242d !important;
}
.bb-nav__brand:hover .bb-nav__brandname { color: #1e242d !important; }

.bb-nav__divider {
  width: 1px;
  height: 20px;
  margin: 0 12px;
  background: #e6e9ee;
  flex: 0 0 auto;
}

/* ---------- 系统切换器 ---------- */
.bb-nav__syswrap { position: relative; flex: 0 0 auto; }
.bb-nav__sys {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  min-width: 87px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: #1e242d !important;
  cursor: pointer;
  transition: background-color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}
.bb-nav__sys:hover { background: #f4f6f8; }
.bb-nav__sysico {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 5px;
  background: var(--bb-accent);
  display: grid;
  place-items: center;
}
.bb-nav__sysico svg { width: 11px; height: 11px; color: #fff; display: block; }
.bb-nav__caret {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  color: #8493a8;
  transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
}
.bb-nav__sys[aria-expanded="true"] .bb-nav__caret { transform: rotate(180deg); }

.bb-nav__menu {
  position: absolute;
  top: 36px;
  left: 0;
  z-index: 60;
  width: 268px;
  padding: 6px;
  background: #fff;
  border: 1px solid #e6e9ee;
  border-radius: 10px;
  box-shadow: 0 16px 40px -16px rgba(15, 23, 42, 0.28);
}
.bb-nav__menu[hidden] { display: none; }
.bb-nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  text-decoration: none;
  color: #1e242d;
  transition: background-color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}
.bb-nav__item:hover {
  background: #f4f6f8 !important;
  color: #1e242d !important;
}
.bb-nav__item--cur { background: var(--bb-accent-soft); }
.bb-nav__item--cur .bb-nav__itemname { color: var(--bb-accent) !important; font-weight: 500; }
.bb-nav__itemico {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 6px;
  display: grid;
  place-items: center;
}
.bb-nav__itemico svg { width: 12px; height: 12px; color: #fff; display: block; }
.bb-nav__itemtext { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.bb-nav__itemname { font-size: 14px; font-weight: 400; }
.bb-nav__itemdesc { font-size: 11px; color: #8493a8; }
.bb-nav__menusep { height: 1px; margin: 6px 8px; background: #e6e9ee; }

/* ---------- 导航项 ---------- */
.bb-nav__links {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 11px;
  /* 任何宽度都要能收缩 + 横向滚动：
     之前 overflow 只写在 ≤560 的规则里，600px 这种「单行但装不下」的
     区间会直接顶出视口，把整页撑出横向滚动条。 */
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.bb-nav__links::-webkit-scrollbar { display: none; }

/* 只有真正溢出时才渐隐（由 bb-nav.js 在 resize 时切这个类）。
   常驻 mask 会把最后一个链接的右边缘削掉，没溢出的时候不该有。 */
.bb-nav__links--scrollable {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent);
}
.bb-nav__link {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 11px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 400;
  color: #4e5d73;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 160ms cubic-bezier(0.22, 1, 0.36, 1),
              color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}
/* 颜色用 !important 压住宿主样式：三个系统吞到的 a:hover 颜色各不相同
   （#1e242d / #555 / 橙色 #ff9d1f），不强制就各走各的。 */
.bb-nav__link:hover {
  background: #f4f6f8 !important;
  color: #1e242d !important;
}
.bb-nav__link[aria-current="page"] {
  color: var(--bb-accent) !important;
  background: var(--bb-accent-soft) !important;
  font-weight: 500;
}
.bb-nav__link[aria-current="page"]:hover {
  color: var(--bb-accent) !important;
  background: var(--bb-accent-soft) !important;
}

/* 左侧前置插槽：博识有一个「级别导航」汉堡按钮，博创没有。
   如果只在博识放，品牌就会被顶右边 40px，窄屏时两端对不上。
   所以这个插槽在共享 CSS 里定义宽度，两端都必须渲染它 ——
   有按钮的填按钮，没有的留空。 */
.bb-nav-bar__leading {
  display: none;
  align-items: center;
  justify-content: flex-start;
  width: 44px;
  flex: 0 0 44px;
}

/* 右侧操作区：各系统自己的内容（搜索、主题、用户菜单…） */
.bb-nav-bar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

/* ---------- 右侧操作区的通用按钮 ----------
   四个系统的右侧内容各不相同（博识是搜索+主题+用户菜单，
   博弈是登录/注册/用户下拉，博创是登录/注册/头像），
   但「登录」「注册」这种主次按钮必须长得一样，所以在这里定义。 */
.bb-act-link {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 11px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 400;
  color: #4e5d73;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 160ms cubic-bezier(0.22, 1, 0.36, 1),
              color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}
.bb-act-link:hover { background: #f4f6f8; color: #1e242d; }

.bb-act-primary {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--bb-accent);
  /* !important 是必须的：宿主页面（尤其 Hydro）有
     `a, a:hover, a:visited { color: #555 }` 这类规则，
     其中 a:hover 的权重 (0,1,1) 会压过 .bb-act-primary (0,1,0)，
     结果按钮文字在悬停/访问后变深灰。 */
  color: #fff !important;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: filter 160ms cubic-bezier(0.22, 1, 0.36, 1);
}
.bb-act-primary:hover,
.bb-act-primary:visited,
.bb-act-primary:active,
.bb-act-primary:focus {
  filter: brightness(0.92);
  color: #fff !important;
  text-decoration: none;
}

/* 导航内所有链接一律不带下划线（含 hover / focus / active）。
   必须 !important：宿主页面普遍有 a:hover { text-decoration: underline }，
   博弈（Hydro）就是如此，悬停时导航项会多一条下划线。 */
.bb-nav-bar a,
.bb-nav-bar a:hover,
.bb-nav-bar a:focus,
.bb-nav-bar a:active {
  text-decoration: none !important;
}

/* 焦点可见：所有交互元素一致 */
.bb-nav-bar :focus-visible {
  outline: 2px solid var(--bb-accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- 断点（全站唯一的三个值）---------- */
@media (max-width: 1024px) {
  .bb-nav-bar { padding: 0 32px; }
  .bb-nav-bar__leading { display: flex; }
}
@media (max-width: 560px) {
  /* 只有到 560 以下才换成两行：第一行「品牌 + 系统切换 + 右侧操作」，
     第二行导航项独占。
     560 以上一律单行 —— 之前断点设在 768，桌面稍微缩一点就变两行，
     和另外两个系统比起来像是排版坏了。 */
  .bb-nav-bar {
    height: auto;
    min-height: 56px;
    padding: 6px 16px;
    /* 只让组件内部换行；条容器本身不换行，
       否则右侧操作区会被挤到第三行（实测条高从 86 涨到 125）。 */
    align-items: flex-start;
  }
  bb-nav { flex: 1 1 0; }
  .bb-nav { flex-wrap: wrap; height: auto; row-gap: 2px; }
  /* 前置插槽 / 右侧操作区与「第一行」对齐，而不是整体垂直居中 */
  .bb-nav-bar__leading,
  .bb-nav-bar__actions { padding-top: 11px; align-self: flex-start; }
  .bb-nav__links {
    flex: 0 0 100%;
    order: 10;
    margin: 2px 0 0;
    padding-bottom: 4px;
  }
  .bb-nav__link { flex: 0 0 auto; }
  .bb-nav__divider { display: none; }
  .bb-nav__brand { width: auto; }
  /* 不要在这里给品牌名追加系统名。
     试过「博邦编程 · 博识」，结果是紧跟其后的切换器也显示「博识」，
     一行里系统名出现两次，还白占宽度把后面的内容顶开。 */
}
/* 系统切换器任何宽度都不隐藏 —— 它是跨系统跳转的唯一入口。
   窄屏靠收缩品牌名 / 右侧图标来让位，而不是砍掉导航能力。 */
@media (max-width: 400px) {
  /* 再窄才牺牲品牌名，给右侧操作留出位置 */
  .bb-nav__brandname { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bb-nav-bar * { transition-duration: 1ms !important; }
}
