/*
 * 驭鬼者论坛 · 悬浮导航（R108 重建，对应 ygz_navigation_runtime.v122.js）
 * 单条悬浮玻璃导航：一级菜单 / 二级菜单在同一条“灵动岛”里切换，
 * 选中指示块用 transform 移动（只触发合成，不触发布局），不闪烁、不抖动。
 */
.ygz-floating-header {
  position: fixed;
  top: var(--ygz-header-top, 10px);
  left: 0;
  right: 0;
  z-index: 6000;
  display: flex;
  justify-content: center;
  padding: 0 max(12px, env(safe-area-inset-left, 0px)) 0 max(12px, env(safe-area-inset-right, 0px));
  pointer-events: none;
  contain: layout style;
}

.ygz-top-nav {
  pointer-events: auto;
  position: relative;
  width: 100%;
  max-width: 760px;
  height: var(--ygz-header-height, 54px);
  border-radius: 999px;
  overflow: hidden;
  transform: translateZ(0);
  transition: max-width .45s var(--ygz-nav-ease, cubic-bezier(.16, 1, .3, 1)), box-shadow .3s ease;
}
.ygz-top-nav.is-scrolled {
  box-shadow: 0 20px 48px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .13);
}

.ygz-nav-scroll {
  position: relative;
  z-index: 1;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 6px;
  scroll-padding-inline: 18px;
}
.ygz-nav-scroll::-webkit-scrollbar { display: none; }

/* 内容超出时两侧渐隐，提示可以横向滑动 */
.ygz-top-nav.has-overflow-end .ygz-nav-scroll { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent); }
.ygz-top-nav.has-overflow-start .ygz-nav-scroll { -webkit-mask-image: linear-gradient(90deg, transparent, #000 34px); mask-image: linear-gradient(90deg, transparent, #000 34px); }
.ygz-top-nav.has-overflow-start.has-overflow-end .ygz-nav-scroll { -webkit-mask-image: linear-gradient(90deg, transparent, #000 34px, #000 calc(100% - 34px), transparent); mask-image: linear-gradient(90deg, transparent, #000 34px, #000 calc(100% - 34px), transparent); }

.ygz-nav-menu-track {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 100%;
  width: max-content;
  min-width: 100%;
  justify-content: space-between;
  transition: opacity .22s ease, transform .32s var(--ygz-nav-ease, cubic-bezier(.16, 1, .3, 1)), filter .22s ease;
}
.ygz-nav-menu-track--secondary { justify-content: flex-start; }
.ygz-nav-menu-track.is-leaving { opacity: 0; transform: translate3d(0, -6px, 0) scale(.985); filter: blur(2px); }
.ygz-nav-menu-track.is-entering { opacity: 0; transform: translate3d(0, 6px, 0) scale(.985); filter: blur(2px); transition: none; }

.ygz-menu-link,
.ygz-menu-return {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  min-width: 52px;
  padding: 0 15px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, .62);
  font: inherit;
  font-size: 14.5px;
  font-weight: 640;
  letter-spacing: .06em;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: color .28s ease, transform .2s var(--ygz-nav-ease, cubic-bezier(.16, 1, .3, 1));
}
.ygz-menu-link:hover { color: rgba(255, 255, 255, .9); }
.ygz-menu-link:active { transform: scale(.96); }
.ygz-menu-link.is-active,
.ygz-menu-link[aria-current="page"] { color: #fff; }

/* 没有 JS（或 JS 尚未定位指示块）时，选中项自身带底色，避免空白一帧 */
.ygz-menu-link.is-active::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, .17), rgba(255, 255, 255, .07));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 6px 16px rgba(0, 0, 0, .35);
}
.ygz-top-nav.is-indicator-ready .ygz-menu-link.is-active::before { display: none; }

.ygz-menu-return {
  order: -1;
  min-width: 0;
  padding: 0 13px 0 10px;
  margin-right: 4px;
  color: rgba(255, 255, 255, .58);
  font-weight: 600;
  letter-spacing: .04em;
}
.ygz-menu-return::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-left: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg) translate(1px, -1px);
  border-radius: 1px;
}
.ygz-menu-return::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 50%;
  width: 1px;
  height: 18px;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, .14);
}
.ygz-menu-return:hover { color: #fff; }

/* 选中指示块：只用 transform/width，由运行时写入 --ygz-ind-x / --ygz-ind-w */
.ygz-primary-indicator,
.ygz-primary-hover-indicator {
  position: absolute;
  z-index: 1;
  left: 0;
  top: 50%;
  height: 42px;
  width: var(--ygz-ind-w, 0px);
  border-radius: 999px;
  transform: translate3d(var(--ygz-ind-x, 0px), -50%, 0);
  pointer-events: none;
  opacity: 0;
  will-change: transform, width;
}
.ygz-primary-indicator {
  background: linear-gradient(180deg, rgba(255, 255, 255, .17), rgba(255, 255, 255, .07));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), inset 0 -1px 0 rgba(255, 255, 255, .04), 0 6px 18px rgba(0, 0, 0, .38);
}
/* 指示块下沿的一线血色微光 */
.ygz-primary-indicator::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 14px;
  height: 2px;
  border-radius: 2px;
  transform: translateX(-50%);
  background: #c23a4b;
  box-shadow: 0 0 10px rgba(214, 52, 74, .85), 0 0 2px rgba(255, 120, 130, .9);
  opacity: .9;
}
.ygz-top-nav.is-indicator-ready .ygz-primary-indicator { opacity: 1; }
.ygz-top-nav.is-indicator-animated .ygz-primary-indicator {
  transition: transform .46s var(--ygz-nav-ease, cubic-bezier(.16, 1, .3, 1)), width .46s var(--ygz-nav-ease, cubic-bezier(.16, 1, .3, 1)), opacity .2s ease;
}
.ygz-primary-hover-indicator {
  background: rgba(255, 255, 255, .06);
  transition: transform .34s var(--ygz-nav-ease, cubic-bezier(.16, 1, .3, 1)), width .34s var(--ygz-nav-ease, cubic-bezier(.16, 1, .3, 1)), opacity .2s ease;
}
@media (hover: hover) and (pointer: fine) {
  .ygz-top-nav.is-hovering .ygz-primary-hover-indicator { opacity: 1; }
}

