"""The merchandise catalogue (iShatat, 12 November 2026: the first board was "very poor"; they asked for at least two
colourways, far more pieces, named materials, and the whole language: the name across and on its side, the S., the
four points, the patterns, the cut S, the line and its point, the tagline).

Every piece is drawn in Night with Ink and in Paper with Carbon, and its label names the material and the finish.
The boards go to templates/merchandise/, their masters to templates/source/pages/merchandise/.

Usage: python3 -I make_merch.py            (every board)
       python3 -I make_merch.py tee        (only the named ones, so the others are not re-recorded)"""
import pathlib, subprocess, sys
HERE = pathlib.Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
import make_templates as T
from merch_drawing import *
import merch_wear as W
from merch_photo import photographed, shot, detail
import merch_carry as C
import merch_desk as D
import merch_give as G
import merch_place as L

OUT = HERE.parent / "merchandise"
PAGES = HERE / "pages" / "merchandise"
BOARDS = []
NI, PC = (NIGHT, INK), (PAPER, CARBON)          # the two colourways, as swatches
ORANGE = "#FF7A1A"            # the Studio's orange, here as a whole colourway with black: the Orange Edition
DYE = "#FF7F22"               # the dye that turns the pale things of the photographs into that orange
OB, BO = (ORANGE, CARBON), (NIGHT, ORANGE)

def a_board(key, title):
    def add(build):
        BOARDS.append((key, title, build))
        return build
    return add

BLACK_TEE = dict(gain=5.5, lift=.25, mid=.1, k=3.0)      # how a black cloth's light is carried into the ink
ECRU_TEE = dict(gain=1.12, lift=.02, mid=.84, k=2.2)
BLACK_GHOST = dict(gain=4.6, lift=.2, mid=.13, k=3.0, bend=7)
ECRU_GHOST = dict(gain=1.15, lift=.02, mid=.8, k=2.2, bend=7)

def photo(svg, x, y, side=432):
    """A photograph on the board, square, with a hair of light on its edge."""
    return at(svg, x, y, side / 1024) + f'<rect x="{x + .5}" y="{y + .5}" width="{side - 1}" height="{side - 1}" fill="none" stroke="#fff" stroke-opacity=".06"/>'

def turned(svg, angle, cx, cy):
    return f'<g transform="rotate({angle} {cx} {cy})">{svg}</g>'

def neck_label(ground, mark):
    """The woven label inside the back neck: the S., nothing else."""
    return f'<rect x="486" y="149" width="52" height="34" fill="{ground}"/>' + S(mark, 510, 166, 17)

def tee_front_s(ink, label=(INK, CARBON), **light):
    return dict(art=neck_label(*label) + embroidered(S(ink, 626, 322, 42)), **light)

def tees(ink_on_black=INK, ink_on_pale=CARBON, dye=None, tone_s="#3E3F45"):
    """The four tee photographs, front and back in each cloth. dye turns the pale cloth into a colour."""
    pale = dict(tint=dye, **ECRU_GHOST) if dye else ECRU_GHOST
    night_front = photographed("tee black ghost front.png", neck_label(INK, CARBON) + embroidered(S(ink_on_black, 626, 322, 42)), **BLACK_GHOST)
    night_back = photographed("tee black ghost back.png", tagline(ink_on_black, 512, 200, 13, "middle") + puff(cut_S(tone_s, 512, 726, 380)),
                              clip='<rect x="0" y="0" width="1024" height="886"/>', **BLACK_GHOST)
    pale_front = photographed("tee ecru ghost front.png", neck_label(CARBON, INK) + name(ink_on_pale, 512, 330, 290), **pale)
    pale_back = photographed("tee ecru ghost back.png", question(ink_on_pale, 330, 290, 52) + line_point(ink_on_pale, 330, 392, 136, weight=3), **pale)
    return night_front, night_back, pale_front, pale_back

def hoodie_night(ink=INK):
    return photographed("hoodie black ghost.png", embroidered(S(ink, 640, 392, 38)) + puff(turned(name(ink, 803, 590, 310), 86.4, 803, 590)), **BLACK_GHOST)

def hoodie_pale(ink=CARBON, dye=None, quiet="#A9A69B", sleeve_name=False):
    pale = dict(tint=dye, **ECRU_GHOST) if dye else ECRU_GHOST
    sleeve = (puff(turned(name(ink, 246, 600, 310), 92.1, 246, 600)) if sleeve_name
              else puff(at(turned(line_point(quiet, 0, 0, 300, weight=7, r=10), 92.1, 0, 0), 254, 420)))
    chest = embroidered(S(ink, 640, 392, 38)) if sleeve_name else embroidered(four_points(ink, 628, 392, 17, 11))
    return photographed("hoodie ecru ghost.png", chest + sleeve, **pale)

def cap_night(ink="#46474C"):
    return photographed("cap black.png", embroidered(S(ink, 506, 400, 120)), **BLACK_TEE)

def cap_pale(ink=CARBON, dye=None):
    return photographed("cap ecru.png", embroidered(S(ink, 510, 400, 120)), **(dict(tint=dye, **ECRU_TEE) if dye else ECRU_TEE))


@a_board("hoodie-cap", "to wear, the hoodie and the cap")
def hoodie_board():
    return spread("MERCHANDISE · TO WEAR", "The hoodie and the cap.", "The name runs down one sleeve, the way it runs down a spine. The cap carries the S. and nothing else.", "02",
                  hoodie_night(), (hoodie_pale(), cap_night(), cap_pale()), [
        ("Hoodie · Night", "480 gsm brushed-back cotton fleece, garment dyed", "The S. embroidered on the chest. The name on its side down the left sleeve, Ink puff print. Brushed steel cord ends.", NI),
        ("Hoodie · Paper", "480 gsm brushed-back cotton fleece, undyed ecru", "The four points embroidered in Carbon. The line and its point down the right sleeve, tone on tone puff.", PC),
        ("Cap · Night", "Washed cotton twill, six panels, unstructured", "The S. in raised embroidery, tone on tone, centred on the front seam.", NI),
        ("Cap · Paper", "Washed cotton twill, six panels, unstructured", "The S. in raised embroidery, Carbon thread.", PC)])

