%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% OUTER THEME - The bones. Heading, footer, and navigation.
% Defines: background, frame title, footline, page geometry
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\mode<presentation>

%%%%% 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]{17cm}{\raggedright \insertframetitle}};}
            \else% INCLUDE SUBTITLE
              {\node[anchor= west, headingcolor,font=\normalsize] at
                (1.05,1.31){\parbox[l]{17cm}{\raggedright \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){\insertshorttitle};
             %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

\mode<all>
