"""The Sport Edition beyond its first tee: more tees, the layers, the shorts and the kit.
Every piece is a blank photograph with the design laid on it, in the photograph's own pixels (1024 square).
Black pieces carry silver, as reflective heat transfer; white pieces carry Carbon; a dye turns the white piece orange."""
from make_merch import *

REFLECTIVE = "url(#steel)"
TONE = "#3F4046"              # tone on tone on a black knit


def tee_seamless():
    """The four points across the chest of the seamless tee, the line and its point at the hem."""
    return shot("sport tee seamless black.png", (foiled(four_points(REFLECTIVE, 517, 292, 18, 16)), SPORT_NIGHT),
                (line_point(SILVER, 392, 790, 84, weight=2), SPORT_NIGHT))

def tee_seamless_back():
    """The same tee turned round: the name across the upper back, reflective, and the line and its point at the hem."""
    return shot("sport tee seamless black back.png", (foiled(name(REFLECTIVE, 512, 252, 236)), SPORT_NIGHT),
                (line_point(SILVER, 400, 806, 84, weight=2), SPORT_NIGHT))

def tee_between(dye, ink=CARBON):
    """The performance tee in a colour between White and Night: the white tee dyed, with the same marks."""
    plain = lambda art: art
    return shot("sport tee white front.png", (name(ink, 512, 372, 270), SPORT_WHITE),
                *[(art, SPORT_WHITE if light is None and clip is None else light, clip) for art, light, clip in [(tuple(x) + (None, None))[:3] for x in sport_touches(ink, plain)]],
                tint=dye, mask="pale")

def tee_race(dye=None):
    """The S. alone on the clear chest of the race tee, above its field of vents."""
    return shot("sport tee race white.png", (S(CARBON, 512, 318, 62), SPORT_WHITE),
                (turned(four_points(CARBON, 212, 372, 7, 5), 22, 212, 372), SPORT_WHITE), tint=dye, mask="pale")

def long_sleeve_back():
    """The name on its side beside the spine of vents, the tagline under the sheer yoke."""
    return shot("sport long sleeve black back.png", (name(SILVER, 566, 560, 330, vertical=True), SPORT_NIGHT),
                (line_point(SILVER, 400, 806, 70, weight=2), SPORT_NIGHT))

def training_tees(dye=None):
    """The boxy training tee: the cut S rising from the hem on black, the name over the tagline on white."""
    return shot("sport training tees.png", (puff(cut_S(TONE, 302, 640, 296)), SPORT_NIGHT, rect(144, 300, 468, 792)),
                (name(CARBON, 775, 392, 200) + tagline(CARBON, 775, 428, 7, "middle"), SPORT_WHITE), tint=dye, mask="pale", tint_clip=rect(520, 160, 1000, 860))

def half_zip():
    """The S. on the chest, the name on its side down the sleeve, the line and its point at the hem."""
    return shot("sport half zip black.png", (foiled(S(REFLECTIVE, 612, 392, 40)), SPORT_NIGHT),
                (turned(name(SILVER, 262, 590, 250, vertical=True), 4, 262, 590), SPORT_NIGHT),
                (line_point(SILVER, 330, 770, 84, weight=2), SPORT_NIGHT))

def jacket():
    """The S. on the chest and the cut S tone on tone across one front, rising from the hem."""
    return shot("sport jacket black.png", (puff(cut_S("#3C3D43", 422, 728, 164)), SPORT_NIGHT, rect(338, 380, 506, 796)),
                (foiled(S(REFLECTIVE, 412, 268, 34)), SPORT_NIGHT),
                (turned(name(SILVER, 782, 548, 210, vertical=True), -7, 782, 548), SPORT_NIGHT))

def singlets(dye=None):
    """The name across the black singlet; the cut S rising from the hem of the white one."""
    return shot("sport singlets.png", (name(SILVER, 285, 404, 190), SPORT_NIGHT), (line_point(SILVER, 214, 742, 60, weight=2), SPORT_NIGHT),
                (faint(cut_S(CARBON, 745, 676, 250), .16), SPORT_WHITE, rect(648, 380, 868, 794)),
                (tagline(CARBON, 745, 300, 6.5, "middle"), SPORT_WHITE), tint=dye, mask="pale")

def shorts(dye=None):
    """The S. at one hem and the four points at the other."""
    return shot("sport shorts.png", (foiled(S(REFLECTIVE, 388, 604, 32)), SPORT_NIGHT), (four_points(SILVER, 150, 610, 7, 5), SPORT_NIGHT),
                (S(CARBON, 838, 632, 32), SPORT_WHITE), (four_points(CARBON, 640, 648, 7, 5), SPORT_WHITE), tint=dye, mask="pale")

def caps(dye=None):
    return shot("sport caps.png", (foiled(S(REFLECTIVE, 212, 452, 36)), SPORT_NIGHT), (S(CARBON, 688, 478, 36), SPORT_WHITE), tint=dye, mask="pale")

def duffel():
    """The name on the flat front of the bag, the four points at its corner."""
    return shot("sport duffel.png", (foiled(name(REFLECTIVE, 392, 640, 250)), HARD_DARK), (four_points(SILVER, 200, 760, 8, 6), HARD_DARK))

def socks(banded=False):
    """The S. under the cuff of each sock. Banded, as they are sold: each pair folded in a paper band that carries the name."""
    if banded:
        return shot("sport socks banded.png", (name(INK, 350, 500, 150) + tagline(INK, 350, 530, 6, "middle"), HARD_DARK),
                    (name(CARBON, 676, 498, 150) + tagline(CARBON, 676, 528, 6, "middle"), HARD_PALE))
    return shot("sport socks.png", (S(SILVER, 396, 282, 30), SPORT_NIGHT), (S(CARBON, 648, 290, 30), SPORT_WHITE))