DARK = dict(gain=4.6, lift=.2, mid=.13, k=3.0, bend=5)       # ink on a black thing in a photograph
PALE = dict(gain=1.15, lift=.02, mid=.8, k=2.2, bend=5)      # ink on a pale thing
HARD_DARK, HARD_PALE = dict(DARK, bend=0), dict(PALE, bend=0)  # board, glaze, lacquer: nothing bends
KRAFT_LIGHT = dict(gain=1.7, lift=.05, bend=0)
SILVER = "#C4C5C8"

def rect(x0, y0, x1, y1):
    return f'<rect x="{x0}" y="{y0}" width="{x1 - x0}" height="{y1 - y0}"/>'

def field(kind, x0, y0, x1, y1, name_w, centre=None):
    """A pattern in black over a rectangle of a photograph, to be pressed in or laid on faintly."""
    return pattern(kind, x0, y0, x1 - x0, y1 - y0, "none", "#000000", name_w, centre=centre)

def faint(art, colour_opacity):
    return f'<g opacity="{colour_opacity}">{art}</g>'

def scarves_photo():
    weave_n = f'<g style="filter:invert(1)">{field("S3", 180, 135, 480, 835, 130, (150, 560))}</g>'
    weave_p = field("S3", 545, 135, 845, 835, 130, (150, 560))
    return shot("scarves.png", (faint(weave_n, .1), None, rect(182, 135, 478, 838)), (faint(weave_p, .1), None, rect(547, 135, 843, 838)),
                (name(INK, 330, 695, 130), DARK), (name(CARBON, 695, 695, 130), PALE))

def socks_photo():
    return shot("socks.png", (name(INK, 364, 340, 230, vertical=True), DARK), (line_point(CARBON, 650, 200, 250, weight=4, vertical=True), PALE))

@a_board("socks-scarf", "to wear, the scarf and socks")
def socks_board():
    return spread("MERCHANDISE · TO WEAR", "The scarf and socks.", "The scarf is the weave itself, S3 around the name. Socks are a small place for the name on its side, and for the line and its point.", "03",
                  scarves_photo(), (socks_photo(), detail(scarves_photo(), 695, 640, 2.4)), [
        ("Scarf · Night and Paper", "Merino lambswool, jacquard woven, 30 × 180 cm, hand-knotted fringe", "S3 woven tone on tone around the name: Ink on Night, Carbon on Paper.", NI + PC),
        ("Socks · Night and Paper", "Combed cotton, 200 needle, ribbed", "Night: the name on its side, knitted in Ink. Paper: the line and its point, knitted in Carbon.", NI + PC)])

def tote_night(ink=INK):
    return shot("tote black.png", (cut_S(ink, 512, 740, 420), DARK, rect(258, 395, 766, 916)))

def tote_natural(dye=None):
    if dye:
        return shot("tote natural.png", (cut_S(CARBON, 512, 740, 420), PALE, rect(258, 395, 766, 916)), tint=dye)
    return shot("tote natural.png", (faint(field("W2", 258, 400, 766, 916, 150), .22), None, rect(260, 400, 764, 914)))

def gift_bags(dye=None, ink_on_black="url(#whitefoil)"):
    return shot("gift bags orange.png" if dye else "gift bags.png", (foiled(name(ink_on_black, 294, 790, 220)), HARD_DARK if ink_on_black.startswith("#") else None),
                (name(CARBON, 731, 790, 220) if dye else four_points(CARBON, 727, 790, 30, 22), HARD_PALE))      # dyed: the photograph of the orange bag itself

def pouch_sleeve():
    return shot("pouch and sleeve.png", (name(INK, 610, 392, 130), DARK), (pressed(name("#000000", 690, 846, 170), "night", .75), None))


def notebooks(dye=None, ink_on_black="url(#whitefoil)"):
    black_name = foiled(name(ink_on_black, 262, 510, 140))
    return shot("notebooks.png", (pressed(field("S3", 112, 236, 412, 784, 140), "night", .7), None, rect(114, 238, 410, 782)),
                (black_name, HARD_DARK if ink_on_black.startswith("#") else None),
                (pressed(field("S3" if dye else "S4", 545, 236, 838, 784, 130, (146, 100) if not dye else None), "paper", .13 if not dye else .28), None, rect(547, 238, 836, 782)),
                (name(CARBON, 691, 336 if not dye else 510, 130), HARD_PALE), tint=dye, mask="light")

def mugs(dye=None, ink_on_black=INK):
    """Night and Paper; for a dyed pair, the photograph of the orange glaze itself: a white glaze lit evenly dyes flat."""
    return shot("mugs orange.png" if dye else "mugs.png", (S(ink_on_black, 342, 590, 110), HARD_DARK),
                (S(CARBON, 668, 590, 110) if dye else four_points(CARBON, 675, 590, 34, 22), HARD_PALE))

def coasters():
    def face(cx, kind):
        return f'<svg x="{cx - 190}" y="322" width="380" height="380" viewBox="0 0 380 380">{pattern(kind, 0, 0, 380, 380, "none", "#000000", 150)}</svg>'
    return shot("coasters.png", (pressed(face(287, "stars"), "night", .75), None, f'<circle cx="287" cy="512" r="184"/>'),
                (pressed(face(742, "fine"), "paper", .13), None, f'<circle cx="742" cy="512" r="186"/>'),
                (foiled(name("url(#whitefoil)", 287, 512, 150)), None), (name(CARBON, 742, 512, 150), HARD_PALE))


