\mode<presentation>

%Requirements
\RequirePackage{tikz}
\RequirePackage{xcolor}
\RequirePackage{graphicx}
\RequirePackage{pgfplots}
\usepackage{geometry}

\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{arrows,chains,decorations.markings,shadows,shapes.arrows,arrows.meta}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% INNER THEME - The meat and potatoes of your slides
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%% TEXT THINGS
    %Itemized Lists / Enumerated Lists
    \setbeamertemplate{items}[square]

    %Blocks
    \setbeamertemplate{blocks}[shadow=true] 

%%%% TITLE PAGE
\defbeamertemplate*{title page}{dane}[1][]{ 
    \begin{beamercolorbox}[wd = \paperwidth, ht = \paperheight]{title page}
        \begin{tikzpicture}
            \useasboundingbox (0,0) rectangle(\paperwidth,\paperheight);
    
            %title
            \node(title)[anchor = north west] at (0,11.75) {\parbox[t]{16cm}{\raggedright\LARGE\textbf\inserttitle}};
            
            %Title Image
            \node(title_image)[anchor = center] at (11,5) {\includegraphics[width = 8cm]{images/title.png}};
    
            %Author Block
            \node(author)[anchor = west] at (0,6) {\parbox[c]{5cm}{\raggedright\insertauthor}};

            \node(institute)[anchor = north, below = 0.1cm of author] {\parbox[c]{5cm}{\raggedright\small\insertinstitute}};

            \node(date)[anchor = north, below = 0.25cm of institute] {\parbox[c]{5cm}{\raggedright\small\insertdate}};
            
            %logo
            \node(logo)[anchor = south west] at (0,.75) {\includegraphics[width = 3cm]{images/logo.png}};
    
            %Surrounding Structure
            \fill[secondary] (0,0) rectangle(\paperwidth, 0.5);
        \end{tikzpicture}
    \end{beamercolorbox}
}

%%%%% SECTION PAGES

%%%%% MONEYSLIDE


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% OUTER THEME - The bones. Heading, footer, and navigation.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% SET PAGE SIZE
\geometry{papersize={19cm,12cm}}
% Customize navigation symbols
\setbeamertemplate{navigation symbols}{}

%%%%%%BACKGROUND
\setbeamertemplate{background}{
        %CREATE TIKZ PICTURE OF BOXES LAYOUT
        \begin{tikzpicture}
            \useasboundingbox (0,0) rectangle(\paperwidth,\paperheight);
            
            \ifnum\thepage>0\relax%
            %LOAD BACKGROUND IMAGE
                \node at (current page.center){\includegraphics[height=\paperheight]{images/back.jpg}};
                \fill[primary,opacity=0.925] (0,0) rectangle(\paperwidth,\paperheight);
            \fi
            
            \if\gridmode1
                \draw[opacity=.3,secondary](0,0) grid (\pagewidth,\pageheight);
                \draw[step=4cm, opacity=.3, red](0,0) grid (\pagewidth,\pageheight);
            \fi
            
        \end{tikzpicture}
    }
    
%%%%%% HEADER
\defbeamertemplate*{frametitle}{dane}[1][]{
  \begin{beamercolorbox}[wd=\paperwidth,ht=2cm]{frametitle} 
      \begin{tikzpicture}
          \useasboundingbox[fill=primary](0,0) rectangle(\the\paperwidth,2);
        
          \fill[tertiary] (0,0) rectangle(1,2);
          \fill[secondary] (1.05,0) rectangle(\paperwidth,2);
          
           \ifx\insertframesubtitle\@empty%
                %NO SUBTITLE
              {\node[anchor=west, headingcolor,font=\large] at (1.05,1.0){\parbox[l]{13cm}{\insertframetitle}};}
            \else% INCLUDE SUBTITLE
              {\node[anchor= west, headingcolor,font=\normalsize] at (1.05,1.31){\parbox[l]{13cm}{\insertframetitle}};%
               \node[anchor= west, headingcolor,font=\footnotesize] at
               (1.05,0.31){\textit{\insertframesubtitle}};
               }%
            \fi
      \end{tikzpicture}
  \end{beamercolorbox}
}

%%%%% FOOTER
\defbeamertemplate*{footline}{dane}[1][]{
    \begin{beamercolorbox}[wd=\paperwidth,ht=0.05cm]{footline}
    
        % \begin{tikzpicture}
            % \includegraphics[width = 2cm]{images/logo.png};
        % \end{tikzpicture} 
        
        % \begin{tikzpicture}
        %     %CREATE BOUNDING BOX
        %     \useasboundingbox[fill=secondary](0,\paperheight-0.5cm) rectangle(\paperwidth,\paperheight);
        %
        %     %INSERT SECTION NAME
        %     \node[anchor=west, tertiary] at (0.1,\paperheight-0.25cm){
        %     %\ifx\insertsectionhead\@empty
        %     %    \insertframetitle
        %     %\elseifx\insertsubsection\@empty
        %     %    {\insertsectionhead : \insertframetitle}
        %     %\else
        %         \insertsectionhead  \insertsubsection
        %     %\fi
        %     };
        %     %INSERT FRAME NUMBER
        %     % \node[anchor=east, tertiary] at (\paperwidth-0.1cm,\paperheight-0.25cm) {\insertframenumber/\inserttotalframenumber};
        % \end{tikzpicture}
    \end{beamercolorbox}   
}

