# Authoring a style for the miwale Game Style Library

Every style lives in its own folder `public/styles/library/<id>/` and consists of
exactly three hand-written files. Everything else (catalog, style pages,
`llms.txt`, `llms-full.txt`) is generated by `node tools/build-styles.mjs`.

| File | Audience | Purpose |
| --- | --- | --- |
| `spec.json` | page + machines | Design tokens and structured facts, grouped by design element. |
| `STYLE.md` | AIs + humans | The full, detailed spec. The single document an AI needs to reproduce the look. |
| `starter.js` | AIs + humans | Dependency-free starter kit: palette + the core drawing techniques + a `draw()` preview scene. |

The visual reference of each style is the Canvas 2D module in
`public/styles/js/styles/<id>.js`.

## The design elements

A style is documented as six separable **elements**. The library page shows each
element on its own, and *Mix your own design* combines elements of different
styles — so every element must be described so that it stands on its own.

| Element | Covers | STYLE.md heading | spec.json key |
| --- | --- | --- | --- |
| **World** | ground, terrain regions, paths, water, ground decals | `## World and ground` | `world` |
| **Characters** | the main character and all creatures: construction, faces, outline, animation | `## Characters` | `characters` |
| **Props** | scenery objects: trees, rocks, buildings, fences, plants | `## Props` | `props` |
| **Effects** | projectiles, collectibles, orbiting objects, particles, impacts, bursts | `## Effects and particles` | `effects` |
| **Atmosphere** | shadows, light, glow, fog, vignette, frames, colour grading | `## Atmosphere and lighting` | `atmosphere` |
| **UI & type** | panels, bars, counters, cards, icons, fonts | `## UI` + `## Typography` | `ui`, `typography` |

The palette and the rendering technique are shared by all elements.

## Language rules — design only

The page and the specs are about **visual design**, not about any game.
- English for everything.
- Never mention the game the modules were drawn for, its title, story, genre or mechanics:
  no "Jack", "turnip", "rutabaga", "pumpkin hero", "survival", "roguelike", "run", "waves",
  "XP", "level-up", "kills", "HP", "damage numbers", "boss", "reference game", "game jam".
- Name things by their visual role: **main character**, **small creature**, **fast creature**,
  **large creature**, **collectible** (small/large), **projectile**, **orbiting object**,
  **particle**, **impact burst**, **HUD panel**, **bar**, **counter**, **card**.
