﻿/* 公开站顶栏：对齐会员端 MemberHeader 白底 pill 导航 */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: var(--console-nav);
  border-bottom: 1px solid var(--console-nav-border);
}

.site-header.scrolled {
  box-shadow: var(--shadow-sm);
}

.header-inner {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0 20px;
  height: var(--console-tab-h);
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-header .brand {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  flex-shrink: 0;
  min-width: 0;
  height: 100%;
  overflow: visible;
  text-decoration: none;
  color: var(--console-nav-fg);
}

.site-header .brand-mark.is-header {
  width: auto;
  min-width: 0;
  max-width: calc(min(280px, 42vw) * 0.54);
  height: calc(var(--console-tab-h) * 0.48);
  max-height: calc(var(--console-tab-h) * 0.48);
  overflow: visible;
}

.site-header .brand-mark.is-header .brand-mark__img {
  width: auto;
  max-width: calc(min(280px, 42vw) * 0.54);
  height: calc(var(--console-tab-h) * 0.48);
  object-fit: contain;
  object-position: left center;
}

/* 顶栏明/暗 Logo 切换（与 pages.css 一致，避免 header 覆盖 display） */
.site-header .brand-mark__img--dark {
  display: none;
}

[data-theme='dark'] .site-header .brand-mark__img--light.has-dark {
  display: none;
}

[data-theme='dark'] .site-header .brand-mark__img--dark {
  display: block;
}

.nav-desktop {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--console-nav-muted);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  transition:
    color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}

.nav-link:hover {
  background: var(--console-nav-hover);
  color: var(--console-nav-fg);
}

.nav-link.on {
  background: var(--console-nav-active);
  color: var(--brand);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn-login,
.btn-register {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease),
    opacity var(--duration) var(--ease);
}

.btn-login {
  background: transparent;
  color: var(--console-nav-fg);
  border: 1px solid var(--console-nav-border);
}

.btn-login:hover {
  background: var(--console-nav-hover);
}

.btn-register {
  background: var(--brand);
  color: #fff;
}

.btn-register:hover {
  opacity: 0.88;
}

/* 图标按钮（主题切换，对齐会员端） */
.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--console-nav-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}

.icon-btn:hover {
  background: var(--console-nav-hover);
  color: var(--brand);
}

.icon-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.theme-btn {
  width: 32px;
  height: 32px;
  font-size: 14px;
}

.menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--console-nav-muted);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.menu-btn:hover {
  background: var(--console-nav-hover);
  color: var(--brand);
}

.menu-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.drawer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 90;
}

