%% This is file `bfh-hkb-doc.cfg' version 2.2.6 (2026-01-12),
%% it is part of
%% BFH-CI -- Corporate Design for Bern University of Applied Sciences
%% ----------------------------------------------------------------------------
%%
%%  Copyright (C) 2021--2026 by
%%      Marei Peischl <marei@peitex.de>
%%      Andreas Habegger <andreas.habegger@bfh.ch>
%%
%% ============================================================================
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008/05/04 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainers of this work are
%%   Marei Peischl <bfh-ci@peitex.de>
%%   Andreas Habegger <andreas.habegger@bfh.ch>
%%
%% The development respository can be found at
%% https://gitlab.ti.bfh.ch/bfh-latex/bfh-ci/
%% Please use the issue tracker for feedback!
%%
%% ============================================================================
%%
\ProvidesExplFile{bfh-hkb-doc.cfg}{2026-01-12}{2.2.6}{hkb-doc module for bfhthesis}
\RenewDocumentCommand{\titlegraphic}{sm}{
	\IfBooleanTF{#1}{
		\tl_gset:Nn \g_ptxcd_titleimage_code_tl {
			\hbox_set:Nn \l__ptxcd_titlegraphic_box {\raisebox{\depth}{#2}}
			\box_resize_to_ht:Nn \l__ptxcd_titlegraphic_box {\height}
			\dim_compare:nTF {\box_wd:N \l__ptxcd_titlegraphic_box - \width > \c_zero_dim}
			{
				\dim_set:Nn \l_tmpa_dim {.5\box_ht:N \l__ptxcd_titlegraphic_box - .5\height}
				\clipbox{0pt~\dim_eval:n{\l_tmpa_dim}~0pt~\dim_eval:n{\l_tmpa_dim}}{\box_use:N \l__ptxcd_titlegraphic_box}
			}{
				\box_use:N \l__ptxcd_titlegraphic_box
			}
		}
	}{
		\tl_gset:Nn \g_ptxcd_titleimage_code_tl {#2}
	}
}

\cs_new:Nn \__ptxcd_title_tabular_entry:n {
	\tl_if_in:nnTF {#1} {= } {
		\__ptxcd_title_tabular_entry:w #1 \q_stop
	} {
		\text_titlecase_first:n {#1}\\
	}
}

\cs_new:Npn \__ptxcd_title_tabular_entry:w #1 = #2 \q_stop {
	\text_titlecase_first:n {#1}\unskip :& #2 \\
}

\seq_new:N \g__ptxcd_projectData_seq
\newcommand*{\ProjectData}[1]{
	\seq_gset_from_clist:Nn \g__ptxcd_projectData_seq {#1}
}

\colorlet{BFH-Title}{black}

\newkomafont{titledata}{\normalfont\footnotesize}
\setkomafont{disposition}{\bfseries}
\addtokomafont{subtitle}{\mdseries\LARGE}
\addtokomafont{caption}{\tiny}
\setkomafont{caption}{\footnotesize}
\setkomafont{captionlabel}{\usekomafont{caption}\bfseries}

\setkomafont{pageheadfoot}{\footnotesize}
\setkomafont{footnote}{}
\setkomafont{pagenumber}{\fontsize{6pt}{6pt}\selectfont}

\colorlet{BFH-textaccentcolor}{.}

\cs_if_exist:NTF \chapter {
	\RedeclareSectionCommand[
		beforeskip=0pt
	]{chapter}
	\setkomafont{chapter}{\LARGE}
	\setkomafont{section}{\Large}
	\setkomafont{subsection}{\large}
	\setkomafont{subsubsection}{\mdseries}
	\setkomafont{paragraph}{\mdseries}
	\setkomafont{subparagraph}{\mdseries}
} {
	\setkomafont{section}{\LARGE}
	\setkomafont{subsection}{\large}
	\setkomafont{subsubsection}{\mdseries}
	\setkomafont{paragraph}{\mdseries}
	\setkomafont{subparagraph}{\mdseries}
}

\AddToHook{begindocument/end}{
	\defcaptionname{swissgerman,nswissgerman,german,ngerman}{\refname}{Literaturverzeichnis}
	\defcaptionname{swissgerman,nswissgerman,german,ngerman}{\bibname}{Literaturverzeichnis}
	\defcaptionname{swissgerman,nswissgerman,german,ngerman}{\figurename}{Fig.}
	\defcaptionname{swissgerman,nswissgerman,german,ngerman}{\tablename}{Tab.}
}

\RedeclareSectionCommand[
	style=section,
	runin=false,
	afterskip=0pt
]{paragraph}

\RedeclareSectionCommand[
	style=section,
	runin=false,
	afterskip=0pt
]{subparagraph}

\RequirePackage{tabularx}


\renewcommand*{\maketitle}[1][1]{
	\def\and{,~ }
	\cs_if_exist_use:N \ptxcd_pass_TitleData:
	\if@titlepage
		\begin{titlepage}
		\KOMAoptions{fontsize=11pt}
			\setcounter{page}{%
				#1%
			}%
			\def\thefootnote{\fnsymbol{footnote}}
			\setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
			\thispagestyle{empty}%TODO title.
			\vspace*{-2cm}
			\tl_if_eq:cnTF {BFH-optional-Logo} {true} {
				\raisebox{.75mm}{\includegraphics[height=17mm]{example-image}}
				\hspace{1.25cm}\includegraphics[height=19mm]{example-image}
			}{
				\raisebox{.75mm}{\includegraphics[height=17mm]{HKB_Markenzeichen\str_if_eq:VnF \g__ptxcd_colormode_tl {RGB} {_CMYK}}}
				\hspace{1.25cm}\includegraphics[height=19mm]{CRC_Logo\str_if_eq:VnF \g__ptxcd_colormode_tl {RGB} {_CMYK}}
			}
			\par
			\vspace{2.15cm}
			\begingroup
				\def\width{\dimexpr14.75cm}
				\def\height{\dimexpr11.1cm}
				\tl_if_empty:NF \g_ptxcd_titleimage_code_tl {
					\g_ptxcd_titleimage_code_tl
				}
				\par
			\endgroup
			\vspace{1.7cm}

			\begingroup
				\usekomafont{disposition}
				{\usekomafont{title}\@title\par}
			\endgroup

			\ifx\@subtitle\@empty\else{\vspace{.2\baselineskip}\usekomafont{subtitle}\@subtitle\par}\fi

		\vfill
		\usekomafont{titledata}
		\begin{tabularx}{\linewidth}{@{}l@{\hspace{1.6em}}X@{}}%
		\seq_map_function:NN  \g__ptxcd_projectData_seq \__ptxcd_title_tabular_entry:n
		\end{tabularx}
		\vspace*{-2\baselineskip}

		\@thanks\let\@thanks\@empty
		\if@twoside
			\@tempswatrue
			\if@tempswa
				\next@tpage
				\begin{minipage}[t]{\textwidth}
					\@uppertitleback
				\end{minipage}\par
				\vfill
				\begin{minipage}[b]{\textwidth}
					\@lowertitleback
				\end{minipage}\par
				\@thanks\let\@thanks\@empty
			\fi
		\fi
		\ifx\@dedication\@empty
		\else
			\next@tdpage\null\vfill
			{\centering\usekomafont{dedication}{\@dedication \par}}%
			\vskip \z@ \@plus3fill
			\@thanks\let\@thanks\@empty
			\cleardoubleemptypage
		\fi
		\end{titlepage}
		\setcounter{footnote}{0}%
		\global\let\and\relax
		\cleardoublepage
	\else
		\par
		\@tempcnta=%
		#1%
		\relax\ifnum\@tempcnta=1\else
			\ClassWarning{\KOMAClassName}{%
				Optional argument of \string\maketitle\space ignored\MessageBreak
				in `titlepage=false' mode%
			}%
		\fi
		\ifx\@uppertitleback\@empty\else
			\ClassWarning{\KOMAClassName}{%
				non empty \string\uppertitleback\space ignored
				by \string\maketitle\MessageBreak
				in `titlepage=false' mode%
			}%
		\fi
		\ifx\@lowertitleback\@empty\else
			\ClassWarning{\KOMAClassName}{%
				non empty \string\lowertitleback\space ignored
				by \string\maketitle\MessageBreak
				in `titlepage=false' mode%
			}%
		\fi
		\begingroup
		\let\titlepage@restore\relax
		\def\thefootnote{\fnsymbol{footnote}}
		\next@tdpage
		\ifx\@extratitle\@empty
			\ifx\@frontispiece\@empty\else \mbox{}\fi
		\else
			\@makeextratitle
		\fi
		\ifx\@frontispiece\@empty
			\ifx\@extratitle\@empty\else\next@tdpage\fi
		\else
			\next@tpage
			\@makefrontispiece
			\next@tdpage
		\fi
		\if@twocolumn
			\twocolumn[\@maketitle]
		\else
			\@maketitle
		\fi
		\ifx\titlepagestyle\@empty\else\thispagestyle{\titlepagestyle}\fi
		\global\let\@thanks\@empty
		\endgroup
	\fi
}


