% Bokeron Template based on Bayes Business School Beamer theme by Emilio Luis Sáenz Guillén

\ProvidesPackage{beamerthemeBokeronTemp}

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

% Eliminate navigation symbols
\setbeamertemplate{navigation symbols}{}

% Section and subsection numbering in table of contents
\setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered]
% Current position in the presentation
\useoutertheme[subsection = false]{miniframes}
\setbeamercolor{section in head/foot}{bg=BokeronBlue, fg=white}

% Captions numbering
\setbeamertemplate{caption}[numbered]

% Set slide margins
\setbeamersize{text margin left=2em, text margin right=10em}

% Set Normal Text Color
\setbeamercolor{normal text}{fg=Black}

% Structure colour (bullet points and section headings...)
\setbeamercolor{structure}{fg=BokeronBlue}

% Font
\RequirePackage{fontspec}
\setromanfont{Arial}
\setsansfont[Scale=MatchLowercase]{Open Sans}
\RequirePackage{tikz}
% Font substitution
\DeclareFontFamilySubstitution{TS1}{\sfdefault}{lmr}
\DeclareFontFamilySubstitution{OMS}{\sfdefault}{lmr}

% Define colours
\definecolor{BokeronTitleBlue}{RGB}{0, 149, 197}
\definecolor{LighterBokeronTitleBlue}{RGB}{204,217,236}
\definecolor{BokeronBlue}{RGB}{30, 160, 186}
\definecolor{BoxLightBlue}{RGB}{173, 235, 255}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%% TITLE %%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Adjust Frame Title Position
\setbeamertemplate{frametitle}{\vskip-0.2\paperheight\insertframetitle} 
% Frame Title Font
\setbeamerfont{frametitle}{family=\rmfamily,series=\mdseries,size=\Large}
% Set Color for Title-like Elements
\setbeamercolor{titlelike}{fg=BokeronTitleBlue}
% Title page
\setbeamertemplate{title page}{
    \vbox{}
    \vfill   
    \hbox{  
        % Uncomment the following line if using Finsbury square or red background
        % \hspace{3.5in}
        \begin{minipage}[t]{0.4\textwidth}
            {\usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle\par}
            \ifx\insertsubtitle\@empty\else
                {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}
            \fi
            \vspace{0.1in}
            {\usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor\par}
            \vspace{0.1in}
            {\usebeamerfont{institute}\usebeamercolor[fg]{institute}\insertinstitute\par}
            {\usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate\par}
        \end{minipage}
        \hfill
    }
    \vfill
}
% Sizes
\setbeamerfont{title}{family=\rmfamily,size=\LARGE}
\setbeamerfont{author}{size=\large}
\setbeamerfont{institute}{size=\large}
% Colours
\setbeamercolor{title}{fg=white}
\setbeamercolor{subtitle}{fg=white}
\setbeamercolor{author}{fg=white}
\setbeamercolor{institute}{fg=white}
\setbeamercolor{date}{fg=white}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%% BACKGROUND %%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usebackgroundtemplate%
{%
\includegraphics[width=\paperwidth,height=\paperheight]{background/corners2.png}%
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% CLOSING SLIDE %%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{endpage}{
\begin{frame}[plain]
\begin{tikzpicture}[remember picture, overlay]
    % Background image
    \node[at=(current page.center)] {
        \includegraphics[width=\paperwidth,height=\paperheight]{background/CoverPage_OpenBokeron.png}
    };
\end{tikzpicture}
\end{frame}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%% ITEMIZE %%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{itemize item}{\textbullet}
\setbeamertemplate{itemize subitem}{--}
\setbeamertemplate{itemize subsubitem}{\textbullet}
% First-Level List Identations
\setlength{\leftmargini}{1.25em}
% Second-Level List Indentation
\setlength{\leftmarginii}{1em}
% Third-Level List Indentation
\setlength{\leftmarginiii}{1em}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% FRAME TITLES %%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Normal frame title
\newcommand{\normalframetitle}{%
  \setbeamertemplate{frametitle}{\vskip0.2\paperheight\insertframetitle} 
  \setbeamerfont{frametitle}{size=\LARGE,series=\mdseries}
  \setstretch{1}
}
% Small frame title
\newcommand{\smallframetitle}{%
  \setbeamertemplate{frametitle}{\vskip0.05\paperheight\insertframetitle}
  \setbeamerfont{frametitle}{size={\fontsize{11}{15}},series=\bfseries}
}
% Smaller frame title
\newcommand{\smallerframetitle}{
  \setbeamertemplate{frametitle}{\vskip0.025\paperheight\insertframetitle}
  \setbeamerfont{frametitle}{size={\fontsize{8}{12}},series=\bfseries}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%% TABLES %%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\arraystretch}{1.3}
\newcommand{\tableheadrow}{\rowcolor{BokeronBlue}}
\newcommand{\tableheadcol}[1]{{\bfseries\color{white}#1}}
\AtBeginEnvironment{tabular}{\color{black}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%% BLOCK %%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamerfont{block title}{family=\rmfamily,size=\large}
\setbeamercolor{block title}{fg=white,bg=BokeronTitleBlue}
\setbeamercolor{block body}{bg=LighterBokeronTitleBlue}
\setbeamertemplate{blocks}[rounded][shadow=false]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%% FOOTLINE %%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{footline}{%
\vskip0.15\paperheight
}
\setbeamercolor{myfootlinecolor}{bg=white,fg=BokeronBlue}
\setbeamertemplate{footline}
{%
  \begin{beamercolorbox}[colsep=1.5pt, ht=3.5ex, dp=1.125ex, leftskip=.3cm, rightskip=.3cm plus1fil]{myfootlinecolor}
    \leavevmode{\usebeamerfont{author in head/foot}\insertshortauthor}%
    \hfill
    {\usebeamerfont{institute in head/foot}\insertshortinstitute}%
    \hfill%    
    {\usebeamerfont{title in head/foot}\insertframenumber/\inserttotalframenumber}
  \end{beamercolorbox}
}  


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%% OTHERS %%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Disable warning on \author
\pdfstringdefDisableCommands{%
  \def\\{}%
  \def\texttt#1{<#1>}%
}