/* 应用外壳样式(spec §3.4 / §8):主题变量 + 三档屏幕适配 + 导航条/tabBar/浮层。
   由 web/css/pages.generated.css 提供页面/组件样式(小程序 app.wxss + 各页 wxss 转换产物),
   本文件只负责「小程序里不存在的东西」:浏览器壳、断点、安全区、hover 态。

   —— 与 app.wxss 的关系 ——
   app.wxss 把主题变量挂在 `page { }` 上 → 转换产物是 `.wx-page`,而 DOM 里没有这个节点
   (模板编译器给元素挂的是 `.wx-view/.wx-text/...`),所以主题变量在此重新声明到 `:root`,
   基座字号/行高由 `#view` 承担(等价 app.wxss 的 `.wx-page` 那一条)。

   —— 屏幕适配(核心)——
   `--shell-max` 三档:手机 750(铺满)/ 平板 640 / 桌面 560;`--rpx` 按**容器宽**而非视口宽
   计算(min(100vw, --shell-max) / 750),于是平板/桌面缩小后页面比例与手机完全一致 ——
   小程序 rpx 语义在三种屏幕上等价。 */

:root {
  /* 主题(色值与 miniprogram/app.wxss 逐字一致) */
  --bg: #12121a;
  --card: #1c1c28;
  --card-2: #232332;
  --text: #e8e8f0;
  --text-dim: #8a8f98;
  --accent-purple: #a855f7;
  --accent-cyan: #4fd1c5;
  --danger: #f56565;

  /* 三档断点 + rpx */
  --shell-max: 750px;
  --rpx: calc(min(100vw, var(--shell-max)) / 750);
}
@media (min-width: 768px) { :root { --shell-max: 640px; } }
@media (min-width: 1024px) { :root { --shell-max: 560px; } }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;                 /* 全局禁止横向滚动 */
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei', sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* —— 内容列:居中「手机屏」——
   transform 让 `position: fixed` 的弹窗遮罩(组件 wxss 里就是 fixed)相对本列定位,
   桌面端遮罩只盖住手机屏而非整个窗口;overflow:hidden 顺带裁掉越界内容。 */
#app {
  position: relative;
  width: min(100vw, var(--shell-max));
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;                     /* 移动端地址栏收放时不跳动 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  transform: translateZ(0);
}

/* 平板/桌面:内容列加边框 + 阴影,形成「手机屏」观感(spec §8) */
@media (min-width: 768px) {
  #app { border-left: 1px solid rgba(255, 255, 255, 0.06); border-right: 1px solid rgba(255, 255, 255, 0.06); box-shadow: 0 0 48px rgba(0, 0, 0, 0.55); }
}

/* —— 顶部导航条(标题居中;非 tab 页左返回、右 ↻) —— */
#nav {
  flex: 0 0 auto;
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  height: calc(88 * var(--rpx));
  padding: 0 calc(8 * var(--rpx));
  background: var(--card);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.nav-title {
  flex: 1 1 auto;
  text-align: center;
  font-size: calc(34 * var(--rpx));
  font-weight: 600;
  letter-spacing: calc(1 * var(--rpx));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 返回箭头 / 刷新按钮:触控目标 >= 44px(无障碍最小尺寸),视觉上仍是小图标 */
.nav-back, .nav-refresh {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  font-size: calc(40 * var(--rpx));
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.nav-back { font-size: calc(52 * var(--rpx)); }
.nav-spacer { flex: 0 0 auto; min-width: 44px; min-height: 44px; }
@media (hover: hover) {
  .nav-back:hover, .nav-refresh:hover { color: var(--accent-purple); }
}

/* —— 页面视图:唯一的滚动容器(下拉刷新读它的 scrollTop) —— */
#view {
  flex: 1 1 auto;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  font-size: calc(28 * var(--rpx));
  line-height: 1.5;
  color: var(--text);
  padding-bottom: env(safe-area-inset-bottom);
}
#view > .af-page { min-height: 100%; }

/* 下拉刷新指示器(纯 CSS,由 shell 切换 #view[data-pulling]) */
#view[data-pulling="1"]::before {
  content: '⏳ 刷新中…';
  position: absolute;
  top: calc(12 * var(--rpx));
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: calc(8 * var(--rpx)) calc(24 * var(--rpx));
  border-radius: calc(999 * var(--rpx));
  background: rgba(28, 28, 40, 0.92);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: var(--accent-cyan);
  font-size: calc(22 * var(--rpx));
  white-space: nowrap;
}

