export interface Station {
  id: string
  name: string
  lat: number
  lng: number
  line: 'red' | 'blue-east' | 'blue-west' | 'sherford' | 'tamar'
  interchange?: boolean
  zone: number
  status: 'open' | 'disused-station' | 'disused-trackbed' | 'new-build'
  closedYear?: number
  description: string
  notes?: string
  slug: string
}

export const STATIONS: Station[] = [

  // ══ RED LINE — Plymouth Station → A386 → Crownhill → Derriford ══
  {
    id: 'r1', slug: 'plymouth-railway-station',
    name: 'Plymouth Railway Station',
    lat: 50.3783, lng: -4.1382, line: 'red',
    interchange: true, zone: 1, status: 'open',
    description: 'Plymouth\'s national rail hub and the origin of all four Metro lines. Currently served by GWR services to London Paddington, Bristol, Exeter and Cornwall, plus Cross Country to the North.',
    notes: 'All Metro lines originate here.',
  },
  {
    id: 'r2', slug: 'mutley-plain',
    name: 'Mutley Plain',
    lat: 50.3838, lng: -4.1365, line: 'red',
    zone: 1, status: 'disused-station', closedYear: 1939,
    description: 'Mutley station closed 1939 when Plymouth North Road (now Plymouth Railway Station) was rebuilt and expanded. Crucially, the active Exeter–Plymouth mainline still runs through Mutley Tunnel directly beneath Mutley Plain today. A new halt is one of the most cost-effective reopenings possible.',
    notes: 'Active mainline beneath. Low-cost reopening candidate.',
  },
  {
    id: 'r3', slug: 'st-judes',
    name: 'St Jude\'s',
    lat: 50.3900, lng: -4.1360, line: 'red',
    zone: 2, status: 'new-build',
    description: 'No historic railway. New segregated Metro trackway required north along the A386 Tavistock Road corridor from Mutley Plain.',
    notes: 'New-build. A386 provides natural alignment with existing bus priority.',
  },
  {
    id: 'r4', slug: 'crownhill',
    name: 'Crownhill',
    lat: 50.4005, lng: -4.1428, line: 'red',
    zone: 2, status: 'new-build',
    description: 'No existing or historic railway. New dedicated Metro trackway along the A386 corridor required. Plymouth City Council has already invested in bus priority on this route, making a segregated Metro corridor feasible.',
    notes: 'New-build. Existing bus priority corridor on A386.',
  },
  {
    id: 'r5', slug: 'derriford',
    name: 'Derriford',
    lat: 50.4148, lng: -4.1103, line: 'red',
    zone: 3, status: 'new-build',
    description: 'Red Line terminus serving Derriford Hospital — one of the largest hospitals in the South West — and Plymouth Science Park. No historic railway. New terminal station required.',
    notes: 'New-build terminus. Major destination — c.7,000 staff at hospital.',
  },

  // ══ BLUE LINE EAST — Plymouth Station → Laira → Plympton → Ivybridge ══
  // This is the correct order on the Exeter–Plymouth mainline
  {
    id: 'be1', slug: 'plymouth-railway-station-blue-east',
    name: 'Plymouth Railway Station',
    lat: 50.3783, lng: -4.1382, line: 'blue-east',
    interchange: true, zone: 1, status: 'open',
    description: 'Origin for all Metro lines. Blue Line East runs eastward along the existing Exeter–Plymouth mainline corridor.',
  },
  {
    id: 'be2', slug: 'laira',
    name: 'Laira',
    lat: 50.3775, lng: -4.1028, line: 'blue-east',
    zone: 2, status: 'disused-station', closedYear: 1930,
    description: 'Laira Halt closed 1930. The active Exeter–Plymouth mainline still passes directly through the site. The former Laira railway bridge over the River Plym was refurbished in 2015 and now carries pedestrians and cyclists — the structure survives. Laira TMD (train maintenance depot) is also here.',
    notes: 'Active mainline. Bridge survives as cycle path. Train depot nearby.',
  },
  {
    id: 'be3', slug: 'plympton',
    name: 'Plympton',
    lat: 50.3728, lng: -4.0548, line: 'blue-east',
    interchange: true, zone: 3, status: 'disused-station', closedYear: 1959,
    description: 'Station closed to passengers 2 March 1959, goods 1 June 1964. Station was demolished — no remains survive. The active Exeter–Plymouth mainline still runs through. Plymouth City Council\'s adopted Plymouth Plan Policy GRO4 specifically includes reopening a Plympton station. Network Rail site review underway 2026/27. Junction for Sherford Branch.',
    notes: 'Active mainline. Plymouth Plan Policy GRO4. Sherford Branch junction. Network Rail review active.',
  },
  {
    id: 'be4', slug: 'bittaford',
    name: 'Bittaford',
    lat: 50.3977, lng: -3.8766, line: 'blue-east',
    zone: 4, status: 'disused-station', closedYear: 1959,
    description: 'Bittaford Platform closed 1959. The active Exeter–Plymouth mainline still runs through the site. No visible platform remains but reinstating a halt is straightforward as the track is present and passes through.',
    notes: 'Active mainline. Halt could be reinstated readily.',
  },
  {
    id: 'be5', slug: 'wrangaton',
    name: 'Wrangaton',
    lat: 50.4044, lng: -3.8545, line: 'blue-east',
    zone: 4, status: 'disused-station', closedYear: 1959,
    description: 'Wrangaton station closed to passengers 1959. The active Exeter–Plymouth mainline still passes through. Part of the original platform is still visible just west of Wrangaton Tunnel — one of the few disused Plymouth-area stations with surviving fabric.',
    notes: 'Active mainline. Platform remnant visible.',
  },
  {
    id: 'be6', slug: 'ivybridge',
    name: 'Ivybridge',
    lat: 50.3940, lng: -3.9050, line: 'blue-east',
    zone: 4, status: 'open',
    description: 'Currently open. Modern station opened 1994 on the Exeter–Plymouth mainline — the original Ivybridge station closed 1965. One of Devon\'s fastest-growing stations with 136,994 passengers in 2024/25. Blue Line East terminus.',
    notes: 'Fully open. 136,994 passengers 2024/25. Growing strongly.',
  },

  // ══ BLUE LINE WEST — Plymouth Station → Devonport ══
  // Separate westward arm using existing Cornish Main Line
  {
    id: 'bw1', slug: 'plymouth-railway-station-blue-west',
    name: 'Plymouth Railway Station',
    lat: 50.3783, lng: -4.1382, line: 'blue-west',
    interchange: true, zone: 1, status: 'open',
    description: 'Origin. Blue Line West runs westward along the Cornish Main Line to Devonport.',
  },
  {
    id: 'bw2', slug: 'devonport',
    name: 'Devonport',
    lat: 50.3762, lng: -4.1782, line: 'blue-west',
    interchange: true, zone: 2, status: 'open',
    description: 'Currently open. Active GWR station on both the Cornish Main Line and Tamar Valley Line. Serves HMNB Devonport — home of the Royal Navy\'s largest base and one of Europe\'s largest naval bases. Blue Line West terminus and Tamar Line interchange.',
    notes: 'Fully open. Interchange with Tamar Line.',
  },

  // ══ SHERFORD BRANCH — Plymouth Station → Plympton → Sherford → Plymstock ══
  // Branches south from Plympton, following broad corridor of old Turnchapel/Yealmpton branches
  {
    id: 's1', slug: 'plympton-sherford',
    name: 'Plympton',
    lat: 50.3728, lng: -4.0548, line: 'sherford',
    interchange: true, zone: 3, status: 'disused-station', closedYear: 1959,
    description: 'Sherford Branch junction with Blue Line East at Plympton. The branch diverges southward here following the approximate corridor of the former Turnchapel and Yealmpton branch lines.',
    notes: 'Interchange with Blue Line East. Branch diverges south.',
  },
  {
    id: 's2', slug: 'langage',
    name: 'Langage',
    lat: 50.3700, lng: -4.0248, line: 'sherford',
    zone: 3, status: 'new-build',
    description: 'New station serving Langage Energy Centre, the Langage Business Park, and the South Devon Freeport — a major new economic zone. No historical railway. Plymouth City Council has specifically cited Langage connectivity as a strategic priority.',
    notes: 'New-build. South Devon Freeport anchor station.',
  },
  {
    id: 's3', slug: 'sherford',
    name: 'Sherford',
    lat: 50.3618, lng: -4.0348, line: 'sherford',
    zone: 3, status: 'new-build',
    description: 'New community of approximately 5,500 homes currently under construction south-east of Plymouth. No historical railway. A purpose-designed Metro station is integral to the development\'s transport strategy. Developer contributions could fund infrastructure.',
    notes: 'New-build. Developer funding potential via planning conditions.',
  },
  {
    id: 's4', slug: 'elburton',
    name: 'Elburton',
    lat: 50.3638, lng: -4.0805, line: 'sherford',
    zone: 3, status: 'disused-trackbed', closedYear: 1947,
    description: 'Elburton Cross station on the Plymouth–Yealmpton branch closed to passengers 1947, completely 1960. The trackbed south from Plympton partially survives but much has been built over or converted. New Metro infrastructure required for this section.',
    notes: 'Former Yealmpton branch. Trackbed partially lost.',
  },
  {
    id: 's5', slug: 'plymstock',
    name: 'Plymstock',
    lat: 50.3608, lng: -4.0982, line: 'sherford',
    zone: 3, status: 'disused-trackbed', closedYear: 1951,
    description: 'Plymstock station on the Turnchapel branch closed to passengers 1951, goods 1961. No station remains survive. The Laira Bridge (former railway bridge over the River Plym) was refurbished in 2015 as a cycle path — community advocates have long proposed using this corridor for a Metro link. Sherford Branch southern terminus.',
    notes: 'No remains. Laira Bridge survives as cycle path. Sherford Branch terminus.',
  },

  // ══ TAMAR LINE — Plymouth → Devonport → St Budeaux → Bere Alston → Tavistock ══
  // Uses existing Tamar Valley Line (Plymouth to Bere Alston) — all open
  // Reinstated trackbed Bere Alston → Tavistock (government-backed scheme)
  {
    id: 't1', slug: 'plymouth-railway-station-tamar',
    name: 'Plymouth Railway Station',
    lat: 50.3783, lng: -4.1382, line: 'tamar',
    interchange: true, zone: 1, status: 'open',
    description: 'Tamar Line origin. Uses the existing Tamar Valley Line northward via Devonport.',
  },
  {
    id: 't2', slug: 'devonport-tamar',
    name: 'Devonport',
    lat: 50.3762, lng: -4.1782, line: 'tamar',
    interchange: true, zone: 1, status: 'open',
    description: 'Currently open. Tamar Valley Line and Cornish Main Line station. Interchange with Blue Line West.',
    notes: 'Fully open. Two lines serve this station.',
  },
  {
    id: 't3', slug: 'dockyard',
    name: 'Dockyard',
    lat: 50.3825, lng: -4.1760, line: 'tamar',
    zone: 1, status: 'open',
    description: 'Currently open. GWR station primarily serving HMNB Devonport workers. 15,102 passengers in 2024/25.',
    notes: 'Open. Growing — large employer base.',
  },
  {
    id: 't4', slug: 'keyham',
    name: 'Keyham',
    lat: 50.3901, lng: -4.1798, line: 'tamar',
    zone: 1, status: 'open',
    description: 'Currently open. GWR station served by both Cornish Main Line and Tamar Valley Line services. 16,126 passengers in 2024/25.',
    notes: 'Fully open. Two lines.',
  },
  {
    id: 't5', slug: 'st-budeaux-ferry-road',
    name: 'St Budeaux Ferry Road',
    lat: 50.4014, lng: -4.1868, line: 'tamar',
    zone: 1, status: 'open',
    description: 'Currently open. GWR station on the Cornish Main Line. 4,484 passengers in 2024/25.',
    notes: 'Open — Cornish Main Line.',
  },
  {
    id: 't6', slug: 'st-budeaux-victoria-road',
    name: 'St Budeaux Victoria Road',
    lat: 50.4020, lng: -4.1880, line: 'tamar',
    interchange: true, zone: 1, status: 'open',
    description: 'Currently open. The junction station where the Tamar Valley Line diverges north from the Cornish Main Line. 11,864 passengers in 2024/25 — growing rapidly. Proposed key interchange with Metro Red Line. Reopening the Tavistock line would significantly increase frequencies here.',
    notes: 'Fully open. Growing fast. Junction — Red Line interchange proposed.',
  },
  {
    id: 't7', slug: 'bere-ferrers',
    name: 'Bere Ferrers',
    lat: 50.4500, lng: -4.1810, line: 'tamar',
    zone: 3, status: 'open',
    description: 'Currently open. Tamar Valley Line request stop in the rural Tamar Valley AONB. 14,614 passengers in 2024/25.',
    notes: 'Open — Tamar Valley Line. Rural gateway.',
  },
  {
    id: 't8', slug: 'bere-alston',
    name: 'Bere Alston',
    lat: 50.4860, lng: -4.2000, line: 'tamar',
    zone: 3, status: 'open',
    description: 'Currently open. Busiest station on the Tamar Valley Line with 39,426 passengers in 2024/25. The junction point where the reinstated line to Tavistock diverges northward. Reopening Tavistock would add an hourly service on top of the existing two-hourly Gunnislake service.',
    notes: 'Fully open. Busiest TVL station. Tavistock junction.',
  },
  {
    id: 't9', slug: 'tavistock',
    name: 'Tavistock',
    lat: 50.5480, lng: -4.1460, line: 'tamar',
    zone: 4, status: 'disused-trackbed', closedYear: 1968,
    description: 'Tavistock North closed 1968 as part of the Beeching cuts. The trackbed from Bere Alston is almost entirely intact — Devon County Council has acquired over 80% of the required land. Engineering surveys confirm bridges, tunnels and viaducts including Shillamill Viaduct are in sound condition. Strategic Outline Business Case submitted to DfT Autumn 2022. Forecast 394,000 passengers/year. New station to be built south of A390 Callington Road.',
    notes: 'Trackbed intact. 80%+ land acquired. SOBC submitted 2022. Govt-backed scheme.',
  },
]

export const LINE_COLOURS: Record<string, string> = {
  'red':      '#E63946',
  'blue-east':'#2E9CCA',
  'blue-west':'#2E9CCA',
  'sherford': '#F5A623',
  'tamar':    '#8B5CF6',
}

export const LINE_LABELS: Record<string, string> = {
  'red':      'Red Line — Derriford via A386',
  'blue-east':'Blue Line — Ivybridge (eastbound)',
  'blue-west':'Blue Line — Devonport (westbound)',
  'sherford': 'Sherford Branch — Plympton to Plymstock',
  'tamar':    'Tamar Line — Tavistock',
}

export const STATUS_LABELS: Record<Station['status'], string> = {
  'open':             'Currently open',
  'disused-station':  'Disused — track still active',
  'disused-trackbed': 'Disused — track & station closed',
  'new-build':        'New infrastructure required',
}

export const STATUS_COLOURS: Record<Station['status'], string> = {
  'open':             '#16A34A',
  'disused-station':  '#D97706',
  'disused-trackbed': '#DC2626',
  'new-build':        '#6B7280',
}