.drawer-panel {
  margin-left: auto;
  width: min(320px, 88vw);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.drawer-label {
  margin: 0;
  padding: 14px 16px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.drawer-nav {
  display: flex;
  flex-direction: column;
  padding: 0 10px 12px;
  gap: 2px;
}

.drawer-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
}

.drawer-link:hover {
  background: var(--accent-soft);
  color: var(--brand);
}

.drawer-link.on {
  background: var(--accent-soft);
  color: var(--brand);
}

.drawer-extra {
  margin-top: auto;
  padding: 12px 16px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.drawer-btn--primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.lang-switch {
  position: relative;
}

/* ============================================================
 * 会员区：快捷搜索 + 站内消息 + 控制台（对齐会员端 MemberHeader）
 * 登录态由 head 内联脚本写入 html[data-member]，避免闪烁
 * ============================================================ */

html:not([data-member='on']) .member-only {
  display: none !important;
}

[data-member='on'] .guest-only {
  display: none !important;
}

.btn-console {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  background: var(--console-nav-hover);
  color: var(--console-nav-fg);
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.btn-console:hover {
  background: var(--brand);
  color: #fff;
}

/* ---------- 快捷搜索 ---------- */

.quick-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 280px;
  flex-shrink: 0;
}

.quick-search .search-icon {
  position: absolute;
  left: 12px;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}

.quick-search .search-input {
  width: 100%;
  height: 34px;
  padding: 0 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition:
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    background var(--duration) var(--ease);
}

.quick-search .search-input::placeholder {
  color: var(--muted);
}

.quick-search .search-input:focus {
  border-color: color-mix(in srgb, var(--brand) 50%, var(--line));
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent);
}

.quick-search .clear-btn {
  position: absolute;
  right: 8px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.quick-search .clear-btn:hover {
  color: var(--ink);
  background: var(--surface-muted);
}

.quick-search .hint {
  position: absolute;
  right: 10px;
  min-width: 16px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  pointer-events: none;
}

.quick-search .panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 120;
  max-height: min(420px, 70vh);
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
}

.quick-search .empty {
  margin: 0;
  padding: 16px 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.quick-search .result {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.quick-search .result:hover,
.quick-search .result.on {
  background: var(--accent-soft);
}

.quick-search .result-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.quick-search .result-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.quick-search .result-text strong {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-search .result-text em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 站内消息铃铛 ---------- */

.notify-bell {
  position: relative;
  flex-shrink: 0;
}

.notify-bell .icon-btn {
  position: relative;
  font-size: 15px;
}

.notify-bell .icon-btn[aria-expanded='true'] {
  background: var(--console-nav-hover);
  color: var(--brand);
}

.notify-bell .fa-bell.is-ringing {
  transform-origin: top center;
  animation: notify-bell-ring 0.75s ease-in-out;
}

@keyframes notify-bell-ring {
  0%,
  100% {
    transform: rotate(0deg);
  }
  15% {
    transform: rotate(12deg);
  }
  30% {
    transform: rotate(-10deg);
  }
  45% {
    transform: rotate(8deg);
  }
  60% {
    transform: rotate(-6deg);
  }
  75% {
    transform: rotate(3deg);
  }
}

/* 独立类名，避免与 tokens .badge（状态标签）样式互相污染 */
.notify-bell .notify-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 1;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border: 2px solid var(--console-nav);
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
  pointer-events: none;
}

/* display:inline-flex 会盖掉 UA 对 [hidden] 的 display:none，无未读时变成空红点 */
.notify-bell .notify-badge[hidden] {
  display: none !important;
}

.notify-bell .panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 120;
  width: min(440px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.notify-bell .panel-head,
.notify-bell .panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.notify-bell .panel-foot {
  justify-content: center;
  border-bottom: 0;
  border-top: 1px solid var(--line);
}

.notify-bell .panel-head strong {
  font-size: 14px;
}

.notify-bell .link-btn {
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.notify-bell .link-btn:hover {
  text-decoration: underline;
}

.notify-bell .panel-body {
  max-height: 360px;
  overflow: auto;
}

.notify-bell .empty {
  margin: 0;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.notify-bell .item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}

.notify-bell .item:last-child {
  border-bottom: 0;
}

.notify-bell .item:hover {
  background: var(--surface-muted);
}

.notify-bell .item.unread {
  background: color-mix(in srgb, var(--accent-soft) 70%, transparent);
}

.notify-bell .dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--brand);
  flex-shrink: 0;
}

.notify-bell .item-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.notify-bell .item-body strong {
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.notify-bell .item-body em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notify-bell .item-body .time {
  font-size: 11px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .quick-search {
    width: 220px;
  }

  .console-label {
    display: none;
  }

  .btn-console {
    padding: 0 10px;
  }
}

.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--console-nav-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition:
    color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}

.lang-trigger .fa-globe {
  font-size: 12px;
}

.lang-code {
  min-width: 1em;
  letter-spacing: 0.02em;
}

.lang-trigger:hover,
.lang-trigger[aria-expanded='true'] {
  color: var(--brand);
  background: var(--console-nav-hover);
}

.lang-trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.lang-trigger .chevron {
  font-size: 9px;
  opacity: 0.7;
}

.lang-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 110;
  min-width: 140px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.lang-option:hover,
.lang-option.on {
  background: var(--accent-soft);
  color: var(--brand);
  font-weight: 600;
}

.lang-option:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.lang-option i {
  font-size: 12px;
  color: var(--brand);
}

.lang-switch--drawer {
  width: fit-content;
}

.lang-switch--drawer .lang-panel {
  right: auto;
  left: 0;
}

@media (max-width: 1100px) {
  .nav-link {
    padding: 0 10px;
    font-size: 14px;
  }
}

@media (max-width: 960px) {
  .nav-desktop,
  .site-header .btn-login {
    display: none;
  }

  .menu-btn {
    display: inline-flex;
  }
}

@media (max-width: 768px) {
  .header-inner {
    padding: 0 12px;
    gap: 8px;
  }

  .lang-desktop,
  .theme-desktop {
    display: none;
  }

  /* 登录态下手机端保留搜索（对齐会员端：搜索 flex 撑开） */
  .quick-search {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .quick-search .hint {
    display: none;
  }
}
