// ============================================================
// FreshWave Digital Studio - content
// Focus: small-format collectibles - anime figures, vintage
// replicas, fidget toys, and display statues up to 12".
// ============================================================

const FEATURED = [
  { name: 'NOVA-X', sub: 'Glow-in-the-dark mecha figure', material: 'UV-reactive resin · 7in', accent: 'cyan' },
  { name: 'ARCADE 84', sub: 'Vintage cabinet miniature', material: 'Detail resin, hand-painted · 4in', accent: 'magenta' },
  { name: 'SPINCORE', sub: 'Palm fidget toy', material: 'Durable resin · tactile action', accent: 'vapor-purple' },
  { name: 'SENTINEL', sub: 'Display statue, made to order', material: 'Standard resin · 12in', accent: 'sunset' },
];

const SERVICES = [
  {
    title: 'Anime & Character Figures',
    description: 'Scale figures, chibis and busts from your favorite characters, or your own OC. Printed at 25 microns so every strand of hair and fold of cloth survives the paint.',
    accent: 'cyan',
    tag: 'RESIN · SLA',
    from: 30,
    details: [
      'Best for characters, busts, chibis, OCs and display figures where tiny details need to stay sharp.',
      'References, pose, scale and finish all shape the quote, especially when hair, cloth, armor or props get complex.',
      'A strong fit when the piece should feel like a collectible instead of a quick novelty print.',
    ],
  },
  {
    title: 'Vintage & Replicas',
    description: 'Palm-sized arcade cabinets, retro consoles, model cars and out-of-production collectibles, reverse-modeled from photos and finished to look like the real thing.',
    accent: 'magenta',
    tag: 'REPLICA · RESTORE',
    from: 28,
    details: [
      'Best for objects that are hard to buy, out of production, too expensive, or personal enough to recreate as a miniature.',
      'Photo references, measurements and key visual details help the model land closer to the real thing.',
      'Great for nostalgia gifts, tiny shelf scenes, cabinet rows, console replicas and collector display pieces.',
    ],
  },
  {
    title: 'Fidget Toys',
    description: 'Pocket sliders, clickers, spinners and tactile desk toys tuned for satisfying motion, clean handling and small-batch gift runs.',
    accent: 'vapor-purple',
    tag: 'FIDGET · TACTILE',
    from: 18,
    details: [
      'Best for pocket pieces, desk toys, sliders, clickers and simple mechanical objects that need satisfying movement.',
      'Material choice matters here because handled pieces need cleaner tolerance, smoother contact points and better impact behavior.',
      'A strong option for small-batch gifts, desk setup pieces and tactile objects that should actually get used.',
    ],
  },
  {
    title: 'Display Statues',
    description: 'Want it big? We go up to a full 12 inches. Multi-part prints seamed, sanded and finished into one continuous statue for the shelf or the cabinet.',
    accent: 'sunset',
    tag: 'UP TO 12 IN',
    from: 40,
    details: [
      'Best for larger display pieces, centerpiece statues, original characters and big shelf moments up to 12 inches.',
      'Large prints often need multiple parts, seam cleanup, stronger bases and more finish time to look intentional.',
      'This is the premium lane when scale, silhouette and display presence matter more than keeping it tiny.',
    ],
  },
];

const MATERIALS = [
  { name: 'Detail Resin', note: 'Crisp figures and replicas', accent: 'cyan' },
  { name: 'Durable Resin', note: 'Fidget toys and moving parts', accent: 'vapor-purple' },
  { name: 'Glow Resin', note: 'Light-up features after dark', accent: 'magenta' },
  { name: 'Metallic Resin', note: 'Armor, hardware and trophy shine', accent: 'sunset' },
];

