# -*- coding: utf-8 -*-
import io, sys, os
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")

CSS = """<style>
:root{--bg:#f7f8fa;--card:#fff;--line:#e5e7eb;--ink:#1f2329;--mut:#6b7280;--pri:#1d4ed8;--tag:#eef2ff;}
*{box-sizing:border-box}body{margin:0;font-family:-apple-system,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;background:var(--bg);color:var(--ink);line-height:1.6}
.wrap{max-width:980px;margin:0 auto;padding:24px}
.crumb{font-size:13px;color:var(--mut);margin-bottom:12px}
.crumb a{color:var(--pri);text-decoration:none}
.card{background:var(--card);border:1px solid var(--line);border-radius:10px;padding:20px 24px;margin-bottom:16px}
h1{font-size:22px;margin:0 0 6px}
h2{font-size:15px;margin:0 0 10px;color:var(--pri)}
.chips{margin:8px 0 0}
.chip{display:inline-block;background:var(--tag);color:var(--pri);border-radius:999px;padding:2px 10px;font-size:12px;margin-right:6px}
.kv{display:grid;grid-template-columns:110px 1fr;row-gap:6px;font-size:14px}
.kv .k{color:var(--mut)}
ul{margin:6px 0 0;padding-left:20px}
.note{background:#fffbeb;border:1px solid #fde68a;border-radius:8px;padding:10px 14px;font-size:13px;color:#92400e}
.back{display:inline-block;margin-top:8px;color:var(--pri);text-decoration:none;font-size:14px}
</style>"""

def build(school_cn, school_en, crumb, title, h1, deg_chip, disc_chip, college_chip, dept, url, ddl, lang, test, tui, core_items, elect_items, note):
    core = "".join(f"<li>{x}</li>" for x in core_items)
    elec = "".join(f"<li>{x}</li>" for x in elect_items) if elect_items else "<li>待补</li>"
    return f"""<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><title>{title}</title>{CSS}</head><body><div class="wrap">
<div class="crumb"><a href="../index_main.html">项目库</a> / {crumb}</div>
<div class="card">
<h1>{h1}</h1>
<div class="chips"><span class="chip">{deg_chip}</span><span class="chip">{disc_chip}</span><span class="chip">{college_chip}</span></div>
</div>
<div class="card"><h2>学位与院系</h2><div class="kv">
<div class="k">学校</div><div>{school_cn}（{school_en}）</div>
<div class="k">院系</div><div>{dept}</div>
<div class="k">学位</div><div>{deg_chip}</div>
<div class="k">官网</div><div><a href="{url}" target="_blank">{url}</a></div>
</div></div>
<div class="card"><h2>申请截止 / 语言 / 标化 / 学费</h2><div class="kv">
<div class="k">截止</div><div>{ddl}</div>
<div class="k">语言</div><div>{lang}</div>
<div class="k">标化</div><div>{test}</div>
<div class="k">学费</div><div>{tui}</div>
</div></div>
<div class="card"><h2>核心要求</h2><ul>{core}</ul></div>
<div class="card"><h2>选修 / 方向</h2><ul>{elec}</ul></div>
<div class="card"><h2>说明</h2><div class="note">{note}</div></div>
<a class="back" href="../index_main.html">← 返回项目库</a>
</div></body></html>"""

pages = []

# 1 Asian and Middle Eastern Studies MA（覆盖占位）
pages.append(("details/unc-asian-and-middle-eastern-studies-ms.html", build(
    "北卡教堂山", "UNC Chapel Hill", "北卡教堂山 / 亚洲与中东研究系 / 亚洲与中东研究",
    "UNC Asian and Middle Eastern Studies MA", "亚洲与中东研究硕士（MA）",
    "MA", "社科", "文理学院",
    "Asian and Middle Eastern Studies 系",
    "https://catalog.unc.edu/graduate/schools-departments/asian-studies/",
    "Graduate School 统一截止，待补",
    "Graduate School 统一要求，待补",
    "Graduate School 统一要求，待补",
    "Graduate School 统一要求，待补",
    ["2年制跨学科人文硕士",
     "两个 track：interdisciplinary track（跨学科）/ Chinese track（中文）",
     "培养语言/文化/智识能力，面向 PhD 深造与政府/非营利/私营部门职业",
     "可与 professional degree（business/journalism/law/MPH/MPP/MSW）互补"],
    ["Arab World / Arabic", "China / Chinese", "South Asia / Hindi-Urdu", "Japan / Japanese", "Korea / Korean"],
    "UNC catalog 仅列项目描述与方向，具体学分数/截止/语言/GRE/学费未在本页公布，待补。录取分布非最低门槛。")))

