It was boisterous, it was bittersweet. On 29 January last year, the European Parliament voted to approve the Brexit Withdrawal Agreement, formally triggering the end of Britain's membership of the EU and prompting a Union Jack-waving Nigel Farage to bellow that he "loved Europe but hated the European Union."

The then vice-president Mairead McGuinness glowered at Farage, telling him: "Put your flags away, you’re leaving, and take them with you". After they’d left the chamber rose en masse to bid a tearful farewell to their remaining British colleagues, linking arms - not to the European Anthem Ode to Joy - but to a Scottish folk song, Auld Lang Syne.

Around the same time Scotland House, the devolved Scottish government’s Brussels office, raised a banner on its penthouse windows over the European quarter saying "SCOTLAND LOVES EU". The banner, proposed by Scottish National Party (SNP) ministers in Edinburgh, remains above the Schuman roundabout, and inside the office the EU flag still stands alongside the Scottish Saltire.

Brexit means Scotland is out of the EU. But from the regional office which the Scottish government retains in Brussels, it is hard not to detect the embers of a hope, if not expectation, that it might one day return.

Today, Scotland House has the same official status as any regional office from a third country. Staff levels have stayed the same - between 20 and 25 officials - but the seniority level was increased after the Brexit referendum when the head of Scotland House was appointed at director level for the first time. That policy remains unchanged.

By contrast, the UK's delegation to the EU, just around the corner, has gone in the other direction, becoming more modest in terms of staffing and seniority (although officials there say the delegation is simply returning to its pre-Article 50 level).

Scotland House is, strictly-speaking, a neutral outpost of the Scottish civil service. However, the Twitter feed of @ScotGovBrussels bristles with meetings and events involving EU commissioners, MEPs, and other European stakeholders.

The office goes out of its way to generate discussions, hold policy debates, invite speakers on issues that preoccupy the Brussels bubble - justice and home affairs, climate and net zero emissions, research and innovation, inclusive growth, the so-called "well-being" economy.

"The Scottish Government engages regularly with the EU Institutions, Member States and other organisations and stakeholders based in Brussels to promote Scotland’s interests and to share and exchange knowledge, best practice and expertise across a range of policy areas," said a spokesperson.

Scotland House is officially awaiting political direction from the new Scottish government, but one need look no further than the SNP manifesto to see what its political role might look like.

"We will prepare to rejoin the EU by keeping a close relationship with Europe," the manifesto says. "We will strengthen our Brussels base and make Scotland House the hub of our diplomatic representation across Europe."

Before exit day on January 31 last year, former MEP and current MP for Stirling Alyn Smith set up the European Friends of Scotland group, an informal network linking 38 MEPs with the Scottish parliament and supported by Scotland House.

Its website insists the group is "neutral in regard to Scotland’s constitutional status within the UK and the UK’s future relationship with the EU", and that Scotland "remains committed to maintaining and developing a positive relationship with our European friends and partners."

As the SNP’s foreign affairs spokesman in Westminster, Mr Smith sees his role as "explaining", but not "evangelising", to the outside world the context in which a referendum might take place, and in which an independent Scotland might rejoin the EU.

The project is entitled 'No Surprises’, a self-conscious effort to reassure Scotland’s interlocutors that if - and only if - a legal and constitutional referendum delivers an independence vote, then Scotland's accession to the EU should not be a traumatic affair.

"A key part of Project No Surprises is to make clear we do not expect anyone to involve themselves in the domestic discussion—on our side or any other," Smith said in Foreign Policy magazine, co-written with Stuart MacDonald, the party’s Westminster defence spokesman.

"That would be as crass as it would be counterproductive. Yet other countries and organisations have a legitimate interest in Scotland’s domestic debate because an independent Scotland will have implications for their own interests."

Those interests should align with an independent Scotland, is the argument. The SNP has already been working the EU embassy circuit in London this week to make the case.

One of the last pieces of legislation the outgoing Holyrood Parliament passed was the Continuity Act, which means the Scottish government will mirror EU, and not UK, norms in areas where it has devolved competence.

"That's on things like animal welfare, environmental standards, the nuts and bolts stuff," Mr Smith told RTÉ News. "That is going to be a challenge, and it will probably butt up against the explicit aims of the UK government and the [UK] Internal Market Act quite quickly. It's our stated intention that where we can align ourselves with EU norms and developments we're committed to do that."

