(() => {
  "use strict";
  const modules = [
    { code: "01", tone: "#1565c0", title: "流量计算", description: "设计洪水、经验公式、单位线与洪水合成", items: [
      ["1-02", "铁一两所法设计洪水"], ["1-09", "中小河流经验公式法"], ["1-11", "水文面积比拟法"], ["1-12", "双对数内插法"], ["1-06", "洪水过程线合成"], ["1-03", "地区经验公式洪峰流量"], ["1-04", "瞬时单位线法"], ["1-05", "推理公式法"]
    ]},
    { code: "02", tone: "#16804a", title: "水位计算", description: "断面水位、能量方程、堰流、波浪与风壅", items: [
      ["4-02", "曼宁公式水位与水位流量关系"], ["4-03", "能量方程与 HEC 标准步法"], ["4-01", "多断面水面线推求"], ["7-02", "堰流公式水位"], ["4-04", "波浪高度计算"], ["4-05", "风壅水位计算"]
    ]},
    { code: "03", tone: "#087f87", title: "桥孔计算", description: "桥孔净宽初值与桥位过流能力", items: [
      ["3-25", "桥孔最小净长度计算"], ["7-09", "桥孔水力"], ["3-17", "净空校核"]
    ]},
    { code: "04", tone: "#5d7f24", title: "河道演变", description: "河相关系、稳定河宽、稳定系数与冲淤判别", items: [
      ["3-23", "河道演变分析"], ["3-09", "河道流量估算"], ["3-10", "河道治导线宽度"]
    ]},
    { code: "05", tone: "#c06a13", title: "壅水计算", description: "阻水比、桥前壅水与回水影响范围", items: [
      ["3-15", "阻水比/过水面积压缩比计算"], ["3-16", "桥前壅水计算"], ["3-14", "壅水曲线与上游回水影响"]
    ]},
    { code: "06", tone: "#7447b4", title: "冲刷计算", description: "规范分项冲刷、一般局部冲刷与基础安全", items: [
      ["3-24", "规范分项冲刷计算"], ["3-13", "一般冲刷 + 局部冲刷计算"], ["3-12", "基础埋深安全"]
    ]}
  ];
  const esc = (value) => String(value).replace(/[&<>"']/g, (char) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[char]));
  document.querySelector("#classic-module-grid").innerHTML = modules.map((module) => `
    <section class="specialty" style="--tone:${module.tone}">
      <header class="specialty-header"><span class="specialty-code">${module.code}</span><div><h2>${esc(module.title)}</h2><p>${esc(module.description)}</p></div></header>
      <nav class="program-list" aria-label="${esc(module.title)}程序">
        ${module.items.map(([id, name]) => `<a class="program-link" href="${id.toLowerCase()}.html"><span class="program-id">${esc(id)}</span><span class="program-name">${esc(name)}</span></a>`).join("")}
      </nav>
      <p class="note">每项均独立录入、计算和导出；本分类不形成前置流程约束。</p>
    </section>`).join("");
})();