const MATERIAL_GUIDE = [
  {
    name: 'Detail Resin',
    accent: 'cyan',
    bestFor: 'Anime figures, vintage replicas, busts and tiny surface details',
    feel: 'Smooth, crisp, display-focused',
    finish: 'Works as a matte monochrome base, or as the foundation for color and glow finishes.',
    details: [
      'Best for crisp surface detail, small facial features, hair, armor lines, logos and replica parts.',
      'This material is chosen when the model needs sharp definition more than flex or impact resistance.',
      'A strong fit for display pieces that will be finished, painted, photographed or kept on a shelf.',
    ],
  },
  {
    name: 'Durable Resin',
    accent: 'vapor-purple',
    bestFor: 'Fidget toys, clickers, sliders, hinges and handled pieces',
    feel: 'More flexible and impact-resistant than standard display resin',
    finish: 'Works best with the color + UV coat tier when the piece needs to be handled.',
    details: [
      'Best for pieces that get picked up, pressed, clicked, slid or handled more than a display statue.',
      'Durable resin gives moving parts a safer material choice without making the piece feel cheap.',
      'A good match for desk toys, fidgets, functional details and commissions that need cleaner everyday handling.',
    ],
  },
  {
    name: 'Glow Resin',
    accent: 'magenta',
    bestFor: 'Eyes, energy cores, panel lines, logos and full glow features',
    feel: 'Charges under light, glows in the dark',
    finish: 'Used for the glow tier, with exposed light-up areas under the UV-coated color finish.',
    details: [
      'Best for planned glow moments like eyes, cores, runes, panel lines, logos and exposed accent areas.',
      'The glow is strongest when it is built into the material choice, not treated as a last-second effect.',
      'A strong option for figures, props and display pieces that should change personality when the lights drop.',
    ],
  },
  {
    name: 'Metallic Resin',
    accent: 'sunset',
    bestFor: 'Armor trim, coins, emblems, robot parts, props and trophy-style accents',
    feel: 'Heavier visual read with a polished metal-effect surface',
    finish: 'Best when the piece should read chrome, steel, gold, bronze or battle-worn metal without needing a full paint job.',
    details: [
      'Best for armor, hardware, coins, emblems, robot details, trophy pieces and metal-look accents.',
      'Metallic resin gives the surface a heavier visual read before any extra finish work is added.',
      'A good choice when the design should suggest chrome, steel, gold, bronze or worn metal from the start.',
    ],
  },
];

const FINISH_GUIDE = [
  {
    name: 'Matte Monochrome',
    accent: 'cyan',
    cost: 'Printable base',
    description: 'Printed in a clean matte single-color finish, cured, support marks handled and refined for a premium display-ready base.',
    details: [
      'Best when the form and silhouette should feel clean, premium and gallery-ready without full color work.',
      'Support points are cleaned, the surface is refined, and the piece is left in a calm single-color finish.',
      'A strong base choice for prototypes, display models, gifts, and clients who may want paint later.',
    ],
  },
  {
    name: 'Color + UV Coat',
    accent: 'magenta',
    cost: 'Finished color',
    description: 'A colored finish with a UV resin clear-coat touch for extra pop, smoother shine and better handling protection.',
    details: [
      'Best for figures, replicas, fidgets and display pieces that should arrive shelf-ready.',
      'Color is applied for the final look, then a UV resin clear-coat touch adds extra pop and handling protection.',
      'A good middle tier when the object needs polish without the full glow treatment.',
    ],
  },
  {
    name: 'Glow + UV Coat',
    accent: 'sunset',
    cost: 'Glow feature',
    description: 'The same colored UV-coated finish, upgraded with glow-in-the-dark features like eyes, cores, trim or logo marks.',
    details: [
      'Best for eyes, energy cores, panel lines, logos, trim and moments that should activate after dark.',
      'Glow areas are planned into the finish so they read clearly in daylight and hit harder when charged.',
      'The most FreshWave option for collectibles, display statues and statement pieces.',
    ],
  },
];

