# -*- coding: utf-8 -*-
"""Claude Codeへの頼み方（ショート専用・舞台型・2026-11-06）
エイイチの言葉: Claude Code への指示を自分で貼って渡す形はNG（2026-11-03）。依頼箱の決まりは 依頼箱/README.md"""
from butai_parts import *
OUTRO_K = 6   # 締めの文の番号（narration.py の最後に足した文）

NAME, VER = "Claude Codeへの頼み方", 4
HEAD = "Claude Code<br>どう頼む？"
T_ON = (0, 1.3)


def flow(names, t0, step, top=300, w=252, lit_all=False):
    out = ""
    for k, (nm, sm) in enumerate(names):
        an = f"animation:{a('on', t0 + k * step, .25)}" if t0 is not None else ""
        out += (f'<div class="card{" or" if lit_all else ""}" style="left:{48 + k * 276}px;top:{top}px;width:{w}px;height:170px;{an}">'
                f'<small>{sm}</small><span style="font-size:42px">{nm}</span></div>')
    return out


def scene(T, S):
    h = CSS
    # 0: まだ手で貼ってる？（ターミナルにコピー→貼り付け）
    t0 = T(0, 1.3)
    h += win(t0, T(1, 0), kick("いままで")
             + '<div class="card" style="left:48px;top:120px;width:804px;height:220px;background:#06090E;font-family:\'Noto Sans Mono CJK JP\',monospace;'
               'font-size:30px;font-weight:500;color:#6F7A8C;justify-content:flex-start;padding-top:30px;line-height:1.6">$ claude<br>&gt; （指示を貼り付け）</div>'
             + f'<div class="stamp" style="left:300px;top:380px;font-size:50px;animation:{a("slam", t0 + 0.5)}">コピー → 貼り付け</div>')
    # 1: 僕が依頼を書いて、依頼箱に置く
    t1 = T(1, 0)
    h += win(t1, T(2, 0), kick("いまは")
             + f'<div class="card or" style="left:330px;top:100px;width:240px;height:110px;font-size:40px;align-items:center;opacity:0;animation:{a("up", t1 + 0.3)}, {a("drop1", t1 + 1.3, .5, "ease-in")}">依頼</div>'
             + '<style>@keyframes drop1 { to { transform:translateY(220px) scale(.8); opacity:0; } }</style>'
             + '<div class="card" style="left:250px;top:300px;width:400px;height:220px;font-size:54px;align-items:center"><small>Claude が置く</small>依頼箱</div>')
    # 2: Mac の見張り係が、1件ずつ Claude Code に渡す
    t2, s2 = T(2, 0), S(2)
    h += win(t2, T(3, 0), kick("1件ずつ") + '<div class="msg" style="font-size:50px">見張り係が、自動で渡す</div>'
             + flow([("依頼箱", "置く"), ("見張り係", "Mac"), ("Claude Code", "作る")], t2 + 0.4, (s2 - 0.8) / 2))
    # 3: 判定つきで報告（合格・止めた・失敗）
    t3, s3 = T(3, 0), S(3)
    chips = "".join(f'<div class="card{" or" if k == 0 else ""}" style="left:{48 + k * 276}px;top:250px;width:252px;height:200px;font-size:52px;align-items:center;opacity:0;'
                    f'animation:{a("pop", t3 + 1.0 + k * 0.45, .3)}"><small>判定</small>{nm}</div>' for k, nm in enumerate(["合格", "止めた", "失敗"]))
    h += win(t3, T(4, 0), kick("終わったら") + '<div class="msg" style="font-size:50px">判定つきで報告</div>' + chips)
    # 4: 自分で貼って渡すのは、もうナシ
    t4, s4 = T(4, 0), S(4)
    h += win(t4, T(5, 0), kick("エイイチの決まり")
             + '<div class="card" style="left:120px;top:180px;width:660px;height:200px;font-size:58px;align-items:center;color:#8A93A3">自分で貼って渡す</div>'
             + f'<div class="strike" style="left:100px;width:700px;top:275px;animation:{a("strike", t4 + 1.4, .35)}"></div>'
             + f'<div class="stamp" style="left:330px;top:400px;font-size:64px;animation:{a("slam", t4 + 1.8)}">ナシ</div>')
    # 5: ただし、実機を動かす依頼は確認待ちで止める
    t5 = T(5, 0)
    h += win(t5, None, kick("ただし")
             + f'<div class="card" style="left:48px;top:150px;width:390px;height:300px;font-size:44px;opacity:0;animation:{a("up", t5 + 0.3)}"><small>ふだんの依頼</small>自動で回す</div>'
             + f'<div class="card or" style="left:462px;top:150px;width:390px;height:300px;font-size:44px;opacity:0;animation:{a("up", t5 + 1.2)}"><small>実機を動かす依頼</small>確認待ちで<br>止める</div>')
    h += outro(T, OUTRO_K)   # 締め：サイトへの入口
    return h


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


FACE = [(-1, 0.0, 1.0, "smile"), (1, 0.0, 2.7, "joy"), (3, 0.0, 4.9, "smile"), (4, 0.0, 2.6, "surprise"), (5, 0.0, 3.0, "wink"), ("end", 0.0, 3.0, "smile")]
POSE = [(-1, 0.0, 2), (1, 0.0, 1), (3, 1.0, 3), (4, 0.0, 2), (5, 0.3, 1)]
LEAN = []
INTRO = "rise"
MOVES = [(1, 0.3, "hop", 1.0), (2, 0.4, "dash", 1.0), (3, 1.0, "jump", 1.0), (5, 0.4, "tilt", 1.2)]
SE = [(-1, 0.0, "se_rise", -9), (0, 1.3, "se_boot", -12), (0, 1.8, "se_pechin", -10), (1, 0.0, "se_whoosh", -12), (1, 1.3, "se_pop", -9),
      (2, 0.0, "se_whoosh", -12), (2, 0.4, "se_tick", -12), (2, 2.0, "se_tick", -12), (2, 3.6, "se_tick", -12),
      (3, 0.0, "se_whoosh", -12), (3, 1.0, "se_ding", -10), (4, 0.0, "se_whoosh", -12), (4, 1.8, "se_pechin", -7), (5, 0.0, "se_whoosh", -12)]
ENDING = dict(kind="jump", at=(4, 1.8))