In a speech in Brussels in 2020, Scottish First Minister and SNP leader Nicola Sturgeon said this would "make it easier, when the time comes, as I believe it will, for Scotland to return to the EU."

That return is conditional on several big ifs - will there be another referendum, and, if so, is a Yes vote likely?

After the No side won by 55% in 2014, opinion polling consistently showed a majority of Scots would vote No to independence again in a follow-up referendum.

However, from mid-2019 that trend was halted. One poll in July of that year showed a majority of voters would vote Yes.

The trend towards Yes continued into 2020, with an IPSOS Mori/STV News poll last October showing 58% in favour of independence. However, the trend slipped back in January of this year, and in March during the parliamentary inquiry into former SNP leader Alex Salmond’s removal over unfounded sexual misconduct claims, the No side regained a narrow lead.

However, both the SNP and Scottish Greens pledged in their respective manifestos before last week’s elections to hold an independence referendum within the lifetime of the new parliament. Between them the two parties won 72 out of 129 seats.

Brexit is feeding into this apparent pro-independence turnaround, according to Professor John Curtice, the leading pollster, of Strathclyde University.

"For some Leave voters Brexit was apparently a reason to stick with the UK but for some Remain voters Britain leaving the EU seems to have made independence look more attractive," he co-wrote in the 2020 paper Is Brexit Fuelling Support for Independence?

"As a result, although Remain voters are far from all being advocates of a highly-integrated EU, many view Brexit with concern and for some at least independence inside the EU has now come to look more attractive than being part of a UK that is outside the EU."

This, Prof Curtice concluded, had pushed the appetite for a second referendum above that of the immediate post-2014 period.

However, the challenges facing an independent Scotland returning to the EU are formidable.

In 2014, pro-independence groups did not have to grapple with the problem of a hard Anglo-Scottish border. Britain was still in the EU, so an independent Scotland rejoining would have meant little or no difference to trade with England.

Brexit obviously changes that completely.

Given that opinion polling had gone cold on a second referendum, the SNP leader Nicola Sturgeon was initially circumspect about calling for another referendum after Scotland voted by 62% to stay in the EU in 2016.

Launching the white paper Scotland’s Place in Europe six months after the Brexit vote, she wrote: "We are determined to maintain Scotland’s current position in the European Single Market."

While insisting that independence was the best way to achieve that, Ms Sturgeon said she was ready "to explore if we can find common ground with the UK Government around a solution that would protect Scotland’s place in the European Single Market from within the UK."

Ms Sturgeon called on then-prime minister Theresa May to keep the UK in the European Economic Area (EEA), in other words, remaining in the EU single market and customs union.

If London refused that, then Scotland should at least be allowed to remain in the EEA. Ms Sturgeon also wanted Westminster to devolve more powers to Edinburgh so that Scotland could retain its own links with EU programmes such as Horizon science and research funding, Erasmus and Europol.

Scotland’s Place in Europe was less certain about the problem of a hard border, if Scotland remained in the single market and England didn’t.

"This proposal does not prioritise the European Single Market over free movement and free trade within the UK," the paper said. "We consider that UK-wide free movement and free trade could and would continue if Scotland becomes independent, just as the UK Government believes that free trade and movement between the UK and the Republic of Ireland will continue after Brexit."

We know now that, whatever the UK believed in 2016, free trade between the UK and Ireland does not mean frictionless trade. Even if there are no tariffs or quotas there would still be customs and regulatory frictions on the Anglo-Scottish border, especially in the agri-food sphere.

Free movement does continue between Ireland and Britain due to the Common Travel Area (CTA), but an independent Scotland sets up some immediate complications.

Firstly, if an independent Scotland re-joined the EU, continued membership of the CTA would prevent it from joining the Schengen Area passport free zone (as is the case for Ireland). Would the UK consent to automatic CTA membership given that Scotland would be anticipating free movement of people from the EU over time?

"The CTA did not come up as a huge issue in the 2014 referendum," says Kirsty Hughes, director of the Scottish Centre of European Relations (SCER). "But you could imagine that if London is desperate to swing a referendum its way, will it start saying it wouldn't immediately allow an independent Scotland into the CTA."

