/**
 * TOASTER ALLEY — a second course, authored entirely as DATA (see spec.ts).
 * Deliberately flat (one big catch-floor, no fall-outs and no elevated
 * geometry) so it is reliably completable without the fine tuning Breakfast
 * Rush needed. It also puts the FAN — a machine that shipped but was never
 * placed — into play as a tailwind.
 *
 * Flow (+Z start → -Z finish): a fan sweeps you off the start pad; red cannons
 * paint you for BURN speed; a green reward mine gives GRIP; a green colour-gate
 * (fed by that mine) opens the straight line to the finish.
 *
 * NOTE: the SEE-SAW is also a supported spec kind (`{kind:'seesaw'}`), but a
 * good see-saw needs an elevated bridge (approach platform + landing) tuned so
 * the blob steps on cleanly — that's level design worth doing deliberately, so
 * it's left out of this flat demo rather than shipped half-working.
 */
import type { CourseSpec } from './spec'

export const TOASTER_ALLEY: CourseSpec = {
  name: 'Toaster Alley',
  spawn: [0, 1.8, 30],
  finish: { xMin: -7, xMax: 7, zMin: -38, zMax: -26, yMax: 4 },
  boxes: [
    // base floor — spans the whole alley so nothing falls out
    { pos: [0, -0.5, -5], half: [14, 0.5, 42], color: '#efe3c6', roughness: 1 },
    // start pad
    { pos: [0, 0.4, 28], half: [6, 0.4, 5], color: '#f7edd2', cast: true },
    // gate flank walls (centre gap x[-2,2] is the gate) — clear side lanes remain
    { pos: [-3, 1.5, -22], half: [1, 1.5, 0.4], color: '#5b6b7a', roughness: 0.85, cast: true },
    { pos: [3, 1.5, -22], half: [1, 1.5, 0.4], color: '#5b6b7a', roughness: 0.85, cast: true },
    // finish podium
    { pos: [0, 0.6, -32], half: [7, 0.6, 5], color: '#FF6EB4', cast: true },
  ],
  machines: [
    // FAN — a tailwind that sweeps you off the start pad down the alley
    { kind: 'fan', cfg: { id: 'ta-fan', position: [0, 1.8, 20], direction: [0, 0, -1], force: 20, range: 18, spread: 4.5 } },
    // green reward mine — GRIP, and it feeds the green gate downstream
    { kind: 'mine', cfg: { id: 'ta-mine', position: [0, 0.05, 4], color: 'green', radius: 0.9, splats: 5, impulse: 5, direction: [0, 1, -0.3], size: [3.4, 3.4] } },
    // green PAINT BUBBLES drifting between mine and gate — a second chance at
    // green if you missed the mine: run/jump through the field, pop a few, and
    // the gate still opens. Bubble colour = payload = the gate's key colour.
    // (radius 0.6 × 2 splats ≈ a quarter-dose per bubble — the gate wants ~2 pops,
    // so the mine stays the fast route and bubbles are the recovery route)
    { kind: 'bubbles', cfg: { id: 'ta-bubbles', position: [0, 1.4, -11], color: 'green', radius: 0.6, splats: 2, count: 7, area: [4, 1.1, 4], drift: [0, 0.3, 0], bubbleRadius: 0.6 } },
    // green gate — opens for the runner who took the reward mine (same loop as
    // Breakfast Rush, proving the gate works identically from a data spec)
    { kind: 'gate', cfg: { id: 'ta-gate', position: [0, 0.02, -22], color: 'green', size: [4, 3, 0.6] }, needColor: 'green', needPct: 0.4 },
    // DOMINO RUN on the right shoulder: detour into the first tile and physics
    // topples the row; the red-striped last tile completes the chain and fires
    // the green volley cannons below — the machine paints you from across the
    // course. A third, most Rube-Goldberg way to earn the gate's green.
    { kind: 'dominoes', cfg: { id: 'ta-dominoes', position: [5.5, 0, 2], direction: [0, 0, -1], count: 8, emits: 'ta-domino-volley' } },
  ],
  cannons: [
    // RED crossfire on the run-up — BURN speed to carry you down the alley
    { color: 'red', position: [-9, 3.5, 12], interval: 1.8 },
    { color: 'red', position: [9, 3.5, 12], interval: 1.8 },
    // domino payoff: signal-only green volley (interval 0 = never auto-fires)
    { color: 'green', position: [-8, 3.5, -14], triggerId: 'ta-domino-volley', interval: 0 },
    { color: 'green', position: [8, 3.5, -16], triggerId: 'ta-domino-volley', interval: 0 },
  ],
  // one checkpoint past the mine — a fall (or a bad gate bonk) costs seconds, not the run
  checkpoints: [[0, 0, -8]],
}