const PROCESS = [
  { step: '01', title: 'Model', body: 'We sculpt from your reference, photo or 3D file, or design an original character with you over a call.' },
  { step: '02', title: 'Print', body: 'Resin at 25 microns for figures, scaled up to 12in for statues. Every micron of detail makes it onto the part.' },
  { step: '03', title: 'Cure & Clean', body: 'Supports removed by hand, parts UV-cured to full strength, seams sanded smooth on multi-part statues.' },
  { step: '04', title: 'Finish', body: 'Left matte monochrome, color-coated with UV resin touch, or upgraded with glow features, then assembled and QC\u2019d.' },
];

const STATS = [
  { label: 'One-off pieces', value: '1:1' },
  { label: 'Fine resin detail', value: '25\u00b5m' },
  { label: 'Starter turnaround', value: '5-14d' },
];

const PROJECTS = [
  {
    slug: 'nova-x',
    title: 'NOVA-X',
    category: 'Anime Figures',
    year: '2025',
    accent: 'cyan',
    description: 'A 7-inch glow-in-the-dark mecha figure for a creator\u2019s merch drop. Printed in UV-reactive resin so the energy core and panel lines charge by day and glow through the night.',
    material: 'UV-reactive resin · 7in',
    overview: 'A streamer wanted a limited figure of their original mecha OC, something fans could actually own that looked like a studio collectible, not a print.',
    challenge: 'Capture razor-fine panel lines and a glowing core at 7 inches while keeping resin cost and finish time realistic.',
    approach: 'We sculpted the figure for printing, split it into paint-friendly sub-assemblies, printed in glow resin at 25 microns, then hand-painted with the core left raw to glow.',
    outcome: 'The 50-piece drop sold out in a weekend. Fans post charge-and-glow photos constantly, and the creator now plans a second pose.',
  },
  {
    slug: 'arcade-84',
    title: 'ARCADE 84',
    category: 'Vintage & Replicas',
    year: '2025',
    accent: 'magenta',
    description: 'A palm-sized replica of a classic 1984 arcade cabinet, reverse-modeled from photos. Four inches tall, working marquee decal, and a coin door that actually opens.',
    material: 'Detail resin, hand-painted · 4in',
    overview: 'A collector wanted a desktop miniature of the cabinet they grew up on, one that no manufacturer makes anymore.',
    challenge: 'Recreate an accurate, recognizable cabinet at palm size, with crisp artwork and tiny working details, from reference photos alone.',
    approach: 'We modeled the cabinet from gathered references, printed it in detail resin, then hand-painted and applied micro-decals for the marquee and side art.',
    outcome: 'A perfect shelf piece. The collector has since commissioned three more cabinets to build a tiny arcade row.',
  },
  {
    slug: 'spincore',
    title: 'SPINCORE',
    category: 'Fidget Toys',
    year: '2024',
    accent: 'vapor-purple',
    description: 'A pocket fidget toy printed in durable resin with smooth tactile motion, glow linework and a UV-coated color finish.',
    material: 'Durable resin · pocket-sized',
    overview: 'A desk-toy collector wanted a small fidget piece that felt premium, moved cleanly and looked like a FreshWave object.',
    challenge: 'Tune the fit so the motion feels satisfying without loose parts, rough edges or cheap toy energy.',
    approach: 'Printed in durable resin, sanded at the contact points, color-finished, then upgraded with glow linework under a UV resin clear coat.',
    outcome: 'A pocketable one-off that became the model for small-batch fidget requests and gift runs.',
  },
  {
    slug: 'sentinel',
    title: 'SENTINEL',
    category: 'Statues',
    year: '2025',
    accent: 'sunset',
    description: 'A full 12-inch display statue printed in five seamed parts. A made-to-order centerpiece, sanded and finished into one continuous surface for the cabinet.',
    material: 'Standard resin · 12in',
    overview: 'A collector wanted a true display-scale statue of an original character, the biggest piece we offer.',
    challenge: 'Hit our 12-inch ceiling with invisible seams, even surface finish, and a base that supports the pose without visible supports.',
    approach: 'Split into five printable sections sized to the build plate, seamed and sanded to one surface, mounted on a printed base and finished to order.',
    outcome: 'The statue anchors the collector\u2019s cabinet and kicked off a waitlist for made-to-order display pieces.',
  },
  {
    slug: 'pocket-diorama',
    title: 'POCKET',
    category: 'Vintage & Replicas',
    year: '2025',
    accent: 'cyan',
    description: 'A palm-sized handheld-console diorama, a tiny scene built around a 90s handheld replica, all under three inches and barely a spool\u2019s worth of resin.',
    material: 'Detail resin, hand-painted · 3in',
    overview: 'A gift commission: a nostalgic micro-scene capturing someone\u2019s favorite childhood handheld.',
    challenge: 'Pack a recognizable, detailed scene into a palm-sized footprint that stays cheap on material.',
    approach: 'Modeled as one compact diorama, printed in detail resin, then hand-painted with weathering to sell the nostalgia.',
    outcome: 'A standout gift, now a popular made-to-order template for other handhelds and consoles.',
  },
  {
    slug: 'chroma-bust',
    title: 'CHROMA',
    category: 'Commission',
    year: '2025',
    accent: 'magenta',
    description: 'A one-off 6-inch character bust commissioned from a single reference image. Sculpted, printed and hand-painted to match the art exactly.',
    material: 'Detail resin, hand-painted · 6in',
    overview: 'A fan wanted a physical bust of an original character that only existed as a single piece of digital art.',
    challenge: 'Translate one flat illustration into an accurate, paint-matched 3D bust the client would recognize instantly.',
    approach: 'We sculpted the bust from the reference, confirmed the form with the client, printed in detail resin and hand-painted to the source palette.',
    outcome: 'A one-of-one keepsake delivered in under two weeks, with a steady stream of bust commissions since.',
  },
];

