// Vehicle data for the prototype.
// One deep, lovingly-detailed record. The interactions are real; the
// numbers are mocked but plausible.

const VEHICLE = {
  // Identity
  year: 1973,
  make: 'Porsche',
  model: '911 Carrera RS 2.7',
  trim: 'Lightweight · M471',
  nickname: 'Old Yeller',
  vin: '9113600542',
  plate: 'CARRERA · CA',
  color: 'Light Yellow / Black',
  mileage: 48219,
  ownership: { since: 'April 2019', years: 5, months: 2 },

  // Status
  status: 'Active',
  statusOptions: ['Active', 'In Restoration', 'Needs Service', 'In Storage', 'Transporting', 'For Sale'],

  // Location
  location: {
    name: 'Carmel Garage',
    city: 'Carmel, CA',
    movedDate: 'May 14, 2024',
    climate: 'Climate-controlled · 68° / 45% RH',
    other: [
      { name: 'Scottsdale Garage', city: 'Scottsdale, AZ', count: 3 },
      { name: 'Manhattan Townhouse', city: 'New York, NY', count: 2 },
      { name: 'Carmel Garage', city: 'Carmel, CA', count: 4, active: true },
    ],
  },

  // Value
  value: {
    current: 1_250_000,
    purchased: 1_210_000,
    purchasedAt: 'Gooding & Co. · Amelia Island',
    purchasedDate: 'February 2021',
    deltaTotal: 40_000,
    deltaPct: 3.3,
    appraisals: [
      { date: 'Nov 2024', source: 'Hagerty',        value: 1_265_000 },
      { date: 'Aug 2024', source: 'Pebble Beach AppraisalCo', value: 1_240_000 },
      { date: 'Nov 2023', source: 'Hagerty',        value: 1_180_000 },
      { date: 'Apr 2022', source: 'Bonhams Estimate', value: 1_150_000 },
      { date: 'Feb 2021', source: 'Purchase price', value: 1_210_000 },
    ],
    investments: [
      { label: 'Suspension rebuild (Bilstein, 2023)', cost: 14_200 },
      { label: 'Concours prep (Pebble 2024)', cost: 9_800 },
      { label: 'Paint touch-up & detail', cost: 3_450 },
      { label: 'Photographic re-archive', cost: 2_100 },
    ],
  },

  // Immediate attention
  attention: [
    { kind: 'service',   label: 'Oil change due',      detail: '14 days · last serviced Oct 8',   severity: 'soon' },
    { kind: 'tires',     label: 'Tires aging',         detail: '4 yrs · replace before next rally', severity: 'soon' },
    { kind: 'docs',      label: 'Registration expiring', detail: 'CA — expires Aug 12, 2026',    severity: 'watch' },
  ],

  // Health
  health: [
    { group: 'Engine',         status: 'Excellent',     note: 'Type 911/83 · 2.7 MFI · matching',   icon: 'spark' },
    { group: 'Transmission',   status: 'Excellent',     note: '915 5-spd · matching · rebuild 2018', icon: 'gauge' },
    { group: 'Suspension',     status: 'Recently rebuilt', note: 'Bilstein · EMC Motorsport · Apr 2023', icon: 'wrench' },
    { group: 'Paint',          status: 'Very good',     note: 'Original Light Yellow · 92% original', icon: 'spark' },
    { group: 'Interior',       status: 'Excellent',     note: 'Original RS basket-weave · pampering', icon: 'archive' },
    { group: 'Electrical',     status: 'Good',          note: 'Battery replaced 2023',               icon: 'gauge' },
    { group: 'Documentation',  status: 'Complete',      note: 'Kardex · COA · owner\'s manual',     icon: 'certificate' },
  ],

  // Provenance
  ownership_chain: [
    { from: '1973',     to: '1973',     owner: 'Porsche AG',           where: 'Stuttgart, DE',          note: 'Karmann body delivered to Werk II',           kind: 'factory' },
    { from: '1973',     to: '1981',     owner: 'Hans Berghoff',        where: 'Stuttgart, DE',          note: 'Original owner · Light Yellow over Black',    kind: 'private' },
    { from: '1981',     to: '2004',     owner: 'Wolfgang Kaufmann',    where: 'München, DE',            note: 'Concours appearances · Solitude Revival',     kind: 'private' },
    { from: '2004',     to: '2019',     owner: 'Bridge House Collection', where: 'London, UK',          note: 'Private museum · sub-1,000 mile yearly avg',  kind: 'collection' },
    { from: '2019',     to: 'present',  owner: 'You',                  where: 'Carmel, CA',             note: 'Active concours rotation',                    kind: 'self', current: true },
  ],

  provenance: {
    matchingVin: true,
    originalEngine: true,
    originalTrans: true,
    awards: [
      { event: "Pebble Beach Concours d'Elegance", placement: '2nd in Class', year: 2024 },
      { event: 'Porsche Werks Reunion, Monterey',  placement: 'Best in Class', year: 2022 },
      { event: 'Quail Motorsports Gathering',       placement: 'Invited',       year: 2023 },
    ],
    significance: [
      'One of ~200 M471 Lightweight examples built',
      'Featured in Porsche Christophorus Vol. 412 (1979)',
      'Period racing history at the 1974 Solitude Revival',
    ],
    docs: ['Kardex', 'Certificate of Authenticity', 'Owner\'s Manual (original)', 'Service book (continuous)', 'Period photography (47 prints)'],
  },

  // Timeline events
  timeline: [
    { date: 'Oct 8, 2024',  type: 'Service',       title: 'Oil & filter change',
      mileage: 48219, vendor: 'Cain Customs · Carmel, CA',     cost: 487,
      note: 'Mobil 1 15W-50 · OEM filter · plugs inspected',     attachments: 2 },
    { date: 'Aug 18, 2024', type: 'Concours',      title: "Pebble Beach Concours d'Elegance",
      mileage: 48180, vendor: 'Pebble Beach Co.',                cost: null,
      note: '2nd in Class · Postwar Sports',                     attachments: 5 },
    { date: 'May 14, 2024', type: 'Transport',     title: 'Trailered Scottsdale → Carmel',
      mileage: 48174, vendor: 'Reliable Carriers',               cost: 2_180,
      note: 'Enclosed transport · climate-monitored',            attachments: 1 },
    { date: 'Nov 22, 2023', type: 'Appraisal',     title: 'Insurance appraisal',
      mileage: 47540, vendor: 'Hagerty',                          cost: null,
      note: 'Agreed value $1,180,000 USD',                       attachments: 1 },
    { date: 'Apr 4, 2023',  type: 'Restoration',   title: 'Suspension rebuild',
      mileage: 47120, vendor: 'EMC Motorsport · Costa Mesa, CA', cost: 14_200,
      note: 'New Bilstein dampers · torsion bars re-indexed',    attachments: 6 },
    { date: 'Sep 9, 2022',  type: 'Concours',      title: 'Porsche Werks Reunion',
      mileage: 46420, vendor: 'Porsche Club of America',         cost: null,
      note: 'Best in Class · Air-Cooled Coupes',                 attachments: 4 },
    { date: 'Mar 30, 2022', type: 'Paint',         title: 'Stone-chip touch-up',
      mileage: 45800, vendor: 'Maaco Bespoke · Newport Beach',    cost: 3_450,
      note: 'Front bumper · color-matched OEM yellow',           attachments: 3 },
    { date: 'Feb 7, 2021',  type: 'Acquisition',   title: 'Purchased',
      mileage: 44912, vendor: 'Gooding & Co. · Amelia Island',   cost: 1_210_000,
      note: 'Hammer + premium · transferred from Bridge House',   attachments: 12 },
  ],

  // Service records
  service: [
    { date: 'Oct 2024', item: 'Oil & filter',        mileage: 48219, vendor: 'Cain Customs',     cost: 487,    next: 'Apr 2025' },
    { date: 'Aug 2024', item: 'Concours detail',     mileage: 48180, vendor: 'Custom Cars Polish', cost: 1_950, next: '—' },
    { date: 'Apr 2023', item: 'Suspension rebuild',  mileage: 47120, vendor: 'EMC Motorsport',    cost: 14_200, next: '50,000 mi' },
    { date: 'Mar 2022', item: 'Stone-chip touch-up', mileage: 45800, vendor: 'Maaco Bespoke',     cost: 3_450,  next: '—' },
    { date: 'Nov 2021', item: 'Annual inspection',   mileage: 45100, vendor: 'Cain Customs',     cost: 320,    next: 'Nov 2025' },
    { date: 'Mar 2021', item: 'Full fluids flush',   mileage: 44950, vendor: 'EMC Motorsport',    cost: 2_140,  next: '—' },
  ],

  // Parts inventory
  parts: [
    { name: 'Michelin Pilot Sport 4S',     spec: '215/60R15 · Set of 4',    type: 'OEM-spec', installed: 'Jan 2022', supplier: 'Tire Rack',         warranty: 'Jan 2030', cost: 1_840 },
    { name: 'Bilstein B6 dampers',         spec: 'M471 spec · set',          type: 'OEM',     installed: 'Apr 2023', supplier: 'EMC Motorsport',     warranty: 'Apr 2028', cost: 4_200 },
    { name: 'Bosch MFI fuel distributor',  spec: 'Rebuilt unit',             type: 'OEM',     installed: 'Mar 2021', supplier: 'Gus Pfister',        warranty: '—',         cost: 3_800 },
    { name: 'Optima Yellow Top battery',   spec: 'Group 34',                 type: 'Modern',  installed: 'Sep 2023', supplier: 'Pelican Parts',      warranty: 'Sep 2026', cost: 280 },
    { name: 'OEM clutch master cylinder',  spec: '911 series',               type: 'OEM-NOS', installed: 'Mar 2021', supplier: 'Porsche Classic',    warranty: '—',         cost: 540 },
    { name: 'Set of 4 Fuchs wheels',       spec: '6×15 / 7×15 · refinished', type: 'Original', installed: 'Jan 2022', supplier: 'Wheel Enhancement', warranty: '—',         cost: 3_200 },
  ],

  // Document vault
  documents: [
    { category: 'Provenance',     items: [
      { name: 'Porsche Kardex',         date: 'Feb 1973', kind: 'pdf',   pages: 4, archival: true },
      { name: 'Certificate of Authenticity', date: 'Mar 2008', kind: 'pdf', pages: 2, archival: true },
      { name: 'Period photographs',     date: '1973–1981', kind: 'image', pages: 47, archival: true },
    ]},
    { category: 'Registration',   items: [
      { name: 'CA Title',               date: 'Mar 2021', kind: 'pdf',   pages: 1 },
      { name: 'CA Registration',        date: 'Aug 2025', kind: 'pdf',   pages: 1, expires: 'Aug 2026' },
      { name: 'Smog exemption',         date: 'Aug 2025', kind: 'pdf',   pages: 1 },
    ]},
    { category: 'Insurance',      items: [
      { name: 'Hagerty Agreed-Value policy', date: 'Nov 2024', kind: 'pdf', pages: 8, expires: 'Nov 2025' },
      { name: 'Hagerty appraisal',      date: 'Nov 2024', kind: 'pdf',   pages: 12 },
    ]},
    { category: 'Service Records',items: [
      { name: 'Cain Customs · oil change', date: 'Oct 2024', kind: 'pdf', pages: 2 },
      { name: 'EMC Motorsport · suspension rebuild', date: 'Apr 2023', kind: 'pdf', pages: 14 },
      { name: 'Original Porsche service book', date: '1973–1981', kind: 'pdf', pages: 28, archival: true },
    ]},
    { category: 'Restoration',    items: [
      { name: 'Suspension teardown photo set',     date: 'Apr 2023', kind: 'image', pages: 64 },
      { name: 'Paint correction report',           date: 'Mar 2022', kind: 'pdf',   pages: 6 },
    ]},
    { category: 'Acquisition',    items: [
      { name: 'Gooding & Co. invoice',  date: 'Feb 2021', kind: 'pdf',   pages: 2 },
      { name: 'Bill of sale',           date: 'Feb 2021', kind: 'pdf',   pages: 1 },
      { name: 'Pre-purchase inspection', date: 'Jan 2021', kind: 'pdf',   pages: 22 },
    ]},
  ],
};

// Section list — drives the section tab strip & screen routing.
const SECTIONS = [
  { id: 'overview',    label: 'Overview',     icon: 'gauge' },
  { id: 'timeline',    label: 'Timeline',     icon: 'archive' },
  { id: 'provenance',  label: 'Ownership',    icon: 'certificate' },
  { id: 'value',       label: 'Value',        icon: 'hammer' },
  { id: 'service',     label: 'Service',      icon: 'wrench' },
  { id: 'documents',   label: 'Vault',        icon: 'bookmark' },
];

// Formatting helpers
const fmtMoney = (n, opts = {}) => {
  if (n == null) return '—';
  if (opts.compact && n >= 1_000_000) return `$${(n / 1_000_000).toFixed(2)}M`;
  if (opts.compact && n >= 1_000)     return `$${(n / 1_000).toFixed(1)}k`;
  return '$' + n.toLocaleString('en-US');
};
const fmtMiles = (n) => n.toLocaleString('en-US') + ' mi';

Object.assign(window, { VEHICLE, SECTIONS, fmtMoney, fmtMiles });