/* —— 底部 tabBar(4 项等分;当前项紫色) —— */
#tabbar {
  flex: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: stretch;
  background: var(--card);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(4 * var(--rpx));
  min-height: 44px;
  padding: calc(10 * var(--rpx)) 0 calc(12 * var(--rpx));
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);            /* app.json tabBar.color */
}
.tab-item.active { color: var(--accent-purple); }   /* app.json tabBar.selectedColor */
.tab-icon {
  width: calc(48 * var(--rpx));
  height: calc(48 * var(--rpx));
  opacity: 0.55;
  object-fit: contain;
}
.tab-item.active .tab-icon { opacity: 1; }
.tab-text { font-size: calc(20 * var(--rpx)); line-height: 1; }
@media (hover: hover) {
  .tab-item:hover { color: var(--accent-cyan); }
  .tab-item:hover .tab-icon { opacity: 0.85; }
}

/* —— 组件弹窗挂载层(升级祝贺 / 拼图弹窗)——
   本身不吃事件,只有里面的遮罩吃,避免盖住 #view 的手势与点击。 */
#layers {
  position: absolute;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}
#layers > * { pointer-events: auto; }
.af-modal-slot { display: contents; }

/* —— 未移植页占位(每个尚未落地的路由都能被打开并看到明确说明) —— */.af-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(16 * var(--rpx));
  min-height: 60vh;
  padding: calc(40 * var(--rpx)) calc(48 * var(--rpx));
  text-align: center;
}
.af-placeholder-icon { font-size: calc(96 * var(--rpx)); line-height: 1; opacity: 0.7; }
.af-placeholder-title { font-size: calc(34 * var(--rpx)); font-weight: 700; color: var(--text); }
.af-placeholder-text { font-size: calc(26 * var(--rpx)); color: var(--text-dim); }
.af-placeholder-hash {
  font-size: calc(22 * var(--rpx));
  color: var(--accent-purple);
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: calc(999 * var(--rpx));
  padding: calc(6 * var(--rpx)) calc(24 * var(--rpx));
}

/* —— wx.* 自绘浮层(toast / modal / actionSheet,由 js/shim/wx.js 生成)—— */
.af-layers {
  position: fixed;
  inset: 0;
  z-index: 1200;
  pointer-events: none;
}
.af-layers > * { pointer-events: auto; }

.af-toast {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 70vw;
  padding: calc(20 * var(--rpx)) calc(32 * var(--rpx));
  border-radius: calc(16 * var(--rpx));
  background: rgba(0, 0, 0, 0.82);
  color: #ffffff;
  font-size: calc(26 * var(--rpx));
  text-align: center;
  animation: af-layer-in 0.15s ease-out;
}
.af-toast-mask { position: fixed; }
.af-toast-text { white-space: pre-wrap; word-break: break-word; }