def pins_photo(dye=None):
    """The S. pins under the product points; dyed, the pale pin turns orange and the black one takes an orange S."""
    return shot("pins.png", (foiled(S(ORANGE if dye else "url(#steel)", 348, 763, 84, stroke=14)), None), (S(CARBON, 661, 768, 84, stroke=14), HARD_PALE), tint=dye, mask="pale", tint_clip='<circle cx="661" cy="768" r="120"/>')

def stickers_tile():
    st = (at(D.sticker(D.ROUND, NIGHT, S(INK, 44, 50, 44)), 0, 0, 1.1) + at(D.sticker(D.ROUND, PAPER, S(CARBON, 44, 50, 44), 8), 130, 14, 1.1)
          + at(D.sticker(D.BAR(250, 62), NIGHT, name(INK, 125, 31, 180), -4, 250, 62), 262, 10) + at(D.sticker(D.BAR(250, 62), PAPER, name(CARBON, 125, 31, 180), 3, 250, 62), 276, 96)
          + at(D.sticker(D.DIAMOND, INK, "", 0), 10, 150, .8) + at(D.sticker(D.SQUARE, INK, "", 6), 108, 164, .66) + at(D.sticker(D.SOFT, NIGHT, "", -8), 190, 176, .7)
          + at(D.sticker(D.SLIP(230, 110), PAPER, question(CARBON, 22, 46, 30), 2, 230, 110), 300, 190)
          + at(D.sticker(D.SLIP(230, 110), NIGHT, question(INK, 22, 46, 30), -3, 230, 110), 30, 290))
    return tile(at(st, 112, 200, 1.5))

@a_board("pins-stickers", "for the desk, pins, the key ring and stickers")
def pins_board():
    return spread("MERCHANDISE · FOR THE DESK", "Pins, key rings and stickers.", "The only colour in the collection lives here: five points, one for each product, in hard enamel.", "07",
                  pins_photo(), (shot("point pins.png"), shot("key rings.png"), shot("key ring name.png"), stickers_tile()), [
        ("The point pins · the products", "Hard enamel, 12 mm, black nickel, on a 350 gsm card", "Five points, one in each product's colour: 1210, SHETA, XXI, the Studio and Athar.", NI),
        ("Pin · the S.", "Hard enamel, 25 mm", "Night enamel with a polished steel S.; Paper enamel with the S. in Carbon.", NI + PC),
        ("The point pins · the four points", "Hard enamel, 12 mm, black nickel", "The diamond, the square, the soft square and the circle: Ink enamel on a Night card, Carbon on Paper.", NI + PC),
        ("Key ring · the S.", "3 mm stainless steel, laser cut: brushed, or black PVD", "The S. itself, cut from one sheet, its point held by a short neck.", ("#B9BABD", "#1B1C1F")),
        ("Key ring · the name", "2 mm stainless steel, laser cut: brushed, or black PVD", "The name cut in one piece, held by a slim rail along its top.", ("#B9BABD", "#1B1C1F")),
        ("Stickers", "Matte vinyl, die-cut, weatherproof", "The S., the name, the points and the question, each in both colourways.", NI + PC)])

def boxes(dye=None, ink_on_black="url(#whitefoil)"):
    black = [(pressed(field("S3", 85, 316, 480, 704, 170), "night", .7), None, rect(88, 319, 477, 701)),
             (foiled(name(ink_on_black, 282, 510, 170)), HARD_DARK if ink_on_black.startswith("#") else None)]
    pale = ([(pressed(field("S3", 545, 312, 940, 708, 170), "paper", .28), None, rect(548, 315, 937, 705)), (name(CARBON, 742, 510, 170), HARD_PALE)] if dye else
            [(pressed(cut_S("#000000", 742, 572, 310), "paper", .14), None, rect(548, 315, 937, 704)), (name(CARBON, 742, 352, 130), HARD_PALE)])
    return shot("boxes closed.png", *black, *pale, tint=dye, mask="light")

def box_open(dye=None):
    seal = f'<g filter="url(#sh-small)"><circle cx="517" cy="525" r="40" fill="{NIGHT}"/>{S(ORANGE if dye else INK, 513, 525, 36)}</g>'
    return shot("box open.png", (faint(field("W1", 232, 222, 792, 836, 150), .13 if not dye else .2), None, rect(236, 226, 788, 832)), (seal, None), tint=dye, mask="light")


WALL_DARK, WALL_PALE = dict(gain=5.2, lift=.34, bend=0), dict(gain=1.2, lift=0, bend=0)

def wall_night():
    return shot("wall night.png", (name(INK, 600, 380, 560) + tagline(GRAPHITE, 600, 452, 13, "middle"), WALL_DARK))

def wall_sign():
    """The name as a sign on the Night wall: letters cut from metal and stood off the wall, lit from behind, so the name
    stands dark in its own light. The light is Ink, never a colour."""
    blur = lambda key, by, gain: f'<filter id="{key}" x="-40%" y="-300%" width="180%" height="700%" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="{by}"/><feComponentTransfer><feFuncA type="linear" slope="{gain}"/></feComponentTransfer></filter>'
    cx, cy, w = 560, 392, 620
    halo = (f'<defs>{blur("signfar", 52, 5)}{blur("signnear", 16, 2.6)}{blur("signedge", 4, 1.4)}</defs>'
            f'<g filter="url(#signfar)" opacity=".55">{name(INK, cx, cy, w)}</g>'
            f'<g filter="url(#signnear)" opacity=".8">{name(INK, cx, cy, w)}</g>'
            f'<g filter="url(#signedge)" opacity=".95">{name("#FFFFFF", cx, cy, w)}</g>')
    letters = (f'<g transform="translate(1.6 2.4)">{name("#060607", cx, cy, w)}</g>'      # the letters' depth, seen from just below
               f'{name("#1A1B1E", cx, cy, w)}'
               f'<g opacity=".5" transform="translate(-.5 -.7)" style="mix-blend-mode:screen">{name("#2B2C31", cx, cy, w)}</g>')
    floor = f'<ellipse cx="{cx}" cy="905" rx="330" ry="34" fill="{INK}" opacity=".05" filter="url(#signfar)"/>'
    return shot("wall night.png", (halo + letters + floor, None))

