/* 「回到顶部」悬浮按钮（方案 A：竖排胶囊）
   生成：tools/build-product-totop.py（勿手改）
   想改样式改这个工具里的模板，再重新执行，全站（产品页 + Astro 页面）一起生效。

   位置规则：不贴屏幕最右边（浏览器插件/小工具都停在那里），锚定在内容区右外侧 22px。
     默认      Astro 页面容器最宽 1280 → 半宽 640
     --wide    7 个静态产品页主容器 1380 → 半宽 690
     --narrow  文章页正文容器 1000 → 半宽 500
   窗口不够宽时自动收回右侧 16~22px，不会跑出屏幕。 */
.rb-totop {
  position: fixed;
  right: auto;
  left: min(calc(50% + 662px), calc(100% - 64px));
  top: 50%;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: 42px;
  padding: 15px 0 13px;
  border: 0;
  border-radius: 999px;
  background: rgba(8, 112, 104, 0.92);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(8, 60, 55, 0.26);
  opacity: 0;
  visibility: hidden;
  transform: translate(6px, -50%);
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s, background 0.2s;
}
.rb-totop--wide {
  left: min(calc(50% + 712px), calc(100% - 64px));
}
.rb-totop--narrow {
  left: min(calc(50% + 522px), calc(100% - 64px));
}
.rb-totop.is-on {
  opacity: 1;
  visibility: visible;
  transform: translate(0, -50%);
}
.rb-totop:hover {
  background: #0b6e63;
}
.rb-totop:focus-visible {
  outline: 3px solid #4db6ac;
  outline-offset: 3px;
}
.rb-totop svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.rb-totop span {
  writing-mode: vertical-rl;
  font-size: 12px;
  letter-spacing: 0.22em;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Microsoft YaHei", sans-serif;
}
@media (max-width: 640px) {
  /* 手机上右侧没有余量，全站统一停右下角 */
  .rb-totop {
    left: auto;
    right: 12px;
    top: auto;
    bottom: 16px;
    width: 36px;
    padding: 12px 0 10px;
    gap: 5px;
    transform: translate(6px, 8px);
  }
  .rb-totop.is-on {
    transform: translate(0, 0);
  }
  .rb-totop span {
    font-size: 11px;
    letter-spacing: 0.16em;
  }
  .rb-totop svg {
    width: 15px;
    height: 15px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .rb-totop {
    transition: none;
  }
}
