/* ============================================================
   GRAILA Visual Engine | float_button_table Stylesheet
   ----------------------------------------------------------------
   洛书 TOC 浮动按钮 + 右侧目录面板
   ============================================================ */

/* ============================================================
   按钮容器
   ============================================================ */
.gve-fbt {
  position: fixed;
  /* bottom/right by JS */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  margin: 0;
  border: none;
  outline: none;
  background: transparent;
  cursor: pointer;
  color: #5A6770;
  opacity: 0;
  visibility: hidden;
  transform: translateX(20px);
  transition:
    opacity 600ms cubic-bezier(0.16, 1, 0.3, 1),
    visibility 600ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 600ms cubic-bezier(0.16, 1, 0.3, 1),
    color 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.gve-fbt.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  pointer-events: auto;
}

.gve-fbt:hover { color: #C8341F; }
.gve-fbt:focus-visible {
  outline: 2px solid #C8341F;
  outline-offset: 4px;
}
.gve-fbt.is-active { color: #C8341F; }

.gve-fbt__svg {
  display: block;
  width: 100%;
  height: 100%;
}

.gve-fbt__svg svg {
  width: 100%;
  height: 100%;
  display: block;
  transition: transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

.gve-fbt:hover .gve-fbt__svg svg {
  transform: translateY(-2px);
}

/* hover - 9 个点位的依次点亮(JS 加 .gve-fbt__dot--lit 时被激活) */
.gve-fbt__svg .gve-luoshu__dot {
  transition:
    transform 280ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 280ms cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: center;
  transform-box: fill-box;
}

.gve-fbt__svg .gve-luoshu__dot--lit {
  filter: drop-shadow(0 0 6px rgba(200, 52, 31, 0.65));
  transform: scale(1.3);
}

/* 中心点常驻脉冲 */
@keyframes gve-fbt-pulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%      { transform: scale(1.25); opacity: 0.7; }
}

.gve-fbt__svg circle.gve-luoshu__dot[data-luoshu-pos="C"] {
  animation: gve-fbt-pulse 4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  transform-origin: center;
  transform-box: fill-box;
}

/* 打开面板时按钮自身的微动 */
.gve-fbt.is-active .gve-fbt__svg svg {
  transform: rotate(-3deg) scale(0.95);
}

/* ============================================================
   TOC 面板
   ============================================================ */
.gve-fbt-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 340px;
  max-width: 90vw;
  background: #0E0E12;
  color: #F7F4ED;
  font-family: var(--gve-font-display-cn, 'Noto Serif SC', serif);
  z-index: 9995;
  transform: translateX(100%);
  transition: transform 500ms cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.gve-fbt-panel[hidden] { display: flex; }   /* 仍参与布局,只是 transform 在屏外 */
.gve-fbt-panel.is-open { transform: translateX(0); }

/* 面板头 */
.gve-fbt-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 28px 20px;
  border-bottom: 1px solid rgba(247, 244, 237, 0.08);
  flex-shrink: 0;
}

.gve-fbt-panel__title-cn {
  font-family: var(--gve-font-display-cn, 'Noto Serif SC', serif);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  color: #F7F4ED;
}

.gve-fbt-panel__title-en {
  font-family: var(--gve-font-display-en, 'Cormorant Garamond', serif);
  font-style: italic;
  font-size: 0.875rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(247, 244, 237, 0.45);
  margin-left: 12px;
  margin-right: auto;
  padding-left: 16px;
  border-left: 1px solid rgba(247, 244, 237, 0.15);
}

.gve-fbt-panel__close {
  background: transparent;
  border: none;
  color: rgba(247, 244, 237, 0.6);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 0;
  transition: color 200ms ease, transform 200ms ease;
}

.gve-fbt-panel__close:hover {
  color: #C8341F;
  transform: rotate(90deg);
}

.gve-fbt-panel__close svg { width: 20px; height: 20px; }

/* TOC 导航区 */
.gve-fbt-panel__nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.gve-fbt-panel__nav::-webkit-scrollbar { width: 4px; }
.gve-fbt-panel__nav::-webkit-scrollbar-track { background: transparent; }
.gve-fbt-panel__nav::-webkit-scrollbar-thumb {
  background: rgba(247, 244, 237, 0.15);
  border-radius: 2px;
}

.gve-fbt-panel__list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: gve-fbt-counter;
}

