/* 稳稳健康 · 可交互 Demo 公共样式
   颜色、圆角、字号取自 Figma 变量（文件「界面设计」）。 */

:root {
  /* Figma 变量 */
  --brand-primary: #3f5fe0;   /* brand/primary → blue/6 */
  --brand-dark: #2b43ba;      /* brand/dark → blue/7，主按钮按下 */
  --brand-light: #ebf1ff;     /* brand/light → blue/2 */
  --brand-disabled: #c2d4ff;  /* blue/3，主按钮 · 状态=禁用 */
  --bg-page: #f0f1f5;         /* bg/page */
  --bg-container: #ffffff;    /* bg/container */
  --bg-pressed: #dfe1e8;      /* bg/pressed → gray/2，次按钮按下 */
  --text-primary: #1a1a1a;    /* text/primary */
  --text-secondary: #666666;  /* text/secondary */
  --text-placeholder: #767676;/* text/placeholder */
  --text-anti: #ffffff;       /* text/anti */
  --border-divider: #dfe1e8;  /* border/divider */
  --radius-16: 16px;
  --radius-24: 24px;
  --radius-full: 999px;

  /* 动效：Figma 关键帧导出为 ease-out / ease-in-out，单段 300ms */
  --ease-out: ease-out;
  --ease-in-out: ease-in-out;
  --dur: 300ms;

  --font-sans: "PingFang SC", "WW Sans Fallback", "Microsoft YaHei", system-ui, sans-serif;
  --font-title: "WW Title", "PingFang SC", "WW Sans Fallback", "Microsoft YaHei", sans-serif;
}