def wall_paper():
    return shot("wall paper.png", (cut_S(CARBON, 720, 602, 500), WALL_PALE, rect(0, 0, 1024, 812)), (name(CARBON, 250, 200, 230), WALL_PALE))


def candles_bottles(dye=None):
    """Night and Paper; for a dyed pair, the photograph of the orange vessel and bottle themselves (see mugs)."""
    return shot("candles and bottles orange.png" if dye else "candles and bottles.png", (S("#6A6B70", 166, 748, 84), HARD_DARK), (S(CARBON, 398, 748, 84), HARD_PALE),
                (name(SILVER, 660, 630, 300, vertical=True), HARD_DARK), (name(CARBON, 860, 630, 300, vertical=True), HARD_PALE))

def pens_photo(dye=None):
    return shot("pens orange.png" if dye else "pens.png", (name(SILVER, 320, 428, 170), HARD_DARK), (name(CARBON, 320, 598, 170), HARD_PALE))      # dyed: the photograph of the orange pen itself

def candles_lit():
    """The orange pair with both candles burning."""
    return shot("candles and bottles orange lit.png", (S("#6A6B70", 166, 748, 84), HARD_DARK), (S(CARBON, 398, 748, 84), HARD_PALE),
                (name(SILVER, 660, 630, 300, vertical=True), HARD_DARK), (name(CARBON, 860, 630, 300, vertical=True), HARD_PALE))

def candles(dye=None, lit=False):
    """The candle on its own: Night and Paper, or Night and orange; unlit or burning. Each is its own photograph."""
    return shot("candles" + (" orange" if dye else "") + (" lit" if lit else "") + ".png", (S("#6A6B70", 296, 650, 130), HARD_DARK), (S(CARBON, 718, 650, 130), HARD_PALE))

def bottles(dye=None, apart=False):
    """The bottle on its own; apart, its cap, gasket and steel strainer stand above each body, the name still down its side."""
    x0, x1, y, length = (396, 649, 730, 270) if apart else (393, 651, 610, 330)
    return shot("bottles" + (" orange" if dye else "") + (" apart" if apart else "") + ".png",
                (name(SILVER, x0, y, length, vertical=True), HARD_DARK), (name(CARBON, x1, y, length, vertical=True), HARD_PALE))

def pens_apart(dye=None):
    """The pen taken apart: barrel, spring, refill, grip and cap; the name stays on the barrel."""
    return shot("pens orange apart.png" if dye else "pens apart.png", (name(SILVER, 240, 429 if dye else 427, 170), HARD_DARK),
                (name(CARBON, 240, 597 if dye else 593, 170), HARD_PALE))

def mugs_in_use(dye=None, ink_on_black=INK):
    return shot("mugs orange in use.png" if dye else "mugs in use.png", (S(ink_on_black, 342, 590, 110), HARD_DARK),
                (S(CARBON, 672, 590, 110) if dye else four_points(CARBON, 675, 590, 34, 22), HARD_PALE))

def notebook_open(dye=None):
    """The notebook open at its first page: the endpaper printed with the pattern, the S. alone on the page.
    Paper: S4 one step darker than the endpaper. Orange: S3 in orange on a black endpaper."""
    endpaper = '<rect x="118" y="240" width="386" height="550" rx="12"/>'
    lining = pattern("S3" if dye else "S4", 118, 240, 386, 550, "none", ORANGE if dye else "#000000", 120, top_name=ORANGE if dye else "#000000")
    return shot("notebook orange open.png" if dye else "notebook open.png", (faint(lining, .55 if dye else .13), None, endpaper),
                (S(CARBON, 712, 500, 46), HARD_PALE), (tagline(CARBON, 716, 748, 7, "middle"), HARD_PALE))

def xxi_tile():
    BX, CARD_N = "#0C0D0F", "#0E0F11"
    box = L.tuck_box(BX, at(L.xxi_back(INK), 4, 5))
    fan = "".join(L.playing_card(L.xxi_face(n, INK), CARD_N, turn=t) for n, t in zip(("I", "IX", "X", "XXI"), (-24, -8, 8, 24)))
    return tile(at(box, 110, 560, 1.7) + at(L.playing_card(L.xxi_back(INK), CARD_N), 390, 600, 1.5) + at(L.playing_card(L.xxi_face("X", CARBON), PAPER), 600, 600, 1.5)
                + at(fan, 420, 90, 2.0))


# ---------------------------------------------------------------- the Orange Edition (iShatat, 12 November 2026)

SPORT_NIGHT = dict(gain=4.2, lift=.22, mid=.13, k=3.0, bend=4)     # a matte technical knit: flatter light, smaller folds
SPORT_WHITE = dict(gain=1.05, lift=.02, mid=.84, k=2.2, bend=4)

