#!/usr/bin/env python3
"""HTML 自适应契约：窄屏换布局，不删混音台能力。"""
from pathlib import Path


def main():
    root = Path(__file__).parents[1]
    html = (root / "index.html").read_text(encoding="utf-8")
    js = (root / "app.js").read_text(encoding="utf-8")
    required = (
        'name="viewport" content="width=device-width, initial-scale=1.0"',
        "html { min-width: 320px;",
        "@media (max-width: 1180px)",
        "@media (max-width: 920px)",
        "@media (max-width: 720px)",
        "@media (max-width: 560px)",
        ".channel { min-height: 128px; flex-direction: column; }",
        ".ch-controls { flex-wrap: wrap;",
        ".ch-vol { order: 10; flex: 1 1 120px; width: auto;",
        ".btn:focus-visible, .t-btn:focus-visible",
        'class="file-input"',
        ".dropzone:focus-within",
        "v1.6.0",
    )
    missing = [rule for rule in required if rule not in html]
    assert not missing, f"missing responsive contracts: {missing}"
    assert ".ch-vol { display: none; }" not in html
    assert "els.dropzone.addEventListener('click'" not in js
    assert "els.dropzone.addEventListener('keydown'" not in js
    assert "e.code !== 'Space'" in js
    assert "空格 播放/暂停" in js
    assert "aria-pressed" in js
    assert 'data-profile="vocal"' in html
    assert 'data-profile="stems6"' in html
    for rejected in ('data-profile="stems4"', "拆成6轨", "/api/refine",
                     'id="btn-zip"', "扒谱重建", "音色细拆"):
        assert rejected not in html + js, f"rejected old workflow remains: {rejected}"
    print("RESPONSIVE_LAYOUT: PASS (desktop/laptop/narrow-screen contracts present)")


if __name__ == "__main__":
    main()