.gve-fbt-panel__list-item {
  border-bottom: 1px solid rgba(247, 244, 237, 0.05);
}

.gve-fbt-panel__link {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 16px 28px;
  color: rgba(247, 244, 237, 0.78);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 300;
  letter-spacing: 0.06em;
  line-height: 1.5;
  transition:
    color 220ms cubic-bezier(0.16, 1, 0.3, 1),
    background 220ms cubic-bezier(0.16, 1, 0.3, 1),
    padding-left 280ms cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.gve-fbt-panel__link::before {
  counter-increment: gve-fbt-counter;
  content: counter(gve-fbt-counter, decimal-leading-zero);
  font-family: var(--gve-font-display-en, 'Cormorant Garamond', serif);
  font-style: italic;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: rgba(247, 244, 237, 0.3);
  flex-shrink: 0;
  min-width: 24px;
}

.gve-fbt-panel__link:hover,
.gve-fbt-panel__link:focus-visible {
  color: #F7F4ED;
  background: rgba(200, 52, 31, 0.06);
  padding-left: 36px;
  outline: none;
}

.gve-fbt-panel__link.is-active {
  color: #C8341F;
}

.gve-fbt-panel__link.is-active::before {
  color: #C8341F;
}

.gve-fbt-panel__link.is-active::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #C8341F;
}

/* 缩进项(子级 H3 等) */
.gve-fbt-panel__list-item--indent-1 .gve-fbt-panel__link {
  padding-left: 56px;
  font-size: 0.875rem;
  color: rgba(247, 244, 237, 0.55);
}
.gve-fbt-panel__list-item--indent-1 .gve-fbt-panel__link::before {
  display: none;
}
.gve-fbt-panel__list-item--indent-2 .gve-fbt-panel__link {
  padding-left: 76px;
  font-size: 0.8125rem;
  color: rgba(247, 244, 237, 0.5);
}
.gve-fbt-panel__list-item--indent-2 .gve-fbt-panel__link::before {
  display: none;
}

/* 印章签名 */
.gve-fbt-panel__seal {
  flex-shrink: 0;
  padding: 24px 28px;
  border-top: 1px solid rgba(247, 244, 237, 0.08);
  display: flex;
  justify-content: flex-end;
  color: #C8341F;
  opacity: 0.55;
}

.gve-fbt-panel__seal svg {
  width: 32px;
  height: 32px;
  transform: rotate(-3deg);
}

/* ============================================================
   遮罩(打开面板时)
   ============================================================ */
.gve-fbt-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 14, 18, 0.5);
  z-index: 9994;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 400ms cubic-bezier(0.16, 1, 0.3, 1),
    visibility 400ms cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.gve-fbt-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 768px) {
  .gve-fbt {
    width: 40px;
    height: 40px;
  }
  .gve-fbt-panel {
    width: 100%;
    max-width: 100%;
  }
  .gve-fbt-panel__header {
    padding: 20px 20px 16px;
  }
  .gve-fbt-panel__link {
    padding: 14px 20px;
  }
  .gve-fbt-panel__link:hover { padding-left: 28px; }
}

/* ============================================================
   降低动效偏好
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .gve-fbt,
  .gve-fbt__svg svg,
  .gve-fbt-panel,
  .gve-fbt-panel__close,
  .gve-fbt-panel__link,
  .gve-fbt-overlay {
    transition: none !important;
    animation: none !important;
  }
  .gve-fbt__svg circle.gve-luoshu__dot[data-luoshu-pos="C"] {
    animation: none !important;
  }
}