def sport_touches(ink, band_tone):
    """What every Sport Edition tee carries besides its one idea: the four points at the sleeve hem, the line and its
    point at the front hem, and S4 knitted tone on tone into the lower body."""
    band = faint(band_tone(field("S4", 325, 640, 705, 840, 120)), .07)
    return [(turned(four_points(ink, 232, 388, 8, 6), 17, 232, 388) + line_point(ink, 348, 826, 96, weight=2), None), (band, None, rect(354, 640, 674, 840))]

def sport_tees(dye=None):
    """The Sport Edition: black front and back, white front and back, and the white dyed when a colour is asked for."""
    inverted = lambda art: f'<g style="filter:invert(1)">{art}</g>'
    plain = lambda art: art
    lit = lambda parts, light: [(a, light if l is None and c is None else l, c) for a, l, c in [(tuple(x) + (None, None))[:3] for x in parts]]
    night_front = shot("sport tee black front.png", (foiled(S("url(#steel)", 634, 348, 44)), SPORT_NIGHT), *lit(sport_touches(SILVER, inverted), SPORT_NIGHT))
    night_back = shot("sport tee black back.png", (tagline(SILVER, 512, 176, 11, "middle"), SPORT_NIGHT),
                      (puff(cut_S("#45464C", 512, 752, 330)), SPORT_NIGHT, rect(0, 0, 1024, 893)))
    white_front = shot("sport tee white front.png", (name(CARBON, 512, 372, 270), SPORT_WHITE), *lit(sport_touches(CARBON, plain), SPORT_WHITE), tint=dye, mask="pale")
    white_back = shot("sport tee white back.png", (question(CARBON, 338, 590, 48) + line_point(CARBON, 338, 688, 128, weight=3), SPORT_WHITE), tint=dye, mask="pale")
    return night_front, night_back, white_front, white_back

@a_board("sport", "the Sport Edition, the performance tee")
def sport_board():
    night_front, night_back, white_front, white_back = sport_tees()
    orange_front = sport_tees(DYE)[2]
    return spread("THE SPORT EDITION", "The Sport Edition.", "The same four ideas, made to run in. Nothing is sewn on: every mark is bonded, knitted in or cut by laser.", "S · 01",
                  night_front, (night_back, white_front, white_back, orange_front), [
        ("Night · front", "110 gsm recycled polyester micro-knit, raglan sleeve, bonded seams", "The S. in reflective heat transfer. Laser-cut vents across the chest; S4 knitted tone on tone into the body.", NI),
        ("Night · back", "The same tee, with a sheer mesh panel down each side", "The cut S rising from the dropped hem, tone on tone. The tagline under the locker loop, reflective.", NI),
        ("White · front", "110 gsm recycled polyester micro-knit, optical white", "The drawn name across the chest, Carbon heat transfer. The four points at the sleeve hem, the line and its point at the hem.", PC),
        ("White · back", "The same tee", "The question, then the line and its point, under a spine of laser-cut vents.", PC),
        ("Orange · front", "The same tee, dyed orange", "The drawn name and every touch in Carbon.", OB)])



# ---------------------------------------------------------------- the pieces iShatat chose on 13 November 2026
def tee_back_question(ink=ORANGE):
    return photographed("tee black ghost back.png", question(ink, 330, 290, 52) + line_point(ink, 330, 392, 136, weight=3), **BLACK_GHOST)

def tote_name():
    return shot("tote natural.png", (name(CARBON, 512, 610, 330) + tagline(CARBON, 512, 660, 11, "middle"), PALE))

def gift_bags_pressed(dye=None):
    """The cut S pressed blind into both bags, rising from the foot."""
    return shot("gift bags orange.png" if dye else "gift bags.png", (pressed(cut_S("#000000", 292, 766, 280), "night", .55), None, rect(108, 372, 480, 884)),
                (pressed(cut_S("#000000", 735, 773, 280), "paper", .2 if dye else .1), None, rect(548, 372, 922, 891)))

def pouch_sleeve_pale():
    return shot("pouch and sleeve pale.png", (four_points(CARBON, 512, 300, 30, 22), PALE), (pressed(name("#000000", 690, 880, 180), "paper", .3), None))

def card_holders():
    spots = ((400, 410, "night", .8), (860, 410, "paper", .16), (400, 800, "night", .8), (860, 800, "paper", .16))
    return shot("card holders.png", *[(pressed(S("#000000", x, y, 46), ground, depth), None) for x, y, ground, depth in spots])

def luggage_tags():
    return shot("luggage tags.png", (foiled(name("url(#whitefoil)", 292, 610, 330, vertical=True)), None), (pressed(name("#000000", 715, 610, 330, vertical=True), "paper", .3), None))

def key_fobs():
    return shot("key fobs.png", (pressed(name("#000000", 335, 620, 330, vertical=True), "night", .85), None), (pressed(name("#000000", 695, 620, 330, vertical=True), "paper", .3), None))

def box_open_white():
    weave = f'<g style="filter:invert(1)">{field("W1", 190, 175, 835, 850, 150)}</g>'
    seal = S(CARBON, 506, 514, 50)
    return shot("box open white.png", (faint(weave, .1), None, rect(196, 180, 830, 846)), (seal, HARD_PALE))

def tissue():
    night = f'<g style="filter:invert(1)">{field("W1", 70, 200, 478, 815, 140)}</g>'
    return shot("tissue.png", (faint(night, .11), None, rect(76, 206, 472, 808)), (faint(field("W1", 555, 200, 955, 815, 140), .1), None, rect(560, 206, 950, 812)))

