"""Events and merchandise (iShatat, 12 November 2026: "all seven, and with creativity").

The booth wall is the roll-up grown to a room: the question at eye height, the S rising from the floor, cut into the
black. The merchandise follows the patterns chapter to the letter: W2 on the tote and the tape, the S3 weave pressed
into the box lid, W1 on the tissue inside it, and one small S. on the chest of the tee, its question on the back.

Usage: python3 -I make_events_and_merch.py            (both)
       python3 -I make_events_and_merch.py booth-wall"""
import pathlib, sys
HERE = pathlib.Path(__file__).resolve().parent
sys.path.insert(0, str(HERE)); sys.path.insert(0, str(HERE.parents[1] / "brand-book/source"))
import make_templates as T
from make_templates import INK, GRAPHITE, NIGHT, PAPER, CARBON, template, wordmark, monogram, cut_s, family, spelled, line_and_point
from patterns import pattern_panel, name_pattern, s3_weave

MINE = []

def mine(key, *args, **kw):
    MINE.append(key)
    return template(key, *args, **kw)

@mine("booth-wall", "Booth wall", 3000, 2250, "An event wall, 3 × 2.25 m; print at full size from the PDF, nothing below 300 mm where tables and people stand", pdf="3000px 2250px")
def booth_wall():
    """One unit a millimetre. Eye height is about 1.5 m from the floor: the question sits there."""
    m = 168
    return f'''{cut_s(2100, -780, 760)}
<div style="position:absolute;left:{m}px;top:{m}px">{wordmark(INK, 620)}</div>
<div class="q" style="position:absolute;left:{m}px;top:560px;width:1500px;font-size:250px;color:{INK}">Made from<br>what if?</div>
<div style="position:absolute;left:{m}px;top:1160px">{line_and_point(420, GRAPHITE)}</div>
<div style="position:absolute;left:{m}px;top:1260px;width:1500px">{family(46)}</div>
<div class="label" style="position:absolute;left:{m}px;top:1420px;font-size:38px;color:{GRAPHITE}">{spelled("SHATATiON.com")}</div>'''

def clip(uid, shape, inner):
    return f'<clipPath id="{uid}">{shape}</clipPath><g clip-path="url(#{uid})">{inner}</g>'

def filled(w, h, ground, tone, words=None, word_w=0, marks=(), x=0, y=0):
    svg = pattern_panel(list(marks), w, h, ground, tone, f"m{x}{y}", words=words, word_w=word_w)
    return svg.replace("<svg ", f'<svg x="{x}" y="{y}" width="{w}" height="{h}" ', 1)

def tote():
    words, marks = name_pattern(340, 380, 120, True)
    body = '<path d="M20 90 H360 L340 470 H40 Z"/>'
    return (f'<g><path d="M120 92 V50 Q120 10 160 10 H220 Q260 10 260 50 V92" fill="none" stroke="#D3CCBD" stroke-width="14"/>'
            f'{clip("tote", body, filled(380, 400, "#E9E4D8", "#D3CCBD", words, 120, marks, 0, 80))}</g>')

def tee():
    shape = '<path d="M120 20 L170 0 Q200 34 230 0 L280 20 L380 84 L344 164 L300 142 L300 430 L100 430 L100 142 L56 164 L20 84 Z"/>'
    cloth = f'<rect width="400" height="440" fill="{NIGHT}"/>'
    chest = monogram(INK, 34)
    return f'<g>{clip("tee", shape, cloth)}<g transform="translate(236 96)">{chest}</g></g>'

def box():
    marks = s3_weave(360, 360, 150, 180, 180)
    lid = filled(360, 360, NIGHT, "#1C1D21", marks=marks, x=20, y=20)
    name = wordmark("#26272C", 150).replace("<svg ", '<svg x="125" y="190" ', 1)
    return f'<g><rect x="34" y="34" width="360" height="360" rx="6" fill="#050506"/>{lid}{name}</g>'

def tape():
    words, marks = name_pattern(300, 64, 100, True)
    strip = filled(300, 64, NIGHT, INK, words, 100, marks, 150, 226)   # unrolling from the bottom of the roll
    return (f'<g>{strip}<circle cx="150" cy="150" r="140" fill="{NIGHT}"/><circle cx="150" cy="150" r="138" fill="none" stroke="#2A2B30" stroke-width="2"/>'
            f'<circle cx="150" cy="150" r="62" fill="#C9B79A"/><circle cx="150" cy="150" r="48" fill="#1A1B1F"/></g>')

def item(drawing, x, y, title, words, scale=1):
    return (f'<g transform="translate({x} {y}) scale({scale})">{drawing}</g>'
            f'<text x="{x}" y="{y + 520}" class="t">{title}</text><text x="{x}" y="{y + 552}" class="w">{words}</text>')

@mine("merchandise", "Merchandise", 1920, 1080, "The tote, the tee, the box and the tape, each wearing the pattern the patterns chapter gives it")
def merchandise():
    return f'''<svg width="1920" height="1080" viewBox="0 0 1920 1080" style="position:absolute;inset:0">
<style>.t {{ font: 500 24px "Mona Sans", sans-serif; fill: {INK}; }} .w {{ font: 400 19px "Mona Sans", sans-serif; fill: {GRAPHITE}; }}</style>
<rect width="1920" height="1080" fill="#16171A"/>
{item(tote(), 80, 300, "The tote", "W2, tone on tone, on natural canvas")}
{item(tee(), 540, 300, "The tee", "One small S. on the chest; the question on the back")}
{item(box(), 1010, 300, "The box", "S3 pressed into the black lid; W1 tissue inside")}
{item(tape(), 1440, 300, "The tape", "W2 in Ink on black, unrolling")}
<text x="80" y="140" style="font: 400 54px 'Mona Sans', sans-serif; font-stretch: 112%" fill="{INK}">Things to hold.</text>
<text x="80" y="190" class="w">Each one wears one pattern, tone on tone, and never more than one point of colour.</text>
</svg>'''

if __name__ == "__main__":
    T.build(tuple(sys.argv[1:]) or tuple(MINE))
