\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{zuendhoelzli}[Zündhölzli Class]
\LoadClass[twoside, 8pt, openright]{extbook}
% Fonts
\RequirePackage{fontspec}
\usepackage{ebgaramond}
\newfontfamily{\urbanistfont}[
  Path = ./font/,
  Extension = .ttf,
  UprightFont = *-Regular,
  BoldFont = *-ExtraBold,
  ItalicFont = *-Italic
  ]{Urbanist}
% Page layout
\RequirePackage[
  paperheight=175mm,
  paperwidth=110mm,
  top=10mm,
  bottom=17mm,
  left=10mm,
  right=10mm,
  % showframe
]{geometry}
\RequirePackage{microtype}

% Color support
\RequirePackage{xcolor}

% Language support
\RequirePackage{babel}
\babelprovide[import]{german-ch}
\babelprovide[import]{french-ch}
\babelprovide[import]{swissgerman}
\babelprovide{american}

% Makros and variables
\newcommand{\zbooktitle}{\textcolor{red}{NO TITLE}}
\newcommand{\booktitle}[1]{\renewcommand{\zbooktitle}{#1}}
\newcommand{\zauthor}{\textcolor{red}{NO AUTHOR}}
\renewcommand{\author}[1]{\renewcommand{\zauthor}{#1}}
\newcommand{\zauthorbio}{\textcolor{red}{NO BIO}}
\newcommand{\authorbio}[1]{\renewcommand{\zauthorbio}{#1}}
\newcommand{\zsummary}{\textcolor{red}{NO SUMMARY}}
\newcommand{\summary}[1]{\renewcommand{\zsummary}{#1}}
\newcommand{\zedition}{\textcolor{red}{NO EDITION}}
\newcommand{\edition}[1]{\renewcommand{\zedition}{#1}}
\newcommand{\zyear}{\textcolor{red}{NO YEAR}}
\renewcommand{\year}[1]{\renewcommand{\zyear}{#1}}
\newcommand{\zisbn}{\textcolor{red}{NO ISBN}}
\newcommand{\isbn}[1]{\renewcommand{\zisbn}{#1}}
\newcommand{\zbooknr}{\textcolor{red}{NO BOOKNR}}
\newcommand{\booknr}[1]{\renewcommand{\zbooknr}{#1}}
\newcommand{\zlicence}{\textcolor{red}{NO licence}}
\newcommand{\licence}[1]{\renewcommand{\zlicence}{#1}}
\newcommand{\zextracopyrightinfo}{\textcolor{red}{NO extracopyrightinfo}}
\newcommand{\extracopyrightinfo}[1]{\renewcommand{\zextracopyrightinfo}{#1}}
\newcommand{\zprint}{\textcolor{red}{NO zprint}}
\newcommand{\print}[1]{\renewcommand{\zprint}{#1}}
\newcommand{\zcoverauthor}{\textcolor{red}{NO zcoverauthor}}
\newcommand{\coverauthor}[1]{\renewcommand{\zcoverauthor}{#1}}
\newcommand{\chapterdedication}[1]{\vspace{-1ex}\hfill{\em #1}\vspace{1ex}}


% Custom Table of Contents Formatting
\addtocontents{toc}{\protect\thispagestyle{empty}}
\RequirePackage{titletoc}
\titlecontents{chapter}[0em]
  {\addvspace{5pt}\bfseries}
  {\itshape}
  {\itshape}
  {\titlerule*[0.5pc]{.}\contentspage}

% Custom Chapter Style
\RequirePackage{titlesec}
\titleformat{\chapter}[display]
  {\centering\normalfont\huge\bfseries}%  format
  {}%                                     label
  {0pt}%                                  sep
  {\Huge\vspace{-2em}}%                   before
  [\vspace{-2em}]%                        after

% Headers and Footers
\RequirePackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[LE,RO]{\small\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

% Styles
\renewcommand{\frontmatter}{%
  \cleardoublepage
  \pagestyle{empty}
  \normalsize
  \rmfamily
}

\renewcommand{\mainmatter}{%
  \cleardoublepage
  \pagestyle{fancy}
  \pagenumbering{arabic}
  \normalsize
  \rmfamily
}

\renewcommand{\backmatter}{%
  \cleardoublepage
  \pagestyle{fancy}
  \normalsize
  \rmfamily
}

% Pages
\renewcommand{\titlepage}{%
  {
    \clearpage
    \vspace*{\fill}
    \begin{center}
      % \Huge\bfseries
      \Huge\bfseries
      \urbanistfont
      \zbooktitle
    \end{center}
    \hspace{3em}
    \hfill
    \Large
    {\it \zauthor}
    \vfill
    \cleardoublepage
  }
}

\newcommand{\zuendhoelzlipage}{%
  {%}
    \clearpage
    \begin{center}%
      Zündhölzli \zbooknr%
    \end{center}%
    \clearpage
  }%
}%

\newcommand{\authorpage}{%
  {%
    \clearpage
    \null\vfill
    {\footnotesize\noindent\zsummary}

    \vspace{3ex}
    {\footnotesize\noindent\zauthorbio}
    \clearpage
  }%
}%

\newcommand{\titleclean}{%
  {%
    \clearpage
    \begin{center}
      {\large \zauthor}

      \vspace{1ex}
      {\Large \zbooktitle}

      \vfill
      Zündhölzli
    \end{center}
    \clearpage
  }%
}%

\newcommand{\copyrightpage}{%
  {%
    \clearpage
    \null\vfill
    \begin{center}%
      {%
        \small
        \zedition~\zyear

        \vspace{1ex}
        Zündhölzli~\zbooknr\\
        \zlicence\\
        Satz und Reproduktion, Zündhölzli Verlag, Zürich\\
        in Lua\TeX{} mit {\urbanistfont Urbanist} und EBGaramond Font\\
        Druk: \zprint\\
        Umschlag: \zcoverauthor\\
        ISBN~\zisbn
      }%
    \end{center}%
  }%
}%

% Table of content Heading
\renewcommand{\contentsname}{}

% End of the Class File
\endinput
