# -*- coding: utf-8 -*-
"""英語の論文を読む（ショート専用・舞台型・2026-11-07）
エイイチの言葉: 英語は「ほんと全然」できない／英語が混ざっていてわからない
事実: 調査メモ（research/）と原文の PDF（research/pdf/）は同じ名前で置く（MASTER の保存先テーブル）。例は AIRoA-0 の調査（2026-11-06）"""
from butai_parts import *
OUTRO_K = 5

NAME, VER = "英語の論文を読む", 3
HEAD = "英語の論文<br>読めない？"
T_ON = (0, 0.9)


def paper(left, top, w, h, n, t0, step=0.04, col="#3A4558", lw=None):
    """英語の論文の行（細かい灰色の帯がびっしり並ぶ）"""
    import random
    random.seed(left + top)
    out = ""
    for k in range(n):
        ww = lw or random.randint(int(w * .55), w)
        out += (f'<div style="position:absolute;left:{left}px;top:{top + k * (h // n)}px;width:{ww}px;height:{max(6, h // n - 10)}px;border-radius:4px;background:{col};'
                f'opacity:0;animation:{a("show", t0 + k * step, .1)}"></div>')
    return out


def scene(T, S):
    h = CSS
    # 0: 英語の論文（細かい行がびっしり）
    t0 = T(*T_ON)
    h += win(t0, T(1, 0), kick("論文（英語）")
             + f'<div class="card" style="left:150px;top:100px;width:600px;height:460px;justify-content:flex-start;padding-top:28px">'
               f'<span style="font-size:34px;letter-spacing:.02em">Abstract</span></div>'
             + paper(180, 180, 540, 360, 16, t0 + 0.2)
             + f'<div class="hero" style="right:40px;top:300px;font-size:260px;opacity:0;animation:{a("pop", T(0, S(0) - 0.6), .35)}">?</div>')
    # 1: 僕が読んで、日本語のメモにする（左の英語 → 右の日本語）
    t1, s1 = T(1, 0), S(1)
    h += win(t1, T(2, 0), kick("Claude が読む")
             + f'<div class="card" style="left:48px;top:150px;width:330px;height:380px;justify-content:flex-start;padding-top:20px"><small>原文</small></div>'
             + paper(74, 210, 280, 300, 12, t1, 0.0)
             + f'<div class="arrowR" style="left:404px;top:324px;opacity:0;animation:{a("show", t1 + 0.6, .2)}"></div>'
             + f'<div class="card or" style="left:452px;top:150px;width:400px;height:380px;justify-content:flex-start;padding-top:20px;opacity:0;animation:{a("pop", t1 + 1.0, .35)}">'
               f'<small>日本語のメモ</small>'
               f'<span style="font-size:38px;margin-top:22px;line-height:1.5">何がすごいのか<br>仕組みの要点<br>うちとの関係</span></div>')
    # 2: 原文の PDF も、メモと同じ名前で並べる
    t2, s2 = T(2, 0), S(2)
    def fcard(top, label, ext, d):
        return (f'<div class="card" style="left:48px;top:{top}px;width:804px;height:150px;opacity:0;animation:{a("inR", t2 + d)}">'
                f'<small>{label}</small><span style="font-size:42px">paper_<b style="color:{ORANGE}">airoa0_20261106</b>{ext}</span></div>')
    h += win(t2, T(3, 0), kick("置き方") + '<div class="msg" style="font-size:50px">メモと原文は、同じ名前</div>'
             + fcard(220, "メモ（research/）", ".md", 0.3) + fcard(392, "原文（research/pdf/）", ".pdf", s2 * 0.45))
    # 3: 英語が混ざってると、わからん（混ざった英語に線を引く）
    t3, s3 = T(3, 0), S(3)
    h += win(t3, T(4, 0), kick("エイイチの声")
             + f'<div class="card" style="left:48px;top:170px;width:804px;height:260px;font-size:46px;line-height:1.5">'
               f'<span>同じ重みが <span style="color:{ORANGE}">cross-embodiment</span> で<br>別のロボットでも動く</span></div>'
             + f'<div class="strike" style="left:300px;width:420px;top:262px;animation:{a("strike", t3 + 0.9, .3)}"></div>'
             + f'<div class="stamp" style="left:48px;top:460px;font-size:52px;animation:{a("slam", t3 + s3 - 0.9, .35)}">わからん</div>')
    # 4: メモは日本語だけで書く
    t4 = T(4, 0)
    h += win(t4, None, kick("だから")
             + f'<div class="card" style="left:48px;top:110px;width:804px;height:230px;font-size:46px;line-height:1.5;opacity:0;animation:{a("up", t4 + 0.3)}">'
               f'<span>同じ重みが、<span style="color:{ORANGE}">別のロボットでも</span><br>そのまま動く</span></div>'
             + f'<div class="msg" style="top:370px;font-size:72px;opacity:0;animation:{a("pop", t4 + 1.2, .4)}">日本語だけ</div>')
    h += outro(T, OUTRO_K)
    return h


def OVER(T):
    return stage_fx(T, shakes=[(T(3, 1.0), 0.5)], fx=[dict(kind="speed", t=T(3, 0.0), d=1.2), dict(kind="shine", t=T(4, 1.2), d=0.9)])


FACE = [(-1, 0.0, 1.0, "smile"), (1, 0.0, 2.5, "joy"), (3, 0.0, 2.3, "surprise"), (4, 0.0, 2.8, "joy"), ("end", 0.0, 3.0, "smile")]
POSE = [(-1, 0.0, 1), (0, 0.4, 3), (1, 0.0, 1), (3, 0.0, 2), (4, 0.6, 4)]
LEAN = []
INTRO = "drop"
MOVES = [(1, 0.3, "hop", 1.0), (3, 0.4, "back", 0.8), (4, 0.3, "spin", 1.0)]
SE = [(-1, 0.0, "se_whoosh", -9), (0, 0.9, "se_boot", -12), (0, 2.4, "se_pop", -12), (1, 1.0, "se_ding", -11),
      (2, 0.3, "se_whoosh", -13), (2, 1.6, "se_whoosh", -13), (3, 0.9, "se_pechin", -10), (3, 1.4, "se_buzz", -14),
      (4, 1.2, "se_ding", -9), (5, 0.0, "se_whoosh", -12)]
ENDING = dict(kind="jump", at=(4, 1.2))
