\documentclass[11pt, twoside, openright, hidelinks]{book}

%% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %%
%%                               Load Packages                               %%
%% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %%

\usepackage[
  centering,
  head=13.6pt
]{geometry}
\geometry{a4paper}

\usepackage{fontspec}
\directlua{
  luaotfload.add_fallback ("fallbackscript",
  {
    "freeserif:mode=harf;script=dev2;color=000000;",
  })
}

\setmainfont{latinmodernroman}[RawFeature={fallback=fallbackscript}]

\usepackage[italian,main=english]{babel} %% language

\usepackage[a-3u,mathxmp]{pdfx}

\directlua{pdf.setminorversion(5)}

\pagestyle{headings}

\usepackage{scrlayer-scrpage}

\ifoot[]{}
\cfoot[]{}
\ofoot[\pagemark]{\pagemark}
\pagestyle{scrplain}

\usepackage[
  backend=biber,
  style=numeric,
  bibencoding=utf8,
]{biblatex} %% for citations
\addbibresource{document.bib}

\usepackage{import} %% specify path for import

%% math packages
\usepackage{graphicx} %% for pictures
\usepackage{float}
\usepackage{amssymb} %% math symbols
\usepackage{amsmath} %% math matrix etc
\usepackage{minted} %% code block
\usepackage{tabularray} %% better tables
\usepackage{tblr-extras}
\usepackage{booktabs} %% rules for tables
\usepackage{mathrsfs}
\usepackage{mathtools}
\usepackage{algorithm} %% for algorithms
\usepackage{algpseudocode} %% loads algorithmicx
\usepackage{amsthm}
\usepackage{thmtools} %% theorems
\usepackage{simplebnf}
\usepackage{stmaryrd}
\usepackage{ebproof}
\usepackage{xfrac}
%\usepackage{caption}
\usepackage{bytefield}

%% plot packages
\usepackage{pgfplots} %% plots used with \begin{tikzpicture}
\usepackage{tikz} %% for pictures
\pgfplotsset{width=10cm,compat=newest}
\usepackage{subcaption}

%% design packages
\usepackage{enumitem} %% for lists and enumerating
\usepackage{luacolor}
\usepackage{xcolor} % xcolor for defining colors, colortbl for table colors
\usepackage{colortbl} % xcolor for defining colors, colortbl for table colors
\usepackage{makecell} %% for multiple lines in cell of table
\usepackage{cancel}
\usepackage{pgfornament} %% ornaments
\usepackage{makeidx}

%% load last
\usepackage{csquotes} %% correct language also for citations
\usepackage{hyperref} %% links for table of contents, load last
\usepackage{bookmark} %% for better table of contents

%% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %%
%%                       Configuration of the packages                       %%
%% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %%

\linespread{1}
\raggedbottom %% spaces if page is empty % chktex 1

%% set max table of contents recursion to subsection (3->subsubsecition)
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}