def pencils_pair(dips=None):
    """Black and white pencils: the name on each, and each end dipped. dips: one colour for every end, or the products' own."""
    colours = [dips] * 5 if dips else list(FAMILY.values())
    dip = lambda y, c: f'<rect x="86" y="{y - 17}" width="44" height="34" rx="3" fill="{c}"/><rect x="86" y="{y - 13}" width="44" height="4" fill="#fff" opacity=".18"/>'
    black, white = (228, 284, 340, 396, 452), (566, 623, 679, 735, 792)
    return shot("pencils black and white.png", ("".join(name(SILVER, 400, y, 150) for y in black), HARD_DARK), ("".join(name(CARBON, 400, y, 150) for y in white), HARD_PALE),
                ("".join(dip(y, c) for y, c in zip(black, colours)), None), ("".join(dip(y, dips or CARBON) for y in white), dict(gain=1.0, lift=.06, bend=0) if not dips else None))

def tape_pulled():
    def strip(y, h, ink, light):
        return (pattern("W2", 348, y, 589, h, "none", ink, 118), light, rect(352, y + 2, 934, y + h - 2))
    return shot("tape pulled.png", strip(189, 128, INK, HARD_DARK), strip(445, 139, CARBON, HARD_PALE), strip(712, 133, CARBON, HARD_PALE),
                tint=DYE, mask="pale", tint_clip=rect(40, 680, 1000, 980))

def cards_photo():
    thanks = lambda ink, y: words("Thank you.", ink, 580, y, 46) + line_point(ink, 580, y + 34, 100, weight=2)
    return shot("cards and envelopes.png", (thanks(CARBON, 330) + name(CARBON, 830, 446, 150), HARD_PALE),
                (thanks("#F4F3EF", 690), HARD_DARK), (foiled(name("url(#whitefoil)", 830, 800, 150)), None),
                (embossed(S("#2E2F33", 284, 384, 38)), None), (embossed(S("#CFCABA", 284, 737, 38)), None))

def card_boxes():
    """The house deck, before XXI: S3 pressed around the name."""
    return shot("card boxes.png", (pressed(field("S3", 62, 320, 334, 706, 120), "night", .7), None, rect(66, 326, 330, 700)), (foiled(name("url(#whitefoil)", 198, 513, 120)), None),
                (foiled(S("url(#whitefoil)", 512, 513, 70)), None),
                (pressed(field("S3", 688, 320, 962, 706, 120), "paper", .2), None, rect(694, 326, 958, 700)), (name(CARBON, 825, 513, 120), HARD_PALE))

def lanyards_flat():
    """Four straps laid straight: the name woven along one of each colour, the S. repeated along the other."""
    def badge(x, product):
        return (S(CARBON, x + 36, 566, 26) + words("First name", CARBON, x + 20, 708, 19) + words("Last name", CARBON, x + 20, 731, 19)
                + words(product.split()[-1], CARBON, x + 20, 782, 12, weight=500) + f'<circle cx="{x + 150}" cy="778" r="5" fill="{FAMILY[product]}"/>')
    row = lambda ink, x: "".join(S(ink, x - 3, y, 19) for y in range(34, 392, 44))
    return shot("lanyards flat.png", (name(INK, 165, 214, 330, vertical=True) + row(INK, 397), HARD_DARK),
                (name(CARBON, 622, 214, 330, vertical=True) + row(CARBON, 852), HARD_PALE),
                (badge(77, "1210") + badge(307, "SHETA") + badge(535, "XXI") + badge(765, "Hekayet Athar"), HARD_PALE))

@a_board("tee", "to wear, the tee")
def tee_board():
    night_front, night_back, _, _ = tees()
    return spread("MERCHANDISE · TO WEAR", "The tee.", "One idea on the front, one on the back. Heavy cotton, cut boxy, washed so it is soft from the first day.", "01",
                  night_front, (night_back, detail(night_front, 600, 300, 2.6)), [
        ("Night · front", "240 gsm combed cotton jersey, garment dyed", "The S. embroidered on the left chest in Ink thread, 40 mm high. A woven neck label with the S.", NI),
        ("Night · back", "The same tee", "The cut S rising from the hem, tone on tone puff print. The tagline under the collar, Ink screen print.", NI),
        ("The S., close", "Ink thread on black jersey", "Satin stitch, 40 mm high, on the left chest.", NI)])

@a_board("carry", "to carry, the tote and the gift bag")
def carry_board():
    return spread("MERCHANDISE · TO CARRY", "The tote and the gift bag.", "What leaves the room with someone. The name travels further on a shoulder than in any advert.", "04",
                  tote_night(), (tote_natural(), tote_name(), gift_bags(), gift_bags_pressed()), [
        ("Tote · Night", "16 oz black cotton canvas, cotton webbing", "The cut S rising from the foot, Ink screen print.", NI),
        ("Tote · Natural, the pattern", "16 oz undyed cotton canvas", "W2, the name and the S. in rows, one shade darker than the cloth.", (CANVAS, CARBON)),
        ("Tote · Natural, the name", "16 oz undyed cotton canvas", "The drawn name and the tagline, Carbon screen print.", (CANVAS, CARBON)),
        ("Gift bag · the name", "250 gsm board, soft-touch black or uncoated Paper, cotton rope", "Night: the name in white foil. Paper: the four points in Carbon.", NI + PC),
        ("Gift bag · the cut S", "The same bags", "The cut S pressed blind, rising from the foot. No ink at all.", NI + PC)])

