@import url("/assets/footer/pulsar-brand.css?v=20261102-shared-header-v1");

/* Shared top navigation. Keep page/business styles outside this component. */
.topbar {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  font-size: 16px;
  line-height: normal;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 0 24px;
  border-bottom: 1px solid #ffffff26;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background-color: #00000080;
  transition: background-color 0.2s ease;
  isolation: isolate;
}
.topbar::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  display: block;
  -webkit-backdrop-filter: blur(25px);
  backdrop-filter: blur(25px);
}
:root[data-theme="light"] .topbar {
  border-bottom-color: var(--border);
  background-color: var(--panel);
}
:root[data-theme="light"] .topbar::after {
  -webkit-backdrop-filter: blur(18px) saturate(115%);
  backdrop-filter: blur(18px) saturate(115%);
}

:where(.topbar) .brand__title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 900;
  letter-spacing: 0.2px;
}

:where(.topbar) .brandLink {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  user-select: none; /* 避免 Pulsar 被复制 */
  -webkit-user-select: none;
  cursor: pointer;
  border-radius: 14px;
  padding: 6px 6px;
  transition: transform 180ms ease, background 180ms ease;
}
:where(.topbar) .brandLink:hover {
  filter: brightness(1.02);
  background: var(--surface);
}
:where(.topbar) .brandLink:active {
  transform: translateY(0px) scale(0.99);
}
:where(.topbar) .brandLink:focus-visible {
  outline: 3px solid var(--focus, var(--accent));
  outline-offset: 3px;
}

/* 隐藏旧版缓存中的品牌副标题，避免占位。 */
:where(.topbar) .brand__sub {
  display: none;
}

:where(.topbar) .brandMark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 20px rgba(2, 6, 23, 0.18);
  flex: 0 0 auto;
  overflow: hidden;
}
:where(.topbar) .brandWord {
  font-weight: 900;
  letter-spacing: 0.2px;
  font-size: 18px; /* 更小更精致 */
  line-height: 1;
}

:where(.topbar) .actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
:where(.topbar) #themeBtn {
  margin-right: 10px;
}
:where(.topbar) #themeBtn[hidden] {
  display: none;
}

:where(.topbar) .nav {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  position: absolute; /* 绝对居中到顶栏中间（不受左右内容宽度影响） */
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  padding: 0 6px;
}

:where(.topbar) .tab {
  appearance: none;
  border: 0;
  background: transparent;
  background-color: transparent;
  display: flex;
  align-items: center;
  white-space: nowrap;
  position: relative;
  height: 40px;
  min-height: 0;
  font-family: Arial;
  line-height: normal;
  padding: 0 8px;
  margin: 0 12px;
  cursor: pointer;
  font-weight: 400;
  font-size: 15px;
  letter-spacing: 0;
  color: var(--text);
  transition: color 0.3s, background-color 0.3s, border-color 0.3s, opacity 0.3s;
  border-radius: 0; /* 取消“胶囊按钮”形态 */
  box-shadow: none;
}

:where(.topbar) .nav .tab {
  background: transparent !important;
  background-color: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}
:where(.topbar) .tab--active {
  color: var(--text);
}
:root[data-theme="light"] :where(.topbar) .tab {
  color: #0f172a;
}
:where(.topbar) .tab:hover {
  color: var(--text);
  background: transparent;
  background-color: transparent;
}
:where(.topbar) .tab:active {
  background: transparent;
  background-color: transparent;
}
:where(.topbar) .tab:focus-visible {
  outline: 2px solid var(--focus, var(--accent));
  outline-offset: 4px;
  border-radius: 10px;
}

/* Expand only the decorative underline; the navigation target stays fixed. */
:where(.topbar) .tab::before {
  content: "";
  display: block;
  position: absolute;
  height: 2px;
  background: currentColor;
  left: 20%;
  right: 20%;
  bottom: 0;
  border-radius: 2px;
  transform: scaleX(0);
  transition: transform 160ms ease-out;
}
:where(.topbar) .tab:hover::before {
  transform: scaleX(1);
}
:where(.topbar) .tab--active::before {
  transform: scaleX(1);
}
@media (prefers-reduced-motion: reduce) { :where(.topbar) .tab::before { transition: none; } }


/* Standalone pages may define generic button and SVG defaults. */
.topbar, .topbar * { box-sizing: border-box; }
:where(.topbar) button.ghost {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--control-text, var(--text));
  cursor: pointer;
  font: 700 13.3333px Arial;
}
:where(.topbar) button.ghost:focus-visible {
  outline: 3px solid var(--focus, var(--accent));
  outline-offset: 2px;
}
:where(.topbar) .iconBtn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
:where(.topbar) .iconBtn svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }

body.hypeflowThemeActive .topbar {
  border-bottom-color: oklch(27% 0.012 190);
  background-color: oklch(15% 0.007 190);
}

body.hypeflowThemeActive :where(.topbar) .brandLink,
body.hypeflowThemeActive :where(.topbar) .tab,
body.hypeflowThemeActive :where(.topbar) .iconBtn {
  color: oklch(97% 0.012 175);
}

body.hypeflowThemeActive :where(.topbar) .tab:not(.tab--active) {
  color: oklch(72% 0.016 185);
  font-weight: 400;
}