%%%%%% NOTES
\if\notemode1
    \setbeameroption{show notes on second screen = right}
\fi
\if\notemode2
    \setbeameroption{show only notes}
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COLOR THEME - All the colors of things
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define colors
\definecolor{pitt_royal}{cmyk}{1.00, 0.75, 0, 0.06}
\definecolor{pitt_gold}{cmyk}{0, 0.31, 0.98, 0}
\definecolor{dark_blue}{cmyk}{1.00, 1.00, 0.06, 0.60}
\definecolor{dark_gold}{cmyk}{0.06, 0.32, 1.00, 0.24}

% Define Primary, Secondary and Tertiary Colors
\if\darkmode1
    %DARK MODE
    \colorlet{primary}{dark_blue!1!black}
    \colorlet{secondary}{black!20!pitt_royal}
    \colorlet{tertiary}{dark_gold!50!pitt_gold}
    \colorlet{quartenary}{purple}
        
    \colorlet{textcolor}{white}
    \colorlet{headingcolor}{white}
\else
    %LIGHT MODE
    \colorlet{primary}{white}
    \colorlet{secondary}{pitt_royal}
    \colorlet{tertiary}{pitt_gold}
    \colorlet{quartenary}{purple}
    
    \colorlet{textcolor}{black}
    \colorlet{headingcolor}{white}
\fi

% Use colors in the theme
    %Title Page
    \setbeamercolor*{frametitle}{fg=headingcolor,bg=secondary}
    \setbeamercolor*{title}{fg=headingcolor, bg=secondary}
    \setbeamercolor*{title page header}{fg = headingcolor, bg = secondary}
    \setbeamercolor*{author}{fg=textcolor}
    \setbeamercolor*{date}{fg=tertiary}
    
    %Pallete Colors
    \setbeamercolor*{palette primary}{fg=primary}
    \setbeamercolor*{palette secondary}{fg=secondary}
    \setbeamercolor*{palette tertiary}{fg=tertiary}
    
    %Table of Contents
    \setbeamercolor*{section in toc}{fg=tertiary}
    
    %Itemized Environment
    \setbeamercolor{item}{fg=secondary}

    %Block Environment
    \setbeamercolor{block title}{fg=headingcolor, bg=secondary!85!primary}
    \setbeamercolor{block body}{fg = textcolor, bg = primary!75!secondary}
    \setbeamercolor{block title alerted}{fg = textcolor, bg = tertiary}
    \setbeamercolor{block body alerted}{fg = textcolor, bg=primary!75!tertiary}
    \setbeamercolor{block title example}{fg = headingcolor, bg = quartenary!75!primary}
    \setbeamercolor{block body example}{fg = textcolor, bg = primary!75!quartenary}

    %Math Text
    \setbeamercolor{math text}{fg = textcolor}

    %Normal Pages
    \setbeamercolor*{alerted text}{fg = textcolor, bg = tertiary}
    \setbeamercolor*{normal text}{fg = black}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FONT THEME - Using default LaTeX fonts
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Just use the default sans-serif family - no fontspec needed!
% This uses Computer Modern Sans, which is always available

% Font family shortcuts for compatibility with original theme
\newcommand{\RubikBold}{\sffamily\bfseries}
\newcommand{\RubikRegular}{\sffamily}
\newcommand{\RubikItalic}{\sffamily\itshape}
\newcommand{\OpenSansBold}{\sffamily\bfseries}
\newcommand{\OpenSansRegular}{\sffamily}
\newcommand{\OpenSansItalic}{\sffamily\itshape}

% Define What the Fonts are Used For
    %Title Page
    \setbeamerfont*{title}{family=\sffamily\bfseries, size=\Large}
    \setbeamerfont*{frametitle}{family=\sffamily\bfseries, size=\large}

    %Outer Stuff 
    \setbeamerfont*{section}{family=\OpenSansBold, size=\Large}
    \setbeamerfont*{subsection}{family=\OpenSansBold, size=\large}
    \setbeamerfont*{footline}{family=\OpenSansItalic, size=\tiny}

    %Itemized Stuff

    %Block Stuff
    \setbeamerfont*{block title}{family=\OpenSansBold, size=\normalsize}
    
    %Alerted Stuff

\setbeamerfont*{caption}{family=\OpenSansRegular, size=\small}
%\setbeamerfont*{normal text}{family=\OpenSansRegular, size=\small}
    
\mode<all>