%% use bar instead of arrow for vectors
\renewcommand{\vec}[1]{\bar{#1}}
%% easy norm
\newcommand{\norm}[1]{\left\lvert#1\right\rvert}

% argmin and argmax
\DeclareMathOperator*{\argmax}{argmax}
\DeclareMathOperator*{\argmin}{argmin}

%% itemize use less vertical space (use olditemize for default behaviour)
\let\olditemize=\itemize%% old itemize
\let\endolditemize=\enditemize%% old end itemize
\renewenvironment{itemize}{\olditemize\itemsep-0.2em}{\endolditemize}

%% items in itemize emph+box
%% usage: \ieb{Class:} for simple item
%%        \ieb[4cm]{Class:} for specific size of box
\newcommand{\ieb}[2][2cm]{
        \makebox[#1][l]{\emph{#2}}
} %% TODO: replace with description environment (? maybe)

% less vertical space around align & align*
\newcommand{\zerodisplayskips}{
  \setlength{\abovedisplayskip}{0pt}
  \setlength{\belowdisplayskip}{0pt}
  \setlength{\abovedisplayshortskip}{0pt}
  \setlength{\belowdisplayshortskip}{0pt}
}

% make dotfill use all the space available
\renewcommand{\dotfill}{
  \leavevmode\cleaders\hbox to 1.00em{\hss .\hss }\hfill\kern0pt } % chktex 1 chktex 26

\setlength{\fboxsep}{-\fboxrule} % for debugging


%% PACKAGE algorithm
\floatname{algorithm}{Algorithm}


%% PACKAGE tabularray
\UseTblrLibrary{amsmath}
\UseTblrLibrary{caption}
\TblrCaptionBelow%


%% PACKAGE color
\definecolor{red}{rgb}{1, 0.1, 0.1}
\definecolor{lightgreen}{rgb}{0.55, 0.87, 0.47}
\definecolor{gray}{rgb}{0.3, 0.3, 0.3}
\newcommand{\lgt}{\cellcolor{lightgreen}} %% light green in tables
\newcommand{\gry}{\textcolor{gray}} %% gray text
\newcommand{\rd}{\textcolor{red}} %% red text
\newcommand{\green}{\textcolor{green}} %% green text
\newcommand{\blue}{\textcolor{blue}} %% blue text

%% PACKAGE minipage
\newcommand{\thend}[1]{\begin{center}
  \begin{minipage}[c][1em][c]{#1}
    \dotfill{}
  \end{minipage}
\end{center}}


%% PACKAGE thmtools
\declaretheoremstyle[
 headfont=\normalfont\bfseries,
 notefont=\mdseries,
 bodyfont=\normalfont,
 qed=\qedsymbol % chktex 1
]{steo}
\declaretheorem[numbered=yes, style=steo]{theorem}

\declaretheoremstyle[
 headfont=\normalfont\bfseries,
 notefont=\mdseries,
 bodyfont=\normalfont,
 qed=\qedsymbol % chktex 1
]{slem}
\declaretheorem[numbered=yes, style=slem]{lemma}

\declaretheoremstyle[
  headfont=\normalfont\bfseries,
  notefont=\mdseries,
  bodyfont=\normalfont,
]{sdef}
\declaretheorem[numbered=yes, style=sdef]{definition}

\declaretheoremstyle[
  spaceabove=-6pt,
  spacebelow=6pt,
  headfont=\normalfont\bfseries,
  bodyfont=\normalfont,
  postheadspace=1em,
  qed=$\blacksquare$,
  headpunct={:}
]{sprf}
\declaretheorem[name={Proof}, style=sprf, numbered=yes]{prof}

%% ......................................................................... %%
%% local changes
% \setcounter{secnumdepth}{0}
\newcommand{\defeq}{\vcentcolon=}

\usetikzlibrary{trees, positioning, shapes.misc, positioning, arrows.meta}

\DeclarePairedDelimiter\abs{\lvert}{\rvert}%
\DeclarePairedDelimiter\doublesq{\llbracket}{\rrbracket}%


\definecolor{color_Error}{HTML}{FC2836}

\definecolor{color_String}{HTML}{0E7AFF}
\definecolor{color_Path}{HTML}{1AC9D8}
\definecolor{color_Svg}{HTML}{86868B}
\definecolor{color_PositiveInt}{HTML}{1BD5B6}
\definecolor{color_Symbol}{HTML}{5A61FF}

\definecolor{color_System}{HTML}{FECF0A}
\definecolor{color_Environment}{HTML}{FFEDA4}
\definecolor{color_Set}{HTML}{FFE370}
\definecolor{color_Context}{HTML}{D9AF00}
\definecolor{color_Reactions}{HTML}{A78700}

\definecolor{color_Experiment}{HTML}{FD7E25}

\definecolor{color_PositiveSystem}{HTML}{A77753}
\definecolor{color_PositiveEnvironment}{HTML}{F3D2BA}
\definecolor{color_PositiveSet}{HTML}{C99D7D}
\definecolor{color_PositiveContext}{HTML}{875733}
\definecolor{color_PositiveReactions}{HTML}{683A18}

\definecolor{color_Trace}{HTML}{FC577D}
\definecolor{color_PositiveTrace}{HTML}{FB003B}

\definecolor{color_Graph}{HTML}{2ECC46}
\definecolor{color_PositiveGraph}{HTML}{00961A}

\definecolor{color_DisplayNode}{HTML}{B2F4BD}
\definecolor{color_DisplayEdge}{HTML}{81E793}
\definecolor{color_ColorNode}{HTML}{3BC553}
\definecolor{color_ColorEdge}{HTML}{1CB236}

\definecolor{color_AssertFunction}{HTML}{CF00EE}
\definecolor{color_GroupFunction}{HTML}{750086}
\definecolor{color_PositiveAssertFunction}{HTML}{35C9FD}
\definecolor{color_PositiveGroupFunction}{HTML}{02B7F3}


%% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %%

\title{Document}
\author{
  Elvis Rossi
}
\date{\today}

\makeindex

%% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %%

\begin{document}

\pagenumbering{roman}

\input{title_page}

\newpage
\null % chktex 1
\vspace*{\fill}
\begin{center}
  \color{black!30}\pgfornament[width=2cm]{123}
\end{center}
\newpage

\tableofcontents

\newpage
\pagenumbering{arabic}
\setcounter{page}{1}

\input{introduction}
\input{background}
\input{design}
\input{development}
\input{validation}
\input{conclusion}
\input{appendix}

\printbibliography%

\end{document}

%% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %%