- Describe *what the subject looks like* when it matters ("a round orange head with a carved
  glowing face", "purple root creatures with leafy tops") — that is design. Don't explain what it *does* in a game.
- "Best for" / "avoid for" name kinds of projects and moods ("cozy farming games", "horror"),
  that's fine.

---

## 1. `spec.json`

All keys are required unless marked optional. Keep strings plain text (no markdown).

```jsonc
{
  "id": "neon",                         // = folder name = id in the module
  "name": "Neon Midnight",              // English display name
  "originalName": "Neon Mitternacht",   // name in the module
  "family": "Vector · Neon",            // English, "Broad · Specific"
  "tags": ["synthwave", "glow", "line art", "dark"],     // 4–8 lowercase tags
  "summary": "Glowing neon vector lines on a black holographic floor.",  // ≤ 140 chars
  "description": "2–4 sentences: what it looks like, how it feels, what makes it distinctive.",
  "mood": ["electric", "nocturnal", "rave"],             // 3–5 adjectives
  "bestFor": ["arcade shooters", "rhythm games"],        // 3–5 project types
  "avoidFor": ["cozy farming sims"],                     // 2–4
  "difficulty": { "stars": 3, "why": "How hard it is to create NEW assets in this style (1 easy – 10 very elaborate)." },
  "technique": {
    "renderer": "Canvas 2D (procedural, no image assets)",
    "pixelArt": false,                   // or { "scale": 1 } – world units per art pixel, copy from module
    "resolution": "How sharp/low-res it renders",
    "summary": "1–2 sentences: the core trick that produces the look.",
    "linework": "Outline/line rules: colour, width in world units, caps/joins.",
    "shading": "How forms get volume (flat, cel bands, gradients, dithering...).",
    "lighting": "Light direction, glows, darkness, colored light.",
    "texture": "Surface texture/noise/grain, or 'none'."
  },
  "palette": [                           // 8–22 entries, the REAL hex values from the module
    { "name": "Void", "hex": "#05040d", "role": "World base (~60% of the screen)" }
  ],
  "paletteRules": ["How colours are combined, ratios, what never appears."],
  "typography": [
    { "family": "Orbitron", "weights": [500, 700, 900], "role": "Titles, counters", "source": "Google Fonts",
      "sample": "LEVEL 07", "css": "font: 900 22px/1 'Orbitron', sans-serif; letter-spacing: .12em; color: #6ff4ff;" }
  ],
  "world":      { "summary": "...", "layers": ["bottom to top: base fill, texture, regions, paths, decals"] },
  "characters": { "summary": "...", "rules": ["silhouette/readability/animation rules"] },
  "props":      { "summary": "...", "rules": ["..."] },
  "effects":    [ { "name": "Impact spark", "how": "What it looks like and how it is drawn." } ],   // 4–8
  "atmosphere": { "summary": "...", "rules": ["shadows, light, overlays, frame, grading"] },
  "ui":         { "summary": "Panels, bars, borders, text treatment.", "css": "Copy-ready CSS for a panel + bar." },
  "motion": ["Animation / timing rules"],
  "do": ["5–8 concrete rules"],
  "dont": ["5–8 anti-patterns that break the look"],
  "performance": "What is baked once, what is per frame, known hot spots."
}
```

## 2. `STYLE.md`

Use **exactly** these `##` headings, in this order. Be concrete: real hex values,
real sizes in world units (the screen shows 360 world units of height; the main
character is ~18 units wide and ~30 tall), real numbers from the module.
Target length 250–550 lines.

```markdown
# <Name> — Game Art Style Spec

> <summary>

<one paragraph description>

## At a glance
Table: Family · Mood · Best for · Renderer · Pixel art · Complexity (n/10) · Fonts · Key colours.

## When to use it
## Color palette
Table: Swatch name | Hex | Role. Then palette rules.

## Typography
## Rendering technique
Shared pipeline: what is baked at init, what is drawn per frame, draw order, resolution/pixel rules.

## World and ground
## Characters
Main character first, then the creatures (small, fast, large): shapes, proportions, outline, faces, colours, frames.

## Props
## Effects and particles
## Atmosphere and lighting
## UI
## Motion and animation
## Do and don't
## Implementation recipe
## Code
2–5 fenced `js` blocks with the core techniques, standalone (no `U.`/`G.`).

## Adapting it to your project
## Performance notes
## Copy-paste prompt
A fenced `text` block, ~15 lines: "Use the <Name> art style for my project: ..."
```

## 3. `starter.js`

Plain ES2017 script, **no dependencies**, no network, no globals except the
registration at the end. 150–450 lines.

```js
(function (root) {
  'use strict';
  const PALETTE = { /* same hex values as spec.json */ };
  function drawHero(ctx, x, y, t, facing) { /* main character, feet at (x, y) */ }
  function drawEnemy(ctx, x, y, t) { /* a typical creature */ }
  function draw(ctx, w, h, t) { /* complete preview scene filling w×h */ }
  const Starter = { id: '<id>', name: '<Name>', palette: PALETTE, fonts: [], drawHero, drawEnemy, draw };
  root.StyleStarters = root.StyleStarters || {};
  root.StyleStarters['<id>'] = Starter;
  if (typeof module !== 'undefined' && module.exports) module.exports = Starter;
})(typeof window !== 'undefined' ? window : globalThis);
```

`draw(ctx, w, h, t)` fills the whole canvas, scales with `h` (360-unit space),
is deterministic for a given `t` (no per-frame `Math.random()`), stays under ~8 ms.

## Checking your work

```bash
node tools/build-styles.mjs            # regenerate catalog, pages, llms files
node --test tools/styles.test.mjs      # schema, headings, design-only wording
node tools/check-styles.mjs <id>       # + browser: starter.js really draws, preview PNG
```