const WORK_CATEGORIES = ['All', 'Anime Figures', 'Vintage & Replicas', 'Fidget Toys', 'Statues', 'Commission'];

// Sleeper items for the quick lane. These are ready-to-scope concepts that
// can later be wired to inventory, checkout, uploads, or a real inquiry API.
const PRELOADS = [
  {
    id: 'controller-cradle',
    title: 'Controller Cradle',
    category: 'Desk Setup',
    accent: 'cyan',
    price: 26,
    tag: 'Sleeper pick',
    size: 'Desk fit',
    turnaround: '5-7 days',
    description: 'A clean dock for controllers, handhelds or remotes that keeps the setup intentional instead of cluttered.',
    includes: ['Device-fit cradle', 'Cable pass-through', 'Optional glow logo'],
  },
  {
    id: 'cable-comb-kit',
    title: 'Cable Comb Kit',
    category: 'Setup Upgrade',
    accent: 'magenta',
    price: 18,
    tag: 'Quiet fix',
    size: 'Small batch',
    turnaround: '5-7 days',
    description: 'Low-profile cable guides for desks, consoles, chargers or printer stations that make the mess disappear.',
    includes: ['3-piece tidy kit', 'Adhesive-ready backs', 'Color-coded options'],
  },
  {
    id: 'pocket-dump-tray',
    title: 'Pocket Dump Tray',
    category: 'Everyday Carry',
    accent: 'vapor-purple',
    price: 24,
    tag: 'Daily carry',
    size: 'Palm tray',
    turnaround: '5-8 days',
    description: 'A landing pad for keys, rings, earbuds, dice or tiny tools so the daily pocket dump has a home.',
    includes: ['Raised lip tray', 'Name or icon mark', 'Glow edge option'],
  },
  {
    id: 'mini-riser',
    title: 'Mini Display Riser',
    category: 'Shelf Upgrade',
    accent: 'sunset',
    price: 32,
    tag: 'Shelf hack',
    size: 'Shelf fit',
    turnaround: '7-10 days',
    description: 'A small riser for figures, perfumes, collectibles or desk objects that instantly makes a shelf read cleaner.',
    includes: ['Low-profile riser', 'Custom top plate', 'Optional label strip'],
  },
];

