local MUM = "%1 metro station (Mumbai)"

local c = {
	Blue    = '00AEEF',
	Yellow  = 'FFC600',
	Aqua    = '059DB2',
	Green   = '00AE5A',
	Orange  = 'FF8200',
	Pink    = 'F99FC9',
	Red     = 'D83431',
	Gold    = 'BF9724',
	Purple  = 'B896D4',
	Magenta = 'E10098',
}

-- Draw stacked bottom bars
local function bottomBars(cols)
    local n = #cols
    if n == 0 then return "" end
    local total = n * 6 + 1
    local images = {"linear-gradient(#000000,#000000)"}
    local sizes = {"100% calc(100% - "..total.."px)"}
    local pos = {"left top"}
    local off = 0
    for _, hex in ipairs(cols) do
        off = off + 1
        images[#images+1], sizes[#sizes+1], pos[#pos+1] = "linear-gradient(#"..hex..",#"..hex..")", "100% 5px", "left bottom "..off.."px"
        off = off + 5
    end
    return "background-color:transparent; background-image:"..table.concat(images,",").."; background-size:"..table.concat(sizes,",").."; background-position:"..table.concat(pos,",").."; background-repeat:no-repeat; padding-bottom:calc(0.3em + "..total.."px);"
end

-- Convert input text to stacked bottom bars

local function styleFromNames(styleText)
    local base = 'font-family:"Segoe UI","Helvetica Neue",Helvetica,Arial,sans-serif; '
        .. 'font-size:150%; background-color:#000000; color:#ABDFF8; '
        .. 'padding:0.625em 4px; line-height:110%; font-weight:500; letter-spacing:0.5px;'

    if not styleText or styleText == "" then
        return base
    end

    local cols = {}
    for part in styleText:gmatch("[^,]+") do
        local key = (part or ""):gsub("[^%w]", "")
        local hex = c[key]
        if not hex then
            return base
        end
        cols[#cols + 1] = hex
    end
    
    local rev = {}
    for i = #cols, 1, -1 do
        rev[#rev + 1] = cols[i]
    end

    return base .. bottomBars(rev)
end


local p = {
	["system title"] = "[[Mumbai Metro]]",
	["line icon format"] = "link",
	["rail box format"] = "title",
	["name format"] = setmetatable({}, {
	    __index = function(_, key)
	        return styleFromNames(key)
	    end
	}),
	["header background color"] = "11254A",
	["header text color"] = "FFFFFF",
	["station format"] = {
		"%1 metro station",
		["Anand Nagar"] = MUM
	},
	["lines"] = {
		["_default"] = {
			["title"] = "[[%1 Line (Mumbai Metro)|%1 Line]]",
			["color"] = "034794",
			["text color"] = "FFFFFF",
		},
		["Blue"] = {
			["color"] = c.Blue,
			["icon"] = "[[File:Logo of Mumbai Metro Line 1.svg|18px|link=Blue Line (Mumbai Metro)]]",
			["left terminus"] = "Versova",
			["right terminus"] = "Ghatkopar",
		},
		["1"] = {
			["title"] = "[[Blue Line (Mumbai Metro)|Blue Line 1]]",
			["color"] = c.Blue,
			["icon"] = "[[File:Logo of Mumbai Metro Line 1.svg|18px|link=Blue Line (Mumbai Metro)]]",
			["left terminus"] = "Versova",
			["right terminus"] = "Ghatkopar",
		},
		["Yellow"] = {
			["color"] = c.Yellow,
			["text color"] = "000000",
			["left terminus"] = "Mandale",
			["right terminus"] = "Dahisar (East)",
		},
		["2"] = {
			["title"] = "[[Yellow Line (Mumbai Metro)|Yellow Line 2]]",
			["color"] = c.Yellow,
			["text color"] = "000000",
			["left terminus"] = "Mandale",
			["right terminus"] = "Dahisar (East)",
		},
		["2A"] = {
			["title"] = "[[Yellow Line (Mumbai Metro)|Yellow Line 2A]]",
			["color"] = c.Yellow,
			["text color"] = "000000",
			["left terminus"] = "Andheri (West)",
			["right terminus"] = "Dahisar (East)",
		},
		["2B"] = {
			["title"] = "[[Yellow Line (Mumbai Metro)|Yellow Line 2B]]",
			["color"] = c.Yellow,
			["text color"] = "000000",
			["left terminus"] = "Mandale",
			["right terminus"] = "Andheri (West)",
		},
		["Aqua"] = {
			["color"] = c.Aqua,
			["icon"] = "[[File:Logo of Mumbai Metro Line 3.png|16px|link=Aqua Line (Mumbai Metro)]]",
			["left terminus"] = "Cuffe Parade",
			["right terminus"] = "Aarey JVLR",
		},
		["3"] = {
			["title"] = "[[Aqua Line (Mumbai Metro)|Aqua Line 3]]",
			["color"] = c.Aqua,
			["icon"] = "[[File:Logo of Mumbai Metro Line 3.png|16px|link=Aqua Line (Mumbai Metro)]]",
			["left terminus"] = "Cuffe Parade",
			["right terminus"] = "Aarey JVLR",
		},
		["Green"] = {
			["color"] = c.Green,
			["note-mid"] = "''(under construction)''",
			["left terminus"] = "Shivaji Chowk (Mira Road)",
			["left terminus"] = "Chhatrapati Shivaji Maharaj Terminus",
		},
		["4"] = {
			["title"] = "[[Green Line (Mumbai Metro)|Green Line 4]]",
			["color"] = c.Green,
			["note-mid"] = "''(under construction)''",
			["left terminus"] = "Kasarvadavali",
			["right terminus"] = "Bhakti Park (Wadala)",
		},
		["4A"] = {
			["title"] = "[[Green Line (Mumbai Metro)|Green Line 4A]]",
			["color"] = c.Green,
			["note-mid"] = "''(under construction)''",
			["left terminus"] = "Gaimukh",
			["right terminus"] = "Kasarvadavali",
		},
		["Orange"] = {
			["color"] = c.Orange,
			["note-mid"] = "''(under construction)''",
			["left terminus"] = "Kapurbawdi",
			["right terminus"] = "Taloja",
		},
		["5"] = {
			["title"] = "[[Orange Line (Mumbai Metro)|Orange Line 5]]",
			["color"] = c.Orange,
			["note-mid"] = "''(under construction)''",
			["left terminus"] = "Kapurbawdi",
			["right terminus"] = "Kalyan APMC",
		},
		["Pink"] = {
			["color"] = c.Pink,
			["text color"] = "000000",
			["note-mid"] = "''(under construction)''",
			["left terminus"] = "Swami Samarth Nagar (Lokhandwala)",
			["right terminus"] = "Vikhroli EEH",
		},
		["6"] = {
			["title"] = "[[Pink Line (Mumbai Metro)|Pink Line 6]]",
			["color"] = c.Pink,
			["text color"] = "000000",
			["note-mid"] = "''(under construction)''",
			["left terminus"] = "Swami Samarth Nagar (Lokhandwala)",
			["right terminus"] = "Vikhroli EEH",
		},
		["Red"] = {
			["color"] = c.Red,
			["note-mid"] = "''(under construction)''",
			["left terminus"] = "Subhash Chandra Bose Stadium",
			["right terminus"] = "Chhatrapati Shivaji Maharaj International Airport - T2",
		},
		["7"] = {
			["title"] = "[[Red Line (Mumbai Metro)|Red Line 7]]",
			["color"] = c.Red,
			["left terminus"] = "Ovaripada",
			["right terminus"] = "Gundavali",
		},
		["7A"] = {
			["title"] = "[[Red Line (Mumbai Metro)|Red Line 7A]]",
			["color"] = c.Red,
			["note-mid"] = "''(under construction)''",
			["left terminus"] = "Gundavali",
			["right terminus"] = "Chhatrapati Shivaji Maharaj International Airport - T2",
		},
		["Gold"] = {
			["color"] = c.Gold,
			["text color"] = "000000",
			["note-mid"] = "''(planned)''",
			["left terminus"] = "Chhatrapati Shivaji Maharaj International Airport - T2",
			["right terminus"] = "Navi Mumbai International Airport",
		},
		["8"] = {
			["title"] = "[[Gold Line (Mumbai Metro)|Gold Line 8]]",
			["color"] = c.Gold,
			["text color"] = "000000",
			["note-mid"] = "''(planned)''",
			["left terminus"] = "Chhatrapati Shivaji Maharaj International Airport - T2",
			["right terminus"] = "Navi Mumbai International Airport",
		},
		["9"] = {
			["title"] = "[[Red Line (Mumbai Metro)|Red Line 9]]",
			["color"] = c.Red,
			["left terminus"] = "Subhash Chandra Bose Stadium",
			["right terminus"] = "Dahisar (East)",
		},
		["10"] = {
			["title"] = "[[Green Line (Mumbai Metro)|Green Line 10]]",
			["color"] = c.Green,
			["note-mid"] = "''(planned)''",
			["left terminus"] = "Shivaji Chowk (Mira Road)",
			["right terminus"] = "Gaimukh",
		},
		["11"] = {
			["title"] = "[[Green Line (Mumbai Metro)|Green Line 11]]",
			["color"] = c.Green,
			["note-mid"] = "''(planned)''",
			["left terminus"] = "Chhatrapati Shivaji Maharaj Terminus",
			["right terminus"] = "Bhakti Park (Wadala)",
		},
		["12"] = {
			["title"] = "[[Orange Line (Mumbai Metro)|Orange Line 12]]",
			["color"] = c.Orange,
			["note-mid"] = "''(planned)''",
			["left terminus"] = "Kalyan APMC",
			["right terminus"] = "Taloja",
		},
		["Purple"] = {
			["color"] = c.Purple,
			["note-mid"] = "''(proposed)''",
			["left terminus"] = "Shivaji Chowk (Mira Road)",
			["right terminus"] = "Virar",
		},
		["13"] = {
			["title"] = "[[Purple Line (Mumbai Metro)|Purple Line 13]]",
			["color"] = c.Purple,
			["note-mid"] = "''(proposed)''",
			["left terminus"] = "Shivaji Chowk (Mira Road)",
			["right terminus"] = "Virar",
		},
		["Magenta"] = {
			["color"] = c.Magenta,
			["note-mid"] = "''(planned)''",
			["left terminus"] = "Vikhroli EEH",
			["right terminus"] = "Badlapur",
		},
		["14"] = {
			["title"] = "[[Magenta Line (Mumbai Metro)|Magenta Line 14]]",
			["color"] = c.Magenta,
			["note-mid"] = "''(planned)''",
			["left terminus"] = "Vikhroli EEH",
			["right terminus"] = "Badlapur",
		},
	},
	["aliases"] = {
		["blue"] = "Blue",
		["blue line"] = "Blue",
		["line 1"] = "1",
		["mumbai metro line 1"] = "1",

		["yellow"] = "Yellow",
		["yellow line"] = "Yellow",
		["2"] = "2",
		["line 2"] = "2",
		["2a"] = "2A",
		["line 2a"] = "2A",
		["yellow line 2a"] = "2A",
		["metro 2a"] = "2A",
		["2b"] = "2B",
		["line 2b"] = "2B",
		["yellow line 2b"] = "2B",
		["metro 2b"] = "2B",

		["aqua"] = "Aqua",
		["aqua line"] = "Aqua",
		["line 3"] = "3",
		["metro 3"] = "3",
		["mumbai metro line 3"] = "3",

		["green"] = "Green",
		["green line"] = "Green",
		["line 4"] = "4",
		["4a"] = "4A",
		["line 4a"] = "4A",
		["green line 4a"] = "4A",

		["orange"] = "Orange",
		["orange line"] = "Orange",
		["line 5"] = "5",

		["pink"] = "Pink",
		["pink line"] = "Pink",
		["line 6"] = "6",

		["red"] = "Red",
		["red line"] = "Red",
		["line 7"] = "7",
		["7a"] = "7A",
		["line 7a"] = "7A",
		["red line 7a"] = "7A",

		["gold"] = "Gold",
		["gold line"] = "Gold",
		["line 8"] = "8",

		["9"] = "9",
		["line 9"] = "9",
		["red line 9"] = "9",

		["10"] = "10",
		["line 10"] = "10",
		["green line 10"] = "10",

		["11"] = "11",
		["line 11"] = "11",
		["green line 11"] = "11",
		
		["12"] = "12",
		["line 12"] = "12",
		["orange line 12"] = "12",
		
		["purple"] = "Purple",
		["purple line"] = "Purple",
		["line 13"] = "13",

		["magenta"] = "Magenta",
		["magenta line"] = "Magenta",
		["line 14"] = "14",
	}
}

return p