/**
 * 导航栏.css — Aevx 首页：布局、配色、字体（静态样式）
 *
 * 动效与动画见同目录 界面动效.css（须在 HTML 中于本文件之后引入）
 *
 * 模块概览：
 * 1) :root、重置、body 背景图与遮罩
 * 2) 顶栏、汉堡/Logo/用户、导航占位
 * 3) 宽屏 ≥768px：三列网格、横排链接
 * 4) .hero-main 首屏标题
 *
 * 背景图路径相对本文件 ../../图片/；断点 768px 与 JS 一致
 */

:root {
  --nav-desktop: 768px;
  --font-apple: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --page-bg: #1a1a2e;
}

/* 全局盒模型重置，减少浏览器默认差异 */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 主页：可滚动长页；首屏标题见「首页滚动与帖子.css」固定层 */
body {
  position: relative;
  font-family: var(--font-apple);
  min-height: 100vh;
  min-height: 100dvh;
  color: #fff;
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 全屏背景图（路径相对本文件 → ../../图片/） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-color: var(--page-bg);
  background-image: url("../../图片/garten-gg-aircraft-1756149.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* 轻微压暗：透明度低于早期「重遮罩」，只略提白字对比 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(12, 10, 20, 0.22) 0%,
    rgba(12, 10, 20, 0.2) 50%,
    rgba(10, 8, 18, 0.26) 100%
  );
}

/* ---------- 顶栏：fixed 叠在背景上，始终可见（不随滚动隐藏） ----------
 * 毛玻璃必须做在 ::before 上，勿写在 .site-header 本身：否则 backdrop-filter
 * 会让子元素里 position:fixed 的窄屏全屏 .nav-dropdown 相对顶栏定位，菜单会坏。
 */
.site-header {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 100;
  padding: 14px 20px;
  background: transparent;
  border-bottom: none;
  font-family: var(--font-apple);
}

.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition:
    opacity 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    -webkit-backdrop-filter 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    backdrop-filter 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

