/* ============================================================
 * 福境 H5（公众号）宿主样式
 * 只负责容器与内置组件模拟，业务样式全部来自小程序的 WXSS
 * ============================================================ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #08141B;
  color: #f7efd9;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* ---------------- 小程序屏幕容器 ---------------- */

.wx-screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;

  /* rpx 基准：与小程序一致，1rpx = 屏幕宽 / 750，随机型等比缩放 */
  --rpx: calc(100vw / 750);

  background: #08141B;
  color: #f7efd9;
  font-size: calc(28 * var(--rpx));
  line-height: 1.6;

  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.wx-screen::-webkit-scrollbar { width: 0; height: 0; }

/* ---------------- 桌面浏览器预览（真机不受影响） ----------------
   宽屏下把页面收进 414 逻辑宽的容器并居中，避免内容被拉散。
   上线到公众号后由手机访问，这段样式不生效。 */
@media (min-width: 640px) {
  html, body {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
      radial-gradient(circle at 50% 0%, rgba(35, 88, 112, 0.32) 0, rgba(5, 8, 11, 0) 58%),
      #05080b;
  }

  .wx-screen {
    width: 414px;
    height: min(896px, 100vh);
    --rpx: calc(414px / 750);
    border-radius: 30px;
    border: 1px solid rgba(235, 196, 116, 0.28);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.62);
  }

  /* 容器外的提示，仅在桌面预览时出现 */
  .fj-desktop-hint {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 18px;
    text-align: center;
    font-size: 12px;
    letter-spacing: 1px;
    color: #4E5A64;
    pointer-events: none;
  }
}

.fj-desktop-hint { display: none; }

@media (min-width: 640px) {
  .fj-desktop-hint { display: block; }
}

/* 自定义组件容器：不产生盒子，保持小程序多根节点布局 */
.wx-comp { display: contents; }

/* ---------------- 内置组件模拟 ---------------- */

.wx-scroll-x {
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.wx-scroll-x::-webkit-scrollbar { height: 0; }
.wx-scroll-y { overflow-y: auto; }

.wx-switch {
  position: relative;
  display: inline-block;
  width: calc(100 * var(--rpx));
  height: calc(60 * var(--rpx));
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(235, 196, 116, 0.28);
  cursor: pointer;
  transition: background 0.2s;
  vertical-align: middle;
}

.wx-switch[data-checked="1"] {
  background: var(--wx-color, #b78a39);
  border-color: transparent;
}

.wx-switch__box { position: absolute; inset: 0; }

.wx-switch__dot {
  position: absolute;
  top: 50%;
  left: calc(4 * var(--rpx));
  width: calc(48 * var(--rpx));
  height: calc(48 * var(--rpx));
  margin-top: calc(-24 * var(--rpx));
  border-radius: 50%;
  background: #fff;
  transition: left 0.2s;
}

.wx-switch[data-checked="1"] .wx-switch__dot { left: calc(48 * var(--rpx)); }

canvas { display: block; }
img { max-width: 100%; }

textarea, input {
  font-family: inherit;
  outline: none;
  border: none;
  background: transparent;
  color: inherit;
}

textarea::placeholder, input::placeholder { color: #4e575b; }

/* ---------------- 提示 / 动作面板 ---------------- */

.wx-toast {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 3000;
  transform: translate(-50%, -50%) scale(0.96);
  max-width: 76%;
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.wx-toast.is-show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.wx-actionsheet {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px calc(10px + env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.5);
}

.wx-actionsheet__box {
  border-radius: 14px;
  overflow: hidden;
  background: #1a2228;
}

.wx-actionsheet__item {
  padding: 15px;
  text-align: center;
  font-size: 15px;
  color: #f7efd9;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.wx-actionsheet__item:last-child { border-bottom: none; }
.wx-actionsheet__item:active { background: rgba(235, 196, 116, 0.12); }

.wx-actionsheet__cancel {
  padding: 15px;
  border-radius: 14px;
  text-align: center;
  font-size: 15px;
  color: #9aa7ad;
  background: #1a2228;
}

/* ---------------- 启动遮罩 ---------------- */

.fj-boot {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(180deg, #102D3C 0%, #08141B 46%, #050A0F 100%);
  transition: opacity 0.5s ease;
}

.fj-boot.is-hidden { opacity: 0; pointer-events: none; }

.fj-boot__logo {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 12px;
  color: #EBC474;
  text-shadow: 0 0 40px rgba(235, 196, 116, 0.4);
}

.fj-boot__tip { font-size: 12px; letter-spacing: 3px; color: #6E7A80; }

.fj-boot__err {
  max-width: 300px;
  padding: 14px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.8;
  color: #e08a6f;
  background: rgba(210, 96, 76, 0.1);
  border: 1px solid rgba(210, 96, 76, 0.3);
}