/* 标题：阿里妈妈方圆体 VF · Bold-Round（wght 700 / BEVL 100），仅含标题用字的子集 */
@font-face {
  font-family: "WW Title";
  src: url("../assets/fonts/AlimamaFangYuanTi-BoldRound-sub.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}
/* 正文：设计稿用苹方。没装苹方的设备回退到阿里巴巴普惠体（本页用字子集） */
@font-face {
  font-family: "WW Sans Fallback";
  src: url("../assets/fonts/AlibabaPuHuiTi-Regular-sub.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "WW Sans Fallback";
  src: url("../assets/fonts/AlibabaPuHuiTi-Bold-sub.woff") format("woff");
  font-weight: 600;
  font-display: swap;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: #e6e8ee;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
img { display: block; }

/* ---------- 电脑上：居中手机框 ---------- */
.stage {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 16px;
}
.device {
  /* 由 app.js 写入 --scale，窗口矮时等比缩小 */
  width: calc(402px * var(--scale, 1));
  height: calc(874px * var(--scale, 1));
  border-radius: calc(52px * var(--scale, 1));
  box-shadow: 0 0 0 calc(10px * var(--scale, 1)) #1c1d22, 0 24px 60px rgba(20, 24, 40, .28);
  overflow: hidden;
  position: relative;
  flex: none;
}
.screen {
  position: absolute;
  left: 0; top: 0;
  width: 402px;
  height: 874px;
  overflow: hidden;
  background: var(--bg-page);
  transform: scale(var(--scale, 1));
  transform-origin: 0 0;
}
.stage-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #5b5f6b;
}
.stage-bar button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-full);
  background: #fff;
  color: var(--text-primary);
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.stage-bar button:active { background: var(--bg-pressed); }

/* 外层舞台跟随深色模式；手机画面本身是浅色设计稿，保持不变 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body { background: #16171b; }
  :root:not([data-theme="light"]) .stage-bar { color: #a3a7b3; }
}
:root[data-theme="dark"] body { background: #16171b; }
:root[data-theme="dark"] .stage-bar { color: #a3a7b3; }

/* ---------- 手机上：铺满宽度，不要外框 ---------- */
@media (max-width: 500px) {
  body { background: var(--bg-page); }
  .stage { padding: 0; gap: 0; justify-content: flex-start; }
  .device { border-radius: 0; box-shadow: none; }
  .stage-bar { display: none; }
}

/* ---------- 通用：Toast ---------- */
.toast {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max-content;
  max-width: 330px;
  padding: 12px 20px;
  border-radius: var(--radius-16);
  background: #2b2d33;               /* 实色，不用透明度 */
  color: var(--text-anti);
  font-size: 18px;
  line-height: 27px;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, calc(-50% + 8px));
  transition: opacity 250ms var(--ease-out), transform 250ms var(--ease-out);
  pointer-events: none;
  z-index: 50;
}
.toast.is-show { opacity: 1; transform: translate(-50%, -50%); }

/* 键盘可达 */
:focus-visible { outline: 3px solid var(--brand-primary); outline-offset: 3px; }

/* 系统开启「减少动态效果」：关闭全部动效，直接显示最终画面 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ================= 多屏：页面容器与转场 ================= */
.page {
  position: absolute; left: 0; top: 0;
  width: 402px; height: 874px;
  overflow: hidden;
  background: var(--bg-page);
  display: none;
}
.page.is-active { display: block; }
.page > * { position: absolute; }

/* 系统栏（设计稿里是位图） */
.statusbar { left: 0; top: 0; width: 402px; height: 50px; z-index: 5; pointer-events: none; }
.homebar { left: 0; bottom: 0; width: 402px; height: 34px; z-index: 5; pointer-events: none; }

/* ================= 导航栏 1064:1001 · 层级=二级 ================= */
.nav {
  left: 0; top: 50px; width: 402px; height: 56px; z-index: 6;
  padding: 8px 16px 0;
  display: flex; align-items: center;
}
.nav-title {
  flex: 1; min-width: 0;
  font-size: 18px; line-height: 27px; font-weight: 600;
  text-align: center; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-on-dark .nav-title { color: var(--text-anti); }
.nav-slot { width: 48px; height: 48px; flex: none; }
.nav-btn {             /* Back / Action · Circle 107:313 */
  position: relative; flex: none;
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.7);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(63,95,224,.08), inset 0 1px 0 rgba(255,255,255,.9);
  transition: background-color 200ms var(--ease-out);
}
.nav-btn::after {      /* 渐变描边：白 80% → blue/3 30%，135° */
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(135deg, rgba(255,255,255,.8), rgba(194,212,255,.3));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}
.nav-btn img { width: 28px; height: 28px; }
.nav-btn:active { background: rgba(255,255,255,.5); }

/* ================= 按钮 ================= */
.btn-primary {         /* 按钮/主按钮 832:927 */
  width: 100%; height: 52px; flex: none;
  border-radius: var(--radius-full);
  background: var(--brand-primary);
  color: var(--text-anti);
  font-size: 18px; line-height: 27px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color 200ms var(--ease-out);
}
.btn-primary:active { background: var(--brand-dark); }      /* 状态=按下 */
.btn-primary:disabled { background: var(--brand-disabled); cursor: not-allowed; }  /* 状态=禁用 */
.btn-primary .spinner { display: none; width: 20px; height: 20px; }
.btn-primary.is-loading { background: var(--brand-primary); }  /* 状态=加载 */
.btn-primary.is-loading .spinner { display: block; animation: ww-spin 1s linear infinite; }
@keyframes ww-spin { to { transform: rotate(360deg); } }

.btn-secondary {       /* 按钮/次按钮 823:882 */
  height: 44px; min-width: 88px; padding: 0 16px;
  border-radius: var(--radius-full);
  background: var(--bg-container);
  color: var(--text-primary);
  font-size: 18px; line-height: 27px; font-weight: 400;
  transition: background-color 200ms var(--ease-out);
}
.btn-secondary:active { background: var(--bg-pressed); }

.btn-text {            /* 文字按钮：视觉 27 高，热区 44 */
  min-height: 44px; width: 100%; margin: -8.5px 0;
  font-size: 18px; line-height: 27px; color: var(--text-secondary);
}
.btn-text:active { color: var(--text-primary); }

/* ================= 勾选框 1819:1701 ================= */
.check { width: 24px; height: 24px; flex: none; position: relative; }
.check img { position: relative; z-index: 1; width: 24px; height: 24px; transition: opacity 200ms var(--ease-out); }
.check::before {       /* 选中=否：1.5 描边 text/secondary（1819:1699） */
  content: ""; position: absolute; inset: 0;
  border-radius: 50%; border: 1.5px solid var(--text-secondary);
}
label > input[type="checkbox"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
input:not(:checked) + .check img { opacity: 0; }
input:focus-visible + .check { outline: 3px solid var(--brand-primary); outline-offset: 3px; border-radius: 50%; }

/* ================= 标签 1234:1437 ================= */
.tag {
  display: inline-flex; align-items: center; justify-content: center;
  height: 24px; padding: 0 8px; border-radius: var(--radius-full);
  /* Figma gradientTransform 换算：起点在 -63%（codegen 丢了负号） */
  background: linear-gradient(147.77deg, #9487fa -63.4%, #3f5fe0 94.7%);
  color: var(--text-anti); font-size: 14px; line-height: 20px; font-weight: 400;
  white-space: nowrap;
}
.tag-sm { height: 20px; padding: 2px 8px; background: linear-gradient(144.45deg, #9487fa -54.4%, #3f5fe0 89.7%); }

/* ================= 单元格 295:99 / 311:203 ================= */
.cell {
  position: relative; width: 100%; height: 64px; padding: 0 16px;
  display: flex; align-items: center; gap: 8px;
  background: transparent; text-align: left; cursor: pointer;
  font-size: 18px; line-height: 27px;
}
.cell + .cell::before {   /* Divider：左缩进 16，border/divider */
  content: ""; position: absolute; left: 16px; right: 0; top: 0; height: 1px;
  background: var(--border-divider);
}
.cell:active { background: var(--bg-pressed); }
.cell-label { font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.cell-grow { flex: 1; }
.cell-value, .cell-input {
  flex: 1; min-width: 0; text-align: right; color: var(--text-primary);
  font: inherit; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cell-value.is-empty { color: var(--text-placeholder); }
.cell-input { border: 0; outline: 0; background: transparent; padding: 0; height: 27px; }
.cell-input::placeholder { color: var(--text-placeholder); opacity: 1; }
.cell:has(.cell-input:focus) { background: transparent; }
.cell-arrow { width: 20px; height: 20px; flex: none; }
.cell-radio { cursor: default; gap: 10px; }
.cell-radio:active { background: transparent; }
.radios { display: flex; align-items: center; gap: 24px; }
.radio { height: 44px; display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text-secondary); }
.radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.radio-dot {               /* 单选 311:158：未选 1.5 描边 #666；选中 brand 实心 + 白点 10 */
  width: 24px; height: 24px; border-radius: 50%; flex: none; position: relative;
  border: 1.5px solid var(--text-secondary);
  transition: background-color 200ms var(--ease-out), border-color 200ms var(--ease-out);
}
.radio input:checked + .radio-dot { border-color: var(--brand-primary); background: var(--brand-primary); }
.radio input:checked + .radio-dot::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%; background: #fff;
}
.radio input:checked ~ span:last-child { color: var(--text-primary); }
.radio input:focus-visible + .radio-dot { outline: 3px solid var(--brand-primary); outline-offset: 3px; }

/* 舞台栏：跳到某一屏（仅电脑上显示） */
.stage-bar .scene { display: flex; align-items: center; gap: 8px; }
.stage-bar select {
  min-height: 44px; padding: 0 12px; border-radius: 12px; border: 0;
  background: #fff; color: var(--text-primary); font: inherit; font-size: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