@media (min-width: 900px) {
  .ygz-top-nav { width: auto; max-width: min(860px, 100%); }
  .ygz-nav-menu-track { justify-content: center; }
  .ygz-menu-link, .ygz-menu-return { padding: 0 18px; }
}
@media (max-width: 360px) {
  .ygz-menu-link { padding: 0 12px; font-size: 14px; letter-spacing: .03em; }
}

/* ============ 切换账号弹层 ============ */
.ygz-account-modal {
  position: fixed;
  inset: 0;
  z-index: 15100; /* 高于论坛悬浮发帖按钮(14000)与音乐卡片(14020) */
  display: grid;
  place-items: end center;
  padding: 12px 12px max(12px, env(safe-area-inset-bottom, 0px));
  background: rgba(3, 3, 6, .58);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .26s ease;
}
.ygz-account-modal.is-open { opacity: 1; }
@media (min-width: 640px) { .ygz-account-modal { place-items: center; } }

.ygz-account-sheet {
  position: relative;
  width: min(420px, 100%);
  max-height: min(78vh, 640px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px 18px 16px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, .13);
  background: linear-gradient(160deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .015) 46%), rgba(16, 17, 24, .96);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .12);
  color: #f3f3f6;
  transform: translate3d(0, 24px, 0) scale(.98);
  transition: transform .42s var(--ygz-nav-ease, cubic-bezier(.16, 1, .3, 1));
}
.ygz-account-modal.is-open .ygz-account-sheet { transform: none; }
.ygz-account-sheet:focus { outline: none; }

