% SPDX-FileCopyrightText: Copyright (c) 2022-2025 Yegor Bugayenko
% SPDX-License-Identifier: MIT

\RequirePackage{geometry}
  \geometry{paperwidth=16in, paperheight=9in, left=4in, right=2in, top=1.5in, bottom=1.5in}
\RequirePackage[absolute]{textpos}
  \TPGrid{16}{16}
\RequirePackage[tt=false,type1=true]{libertine} % the font we use
\RequirePackage{microtype} % just to make rendering smooth
\AddToHook{env/verbatim/begin}{\microtypesetup{protrusion=false}}
\RequirePackage{anyfontsize} % to support all sizes
\RequirePackage{multicol} % for pptWide environment
\RequirePackage[fontsize=24pt]{fontsize} % to make fonts larger
\RequirePackage{changepage} % to use 'adjustwidth' environment in pptWide
\RequirePackage{soul} % for underscores in crumbs
\RequirePackage{tikz} % for drawing circles
\RequirePackage{lastpage} % to count pages and show total

\makeatletter\ifdefined\ppt@nocrumbs\else
\RequirePackage{crumbs}
  \renewcommand\crumb[2]{%
    \ifnum\value{crumbi}=1\else\hspace{1em}\fi
    \ifnum\value{crumbi}=\value{section}%
      {\setulcolor{blue}\color{blue}\ul{#1}}%
    \else%
      #1%
    \fi%
  }
  \renewcommand\subcrumb[2]{%
    \ifnum\value{subcrumbi}=1\else\hspace{0.5em}\fi
    \ifnum\value{subcrumbi}=\value{subsection}%
      {\setulcolor{blue}\color{blue}\ul{#1}}%
    \else%
      #1%
    \fi%
  }
\fi
\makeatother

\RequirePackage{fancyhdr}
  \pagestyle{fancy}
  \renewcommand{\headrulewidth}{0pt}
  \fancyhf{}
  \fancyhead[L]{%
    \ifx\crumbs\empty\else
      \begin{textblock}{12}(1,1)%
        \ifnum\value{section}=0\else
          {\small\ttfamily\crumbs}
          \ifnum\value{subsection}=0\else
            \\[6pt]
            {\quad\scriptsize\ttfamily\color{grey}[ \subcrumbs{} ]}
          \fi
        \fi
      \end{textblock}%
    \fi
  }
  \fancyhead[R]{%
    \ifnum\value{page}=1\else%
      \begin{textblock}{4}[1,0](15,1)%
        {\ttfamily\normalsize {\thepage{}}{\footnotesize{\color{grey}/\pageref{LastPage}}}}
      \end{textblock}%
      \makeatletter\ifdefined\ppt@nominutes\else
        \ifcsname c@minutes\endcsname
          \ifnum\value{minutes}=0\else%
            \begin{textblock}{1}[1,0](15.8,0.2)%
              \tikz{\node[inner sep=2pt,circle,draw=grey]{\color{grey}\scriptsize\ttfamily\theminutes{}};}
            \end{textblock}%
          \fi
        \fi
      \fi\makeatother
    \fi
  }

\newcommand\pptLeft[1]{%
  \fancyfoot[L]{%
    \ifnum\value{page}=1\else%
      \begin{textblock}{8}[0,1](1,15)%
        {\color{grey}\scriptsize\ttfamily #1}
      \end{textblock}%
    \fi
  }
}

\newcommand\pptRight[1]{%
  \fancyfoot[R]{%
    \ifnum\value{page}=1\else%
      \begin{textblock}{8}[1,1](15,15)%
        {\color{grey}\scriptsize\ttfamily #1}
      \end{textblock}%
    \fi
  }
}

\makeatletter
\AtBeginDocument{%
  \raggedbottom%
  \raggedright%
  \raggedcolumns%
  \setlength\topskip{0pt}%
  \setlength\footskip{32pt}%
  \setlength\parindent{0pt}%
  \setlength\parskip{18pt}%
  \setlength\columnsep{32pt}%
  \ifdefined\ppt@nocrumbs%
    \setlength\headheight{6pt}%
  \else%
    \setlength\headheight{32pt}%
  \fi%
  \normalsize%
  \sffamily%
}