Ms Hughes admits that would be an extreme scenario, not least because English and Welsh people also like to live and work in Scotland.

But the gruelling experience of trying to reconcile Brexit with the Irish land border is a reminder of how these issues can escalate.

In normal circumstances, the Irish border would have been a guide as to how an Anglo-Scottish border might look like if Scotland was in the EU and England wasn’t.

However, because of the legacy of conflict, partition and the Good Friday Agreement, the EU, at Ireland’s behest, sought a solution to avoid a hard border on the island of Ireland, and the UK ultimately and reluctantly agreed to that solution.

But Scotland does not have the same argument to make for its 150km border with England. Granted, there are far fewer crossings than the Irish land border - five main arterial roads - and fewer minor roads.

But, as Katy Hayward, of Queen’s University Belfast, points out in a paper for the Scottish Centre for European Relations: "As was the case for the Irish border for much of the twentieth century, controls along the Scottish land border would be a challenge to design and administer.

"They would require new systems of cooperation and communication (including to facilitate and process customs declarations), new infrastructure (e.g. facilities for veterinary inspections), new recruits for border management (among whom customs inspectors are but the tip of the iceberg), and new rules for traders to comply with if they wish to move goods across Scotland’s borders."

Had Theresa May acceded to Nicola Sturgeon’s request that the UK remain in the EEA, things would have turned out differently.

"If the UK had pursued this option," notes a detailed analysis by the UK Institute for Government, "an independent Scotland might still have been able to join the EU without customs checks and major risks of economic dislocation on the border".

We know now that not only did London not go for a soft Brexit, under Boris Johnson it went for a pretty hard Brexit, reflected in the Trade and Cooperation Agreement (TCA) concluded in December.

This has knock-on implications for the Anglo-Scottish border. The Institute for Government points out that Scotland trades some three times as much across that border as it does with the EU. Exports of manufactured goods were worth an average of over £3 billion more to the Scottish economy than exports to the EU in the ten years up to 2018.

Challenged on the risk of hampering that trade Ms Sturgeon has said that Scotland would "keep trade flowing" while complying with the requirements of EU membership.

"Of course we want to keep trade flowing across the England-Scotland border, that would be in the interests of Scotland as well and we would work to make sure that happened," she told the BBC’s Andrew Marr during the election campaign.

When pressed, Ms Sturgeon said the modelling for such a scenario had yet to be done since "we would have to redo it when we were asking people to make that choice. I believe its right to only ask people to make a choice of that magnitude on the basis of quality up-to-date information."

That up-to-date information will also need to cover other tough questions about Scotland rejoining the EU, such as whether or not it will have to join the euro (in principle yes, in practice probably no), how a return to the Common Fisheries Policy (CFP) might go down, how Scotland might cope with the EU’s fiscal rules, and the issue of retaining some - if any - of the opt-outs from EU rules that the UK had enjoyed.

Kirsty Hughes, of the SCER, says the SNP will have to confront these questions head on, and not just about how to deal with a hard border.

"The border is a very big issue. By the time we get to a referendum in 2024 or 2025 there will be a lot more experience [of the EU-UK trading relationship], or there should presumably be some easing.

"The SNP have to be able to say why you’re going to be able to benefit from the free movement of people, how you're going to attract more foreign direct investment, how you're going to restructure the economy in the next ten years, how you're going to reorient more towards Europe."

The SNP government was actually in the process of preparing detailed papers on all aspects of independence but halted the work in March of last year due to the pandemic.

That work will now resume and the papers are expected to be published next year.

It’s understood they will emphasise that Scotland exports more manufactured goods to the rest of the world than the rest of the UK, and that membership of both the CTA and the EU’s single market would give Scotland a particular advantage in the services sector (being able to provide services throughout the UK, where 60% of exports are in services, as well as throughout the single market, where 30% of exports are in services).

While Ireland’s evolution from an agrarian to a highly-skilled, export-driven economy due to EU membership is often cited as a role model for Scotland, it’s understood the new government will look at a range of smaller EU member states and how they benefit from EU membership (Scotland would become the 18th largest member state).