@a_board("leather", "to carry, the pouch, the sleeve and leather")
def leather_board():
    return spread("MERCHANDISE · TO CARRY", "The pouch, the sleeve and leather.", "Close to the hand, so nearly nothing is printed: the design is pressed in, and the point is the stud that closes the sleeve.", "05",
                  card_holders(), (pouch_sleeve(), pouch_sleeve_pale(), luggage_tags(), key_fobs()), [
        ("Card holder", "Full-grain leather, pebbled or smooth calf, hand-stitched", "The S. blind debossed in the corner. Black or cream, in both leathers.", NI + PC),
        ("Zip pouch and laptop sleeve · Night", "Waxed 12 oz canvas; 3 mm merino wool felt, leather strap", "The name in Ink on the pouch, pressed blind into the felt. The steel stud is the point.", NI),
        ("Zip pouch and laptop sleeve · Paper", "Undyed waxed canvas; cream merino felt", "The four points in Carbon on the pouch. The name pressed blind into the felt.", PC),
        ("Luggage tag", "Full-grain leather, steel buckle", "The name on its side: white foil on black, blind on cream.", NI + PC),
        ("Key fob", "Full-grain leather, steel ring", "The name on its side, pressed blind along the strap.", NI + PC)])

@a_board("desk", "for the desk")
def desk_board():
    return spread("MERCHANDISE · FOR THE DESK", "For the desk.", "Small, heavy and well made: things that stay on a desk for years. Each pencil ends in a point, dipped in one product's colour.", "06",
                  notebooks(), (mugs(), pencils_pair(), coasters()), [
        ("Notebook · Night and Paper", "A5 hardback, 120 gsm pages: soft-touch black, or undyed linen cloth", "Night: S3 blind debossed around the name in white foil. Paper: S4 pressed blind around the name in Carbon.", NI + PC),
        ("Mug · Night and Paper", "Stoneware, matte glaze, 300 ml", "Night: the S. in gloss Ink glaze. Paper: the four points in Carbon.", NI + PC),
        ("Pencils · Night and Paper", "Cedar, hexagonal, HB, matte lacquer", "The name in silver foil on black, Carbon on white. The black ends are dipped in the product colours: 1210, SHETA, XXI, the Studio, Athar.", NI + PC),
        ("Coasters", "4 mm vegetable-tanned leather, or 900 gsm cotton board", "The point field pressed around the name: white foil on leather, Carbon letterpress on cotton.", NI + PC)])

@a_board("give", "to give, the box and tissue")
def give_board():
    return spread("MERCHANDISE · TO GIVE", "The box and tissue.", "Opening it should feel like the first time someone sees the S. Outside, almost nothing; inside, the name, again and again.", "08",
                  box_open(), (boxes(), box_open_white(), tissue()), [
        ("Gift box · Night, open", "2 mm greyboard, black soft-touch wrap; 17 gsm tissue", "W1 printed on Paper tissue, one step darker, sealed with the S. sticker.", NI),
        ("Gift box · Night and Paper", "Rigid two-piece box, wrapped", "Night: S3 blind debossed around the name in white foil. Paper: the cut S pressed blind, the name in Carbon foil.", NI + PC),
        ("Gift box · Paper, open", "Uncoated Paper wrap; 17 gsm black tissue", "W1 tone on tone on black tissue, sealed with the S. sticker.", PC),
        ("Tissue", "17 gsm acid-free tissue, 50 × 75 cm", "W1 in rows, one step from the sheet's own colour.", NI + PC)])

@a_board("tape-card", "to give, the tape and the thank-you card")
def tape_board():
    cards = cards_photo()
    return spread("MERCHANDISE · TO GIVE", "The tape and the thank-you card.", "Everything a parcel is closed with says the name, quietly. The seal is the S., pressed in wax.", "09",
                  tape_pulled(), (cards, detail(cards, 760, 395, 2.6)), [
        ("Packing tape", "50 mm water-activated paper tape: black, Paper, orange", "W2 in one colour: Ink on black, Carbon on Paper and on orange.", (NIGHT, PAPER, ORANGE)),
        ("Thank-you card", "600 gsm cotton card, lined envelope, wax seal", "Carbon letterpress on Paper, white foil on Night. The name closes the card, bottom right.", PC + NI),
        ("The card, close", "Paper card", "Thank you, the line and its point, then the name.", PC)])

@a_board("signage", "signage, the wall and the lanyard")
def signage_board():
    return spread("MERCHANDISE · SIGNAGE", "The wall and the lanyard.", "At small scale the rules of the booth wall hold: the name at eye height, the S rising from the floor, and one point of colour on the badge.", "10",
                  wall_night(), (wall_sign(), wall_paper(), lanyards_flat()), [
        ("Wall vinyl · Night", "Matte cast vinyl, cut to shape, on a wall painted Night", "The name 1.2 m wide at eye height, in Ink; the tagline under it in Graphite.", NI),
        ("Wall sign · Night", "Letters cut from 3 mm aluminium, painted Night, stood 30 mm off a wall painted Night", "The name 1.8 m wide, lit from behind in Ink: it stands dark in its own light.", NI),
        ("Wall vinyl · Paper", "Matte cast vinyl on a wall painted Paper", "The cut S rising from the floor, 1.6 m high, in Carbon; the name small, top left.", PC),
        ("Lanyard and badge", "20 mm woven polyester, steel swivel clip", "Two straps in each colour: the name woven along one, the S. repeated along the other. The badge carries one point, in the product's colour.", NI + PC)])

@a_board("more", "a little more, the candle, the bottle, the pen and the decks")
def more_board():
    return spread("MERCHANDISE · A LITTLE MORE", "A little more.", "Pieces that turn a set of merchandise into a gift. Two decks: the house's own, and XXI's with its black card and red diamond.", "11",
                  candles(), (bottles(), pens_photo(), card_boxes(), xxi_tile()), [
        ("Candle", "Poured soy wax in stoneware", "The S. alone: tone on tone on Night, Carbon on Paper.", NI + PC),
        ("Bottle", "Double-wall steel, 500 ml, with a steel strainer", "The name on its side, laser etched.", NI + PC),
        ("Pen", "Brass barrel, matte lacquer, rollerball", "The clip ends in the point. The name etched on the barrel.", NI + PC),
        ("The house deck", "310 gsm linen-finish card, rigid tuck box", "S3 pressed blind around the name; the S. alone on the second box.", NI + PC),
        ("The XXI deck", "310 gsm black-core card, rigid two-piece box", "XXI's card from its logo: the Didone letters over one red diamond.", (NIGHT, "#D8202E"))])