body.hypeflowThemeActive :where(.topbar) .tab--active {
  color: oklch(88% 0.2 166);
  font-weight: 400;
}

body.hypeflowThemeActive :where(.topbar) .tab--active::before {
  background: oklch(88% 0.2 166);
}

body.hypeflowThemeActive :where(.topbar) button.ghost {
  border-color: oklch(31% 0.016 190);
  background: oklch(20% 0.01 190);
}

body.hypeflowThemeActive :where(.topbar) button.ghost:hover {
  border-color: color-mix(in oklch, oklch(88% 0.2 166) 36%, oklch(31% 0.016 190));
  background: oklch(24% 0.014 185);
}

:root[data-theme="light"] body.hypeflowThemeActive .topbar {
  border-bottom-color: oklch(90% 0.01 185);
  background-color: #ffffff;
}

:root[data-theme="light"] body.hypeflowThemeActive :where(.topbar) .brandLink,
:root[data-theme="light"] body.hypeflowThemeActive :where(.topbar) .tab,
:root[data-theme="light"] body.hypeflowThemeActive :where(.topbar) .iconBtn {
  color: oklch(24% 0.018 185);
}

:root[data-theme="light"] body.hypeflowThemeActive :where(.topbar) .tab:not(.tab--active) {
  color: oklch(48% 0.026 185);
  font-weight: 400;
}

:root[data-theme="light"] body.hypeflowThemeActive :where(.topbar) .tab--active {
  color: oklch(50% 0.14 166);
  font-weight: 400;
}

:root[data-theme="light"] body.hypeflowThemeActive :where(.topbar) .tab--active::before {
  background: oklch(50% 0.14 166);
}

:root[data-theme="light"] body.hypeflowThemeActive :where(.topbar) button.ghost {
  border-color: oklch(86% 0.014 185);
  background: oklch(96% 0.008 175);
}

:root[data-theme="light"] :where(.topbar) .brandMark { box-shadow: none; }

:where(.topbar) .siteMembershipLink {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  min-height: 34px;
  margin-inline-end: 8px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 17%, transparent);
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
}
:where(.topbar) .siteMembershipLink svg { width: 16px; height: 16px; flex: none; }
:where(.topbar) .siteMembershipLink:hover { background: color-mix(in srgb, var(--accent) 27%, transparent); }
:where(.topbar) .siteMembershipLink:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.siteNavToggle { display: none; }

@media (max-width: 900px) {
  :root .topbar[data-site-header] {
    grid-template-columns: minmax(76px, 1fr) minmax(0, auto);
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
  }

  .topbar[data-site-header] .brand {
    grid-area: 1 / 1;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    container: site-brand / inline-size;
  }

  .topbar[data-site-header] .brandLink { gap: 7px; padding: 3px; }
  .topbar[data-site-header] .brandMark { width: 28px; height: 28px; }
  .topbar[data-site-header] .brandWord { font-size: 16px; }

  .topbar[data-site-header] .siteNavToggle {
    display: inline-grid;
    place-items: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--control-border, var(--border));
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    box-shadow: none;
    cursor: pointer;
  }

  .topbar[data-site-header] .siteNavToggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-width: 1.8;
  }

  .topbar[data-site-header] .siteNavToggle:is(:hover, [aria-expanded="true"]) {
    border-color: var(--accent);
    background: var(--surface-2, var(--surface-hover));
  }

  .topbar[data-site-header] .siteNavToggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .topbar[data-site-header] .actions {
    grid-area: 1 / 2;
    min-width: 0;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }

  .topbar[data-site-header] :is(.siteMembershipLink, #themeBtn) { margin: 0; }
  .topbar[data-site-header] #accountBtn:not([data-account-signed-in="true"]) { max-width: none; }

  .topbar[data-site-header] #siteNavigation {
    display: none;
    grid-area: auto;
    position: absolute;
    inset: calc(100% + 6px) auto auto;
    inset-inline-start: 10px;
    width: min(216px, calc(100% - 20px));
    max-height: calc(100dvh - 86px);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: none;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: var(--shadow-sm, none);
  }

  .topbar[data-site-header][data-nav-open] #siteNavigation {
    display: grid;
    align-items: stretch;
    justify-content: stretch;
    gap: 4px;
  }

  .topbar[data-site-header] #siteNavigation .tab {
    width: 100%;
    height: 40px;
    margin: 0;
    padding-inline: 10px;
    font-size: 14px;
  }

  .topbar[data-site-header] #siteNavigation .tab::before {
    inset-inline: 10px auto;
    width: 24px;
  }

  .topbar[data-site-header] #siteNavigation .tab:focus-visible { outline-offset: -2px; }
}

@container site-brand (max-width: 159px) {
  .topbar[data-site-header] .brandWord { display: none; }
}

@media (max-width: 720px) {
  :root .topbar[data-site-header] { position: sticky; }
}

@media (max-width: 380px) {
  .topbar[data-site-header] .siteMembershipLink {
    position: relative;
    width: 34px;
    justify-content: center;
    padding: 0;
  }

  .topbar[data-site-header] .siteMembershipLink span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}