body.nav-over-posts .site-header::before {
  opacity: 1;
  background: linear-gradient(
    to bottom,
    rgba(14, 12, 22, 0.42) 0%,
    rgba(18, 16, 28, 0.62) 55%,
    rgba(18, 16, 28, 0.72) 100%
  );
  -webkit-backdrop-filter: blur(20px) saturate(165%);
  backdrop-filter: blur(20px) saturate(165%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* 全屏菜单打开时去掉顶栏毛玻璃条，避免叠层干扰 */
body.menu-open .site-header::before {
  opacity: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
  .site-header::before {
    transition-duration: 0.15s !important;
  }
}

/* 内容区最大宽度居中；窄屏内部仍为 flex 换行（汉堡 / 用户 / 导航第二行） */
.site-header__inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1080px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

/* 汉堡：order:1 保证首行左侧；点击区域 ≥44px 利于触摸 */
.menu-btn {
  order: 1;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.menu-btn .line {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  transform-origin: center;
}

/* 窄屏 logo 在首行水平居中（相对 .site-header__inner） */
.brand {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 46%;
  pointer-events: none;
}

.brand img {
  /* 仅调整 logo：窄屏也保持足够高度 */
  max-height: clamp(44px, 11vw, 54px);
  width: auto;
  object-fit: contain;
  display: block;
  pointer-events: auto;
}

/* 用户图标：order:2 + margin-left:auto 顶到首行右侧（按钮，用于打开登录抽屉） */
button.user-link {
  font: inherit;
  color: inherit;
  border: none;
  background: transparent;
  cursor: pointer;
}

.user-link {
  position: relative;
  order: 2;
  margin-left: auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}

.user-link:hover {
  opacity: 0.9;
}

/* 去掉点击后的蓝色系统描边；键盘 Tab 时保留浅色轮廓便于无障碍 */
.user-link:focus {
  outline: none;
}

.user-link:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
}

.user-link__initial {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #0a84ff, #5ac8fa);
  letter-spacing: -0.03em;
}

/* 无头像时由 JS 按姓名设置背景；两字缩写略缩小字号 */
.user-link__initial.user-link__initial--double {
  font-size: 11px;
  letter-spacing: -0.08em;
}

body.user-logged-in .user-link__initial:not([hidden]) {
  display: flex;
}

body.user-logged-in .user-link #userAvatarImg {
  display: none;
}

body.user-logged-in.user-has-avatar .user-link #userAvatarImg {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

body.user-logged-in.user-has-avatar .user-link__initial {
  display: none !important;
}

.user-link img {
  max-width: 28px;
  max-height: 28px;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* 导航外层：order 与桌面网格一致；窄屏尺寸见 max-width 内 */
.nav-wrap {
  order: 3;
  position: relative;
  z-index: 99;
}

@media (max-width: 767.98px) {
  .nav-wrap {
    flex-basis: 0;
    width: 100%;
    height: 0;
    min-height: 0;
    overflow: visible;
    z-index: 250;
    pointer-events: none;
  }
}

.nav-dropdown {
  font-family: var(--font-apple);
}

/* 仅宽屏：当前导航项下方小白点 */
@media (min-width: 768px) {
  .nav-dropdown a.is-active::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 4px;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #fff;
    opacity: 0.95;
  }
}

/*
 * 宽屏 ≥768px：
 * grid 三列 [ logo | nav | user ]，导航几何居中；
 * 取消汉堡与下拉动画，导航为普通横向链接
 */
@media (min-width: 768px) {
  .brand img {
    max-height: clamp(48px, 6vw, 60px);
  }

  .site-header__inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    column-gap: 12px;
    flex-wrap: unset;
    justify-content: unset;
  }

  .menu-btn {
    display: none;
  }

  .brand {
    position: static;
    transform: none;
    left: auto;
    max-width: none;
    pointer-events: auto;
    grid-column: 1;
    justify-self: start;
    order: unset;
  }

  .nav-wrap {
    grid-column: 2;
    justify-self: center;
    order: unset;
    flex-basis: auto;
    width: auto;
    height: auto;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
    pointer-events: auto;
    z-index: 99;
  }

  /* 桌面：仅保留链接行，顶栏/搜索为参考图二窄屏专用 */
  .mobile-menu-sheet {
    display: contents;
  }

  .mobile-menu-top {
    display: none !important;
  }

  .nav-dropdown {
    position: static;
    left: auto;
    right: auto;
    width: auto;
    max-width: none;
    transform: none !important;
    transform-origin: unset;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    overflow: visible;
    max-height: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    isolation: auto;
    clip-path: none !important;
    transition: none !important;
  }

  .nav-dropdown-inner {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px 6px;
    padding: 0;
    transform: none !important;
    opacity: 1 !important;
    transition: none !important;
    will-change: auto;
  }

  .mobile-menu-sheet {
    will-change: auto;
  }

  .nav-dropdown a {
    position: relative;
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    padding: 10px 8px 14px;
    white-space: nowrap;
    width: auto;
    max-width: none;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.02em;
    text-align: center;
    text-shadow: none;
    line-height: inherit;
  }

  .nav-dropdown a:visited {
    color: rgba(255, 255, 255, 0.92);
  }

  .nav-dropdown a.is-active {
    color: #fff;
  }

  .nav-dropdown a:hover,
  .nav-dropdown a:focus-visible {
    background: transparent;
    opacity: 0.85;
  }

  .user-link {
    grid-column: 3;
    justify-self: end;
    order: unset;
    margin-left: 0;
    width: 52px;
    height: 52px;
  }

  /* PC：头像比 28px 触控规格更大，仍保持圆形点击区 */
  .user-link__initial {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .user-link__initial.user-link__initial--double {
    font-size: 13px;
  }

  body.user-logged-in.user-has-avatar .user-link #userAvatarImg {
    width: 40px;
    height: 40px;
  }

  .user-link img {
    max-width: 40px;
    max-height: 40px;
  }
}

/* ---------- 首屏标题：由首页滚动与帖子.css 中 .hero-fixed 承载（固定于视口） ---------- */
.hero-title {
  font-family: var(--font-apple);
  font-size: clamp(1.5rem, 6vw, 2.25rem);
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: 14px;
  max-width: 22em;
  letter-spacing: -0.02em;
}

.hero-sub {
  font-family: var(--font-apple);
  font-size: clamp(1.05rem, 3.2vw, 1.2rem);
  font-weight: 600;
  opacity: 0.92;
  max-width: 24em;
  letter-spacing: -0.01em;
}
