import json,html
from build import T,THEMES
OUT='/workspace/w20/logo/out'
M=json.load(open(f'{OUT}/directions.json'))
TOP=json.load(open('top.json')) if __import__('os').path.exists('top.json') else {'ids':[],'text':{}}
NAV=0.19  # px per unit: landing nav word is 19px Clash 600
def vb(id_):
    s=open(f'{OUT}/{id_}/wordmark.svg').read(); v=s.split('viewBox="')[1].split('"')[0].split(); return float(v[2]),float(v[3])
css=open('index.css').read()
o=[]
o.append(f'''<!doctype html><html lang="en-ZA"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex,nofollow">
<title>Go Around logo directions · 20 Nov 2026</title><link rel="icon" href="02-climb-out/favicon-pearl.svg" type="image/svg+xml">
<style>{css}</style></head><body>
<header class="top"><div class="wrap"><p class="eyebrow">Brand · logo directions · 20 Nov 2026</p>
<h1>The landing word,<br>made into a logo.</h1>
<p class="lead">Every direction starts from the way “Go Around” is set on landing v4: Clash Display 600 at −0.02em. Ten directions, each in Pearl, Midnight, Amethyst and Champagne, at nav size, as a 512 app icon, and as real 32 and 16 pixel favicons. All are clean SVG outlines, so none of them need a font to load.</p>
<nav class="jump" aria-label="Directions">{"".join(f'<a href="#{m["id"]}">{m["id"][:2]} {html.escape(m["name"])}</a>' for m in M)}</nav></div></header>''')
if TOP['ids']:
    o.append('<section class="rec wrap" id="top2"><h2>My top two</h2><div class="rec-grid">')
    for i,id_ in enumerate(TOP['ids']):
        m=[x for x in M if x['id']==id_][0]
        o.append(f'''<article class="rec-card"><p class="num">{"First" if i==0 else "Second"} choice · {id_[:2]}</p><div class="rec-art"><img src="{id_}/wordmark-pearl.svg" alt="{html.escape(m["name"])} wordmark" class="rec-word"><img src="{id_}/icon-512-pearl.png" alt="" class="rec-icon" width="96" height="96"></div><h3>{html.escape(m["name"])}</h3><p>{TOP["text"][id_]}</p></article>''')
    o.append(f'</div><p class="rec-note">{TOP.get("note","")}</p></section>')
for m in M:
    w,h=vb(m['id']); nw,nh=w*NAV,h*NAV; bw=min(w*0.52,300)
    o.append(f'''<section class="dir" id="{m["id"]}"><div class="wrap"><header class="dir-h"><p class="num">{m["id"][:2]} · {html.escape(m["kind"])}</p><h2>{html.escape(m["name"])}</h2><p class="why">{html.escape(m["why"])}</p>
<p class="files"><a href="{m["id"]}/wordmark.svg">wordmark.svg</a> <a href="{m["id"]}/icon-512.svg">icon-512.svg</a> <a href="{m["id"]}/icon-512-pearl.png">icon-512 PNG</a> <a href="{m["id"]}/favicon-pearl.svg">favicon.svg</a></p></header><div class="themes">''')
    for th in THEMES:
        t=T[th]
        o.append(f'''<figure class="th" style="--bg:{t['bg']};--ink:{t['ink']};--sub:{t['sub']};--ln:{'rgba(20,20,19,.09)' if th in ('pearl','champagne') else 'rgba(255,255,255,.09)'}"><figcaption>{t['name']}</figcaption>
<div class="nav"><img src="{m["id"]}/wordmark-{th}.svg" alt="{html.escape(m["name"])} at nav size" width="{nw:.1f}" height="{nh:.1f}"><span>Sign in</span></div>
<div class="big"><img src="{m["id"]}/wordmark-{th}.svg" alt="" style="width:min(100%,{bw:.0f}px)"></div>
<div class="sizes"><div class="app"><img src="{m["id"]}/icon-512-{th}.png" alt="App icon, {t['name']}" width="88" height="88"><span>512</span></div>
<div class="tab"><span class="tabchip"><img src="{m["id"]}/favicon-32-{th}.png" width="16" height="16" alt=""><i>Go Around</i></span><span class="px"><img src="{m["id"]}/favicon-32-{th}.png" width="32" height="32" alt="Favicon 32"><img src="{m["id"]}/favicon-16-{th}.png" width="16" height="16" alt="Favicon 16"></span><span class="zoom"><img src="{m["id"]}/favicon-16-{th}.png" width="48" height="48" alt="Favicon 16 at 3x"></span><span class="lbl">32 · 16 · 16 at 3×</span></div></div></figure>''')
    o.append('</div></div></section>')
o.append(f'''<footer class="foot wrap"><p>{TOP.get("foot","")}</p></footer></body></html>''')
open(f'{OUT}/index.html','w').write('\n'.join(o))