.ygz-account-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.ygz-account-head h2 { margin: 0; font-size: 17px; letter-spacing: .08em; }
.ygz-account-close {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .05);
  color: rgba(255, 255, 255, .78);
  font-size: 20px; line-height: 1;
  display: grid; place-items: center;
  transition: background .2s ease, color .2s ease;
}
.ygz-account-close:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.ygz-account-message { min-height: 18px; margin: 2px 0 8px; font-size: 12.5px; color: rgba(255, 255, 255, .55); }
.ygz-account-message.is-error { color: #ef8f97; }
.ygz-account-message.is-ok { color: #8fd3a9; }

.ygz-account-list { display: grid; gap: 8px; margin-bottom: 12px; }
.ygz-account-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .035);
  color: inherit; text-align: left;
  transition: background .2s ease, border-color .2s ease, transform .2s var(--ygz-nav-ease, cubic-bezier(.16, 1, .3, 1));
}
.ygz-account-item:hover { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); }
.ygz-account-item:active { transform: scale(.99); }
.ygz-account-item.is-current { border-color: rgba(217, 180, 106, .35); background: rgba(217, 180, 106, .06); cursor: default; }
.ygz-account-item.is-busy { opacity: .6; pointer-events: none; }
.ygz-account-avatar { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; object-fit: cover; background: #1d1e26; box-shadow: 0 0 0 1px rgba(255, 255, 255, .12); }
.ygz-account-meta { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ygz-account-name { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ygz-account-sub { font-size: 12px; color: rgba(255, 255, 255, .5); }
.ygz-account-badge { flex: 0 0 auto; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; color: #e9cf96; background: rgba(217, 180, 106, .14); border: 1px solid rgba(217, 180, 106, .28); }
.ygz-account-remove {
  flex: 0 0 30px; width: 30px; height: 30px;
  border-radius: 50%; border: 0;
  background: transparent; color: rgba(255, 255, 255, .42);
  font-size: 18px; line-height: 1;
  display: grid; place-items: center;
}
.ygz-account-remove:hover { color: #ef8f97; background: rgba(239, 143, 151, .1); }
.ygz-account-empty { padding: 14px; text-align: center; font-size: 13px; color: rgba(255, 255, 255, .45); border: 1px dashed rgba(255, 255, 255, .1); border-radius: 16px; }

.ygz-account-add,
.ygz-account-submit,
.ygz-account-back {
  height: 46px;
  border-radius: 16px;
  font-weight: 650;
  font-size: 15px;
  letter-spacing: .04em;
  transition: background .2s ease, border-color .2s ease, opacity .2s ease, transform .2s var(--ygz-nav-ease, cubic-bezier(.16, 1, .3, 1));
}
.ygz-account-add { width: 100%; border: 1px dashed rgba(255, 255, 255, .22); background: transparent; color: rgba(255, 255, 255, .82); }
.ygz-account-add:hover { border-color: rgba(255, 255, 255, .38); color: #fff; }
.ygz-account-form { display: grid; gap: 12px; margin-top: 4px; }
.ygz-account-form label { display: grid; gap: 6px; font-size: 13px; color: rgba(255, 255, 255, .62); }
.ygz-account-form input {
  height: 46px; width: 100%;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .06);
  color: #fff; font-size: 15px;
}
.ygz-account-form input:focus { border-color: rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .09); }
.ygz-account-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 4px; }
.ygz-account-back { border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .04); color: rgba(255, 255, 255, .8); }
.ygz-account-submit { border: 1px solid rgba(255, 255, 255, .2); background: linear-gradient(180deg, #f4f4f6, #d9d9df); color: #0c0c10; }
.ygz-account-submit:disabled { opacity: .6; }
.ygz-account-add:active, .ygz-account-submit:active, .ygz-account-back:active { transform: scale(.985); }

html.ygz-modal-open, html.ygz-modal-open body { overflow: hidden; }

/* ============ 页面入场 ============
   fill-mode 用 backwards：动画结束后不再作用，#mainWrapper 不会长期成为层叠上下文，
   页面里的弹窗（fixed + 高 z-index）仍能盖住导航。只淡入不位移（#mainWrapper 上的 transform 会让内部 fixed 按钮在动画期间跳动）；
   必须在 <head> 中加载，首帧即生效，才不会闪。刷新时不播放。 */
@keyframes ygz-page-fade-in { from { opacity: 0; } to { opacity: 1; } }
html:not(.ygz-nav-reload) #mainWrapper,
html:not(.ygz-nav-reload) .main-wrapper { animation: ygz-page-fade-in .24s cubic-bezier(.22, 1, .36, 1) backwards; }
@media (prefers-reduced-motion: reduce) {
  #mainWrapper, .main-wrapper { animation: none !important; }
  .ygz-primary-indicator, .ygz-primary-hover-indicator, .ygz-nav-menu-track, .ygz-account-modal, .ygz-account-sheet { transition: none !important; }
}
