%% Copyright (C) 2016,2017 Achim D. Brucker, https://www.brucker.ch
%%
%% License:
%%   This program can be redistributed and/or modified under the terms
%%   of the LaTeX Project Public License Distributed from CTAN
%%   archives in directory macros/latex/base/lppl.txt; either
%%   version 1.3c of the License, or (at your opinion) any later version.
%%   OR
%%   The 2-clause BSD-style license.
%%
%%   SPDX-License-Identifier: LPPL-1.3c+ OR BSD-2-Clause
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{beamerouterthemelh}
     [2016/11/01 v0.0  LaTeX presentation class implementing the cooperate design of LogicalHacking.com]
\mode<presentation>

\def\insertpresentationendframe{\inserttotalframenumber}
\g@addto@macro{\appendix}{\immediate\write\@auxout{\string\@writefile{nav}{\noexpand\headcommand{\noexpand\def\noexpand\insertpresentationendframe{\the\c@framenumber}}}}}


  \defbeamertemplate*{navigation symbols}{lh}{}

  % Section and subsections in head/foot
  \defbeamertemplate*{section in head/foot}{lh}{\insertsectionhead}
  \defbeamertemplate*{section in head/foot shaded}{lh}[1][50]
                     {\color{fg!#1!bg}\usebeamertemplate{section in head/foot}}

  \defbeamertemplate*{subsection in head/foot}{lh}{\insertsubsectionhead}

  \defbeamertemplate*{subsection in head/foot shaded}{lh}[1][50]
                     {\color{fg!#1!bg}\usebeamertemplate{subsection in head/foot}}

  \defbeamertemplate*{subsubsection in head/foot}{lh}
                     {\insertsubsubsectionhead}

  \defbeamertemplate*{subsubsection in head/foot shaded}{lh}[1][50]
                     {\color{fg!#1!bg}\usebeamertemplate{subsubsection in head/foot}}


  % Headline and footline
  \defbeamertemplate*{headline}{lh}{%
    \@tempdima=\paperwidth%
    \advance\@tempdima by -6mm%
    \leavevmode%
    \vspace{-.2cm}%
    \centerline{\setlength{\fboxsep}{2.25pt}
      \colorbox{lhOrange}{%
    \parbox{\@tempdima}{\mbox{}\hfill\mbox{}}}}%
    \vskip0pt%
  }

  \defbeamertemplate*{footline}{lh}{%
    \@tempdima=\paperwidth%
    \advance\@tempdima by -6mm
    \leavevmode%
    \centerline{%
    \usebeamercolor{footer}{\setlength{\fboxsep}{2.25pt}
    \colorbox{bg}{%
      \parbox{\@tempdima}{%\mbox{}\\[.0005cm]  
      \mbox{}\quad \textcolor{fg}{\sffamily\tiny\bfseries \textcopyright~\the\year{} \href{https://logicalhacking.com}{LogicalHacking.com}. \hfill\hfill 
      \lh@classification\hfill\hfill\hfill
      Page \insertframenumber{} of \insertpresentationendframe%\inserttotalframenumber
    }\quad\mbox{}%\\[.0005cm]
  }}}}%
    \vskip0pt%
  }

  % background
  \defbeamertemplate*{background}{lh}{}
  \defbeamertemplate*{background canvas}{lh}{%
    \ifbeamercolorempty[bg]{background canvas}{}{\color{bg}\vrule width\paperwidth height\paperheight}%
  }

  \newdimen\beamer@headheight
  \beamer@headheight=1.7\baselineskip
  \defbeamertemplate*{frametitle}{lh}[1][left]{
     \@tempdima=\textwidth%
    \usebeamerfont{frametitle}%
    \vbox to \beamer@headheight{%
      \vskip.8em%
      \vfil%
      % 
      \if@tempswa\else\csname beamer@fte#1\endcsname\fi%
      \strut\hspace{2mm}\insertframetitle\strut\par%
     {%
       \ifx\insertframesubtitle\@empty%
       \else%
       {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\hspace{2mm}\insertframesubtitle\strut\par}%
       \fi
     }%
      %
      \vbox{}%
      \vskip-1em%
      \vfill%
    }%
    \centerline{\color{lhDarkGray}% lhBlack}% lhDarkGray}%
    \parbox{\@tempdima}{\rule{\textwidth}{.3pt}}}    
  }


  \def\beamer@fteright{\vskip0.35cm\advance\leftskip by 1.7cm\advance\rightskip by1.7cm}

  % Frame title continuations, default
  \defbeamertemplate*{frametitle continuation}{lh}{\insertcontinuationcountroman}

\mode
<all>
