%% This is file `bfh-hkb-report.cfg' version 2.2.8 (2026-08-13),
%% 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-report.cfg}{2026-08-13}{2.2.8}{hkb-report module for bfhthesis}
\RenewDocumentCommand{\titlegraphic}{smo}{
	\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}
	}
	\IfNoValueF{#3}{\tl_gset:Nn \g_ptxcd_titleimage_caption_tl {#3}}
}

\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 \\
}


\prop_new:N \g__ptxcd_projectTitle_prop

\keys_define:nn {hkb/project} {
	title .prop_gput:N =\g__ptxcd_projectTitle_prop,
	artist .prop_gput:N =\g__ptxcd_projectTitle_prop,
	dating  .prop_gput:N =\g__ptxcd_projectTitle_prop,
}

\newcommand*{\ProjectTitle}[1]{
	\keys_set:nn {hkb/project} {#1}
	\tl_gset:Nf \@title {\prop_item:Nn \g__ptxcd_projectTitle_prop {artist},~\prop_item:Nn \g__ptxcd_projectTitle_prop {title}~(\prop_item:Nn \g__ptxcd_projectTitle_prop {dating})}
}

\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{title}{\mdseries\LARGE}
\addtokomafont{subject}{\mdseries\Large}
\addtokomafont{subtitle}{\mdseries\normalsize}
\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}{Abb.}
	\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*{-8.5mm}
			\tl_if_eq:cnTF {BFH-optional-Logo} {true} {
				\kern1pt\raisebox{.75mm}{\includegraphics[height=17.5mm]{example-image}}
				\hspace{1.25cm}\includegraphics[height=17mm]{example-image}
			}{
				\leavevmode\kern1pt\raisebox{-.75mm}{\includegraphics[height=17.5mm]{HKB_Markenzeichen\str_if_eq:VnF \g__ptxcd_colormode_tl {RGB} {_CMYK}}}
				\hfill\includegraphics[height=17.5mm]{SCRC-logo_2025\str_if_eq:VnF \g__ptxcd_colormode_tl {RGB} {_CMYK}}
			}
			\par
			\begingroup
			\usekomafont{title}
			\vskip2\baselineskip
			\prop_if_in:NnT \g__ptxcd_projectTitle_prop {artist} {
				\prop_item:Nn \g__ptxcd_projectTitle_prop {artist},~
			}
			\prop_if_in:NnT \g__ptxcd_projectTitle_prop {title} {
				\textit{\prop_item:Nn \g__ptxcd_projectTitle_prop {title}}~
			}
			\prop_if_in:NnT \g__ptxcd_projectTitle_prop {dating} {
				(\prop_item:Nn \g__ptxcd_projectTitle_prop {dating})
			}
			\par
			%\vskip.5\baselineskip
			\endgroup
			\begingroup
						\par\vskip.5\baselineskip
				{\usekomafont{subject}\@subject\par}
			\endgroup
						\ifx\@subtitle\@empty\else{\vspace{\baselineskip}\usekomafont{subtitle}\@subtitle\par}\fi
			\vspace{1cm}
			\begingroup
				\def\width{\dimexpr16cm}
				\def\height{\dimexpr10cm}
				\tl_if_empty:NF \g_ptxcd_titleimage_code_tl {
					\g_ptxcd_titleimage_code_tl
				}
				\tl_if_empty:NF \g_ptxcd_titleimage_caption_tl {
					\setkomafont{captionlabel}{}
					\setkomafont{caption}{\scriptsize}
					\captionof{figure}{\g_ptxcd_titleimage_caption_tl}
				}
				\par
			\endgroup
			\vspace{1.7cm}

		\vfill
		\usekomafont{titledata}
		\begingroup
		\renewcommand*{\arraystretch}{1.3}
		\begin{tabularx}{\linewidth}{@{}l@{\hspace{1.6em}}X@{}}%
		\seq_map_function:NN  \g__ptxcd_projectData_seq \__ptxcd_title_tabular_entry:n
		\end{tabularx}
		\endgroup
		\tl_if_eq:cnTF {BFH-optional-Logo} {true} {
			\raisebox{-3cm}[0pt][0pt]{\rlap{\hskip3.5mm\includegraphics[height=10mm]{example-image}}}
		}{
			\raisebox{-3cm}[0pt][0pt]{\rlap{\hskip3.5mm\includegraphics[height=10mm]{BFH-logo_SW.pdf}}}
		}
		\vspace*{-1.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 {30mm}
\dim_gset:Nn \g_ptxcd_outerMargin_dim {20mm}%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