const PRELOAD_FINISHES = [
  { id: 'white', label: 'Matte monochrome', price: 0 },
  { id: 'color', label: 'Color + UV coat', price: 18 },
  { id: 'glow', label: 'Glow + UV coat', price: 28 },
];

const PRELOAD_SIZES = [
  { id: 'standard', label: 'Standard', mult: 1 },
  { id: 'plus', label: 'Plus size', mult: 1.35 },
];

// Commission wizard config
const COMMISSION_CATEGORIES = [
  { id: 'figure', label: 'Anime / Character Figure', note: 'Scale figure, chibi or bust' },
  { id: 'vintage', label: 'Vintage / Replica', note: 'Arcade, console, model, collectible' },
  { id: 'fidget', label: 'Fidget Toy', note: 'Slider, clicker, spinner, desk toy' },
  { id: 'statue', label: 'Display Statue', note: 'Up to a full 12 inches' },
  { id: 'surprise', label: 'Not sure yet', note: 'Bring us the idea. We\u2019ll scope it' },
];

const COMMISSION_MATERIALS = [
  { id: 'detail', label: 'Detail Resin', note: 'Fine figure detail', accent: 'cyan' },
  { id: 'durable', label: 'Durable Resin', note: 'Fidgets & moving parts', accent: 'vapor-purple' },
  { id: 'glow', label: 'Glow Resin', note: 'Charges & glows', accent: 'magenta' },
  { id: 'metallic', label: 'Metallic Resin', note: 'Metal-look accents', accent: 'sunset' },
];

const COMMISSION_FINISHES = [
  { id: 'white', label: 'Matte monochrome', note: 'Clean single-color base with a refined matte surface' },
  { id: 'color', label: 'Color + UV coat', note: 'Colored finish with UV resin clear coat' },
  { id: 'glow', label: 'Glow + UV coat', note: 'Color finish with glow-in-the-dark features' },
];

// --- Live price model (estimates only; final quote confirmed by hand) -----
const PRICING = {
  category: { figure: 30, vintage: 28, fidget: 18, statue: 40, surprise: 30 },
  // keyed by the size labels used in the wizard
  size: { 'Palm (≤3in)': 1, 'Desk (3-6in)': 1.6, 'Shelf (6-9in)': 2.4, 'Statue (up to 12in)': 3.6 },
  sizeAdd: {},
  categorySizeAdd: {
    fidget: { 'Palm (≤3in)': 6, 'Desk (3-6in)': 10, 'Shelf (6-9in)': 18, 'Statue (up to 12in)': 28 },
  },
  material: { detail: 0, durable: 4, glow: 6, metallic: 8 },
  finish: { white: 0, color: 18, glow: 28 },
};

function estimateRange(d) {
  if (!d.category) return null;
  const base = PRICING.category[d.category] || 30;
  const sizeMult = PRICING.size[d.size] != null ? PRICING.size[d.size] : 1;
  const sizeAdd = PRICING.sizeAdd[d.size] || 0;
  const categorySizeAdd = ((PRICING.categorySizeAdd || {})[d.category] || {})[d.size] || 0;
  const matAdd = PRICING.material[d.material] || 0;
  const finAdd = PRICING.finish[d.finish] || 0;
  const qty = Math.max(1, d.qty || 1);
  const unit = base * sizeMult + Math.max(sizeAdd, categorySizeAdd) + matAdd + finAdd;
  const total = unit * qty;
  const round5 = (n) => Math.max(5, Math.round(n / 5) * 5);
  return { low: round5(total * 0.9), high: round5(total * 1.15), unit: round5(unit), qty };
}

Object.assign(window, {
  FEATURED, SERVICES, MATERIALS, MATERIAL_GUIDE, FINISH_GUIDE, PROCESS, STATS, PROJECTS, WORK_CATEGORIES,
  PRELOADS, PRELOAD_FINISHES, PRELOAD_SIZES,
  COMMISSION_CATEGORIES, COMMISSION_MATERIALS, COMMISSION_FINISHES,
  PRICING, estimateRange,
});