@a_board("orange-wear", "the Orange Edition, to wear")
def orange_wear_board():
    _, night_back, _, _ = tees(ink_on_black=ORANGE, tone_s=ORANGE)
    return spread("THE ORANGE EDITION", "The Orange Edition.", "A capsule of its own: orange with black, and nothing else. Orange cloth carries black; black cloth carries orange.", "O · 01",
                  hoodie_pale(CARBON, DYE, sleeve_name=True), (night_back, tee_back_question(), cap_pale(CARBON, DYE), cap_night(ORANGE)), [
        ("Hoodie · Orange", "480 gsm brushed-back fleece, dyed orange", "The S. embroidered on the chest; the name on its side down the sleeve, Carbon puff print.", OB),
        ("Tee · Night, the cut S", "240 gsm cotton jersey, garment dyed black", "The cut S rising from the hem and the tagline, orange screen print.", BO),
        ("Tee · Night, the question", "The same tee", "The question, then the line and its point, orange screen print.", BO),
        ("Cap · Orange", "Washed cotton twill, dyed orange", "The S. in raised Carbon embroidery.", OB),
        ("Cap · Night", "Washed cotton twill, black", "The S. in raised orange embroidery.", BO)])

@a_board("orange-carry", "the Orange Edition, to carry and to give")
def orange_carry_board():
    return spread("THE ORANGE EDITION", "The Orange Edition, to carry and to give.", "The same pieces, the same finishes. The orange is the material itself, never a print on top, and black is its only ink.", "O · 02",
                  tote_natural(DYE), (gift_bags(DYE, ORANGE), gift_bags_pressed(DYE), boxes(DYE, ORANGE), box_open(DYE)), [
        ("Tote · Orange", "16 oz canvas dyed orange", "The cut S rising from the foot, Carbon screen print.", OB),
        ("Gift bag · the name", "250 gsm board: black, or orange", "The name: orange foil on black, Carbon on orange.", BO + OB),
        ("Gift bag · the cut S", "The same bags", "The cut S pressed blind, rising from the foot.", BO + OB),
        ("Gift box", "Rigid box, soft-touch wrap", "S3 blind debossed around the name: orange foil on black, black foil on orange.", BO + OB),
        ("Gift box, open", "Black box, orange tissue", "W1 on orange tissue, sealed with the S. in orange.", BO)])

@a_board("orange-desk", "the Orange Edition, for the desk")
def orange_desk_board():
    return spread("THE ORANGE EDITION", "The Orange Edition, for the desk.", "Black and orange on the desk: the orange is a glaze, a lacquer, a cloth, and black is its only ink.", "O · 03",
                  notebooks(DYE, ORANGE), (mugs(DYE, ORANGE), pencils_pair(ORANGE), pins_photo(DYE), pens_photo(DYE)), [
        ("Notebook", "A5 hardback: soft-touch black, or orange cloth", "S3 debossed around the name, orange on black and Carbon on orange.", BO + OB),
        ("Mug", "Stoneware, matte glaze", "The S.: orange glaze on black, Carbon on orange.", BO + OB),
        ("Pencils", "Cedar, matte lacquer", "Every end dipped in orange.", BO),
        ("Pins", "Hard enamel, 25 mm", "The S.: orange on Night enamel, Carbon on orange. The five product points on their card.", BO + OB),
        ("Pen", "Brass barrel, matte lacquer", "The name etched on the barrel: silver on black, Carbon on orange.", BO + OB)])

@a_board("orange-candle-bottle", "the Orange Edition, the candle and the bottle")
def orange_candle_bottle_board():
    return spread("THE ORANGE EDITION", "The candle and the bottle.", "Two pieces, each on its own. Lit, the candle shows its glaze; taken apart, the bottle shows how it is made.", "O · 04",
                  candles(DYE), (bottles(DYE), candles(DYE, lit=True), bottles(DYE, apart=True)), [
        ("Candle", "Poured soy wax in stoneware: black, or orange", "The S. alone: Carbon on orange, tone on tone on black.", BO + OB),
        ("Bottle", "Double-wall steel, 500 ml: black, or orange", "The name on its side: silver on black, Carbon on orange.", BO + OB),
        ("Candle, lit", "The same pair, burning", "The glaze takes the flame's light.", BO + OB),
        ("Bottle, taken apart", "Steel cap, gasket, strainer and body", "The name stays on its side down the body.", BO + OB)])

def build(only=()):
    OUT.mkdir(exist_ok=True); PAGES.mkdir(parents=True, exist_ok=True)
    unknown = set(only) - {k for k, _, _ in BOARDS}
    if unknown:
        raise SystemExit(f"no such board: {sorted(unknown)}")
    for key, title, make in BOARDS:
        if only and key not in only:
            continue
        src = PAGES / f"{key}.html"
        src.write_text(T.page(f"Merchandise, {title}", 1920, 1080, make()), encoding="utf-8")
        png = OUT / f"SHATATiON Merchandise, {title} - 1920x1080.png"
        subprocess.run([T.CHROME, "--headless", "--disable-gpu", "--hide-scrollbars", "--virtual-time-budget=6000",
                        "--window-size=1920,1080", f"--screenshot={png}", src.as_uri()], check=True, capture_output=True)
        print("made", png.name)

sys.modules.setdefault("make_merch", sys.modules[__name__])     # merch_sport reads this module, run as a script or imported
import merch_sport                                               # the rest of the Sport Edition: its boards join BOARDS

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