\clearpairofpagestyles
\ofoot[\pagemark]{\pagemark}

% disable adjustment of \labelitemi
\RemoveFromHook{begindocument/end}[bfh-ci-label]

% margins
\dim_if_exist:NF \g_ptxcd_innerMargin_dim {
	\dim_new:N \g_ptxcd_innerMargin_dim
	\dim_new:N \g_ptxcd_outerMargin_dim
	\dim_new:N \g_ptxcd_bottomMargin_dim
	\dim_new:N \g_ptxcd_topMargin_dim
	\dim_new:N \g_ptxcd_topLogoMargin_dim
	\dim_new:N \g_ptxcd_columnSep_dim
	\RequirePackage{geometry}
}
\dim_gset:Nn \g_ptxcd_columnSep_dim {4mm}

\dim_gset:Nn \g_ptxcd_topMargin_dim {26mm}
\dim_gset:Nn \g_ptxcd_bottomMargin_dim {15mm}%20mm}
\dim_gset:Nn \g_ptxcd_innerMargin_dim {35mm}
\dim_gset:Nn \g_ptxcd_outerMargin_dim {28mm}%12mm}
\dim_gset:Nn \g_ptxcd_topLogoMargin_dim {25mm}

\geometry{
	includefoot,
	%		footskip=\dim_eval:n {\footskip+\baselineskip},
	top=\g_ptxcd_topMargin_dim,
	inner=\g_ptxcd_innerMargin_dim,
	outer=\dim_eval:n {\g_ptxcd_outerMargin_dim},
	bottom=\dimexpr\g_ptxcd_bottomMargin_dim-\dp\strutbox,
	columnsep= \g_ptxcd_columnSep_dim,
}


\KOMAoptions{
	bibliography=totoc,
	listof=totoc,
	parskip=full,
	fontsize=9bp,
	headsepline=false,
	captions=nooneline,
	footwidth=\dimexpr\textwidth+13mm,
}

\DeclareTOCStyleEntries[beforeskip=1ex]{tocline}{section,subsection,subsubsection,paragraph,subparagraph}

\cs_if_exist:NTF \chapter {
	\DeclareTOCStyleEntries[beforeskip=\baselineskip]{tocline}{chapter}
}{
	\DeclareTOCStyleEntries[beforeskip=\baselineskip]{tocline}{section}
}


\setcounter{secnumdepth}{\subparagraphnumdepth}
\setcounter{tocdepth}{\subparagraphnumdepth}

\raggedbottom

\iftutex
	\setsansfont{texgyreheros}[Scale=1.1,LetterSpace=1.3]
\fi
\renewcommand*{\familydefault}{\sfdefault}

\endinput
