/**
 * 顶栏导航改版：紧凑品牌、单行主导航（可横向滑动）、宽屏下与搜索并排
 * 在 portal.css 之后引入
 */

/* ---------- 品牌：限制宽度，标题单行省略 ---------- */
.site-header.hn.hn--lux .hn__brand {
  min-width: 0;
  max-width: min(70vw, 16rem);
  text-decoration: none;
  color: inherit;
}

.site-header.hn.hn--lux .hn__brand-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.08rem;
}

.site-header.hn.hn--lux .hn__title {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(0.9375rem, 2.2vw, 1.125rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.02em;
}

.site-header.hn.hn--lux .hn__tagline {
  display: block;
  max-width: 100%;
  font-size: 0.6875rem;
  line-height: 1.35;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

@media (max-width: 820px) {
  .site-header.hn.hn--lux .hn__tagline {
    display: none;
  }
}

@media (max-width: 420px) {
  .site-header.hn.hn--lux .hn__brand {
    max-width: min(64vw, 14rem);
  }
  .site-header.hn.hn--lux .hn__logo svg {
    width: 34px;
    height: 34px;
  }
}

/* ---------- 宽屏：中间区横向，导航单行 + 可滑动 ----------
   注意：portal.css 使用 max-width:960px 作为移动端抽屉，此处用 961px
   避免在恰好 960px 时与抽屉规则同时生效导致分类不显示 ---------- */
@media (min-width: 961px) {
  body:not(.hn-menu-open) .site-header.hn.hn--lux .container.hn__bar {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
    align-items: center;
    gap: clamp(0.5rem, 1.6vw, 1.1rem);
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__brand {
    max-width: min(28vw, 14rem);
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__drawer-label {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__mid {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: clamp(0.65rem, 1.8vw, 1.15rem);
    min-width: 0;
    position: relative;
    padding: 0;
    margin: 0;
    background: transparent;
    box-shadow: none;
    border: 0;
    max-height: none;
    overflow: visible;
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__nav-rail {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__nav {
    display: flex !important;
    flex-flow: row nowrap !important;
    align-items: center;
    gap: 0.1rem;
    width: max-content;
    min-height: 2.35rem;
    padding: 0.2rem 0.15rem !important;
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__link {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__search-wrap {
    flex: 0 0 auto;
    width: min(15rem, 28vw);
    max-width: 100%;
    margin: 0;
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__search--lux {
    width: 100%;
  }
}

/* ---------- 移动端抽屉打开：抵消与顶栏 grid 的冲突，保证分类可见 ---------- */
@media (max-width: 960px) {
  body.hn-menu-open .site-header.hn.hn--lux {
    z-index: 200;
  }

  body.hn-menu-open .site-header.hn.hn--lux .container.hn__bar:not(.hn__bar--mob3) {
    display: flex !important;
    flex-wrap: nowrap;
    align-items: center;
  }

  body.hn-menu-open .site-header.hn.hn--lux .hn__mid {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    flex: none !important;
    width: 100% !important;
    min-height: 0 !important;
    z-index: 210 !important;
  }

  body.hn-menu-open .site-header.hn.hn--lux .hn__nav-rail {
    flex: 0 0 auto !important;
    width: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  body.hn-menu-open .site-header.hn.hn--lux .hn__nav {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    width: 100% !important;
    min-height: 0 !important;
  }

  body.hn-menu-open .site-header.hn.hn--lux .hn__link {
    flex: 0 0 auto !important;
    width: 100% !important;
    white-space: normal !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  body.hn-menu-open .site-header.hn.hn--lux .hn__search-wrap {
    flex: 0 0 auto !important;
    width: 100% !important;
    display: block !important;
  }

  /* mob3：菜单打开时顶栏仍为三列网格，侧栏可滚动 */
  body.hn-menu-open .site-header.hn.hn--lux .container.hn__bar.hn__bar--mob3 {
    display: grid !important;
    grid-template-columns: 2.5rem minmax(0, 1fr) 2.5rem;
    align-items: center;
    min-height: var(--hn-h, 65px);
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 0;
    padding-bottom: 0;
    box-sizing: border-box;
  }

  body.hn-menu-open .site-header.hn.hn--lux .hn__bar--mob3 .hn__mid {
    width: min(88vw, 300px) !important;
    max-width: 100% !important;
    right: auto !important;
    left: 0 !important;
    transform: translateX(0) !important;
  }

  body.hn-menu-open .site-header.hn.hn--lux .hn__bar--mob3 .hn__nav-rail {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
  }
}

/* 抽屉关闭时：避免 fixed 侧栏层仍拦截触摸（部分机型） */
@media (max-width: 960px) {
  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__mid {
    pointer-events: none;
  }

  body.hn-menu-open .site-header.hn.hn--lux .hn__mid {
    pointer-events: auto;
  }
}

/* ---------- 全站：合并 #root.app-shell 时页脚在壳内，纵向 flex 不挤压主内容 ---------- */
#root.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100svh;
}

#root.app-shell > main {
  flex: 1 1 auto;
  min-width: 0;
}

#root.app-shell > footer.site-footer,
#root.app-shell > footer.nj-footer {
  flex: 0 0 auto;
}

@media (max-width: 960px) {
  body.body-tpl-hipds #root.app-shell > main.inner-page,
  body.body-tpl-portal #root.app-shell > main.inner-page {
    position: relative;
    z-index: 1;
    isolation: isolate;
    padding-bottom: max(2.5rem, env(safe-area-inset-bottom, 0px));
  }

  body.body-tpl-hipds .nj-cat-head h1,
  body.body-tpl-portal .nj-cat-head h1 {
    word-break: break-word;
    overflow-wrap: anywhere;
  }
}

/* 首页首屏大标题：窄屏换行，避免溢出像底部横条遮挡 */
.hipds-hero__title {
  word-break: break-word;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

@media (max-width: 520px) {
  .hipds-hero__title {
    font-size: clamp(0.88rem, 4.2vw, 1.2rem);
    line-height: 1.35;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }
}

/* ---------- 手机顶栏：左汉堡 · 中品牌 · 右搜索；抽屉从左侧滑出（.hn__bar--mob3）
   布局参考 Stui03「gm-head」：http://23.224.43.162:915/ （/template/stui03/asset/css/app2.css） ---------- */
.site-header.hn.hn--lux .hn__head-search {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: #0f172a;
  background: transparent;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.site-header.hn.hn--lux .hn__head-search:hover {
  color: #1d4ed8;
  background: #f1f5f9;
}

.site-header.hn.hn--lux .hn__burger--bar {
  display: none;
}

.hn__drawer-auth {
  display: none;
}

@media (min-width: 961px) {
  body:not(.hn-menu-open) .site-header.hn.hn--lux .container.hn__bar.hn__bar--mob3 .hn__burger--bar,
  body:not(.hn-menu-open) .site-header.hn.hn--lux .container.hn__bar.hn__bar--mob3 .hn__head-search {
    display: none !important;
  }
}

@media (max-width: 960px) {
  /* 与 Stui03 gm-head 一致：白底约 65px、浅阴影 */
  body.body-tpl-hipds:has(.hn__bar--mob3) .site-header.hn.hn--lux.site-header--main {
    --hn-h: 65px;
    background: #fff !important;
    box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.1), 0 1px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  body.body-tpl-hipds:has(.hn__bar--mob3) .hn--lux::before {
    opacity: 0.35;
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .container.hn__bar.hn__bar--mob3 {
    display: grid;
    grid-template-columns: 2.5rem minmax(0, 1fr) 2.5rem;
    align-items: center;
    gap: 0.2rem;
    column-gap: 0.25rem;
    min-height: var(--hn-h, 65px);
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 0;
    padding-bottom: 0;
    box-sizing: border-box;
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__bar--mob3 .hn__burger--bar {
    display: inline-flex;
    grid-column: 1;
    justify-self: start;
    width: 2.5rem;
    height: 2.5rem;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    box-shadow: none;
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__bar--mob3 .hn__burger--bar:hover {
    background: #f1f5f9;
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__bar--mob3 .hn__burger-line {
    background: #0f172a;
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__bar--mob3 .hn__brand {
    grid-column: 2;
    justify-self: center;
    max-width: 100%;
    min-width: 0;
    margin-left: 0;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__bar--mob3 .hn__head-search {
    display: inline-flex;
    grid-column: 3;
    justify-self: end;
  }

  body:not(.hn-menu-open) .site-header.hn.hn--lux .hn__bar--mob3 .hn__end--auth {
    display: none !important;
  }

  /* 左侧抽屉：覆盖 portal 的 translate(100%) 全宽从右滑入 */
  body.body-tpl-hipds .site-header.hn.hn--lux .hn__bar--mob3 .hn__mid {
    left: 0;
    right: auto;
    width: min(88vw, 300px);
    max-width: 100%;
    border-top: 0;
    border-right: 1px solid #e2e8f0;
    box-shadow: 6px 0 28px rgba(15, 23, 42, 0.12);
    transform: translateX(-100%);
    transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    padding: 1rem 0 1.25rem;
    gap: 0;
    align-items: stretch;
    justify-content: flex-start;
  }

  body.body-tpl-hipds .site-header.hn.hn--lux .hn__bar--mob3 .hn__mid.hn__mid--open {
    transform: translateX(0);
  }

  body.body-tpl-hipds .site-header.hn.hn--lux .hn__bar--mob3 .hn__drawer-label {
    padding: 0 1.1rem 0.5rem;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    color: #94a3b8;
  }

  body.body-tpl-hipds .site-header.hn.hn--lux .hn__bar--mob3 .hn__nav-rail {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    border-radius: 0;
    padding: 0;
    margin: 0 0.75rem;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  body.body-tpl-hipds .site-header.hn.hn--lux .hn__bar--mob3 .hn__nav {
    gap: 0;
  }

  body.body-tpl-hipds .site-header.hn.hn--lux .hn__bar--mob3 .hn__link {
    border-radius: 0;
    padding: 0.95rem 0.85rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9375rem;
    letter-spacing: 0.02em;
  }

  body.body-tpl-hipds .site-header.hn.hn--lux .hn__bar--mob3 .hn__link::after {
    content: none;
    display: none;
  }

  body.body-tpl-hipds .site-header.hn.hn--lux .hn__bar--mob3 .hn__link--active {
    background: #eff6ff !important;
    color: #1d4ed8 !important;
    box-shadow: none !important;
    font-weight: 600;
    border-left: 3px solid #2563eb;
    padding-left: calc(0.85rem - 3px);
  }

  body.body-tpl-hipds .site-header.hn.hn--lux .hn__bar--mob3 .hn__link:last-child {
    border-bottom: 0;
  }

  body.body-tpl-hipds .site-header.hn.hn--lux .hn__bar--mob3 .hn__search-wrap {
    padding: 0.75rem 1rem 0;
    flex-shrink: 0;
  }

  body.hn-search-open {
    overflow: hidden;
  }
}

/* ---------- 顶栏放大镜：下拉搜索（#hn-pop-search）
   默认宽屏 display:none，仅在 ≤960px 启用，避免放在 <header> 内时在 PC 排成第二行 ---------- */
.site-header.hn.hn--lux button.hn__head-search {
  font: inherit;
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.hn__pop-search,
.hn__search-scrim {
  display: none !important;
}

.hn__pop-search__inner {
  max-width: 100%;
}

.hn__pop-search__title {
  margin: 0 0 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #94a3b8;
  text-transform: uppercase;
}

.hn__pop-search .hn__search--pop {
  width: 100%;
  max-width: none;
  height: 48px;
}

.hn__pop-search__hint {
  margin: 0.55rem 0 0;
  font-size: 0.8125rem;
  text-align: center;
}

.hn__pop-search__hint a {
  color: #64748b;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hn__pop-search__hint a:hover {
  color: #2563eb;
}

@media (max-width: 960px) {
  .hn__search-scrim:not([hidden]) {
    display: block !important;
    position: fixed;
    inset: 0;
    z-index: 215;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(15, 23, 42, 0.42);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .hn__search-scrim[hidden] {
    display: none !important;
  }

  .hn__pop-search {
    display: block !important;
    position: fixed;
    left: 0;
    right: 0;
    top: var(--hn-h, 65px);
    z-index: 220;
    padding: 0.65rem 0 0.85rem;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-0.4rem);
    pointer-events: none;
  }

  .hn__pop-search.hn__pop-search--open {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
}

/* 顶栏搜索：去掉内层 input 的 :focus-visible 紫框；整条的聚焦态由 .hn__search:focus-within 外圈承担 */
.hn__search .hn__search-input:focus-visible {
  outline: none;
}

/* ---------- hipds：主导航（分类）居中、浅色条、蓝色选中态（覆盖 portal 默认粉红指示） ---------- */
@media (min-width: 961px) {
  body.body-tpl-hipds:not(.hn-menu-open) .site-header.hn.hn--lux .hn__nav-rail {
    display: flex;
    justify-content: center;
    align-items: center;
  }
}

body.body-tpl-hipds .hn__nav-rail {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 5px 6px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

body.body-tpl-hipds .hn__link {
  border-radius: 10px;
  padding: 8px 16px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #64748b;
}

body.body-tpl-hipds .hn__link:hover {
  color: #1e40af;
  background: #f8fafc;
}

body.body-tpl-hipds .hn__link::after {
  background: #2563eb;
  background-image: none;
  height: 2px;
  bottom: 5px;
  border-radius: 999px;
  opacity: 0;
  width: 0;
  transition: width 0.28s ease, opacity 0.2s ease;
}

body.body-tpl-hipds .hn__link:hover::after {
  width: 38%;
  opacity: 0.45;
}

body.body-tpl-hipds .hn__link--active {
  color: #1e40af !important;
  background: #eff6ff !important;
  box-shadow: none !important;
  font-weight: 600;
}

body.body-tpl-hipds .hn__link--active::after {
  width: 55%;
  opacity: 1;
}