# 2 Mathematics MA/MS（新建）
pages.append(("details/unc-mathematics-ma.html", build(
    "北卡教堂山", "UNC Chapel Hill", "北卡教堂山 / 数学系 / 数学",
    "UNC Mathematics MA/MS", "数学硕士（MA/MS）",
    "MA/MS", "理科", "文理学院",
    "Mathematics 系",
    "https://catalog.unc.edu/graduate/schools-departments/mathematics/",
    "Graduate School 统一截止，待补",
    "Graduate School 统一要求，待补",
    "Graduate School 统一要求，待补",
    "Graduate School 统一要求，待补",
    ["提供 MA / MS / PhD 三种学位",
     "硕士学位可作为 PhD 项目的一部分，也可独立攻读",
     "正常课载：每学期 3 门课（9 学分）",
     "研究生课程须 600 -level 及以上",
     "系里提供 TA / teaching fellowship，学校层面另有 fellowship"],
    ["Pure Mathematics", "Applied Mathematics", "Probability", "Statistics", "Mathematical Physics"],
    "UNC catalog 仅列项目描述与课载，具体学分数/截止/语言/GRE/学费未在本页公布，待补。录取分布非最低门槛。")))

# 3 Classics MA（新建）
pages.append(("details/unc-classics-ma.html", build(
    "北卡教堂山", "UNC Chapel Hill", "北卡教堂山 / 古典学系 / 古典学",
    "UNC Classics MA", "古典学硕士（MA）",
    "MA", "人文艺术", "文理学院",
    "Classics 系",
    "https://catalog.unc.edu/graduate/schools-departments/classics/",
    "Graduate School 统一截止，待补",
    "Graduate School 统一要求，待补",
    "Graduate School 统一要求，待补",
    "Graduate School 统一要求，待补",
    ["MA 方向：Greek and Latin（希腊拉丁）或 Classical Archaeology（古典考古）",
     "PhD 方向：classical philology / classics with historical emphasis / classical archaeology",
     "学校是 American Academy in Rome / American School of Classical Studies at Athens 等机构成员",
     "提供考古田野与研究机会"],
    ["Classical Archaeology", "Greek", "Latin", "Classical Civilization", "Ancient History"],
    "UNC catalog 仅列项目方向与机构资源，具体学分数/截止/语言/GRE/学费未在本页公布，待补。录取分布非最低门槛。")))

# 4 Sociology MA（新建）
pages.append(("details/unc-sociology-ma.html", build(
    "北卡教堂山", "UNC Chapel Hill", "北卡教堂山 / 社会学系 / 社会学",
    "UNC Sociology MA", "社会学硕士（MA）",
    "MA", "社科", "文理学院",
    "Sociology 系",
    "https://catalog.unc.edu/graduate/schools-departments/sociology/",
    "Graduate School 统一截止，待补",
    "Graduate School 统一要求，待补",
    "Graduate School 统一要求，待补",
    "Graduate School 统一要求，待补",
    ["提供 MA / PhD 学位",
     "核心课：sociological theory / research methods / statistics / substantive areas",
     "强调理论、方法与实质知识的整合",
     "研究方向：demography / migration / health / stratification / political sociology / research methods / labor",
     "前 5 年资助：TA / RA / nonservice fellowship"],
    ["Demography and Population", "Migration", "Health", "Stratification and Inequality", "Political Sociology", "Research Methods", "Labor and Complex Organizations"],
    "UNC catalog 仅列项目描述与方向，具体学分数/截止/语言/GRE/学费未在本页公布，待补。系里与 Carolina Population Center / Odum Institute 关联，编辑 Social Forces 期刊。录取分布非最低门槛。")))

# 5 Geography MA（新建）
pages.append(("details/unc-geography-ma.html", build(
    "北卡教堂山", "UNC Chapel Hill", "北卡教堂山 / 地理与环境系 / 地理",
    "UNC Geography MA", "地理硕士（MA）",
    "MA", "社科", "文理学院",
    "Geography and Environment 系",
    "https://catalog.unc.edu/graduate/schools-departments/geography/",
    "Graduate School 统一截止，待补",
    "Graduate School 统一要求，待补",
    "Graduate School 统一要求，待补",
    "Graduate School 统一要求，待补",
    ["提供研究生学位（catalog 列 MA/PhD 方向）",
     "研究方向：人文地理 / 自然地理 / GIS / 环境研究",
     "系里与 Carolina Population Center / Odum Institute 等研究中心关联"],
    ["Human Geography", "Physical Geography", "GIS", "Environmental Studies", "Urban Geography"],
    "UNC catalog 系页 200 可达但具体硕士要求段需进一步提取；具体学分数/截止/语言/GRE/学费未在本页公布，待补。录取分布非最低门槛。")))

for path, html in pages:
    open(path, "w", encoding="utf-8").write(html)
    print("WRITTEN", path, len(html))
