# -*- coding: utf-8 -*-
"""別のAIに疑わせる（ショート専用・舞台型・2026-11-06）
エイイチの言葉: codex に任せると、ただのニュースのようになってしまう（2026-10-28）／最終判断はエイイチ（MASTER）"""
from butai_parts import *
OUTRO_K = 6   # 締めの文の番号（narration.py の最後に足した文）

NAME, VER = "別のAIに疑わせる", 4
HEAD = "AIの間違い<br>誰が見つける？"
T_ON = (0, 1.3)


def script_card(left, top, w, t, label="台本", n=5):
    ln = "".join(f'<div class="line" style="left:{left + 30}px;top:{top + 70 + k * 44}px;width:{ww}px;transform-origin:left;transform:scaleX(0);animation:{a("grow", t + 0.12 * k, .3)}"></div>'
                 for k, ww in enumerate([w - 90, w - 140, w - 70, w - 160, w - 110][:n]))
    return f'<div class="card" style="left:{left}px;top:{top}px;width:{w}px;height:{90 + n * 44}px;justify-content:flex-start;padding-top:20px"><small>{label}</small></div>' + ln


def scene(T, S):
    h = CSS
    # 0: AI が書いた台本
    h += win(T(0, 1.3), T(1, 0), kick("AIが書いた台本") + script_card(250, 130, 400, T(0, 1.35)))
    # 1: 別のAIに、1文ずつ疑わせる（右に疑う役。行を順に照らす）
    t1, s1 = T(1, 0), S(1)
    scan = "".join(f'<div style="position:absolute;left:62px;top:{186 + k * 44}px;width:330px;height:30px;border-radius:6px;background:{ORANGE};opacity:0;'
                   f'animation:{a("show", t1 + 0.6 + k * 0.4, .1)}, {a("hide", t1 + 0.95 + k * 0.4, .1)}"></div>' for k in range(5))
    h += win(t1, T(2, 0), kick("1文ずつ") + scan + script_card(48, 130, 380, t1 - 1, "Claude が書く")
             + f'<div class="card or" style="left:480px;top:200px;width:372px;height:200px;font-size:46px;opacity:0;animation:{a("pop", t1 + 0.3, .35)}"><small>別のAIが</small>疑う</div>')
    # 2: 数字の出どころ・言い過ぎ・引用の原文
    t2 = T(2, 0)
    rows = [("ok", "数字の出どころ"), ("ng", "言い過ぎ"), ("ok", "引用の原文")]
    h += win(t2, T(3, 0), kick("見るところ") + "".join(
        f'<div class="chk{" ng" if c == "ng" else ""}" style="top:{150 + k * 110}px;height:90px;font-size:42px;animation:{a("up", t2 + 0.3 + k * 0.7)}"><i>{"✕" if c == "ng" else "✓"}</i>{tx}</div>'
        for k, (c, tx) in enumerate(rows)))
    # 3: codex に任せると、ただのニュースみたいになる
    t3, s3 = T(3, 0), S(3)
    news = ("〇〇社は、新しいロボットを発表しました。<br>価格は未定で、来年の発売を目指すとしています。<br>専門家は、今後の普及に期待を寄せています。")
    h += win(t3, T(4, 0), kick("codex に台本を任せると")
             + f'<div class="card" style="left:48px;top:130px;width:804px;height:280px;font-size:32px;font-weight:700;line-height:1.7;color:{DIM}">{news}</div>'
             + f'<div class="stamp" style="left:420px;top:410px;font-size:52px;animation:{a("slam", t3 + s3 - 1.2)}">ただのニュース</div>')
    # 4: codex は事実確認だけ。話の筋は変えない
    t4, s4 = T(4, 0), S(4)
    h += win(t4, T(5, 0), kick("だから")
             + f'<div class="card or" style="left:48px;top:150px;width:390px;height:300px;font-size:52px;opacity:0;animation:{a("up", t4 + 0.4)}"><small>codex に任せる</small>事実確認</div>'
             + f'<div class="card" style="left:462px;top:150px;width:390px;height:300px;font-size:52px;opacity:0;animation:{a("up", t4 + s4 - 2.2)}"><small>変えない</small>話の筋</div>')
    # 5: 最後に決めるのは、オレ
    t5 = T(5, 0)
    h += win(t5, None, kick("最後に決めるのは")
             + f'<div class="stamp" style="left:0;right:0;margin:auto;width:520px;text-align:center;top:200px;font-size:110px;padding:20px 0;animation:{a("slam", t5 + 0.4)}">エイイチ</div>')
    h += outro(T, OUTRO_K)   # 締め：サイトへの入口
    return h


def OVER(T):
    return stage_fx(T, fx=[dict(kind="spot", t=T(5, 0.2), d=3.0, x=690)])


FACE = [(-1, 0.0, 1.0, "smile"), (1, 0.0, 2.6, "joy"), (2, 0.0, 3.4, "think"), (3, 0.0, 3.6, "trouble"), (4, 0.0, 4.6, "wink"), ("end", 0.0, 3.0, "smile")]
POSE = [(-1, 0.0, 1), (1, 0.0, 2), (3, 0.0, 1), (4, 0.0, 2), (5, 0.3, 4)]
LEAN = []
INTRO = "spin"
MOVES = [(1, 0.3, "hop", 1.0), (2, 0.4, "tilt", 1.2), (3, 2.4, "back", 1.0), (5, 0.4, "spin", 1.0)]
SE = [(-1, 0.0, "se_spin", -10), (0, 1.3, "se_boot", -12), (1, 0.3, "se_pop", -10)] + [(1, 0.6 + k * 0.4, "se_tick", -14) for k in range(5)] + [
      (2, 0.0, "se_whoosh", -12), (2, 0.3, "se_ding", -13), (2, 1.0, "se_buzz", -12), (2, 1.7, "se_ding", -13),
      (3, 0.0, "se_whoosh", -12), (3, 2.46, "se_pechin", -9), (4, 0.0, "se_whoosh", -12), (5, 0.4, "se_pechin", -6), (5, 0.4, "se_jaran", -11)]
ENDING = dict(kind="jump", at=(5, 0.4))