def squeeze_bottles(apart=False):
    """The name on its side down each bottle; apart, the dust cap, the valve and the lid stand above each body."""
    y = 702 if apart else 606
    return shot("sport bottles apart.png" if apart else "sport bottles.png", (name(SILVER, 367, y, 240, vertical=True), HARD_DARK),
                (name(CARBON, 654, y, 240, vertical=True), HARD_PALE))


# ---------------------------------------------------------------- second views: the piece turned round, taken apart, or in its other colour
def jacket_back():
    """The name across the back under the vent band; the cut S tone on tone, rising from the dropped hem."""
    return shot("sport jacket black back.png", (puff(cut_S("#34353A", 512, 700, 330)), SPORT_NIGHT, rect(300, 440, 730, 852)),
                (foiled(name(REFLECTIVE, 512, 398, 280)), SPORT_NIGHT))

def shorts_turned():
    """The Night pair in orange, front; the White pair from the back: the name at one hem, the line and its point at the other."""
    return shot("sport shorts orange and back.png", (S(CARBON, 392, 606, 32), SPORT_WHITE), (four_points(CARBON, 160, 612, 7, 5), SPORT_WHITE),
                (name(CARBON, 858, 592, 112), SPORT_WHITE), (line_point(CARBON, 600, 630, 56, weight=2), SPORT_WHITE))

def caps_turned():
    """The Night cap from the back, the four points above its cord; the White cap in orange."""
    return shot("sport caps back and orange.png", (four_points(SILVER, 416, 452, 8, 6), SPORT_NIGHT), (S(CARBON, 694, 482, 36), SPORT_WHITE))


@a_board("sport-tees", "the Sport Edition, more tees")
def sport_tees_board():
    return spread("THE SPORT EDITION", "The Sport Edition, more tees.", "Four more ways to build a tee, each around one idea. The fabric does the decorating: zones, vents, sheer panels.", "S · 02",
                  tee_seamless(), (tee_seamless_back(), tee_race(), long_sleeve_back(), training_tees(), tee_race(DYE)), [
        ("Seamless · Night, front and back", "Circular-knit in one piece, body-mapped: dense on the chest, open mesh on the flanks", "Reflective: the four points across the chest, the name across the upper back. The line and its point at the hem.", NI),
        ("Race · White", "72 gsm ultralight knit, laser-cut vents growing toward the hem, sheer side panels", "The S. alone on the chest, Carbon heat transfer. The four points at the sleeve hem.", PC),
        ("Long sleeve · Night, back", "Panelled knit, sheer mesh yoke, a spine of laser-cut vents", "The name on its side beside the spine, reflective. The line and its point at the hem.", NI),
        ("Training · Night and White", "180 gsm technical pique, boxy cut, mesh shoulder panels", "Night: the cut S rising from the hem, tone on tone. White: the name over the tagline, Carbon.", NI + PC),
        ("Race · Orange", "The same race tee, dyed orange", "The S. and the four points in Carbon.", OB)])

@a_board("sport-layers", "the Sport Edition, layers and shorts")
def sport_layers_board():
    return spread("THE SPORT EDITION", "The Sport Edition, layers and shorts.", "What goes over the tee and under it. Every mark is reflective, so the name is the last thing seen at night.", "S · 03",
                  half_zip(), (jacket(), singlets(), shorts(), singlets(DYE)), [
        ("Half zip · Night", "Brushed-back technical knit, bonded zip, thumb-hole cuffs, laser-cut chest vents", "The S. on the chest, the name on its side down the sleeve, the line and its point at the hem.", NI),
        ("Jacket · Night", "38 gsm ripstop nylon, semi-sheer, packs into its chest pocket", "The S. on the chest; the cut S tone on tone across one front; the name on its side down the sleeve.", NI),
        ("Singlet · Night and White", "Featherweight micro-knit, bonded armholes, sheer side panels", "Night: the name across the chest. White: the cut S rising from the hem, tone on tone, under the tagline.", NI + PC),
        ("Shorts · Night and White", "Four-way stretch woven, 5 inch, laser-cut side vents, bonded hems", "The S. at one hem, the four points at the other.", NI + PC),
        ("Singlet · Orange", "The same singlet, dyed orange", "The cut S and the tagline in Carbon.", BO + OB)])

@a_board("sport-kit", "the Sport Edition, the kit")
def sport_kit_board():
    return spread("THE SPORT EDITION", "The Sport Edition, the kit.", "Everything else that goes to the track: the bag, the cap, the socks and the bottle.", "S · 04",
                  duffel(), (caps(), socks(), squeeze_bottles(), caps(DYE), detail(duffel(), 330, 690, 2.2)), [
        ("Duffel", "Technical ripstop, 35 L, bonded waterproof zips, ventilated shoe pocket", "The name on the front panel, reflective. The four points at the corner.", NI),
        ("Cap · Night and White", "Featherweight woven, five panels, laser-cut side panels", "The S. on the front panel: reflective on Night, Carbon on White.", NI + PC),
        ("Socks", "Technical knit crew socks, ribbed cuff, mesh instep", "The S. under the cuff: silver on Night, Carbon on White.", NI + PC),
        ("Bottle", "600 ml squeeze bottle, soft bite valve, dust cap", "The name on its side down the bottle.", NI + PC),
        ("Cap · Orange", "The same cap, dyed orange", "The S. in Carbon.", BO + OB),
        ("Duffel, close", "The front panel", "Reflective heat transfer on matte ripstop: the name, and the four points under it.", NI)])
