/* ==========================================================================
   common.css — 双星引力 · 全站公共样式
   引入位置：放在各页面自身 <style> 之前
   <link rel="stylesheet" href="common.css">
   ========================================================================== */

/* ---------- 1. 深色色彩方案 ---------- */
html {
  color-scheme: dark;
}

/* ---------- 2. 字体回退补强 ---------- */
html, body {
  font-family:
    "Songti SC",
    "STSong",
    "SimSun",
    "Noto Serif CJK SC",
    "Noto Serif SC",
    "Source Han Serif SC",
    "Source Han Serif CN",
    "PingFang SC",
    "Microsoft YaHei",
    serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- 3. 触屏热区扩展 ---------- */
.tap-target {
  position: relative;
}
.tap-target::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: max(100%, 44px);
  height: max(100%, 44px);
  background: transparent;
  pointer-events: auto;
}

.icon-btn {
  position: relative;
}
.icon-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  pointer-events: auto;
}

/* ---------- 4. hover 效果在触屏降级 ---------- */
@media (hover: none) {
  .hover-only {
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
  }
}

/* ---------- 5. 移动端输入框防自动缩放 ---------- */
@media (max-width: 768px) {
  input:not([type="range"]):not([type="checkbox"]):not([type="radio"]),
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* ---------- 6. 内嵌模式：iframe 中不重复背景 ---------- */
html.embed-mode,
html.embed-mode body {
  background: transparent !important;
  background-image: none !important;
}

/* ---------- 7. 全局 reduced-motion 兜底 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 8. 滚动容器通用优化 ---------- */
.scroll-contain {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.scroll-invisible {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.scroll-invisible::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* ---------- 9. 断点变量 ---------- */
:root {
  --bp-tablet-max: 1024px;
  --bp-phone-max:  768px;
  --bp-tiny-max:   480px;
}

/* ---------- 10. 焦点可见性（全局兜底） ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- 11. 横屏手机通用兜底 ---------- */
@media (max-height: 560px) and (orientation: landscape) {
  body { overflow-y: auto; }
}

/* ---------- 12. 图片默认不拖拽、不选中 ---------- */
img {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- 13. 防止横向溢出 ---------- */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

/* ==========================================================================
   14. 可选：思源宋体 Web Font（自托管）
   ──────────────────────────────────────────────────────────────────────
   如需启用：
   1. 下载思源宋体 SC 子集（woff2），放在 fonts/ 目录
      推荐从 https://github.com/adobe-fonts/source-han-serif 或
      https://github.com/notofonts/noto-cjk 获取
   2. 把下面的 /* 和 */ 去掉即可生效
   ────────────────────────────────────────────────────────────────────── */

/*
@font-face {
  font-family: "SourceHanSerif";
  src: url("fonts/SourceHanSerifSC-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "SourceHanSerif";
  src: url("fonts/SourceHanSerifSC-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "SourceHanSerif";
  src: url("fonts/SourceHanSerifSC-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

html, body {
  font-family:
    "SourceHanSerif",
    "Songti SC",
    "STSong",
    "SimSun",
    "Noto Serif CJK SC",
    "Noto Serif SC",
    serif;
}
*/

/* ==========================================================================
   15. 图片优化
   ========================================================================== */

/* 全局：图片默认不超出容器，并保持宽高比 */
img {
  max-width: 100%;
  height: auto;
}

/* 有 width / height 属性的图片，用 aspect-ratio 预占位，避免 CLS */
img[width][height] {
  aspect-ratio: attr(width) / attr(height);
}

/* 装饰图 / 光效层：不占位、不可交互 */
img[aria-hidden="true"],
img.deco-img {
  pointer-events: none;
  user-select: none;
}

/* 首屏关键图：不延迟、高优先级 */
img.hero-img,
img[data-priority="high"] {
  loading: eager;
  fetchpriority: high;
}

/* 长列表 / 折叠区图片：延迟加载 + 异步解码 */
img[data-lazy="1"] {
  content-visibility: auto;
  contain-intrinsic-size: 300px 200px;
}

/* ==========================================================================
   16. ⭐ 移动端滚动稳定性（本次新增）
   ========================================================================== */

/* 关闭浏览器的自动滚动锚定。
   iOS Safari 的自动锚定经常选错 anchor，
   在 iframe 高度变化时会二次补偿，表现为"跳两下"。
   我们已在各页 JS 里手动补偿，这里关掉浏览器自己的。 */
html {
  overflow-anchor: none;
}

/* iframe 高度变化时给浏览器提前准备层，减少抖动 */
.converge-embed iframe,
.roche-embed iframe,
.room-frame {
  will-change: height;
}