/* ── Data ────────────────────────────────────────────────────────── */

const STATES = ['normal', 'tilted', 'compensated'];

const STATE_INFO = {
  normal: {
    cn: '中立位',
    en: 'Neutral',
    sub: '理想骨盆位置',
    angle: 7,
    range: '4°–7°',
    desc: '骨盆轻微前倾位于生理范围内，腰椎自然曲度。前后链肌力均衡，无任何代偿。'
  },
  tilted: {
    cn: '骨盆前倾',
    en: 'Anterior Tilt',
    sub: '初始结构问题',
    angle: 18,
    range: '> 15°',
    desc: '髋屈肌长期紧缩 → 拉动骨盆向前下方旋转。腰椎前凸增大（hyperlordosis），ASIS 显著低于 PSIS。'
  },
  compensated: {
    cn: '链式代偿',
    en: 'Lower Crossed Syndrome',
    sub: '下交叉综合征',
    angle: 18,
    range: '> 15°',
    desc: '腰部竖脊肌持续高强度收缩以维持躯干直立 → 腰肌劳损；臀肌与腹肌被神经性抑制，形成"上紧—下松/下紧—上松"的交叉。'
  }
};

/* state 取值: 'neutral' | 'tight' | 'overworking' | 'weak' | 'lengthened' */
const STATE_STYLE = {
  neutral:    { fill: 'var(--tan)',     glow: 'none',          ring: 'var(--tan-soft)',  zhCn: '正常张力' },
  tight:      { fill: 'var(--rust)',    glow: 'pulse-tight',   ring: 'var(--rust-soft)', zhCn: '紧张缩短' },
  overworking:{ fill: 'var(--rust-deep)', glow: 'pulse-fire',  ring: 'var(--rust)',      zhCn: '代偿过劳' },
  weak:       { fill: 'var(--slate)',   glow: 'none',          ring: 'var(--slate-soft)',zhCn: '抑制弱化' },
  lengthened: { fill: 'var(--slate-soft)', glow: 'none',       ring: 'var(--slate)',     zhCn: '被动拉长' },
};

const MUSCLES_ORDER = ['iliopsoas', 'rectusFemoris', 'erectorSpinae', 'glutes', 'abs', 'hamstrings'];

const MUSCLES = {
  iliopsoas: {
    cn: '髂腰肌', en: 'Iliopsoas', side: 'front',
    states: { normal: 'neutral', tilted: 'tight', compensated: 'tight' },
    fn: '主要髋关节屈肌',
    role: '久坐时持续缩短；反弹性收缩拉动骨盆前倾',
    attach: 'T12–L4 椎体侧面 / 髂窝 → 股骨小转子',
    arrow: 'pull-down-front',
    chain: '罪魁祸首 · 主动肌'
  },
  rectusFemoris: {
    cn: '股直肌', en: 'Rectus Femoris', side: 'front',
    states: { normal: 'neutral', tilted: 'tight', compensated: 'tight' },
    fn: '跨双关节：屈髋 + 伸膝',
    role: '与髂腰肌协同，将髋骨前下牵引',
    attach: 'AIIS（髂前下棘） → 髌骨/胫骨粗隆',
    arrow: 'pull-up-asis',
    chain: '协同紧张'
  },
  erectorSpinae: {
    cn: '腰部竖脊肌', en: 'Lumbar Erector Spinae', side: 'back',
    states: { normal: 'neutral', tilted: 'tight', compensated: 'overworking' },
    fn: '后伸腰椎、维持躯干直立',
    role: '骨盆前倾后被迫长期高张力收缩 → 腰肌劳损',
    attach: '骶骨 / 髂嵴 → 沿腰椎横突向上',
    arrow: 'pull-up-back',
    chain: '代偿主力 · 腰痛根源'
  },
  glutes: {
    cn: '臀大肌', en: 'Gluteus Maximus', side: 'back',
    states: { normal: 'neutral', tilted: 'weak', compensated: 'weak' },
    fn: '伸髋 / 外旋 / 站立行走主力',
    role: '与髂腰肌相互抑制；久坐使其神经驱动下降，扁平萎缩',
    attach: '髂嵴 / 骶骨 → IT 束 / 股骨臀肌粗隆',
    arrow: 'inhibit-back',
    chain: '抑制 · 拮抗失能'
  },
  abs: {
    cn: '腹直肌 / 腹横肌', en: 'Abdominals', side: 'front',
    states: { normal: 'neutral', tilted: 'weak', compensated: 'weak' },
    fn: '收紧核心、防止骨盆前倾',
    role: '功能弱化时核心稳定性下降，下腹前凸',
    attach: '耻骨 → 第 5–7 肋',
    arrow: 'inhibit-front',
    chain: '抑制 · 核心失稳'
  },
  hamstrings: {
    cn: '腘绳肌', en: 'Hamstrings', side: 'back',
    states: { normal: 'neutral', tilted: 'lengthened', compensated: 'lengthened' },
    fn: '伸髋、屈膝',
    role: '骨盆前倾使其被动拉长，发力效率↓，常误诊为"紧"',
    attach: '坐骨结节 → 胫骨/腓骨',
    arrow: 'tension-back',
    chain: '拉长性紧张'
  }
};

const SYMPTOMS = [
  { cn: '下腰部酸痛', en: 'Low back pain',          why: '竖脊肌持续高张力 → 劳损' },
  { cn: '小腹凸出',   en: 'Lower-belly pooch',       why: '骨盆前倾推内脏前移 + 腹肌弱' },
  { cn: '臀部扁平',   en: 'Flat glutes',             why: '臀大肌长期被神经抑制萎缩' },
  { cn: '膝关节超伸', en: 'Knee hyperextension',     why: '重心代偿性后移以平衡躯干' },
  { cn: '走路腰发紧', en: 'Walking tightness',       why: '伸髋受限，腰肌额外做功' },
  { cn: '肩颈代偿前引', en: 'Forward head posture',  why: '链式代偿向上传递' }
];

const CAUSES = [
  { cn: '长期久坐',         en: 'Sedentary',         icon: 'chair' },
  { cn: '高跟鞋习惯',       en: 'High heels',        icon: 'heel' },
  { cn: '产后核心未恢复',   en: 'Postpartum',        icon: 'preg' },
  { cn: '核心力量不足',     en: 'Weak core',         icon: 'core' },
  { cn: '臀肌失忆症',       en: 'Gluteal amnesia',   icon: 'glute' },
  { cn: '过度训练腰背',     en: 'Over-training',     icon: 'back' }
];

const EXERCISES = {
  stretch: [
    { cn: '弓步髋屈肌拉伸',   en: 'Hip-flexor lunge',  target: '髂腰肌',     dose: '每侧 30s × 3' },
    { cn: '股四头肌站姿拉伸', en: 'Standing quad',     target: '股直肌',     dose: '每侧 30s × 3' },
    { cn: '猫驼式背部松动',   en: 'Cat–camel',         target: '腰竖脊肌',   dose: '10 次 × 2' }
  ],
  activate: [
    { cn: '臀桥',     en: 'Glute bridge',  target: '臀大肌',   dose: '12 × 3' },
    { cn: '死虫',     en: 'Dead bug',      target: '腹横肌',   dose: '10/侧 × 3' },
    { cn: '蚌式开合', en: 'Clamshell',     target: '臀中肌',   dose: '15/侧 × 3' }
  ]
};

Object.assign(window, {
  STATES, STATE_INFO, STATE_STYLE,
  MUSCLES, MUSCLES_ORDER,
  SYMPTOMS, CAUSES, EXERCISES,
});