.af-modal-mask, .af-actionsheet-mask {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 16, 0.7);
}
.af-modal {
  width: min(84vw, calc(560 * var(--rpx)));
  border-radius: calc(24 * var(--rpx));
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  animation: af-layer-in 0.18s ease-out;
}
.af-modal-title { padding: calc(36 * var(--rpx)) calc(36 * var(--rpx)) 0; font-size: calc(32 * var(--rpx)); font-weight: 700; text-align: center; }
.af-modal-content { padding: calc(20 * var(--rpx)) calc(36 * var(--rpx)) calc(28 * var(--rpx)); font-size: calc(27 * var(--rpx)); color: var(--text-dim); text-align: center; line-height: 1.6; }
.af-modal-input {
  display: block;
  width: calc(100% - calc(72 * var(--rpx)));
  margin: 0 calc(36 * var(--rpx)) calc(28 * var(--rpx));
  padding: calc(16 * var(--rpx)) calc(20 * var(--rpx));
  border-radius: calc(12 * var(--rpx));
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--card-2);
  color: var(--text);
  font-size: calc(27 * var(--rpx));
}
.af-modal-actions { display: flex; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.af-modal-btn {
  flex: 1 1 0;
  min-height: 48px;
  padding: calc(22 * var(--rpx)) 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: calc(29 * var(--rpx));
  color: var(--text);
}
.af-modal-cancel { color: var(--text-dim); border-right: 1px solid rgba(255, 255, 255, 0.08); }
.af-modal-confirm { color: var(--accent-purple); font-weight: 600; }
@media (hover: hover) {
  .af-modal-btn:hover { background: rgba(255, 255, 255, 0.04); }
}

.af-actionsheet-mask { align-items: flex-end; }
.af-actionsheet {
  width: 100%;
  background: var(--card);
  border-radius: calc(24 * var(--rpx)) calc(24 * var(--rpx)) 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  animation: af-layer-in 0.18s ease-out;
}
.af-actionsheet-item {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: calc(26 * var(--rpx)) 0;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: calc(30 * var(--rpx));
  cursor: pointer;
}
.af-actionsheet-cancel { color: var(--text-dim); border-bottom: none; }
@media (hover: hover) {
  .af-actionsheet-item:hover { background: rgba(255, 255, 255, 0.04); }
}

@keyframes af-layer-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
/* actionsheet / 全宽浮层不需要居中位移,单独给一条简单淡入 */
.af-actionsheet, .af-modal, .af-modal-mask, .af-actionsheet-mask { animation-name: af-fade-in; }
@keyframes af-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* —— Web 专有页:登录/注册(#/login)——
   小程序无此页,故样式不进 pages.generated.css(生成产物只来自 miniprogram/**)。
   命名前缀 lg-*,与页面内联模板一一对应。 */
.lg-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(28 * var(--rpx));
  min-height: 100%;
  padding: calc(56 * var(--rpx)) calc(32 * var(--rpx)) calc(40 * var(--rpx));
}
.lg-brand { gap: calc(10 * var(--rpx)); }
.lg-logo { width: calc(120 * var(--rpx)); height: calc(120 * var(--rpx)); }
.lg-title { font-size: calc(48 * var(--rpx)); font-weight: 800; letter-spacing: calc(4 * var(--rpx)); color: var(--text); }
.lg-sub { font-size: calc(22 * var(--rpx)); color: var(--text-dim); text-align: center; }

.lg-card { width: 100%; margin: 0; display: flex; flex-direction: column; gap: calc(20 * var(--rpx)); }
.lg-tabs { gap: calc(12 * var(--rpx)); }
.lg-tab {
  flex: 1 1 0;
  text-align: center;
  padding: calc(16 * var(--rpx)) 0;
  border-radius: calc(14 * var(--rpx));
  font-size: calc(28 * var(--rpx));
  color: var(--text-dim);
  background: var(--card-2);
  cursor: pointer;
}
.lg-tab.active { color: #ffffff; background: linear-gradient(135deg, var(--accent-purple), #7c3aed); }

.lg-field { display: flex; flex-direction: column; gap: calc(8 * var(--rpx)); }
.lg-input {
  width: 100%;
  padding: calc(20 * var(--rpx));
  border-radius: calc(14 * var(--rpx));
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--card-2);
  color: var(--text);
  font-size: calc(28 * var(--rpx));
}
.lg-input::placeholder { color: var(--text-dim); }
.lg-error { font-size: calc(22 * var(--rpx)); color: var(--danger); }
.lg-hint { font-size: calc(20 * var(--rpx)); color: var(--text-dim); }

.lg-row { font-size: calc(22 * var(--rpx)); color: var(--text-dim); }
.lg-eye { cursor: pointer; color: var(--accent-cyan); }
.lg-mode-hint { color: var(--text-dim); }
@media (hover: hover) {
  .lg-eye:hover { color: var(--accent-purple); }
  .lg-tab:hover { color: var(--text); }
}

.lg-submit { margin-top: calc(8 * var(--rpx)); }
.lg-disabled { opacity: 0.5; }

.lg-pending {
  padding: calc(16 * var(--rpx));
  border-radius: calc(12 * var(--rpx));
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid rgba(245, 166, 35, 0.35);
  color: #f5d78a;
  font-size: calc(21 * var(--rpx));
  line-height: 1.6;
}

.lg-back { font-size: calc(24 * var(--rpx)); color: var(--accent-cyan); cursor: pointer; padding: calc(8 * var(--rpx)) calc(20 * var(--rpx)); }