The SNP view is - and it is obviously a partisan one - that Ireland’s economy was held back by a dependence on a slow-growth UK economy in the 1950s, ‘60s and ‘70s. In the same way, the argument goes, Scotland would be held back by a slow-growing, post-Brexit UK economy, and it will make economic sense to return to the EU.

An independent Scotland is unlikely to chase Ireland’s low corporate tax model, which in any case is under pressure from international moves on taxation.

Instead, the incoming government will, it seems, advertise sobriety over hyperbole, emphasising research and innovation, climate awareness, a hi-tech economy, and positioning Scotland as a "normal", social-democratic European country which will abide by EU rules.

"The more you see the behaviour of the Boris Johnson/Brexit UK thing, the more the idea of just being a normal European, Nordic, or Ireland-type country, appeals," says Ms Hughes. "Those are the sorts of images that people have in mind."

Should a referendum be held - and this is another story entirely - and the Yes side wins, how quickly or easily could an independent Scotland rejoin the EU?

When discussing Scotland’s case, observers often raise the prospect of a Spanish veto, given the trauma of the Catalan independence vote. However, the SNP argues that the circumstances will be entirely different, and indeed in 2018 the Spanish foreign minister said Madrid would accept an accession application if it complied with the UK’s own constitutional arrangements.

"So long as this is an agreed, constitutional route, which is our preference too, I don't envisage significant difficulties with Spain," says Alyn Smith MP. "They also recognise European solidarity, the way we've treated Spanish nationals in Scotland, as opposed to the way they're treated in the UK."

Should an independence vote be carried, Scotland would then face years of negotiations to leave the UK and then to rejoin the EU, assuming a future Scottish government does not feel the need to hold a further referendum.

As the Institute for Government has pointed out, there is no precedent for the EU to negotiate accession with a country that is not yet fully independent, and the question would arise as to whether Scotland could qualify for pre-accession funding before it has fully departed from the UK.

Then we would be in the realm of overlapping transition periods. "To minimise economic disruption during this period, Scotland could look to negotiate an interim trading arrangement with the UK – and possibly the EU as well – which could apply until Scotland joined the EU as a full member state," says the Institute for Government report.

Privately, officials say that if Scotland is properly independent its accession should be relatively straightforward, given that it was an EU member state for 47 years, had remained aligned with the EU up until January of this year, and would be a functioning democracy.

But Scotland would still need to have a range of institutions set up - central bank, statistics agency, foreign office, food safety agency - in order to plug into the EU's body of law.

Scotland would join a queue currently headed by Montenegro, which became independent in 2006 and applied for membership in 2008, with negotiations starting in 2012.

Montenegro has opened 33 out of 35 accession "chapters" but only provisionally closed three, and the process has stalled over the chapters on freedom of expression, combating corruption and organised crime, and judicial reform.

While the former European Council President Donald Tusk said in February last year that Europe would be "enthusiastic" about Scotland rejoining, the EU will studiously avoid commenting in the coming years.

"The European Commission will not get involved in British internal politics," says one EU diplomat. "There will be no statements about Scotland and accession and independence. The EU, in general, will stay well away from it."

David McAllister, a German MEP and prominent member of the CDU party, is a member of the European Friends of Scotland Group. His father was Scottish and he has many relatives in Scotland who are on both sides of the independence debate.

He is adamant that the group is neutral and so is he.

"The question of Scottish is a UK internal matter, whether a referendum will take place, if, when, and in which condition," he told RTÉ News. "I don’t believe that any leading EU representative will want to get into this and take sides.

"The European Union has just seen the United Kingdom leave our family of nations. I’m glad our new relationship is on a solid legal basis. Article 49 applies to any independent state which lies geographically in Europe, which shares our values, and which can apply for EU membership. In the end, after a complex negotiating process this independent country will have to meet all the political, economic and legal criteria of membership."

One Brussels observer who has worked on a number of accession files says that the EU instinctively dislikes any rupture to stable structures.

"There are a lot of people working in Brussels who like systems to stay pretty much as they are and who regret any disruption," he says, "having said that, there is already sympathy for the Scots, who voted against Brexit and were then dragged into it."

But the pressure for a second referendum will mount and it is impossible to predict what arguments will have the greatest sway over Scottish voters, whether economic, cultural, political, emotional or all of the above. But whether or not Scotland’s destiny lies in a return to Europe, that will be central to the debate.