% Academic Letter Header Configuration
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{microtype}
\usepackage{url}
\usepackage[hidelinks]{hyperref}
\usepackage{setspace}
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage[quiet]{fontspec}

\geometry{
    headheight = 0.7in,
    top=1.5in,
    bottom=1.5cm,
    left=3cm,
    right=3cm,
}

\setmainfont{Calibri}

% Custom letter formatting
%
\makeatletter
\renewcommand{\opening}[1]{%
  \thispagestyle{firstpage}%
  \par\nobreak\vspace{2\parskip}%
  \noindent\ignorespaces #1\par\nobreak
  \@afterheading
}

\let\ps@empty\ps@plain
\let\ps@firstpage\ps@plain

\newcommand{\authordetails}[1]{\renewcommand{\authordetails}{#1}}
\newcommand{\recipientdetails}[1]{\renewcommand{\recipientdetails}{#1}}

\fancypagestyle{firstpage}{
    \fancyhf{}
    \fancyhead[L]{\includegraphics[height=0.6in]{$from_institution_logo$}}
    \fancyhead[R]{$author$\\\footnotesize{$from_email$\\$from_phone$}}
}

\fancypagestyle{plain}{
    \fancyhf{}
    \fancyhead[L]{\includegraphics[height=0.6in]{$from_institution_logo$}}
    \fancyhead[R]{$author$\\\footnotesize{$from_email$\\$from_phone$}}
}

\fancypagestyle{empty}{
    \fancyhf{}
    \fancyhead[L]{\includegraphics[height=0.6in]{$from_institution_logo$}}
    \fancyhead[R]{$author$\\\footnotesize{$from_email$\\$from_phone$}}
}
\makeatother


\newcommand{\forcelettermode}{\ifhmode\unskip\par\fi}

