% beamerthemeUVic.sty v1.0 (February 27, 2021)
% by Nicholas Bruce (nsbruce@uvic.ca)
%
% based off of the beamerthemeUCBerkeley by Overleaf
% colors, background, typography from the UVic Edge Brand as of Feb. 2021

\ProvidesPackage{beamerthemeUVic}

\RequirePackage{silence}
\WarningsOff[mathdesign/mdbch]

\RequirePackage{etoolbox}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]

\RequirePackage{fontspec}
% \setromanfont{Verdana}
% \setsansfont{Open Sans Regular}

\RequirePackage{tikz}

\definecolor{UVicBlue}{RGB}{0,94,184}
\definecolor{UVicYellow}{RGB}{234,170,0}
\definecolor{UVicRed}{RGB}{210,38,48}
\definecolor{UVicDarkBlue}{RGB}{0,46,93}
\definecolor{UVicEngineering}{RGB}{255,117,0}
\definecolor{UVicTableBlue1}{RGB}{204,230,255}
\definecolor{UVicTableBlue2}{RGB}{230,243,255}

\setbeamertemplate{title page}[default][left]
\setbeamerfont{title}{family=\sffamily,size=\Huge}
\setbeamerfont{author}{size=\Large}

\setbeamersize{text margin left=2em, text margin right=2em}

\setbeamertemplate{frametitle}{\vskip0.1\paperheight\insertframetitle} 
\setbeamerfont{frametitle}{family=\sffamily,series=\mdseries,size=\LARGE}
\setbeamerfont{block title}{family=\sffamily,size=\large}
\setbeamercolor{titlelike}{fg=UVicDarkBlue}
\setbeamerfont{normal text}{family=\rmfamily}
\setbeamercolor{normal text}{fg=UVicDarkBlue}
\setbeamercolor{structure}{fg=UVicDarkBlue}
\setbeamercolor{block title}{fg=UVicBlue}

\setbeamertemplate{itemize item}{\textbullet}
\setbeamertemplate{itemize subitem}{--}
\setbeamertemplate{itemize subsubitem}{\textbullet}
\setlength{\leftmargini}{1.25em}
\setlength{\leftmarginii}{1em}
\setlength{\leftmarginiii}{1em}

\pgfdeclareimage[height=0.07\paperheight]{logo}{images/UVic_logo_BW_reversed.pdf}

\usetikzlibrary{calc}
\setbeamertemplate{background}{%
\begin{tikzpicture}[overlay,remember picture]
    \fill[UVicDarkBlue] (current page.south west) -- ++(0, 0.10\paperheight) -- ++(\paperwidth, 0) -- (current page.south east) -- cycle;  
    \fill[UVicBlue] ($ (current page.south west) + (0.708333\paperwidth, 0)$) -- ++(-0.18055\paperwidth, 0) -- ++(40:0.15557\paperheight) -- ++(0.17\paperwidth, 0) -- cycle;
    \fill[UVicYellow] (current page.south east) -- +(-0.12\paperwidth, 0) -- +(-0.12\paperwidth,0.1\paperheight) -- +(\paperwidth, 0.1\paperheight) -- cycle;
    \fill[UVicRed] ($ (current page.south west) + (0.88888\paperwidth, 0)$) -- ++(-0.125\paperwidth, 0) -- ++(45:0.14142\paperheight) -- ++(0.1255\paperwidth, 0) -- cycle;
    \node[anchor=south west,inner sep=0pt,draw=none,xshift=0.055\paperheight,yshift=0.015\paperheight] at (current page.south west) {\pgfuseimage{logo}};%
\end{tikzpicture}%
}

\setbeamertemplate{footline}{%
\vskip0.15\paperheight
}

\newcommand{\smallframetitle}{%
  \setbeamertemplate{frametitle}{\vskip0.15\paperheight\insertframetitle}
  \setbeamerfont{frametitle}{size=\large,series=\bfseries}
}
\newcommand{\normalframetitle}{%
  \setbeamertemplate{frametitle}{\vskip0.2\paperheight\insertframetitle} 
  \setbeamerfont{frametitle}{size=\LARGE,series=\mdseries}
}

\renewcommand{\arraystretch}{1.2}
\newcommand{\tableheadrow}{\rowcolor{UVicYellow}}
\newcommand{\tableheadcol}[1]{{\bfseries\color{white}#1}}
% \rowcolors{2}{UVicTableBlue1}{UVicTableBlue2}
\AtBeginEnvironment{tabular}{\color{black}}