/* 回到页首按钮 — 全站共用。向下滚动一屏后淡入，点击平滑回到顶部。
   刻意用中性深灰，五套配色（金/蓝/纸白黄/宝可梦/绿）上都不打架。 */
.hq-totop {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 900;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(20, 22, 27, 0.9);
  color: #f2f4f8;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);

  /* 未显示时不接收点击 */
  opacity: 0;
  transform: translateY(8px) scale(0.94);
  pointer-events: none;
  transition:
    opacity 200ms cubic-bezier(0.23, 1, 0.32, 1),
    transform 200ms cubic-bezier(0.23, 1, 0.32, 1),
    background 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

.hq-totop.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.hq-totop svg {
  width: 20px;
  height: 20px;
  display: block;
}

.hq-totop:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

/* hover 只给真鼠标，避免移动端点完卡在 hover 态 */
@media (hover: hover) and (pointer: fine) {
  .hq-totop:hover {
    background: rgba(44, 47, 55, 0.94);
  }
}

.hq-totop:active {
  transform: translateY(0) scale(0.92);
}

/* 手机上原来是 40×40，低于 iOS 44px 的最小点按尺寸 */
@media (max-width: 640px) {
  .hq-totop {
    right: 16px;
    bottom: 16px;
    width: 44px;
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hq-totop {
    transition: opacity 1ms linear;
    transform: none;
  }
  .hq-totop.is-visible,
  .hq-totop:active {
    transform: none;
  }
}
