%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% nova/fct//nova-fct-defaults.clo
%% NOVA thesis document template
%%
%% This work is licensed under the
%% The LaTeX project public license (LPPL), version 1.3c
%% To view a copy of this license, visit
%% https://www.latex-project.org/lppl/lppl-1-3c/
%%
%% Authors / Contributors:
%%      - João Lourenço <joao.lourenco@fct.unl.pt>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\typeout{NT FILE schools/nova/fct/nova-fct-defaults.clo}%


%%=======================================================================
%% METADATA & GLOBAL PROPERTIES
%%=======================================================================

% All LaTeX engines (pdfLaTeX, XeLaTeX, LuaLaTeX) are accepted
\AddValidProcessor{nova/fct/plain}{pdf,lua,xe}

% NOVA/FCT
\NTOptNewValue{nova/fct/company/logo}{}
\NTOptNewValue{nova/fct/company/name}{}

\ntsetup{print/frontpage=true}
\openany

\@nt@printorder@set{frontmatter_working}{%
    abstracts,       % Print abstracts in multiple languages.
    aidisclose,      % AI disclosure statement
    alllistof,       % Print all the listof defined in “6_list_of.tex”
    myprintglossaries, % Print the Glossary, Acronyms, Symbols, etc…
}
\@nt@printorder@set{frontmatter_provisional}{%
    abstracts,       % Print abstracts in multiple languages.
    aidisclose,      % AI disclosure statement
    alllistof,       % Print all the listof defined in “6_list_of.tex”
    myprintglossaries, % Print the Glossary, Acronyms, Symbols, etc…
}
\@nt@printorder@set{frontmatter_final}{%
    abstracts,       % Print abstracts in multiple languages.
    aidisclose,      % AI disclosure statement
    alllistof,       % Print all the listof defined in “6_list_of.tex”
    myprintglossaries, % Print the Glossary, Acronyms, Symbols, etc…
}


%%=======================================================================
%% COLORS
%%=======================================================================

\definecolor{fctlightgreen}{RGB}{67,140,74}%
\definecolor{fctdarkgreen}{RGB}{67,140,74}%
\definecolor{fctlightblue}{RGB}{67,120,188}%
\definecolor{fctdarkblue}{RGB}{46,108,195}%
\definecolor{fctlightred}{RGB}{95,5,44}%
\definecolor{fctdarkred}{RGB}{117,37,60}%
\definecolor{fctlightbrown}{RGB}{129,87,36}%
\definecolor{fctdarkbrown}{RGB}{142,112,51}%

\def\@fctblackheight{4.088cm}


%%=======================================================================
%% STRINGS (UNIVERSITY & SCHOOL)
%%=======================================================================

% Faculty / School
\SetSchool*(cat)={NOVA School of Science and Technology}
\SetSchool*(cz)={NOVA School of Science and Technology}
\SetSchool*(de)={NOVA School of Science and Technology}
\SetSchool*(dk)={NOVA School of Science and Technology}
\SetSchool*(en)={NOVA School of Science and Technology}
\SetSchool*(es)={NOVA School of Science and Technology}
\SetSchool*(fr)={NOVA School of Science and Technology}
\SetSchool*(gr)={NOVA School of Science and Technology}
\SetSchool*(it)={NOVA School of Science and Technology}
\SetSchool*(nl)={NOVA School of Science and Technology}
\SetSchool*(pl)={NOVA School of Science and Technology}
\SetSchool*(pt)={Faculdade de Ciências e Tecnologia}
\SetSchool*(sk)={NOVA School of Science and Technology}
\SetSchool*(uk)={NOVA School of Science and Technology}

% Logos
\SetSchool*(logo,pt)={nova-fct-logo-pt}
\SetSchool*(logo,en)={nova-fct-logo-en}
\IfMemVoidTF{School}{logo,\@LANG@COVER}
  {\SetSchool*(logo)={\GetSchool(logo,en)}}
  {\SetSchool*(logo)={\GetSchool(logo,\@LANG@COVER)}}

\SetSchool*(logo,neg,pt)={nova-fct-logo-negative-pt}
\SetSchool*(logo,neg,en)={nova-fct-logo-negative-en}
\IfMemVoidTF{School}{logo,neg,\@LANG@COVER}
  {\SetSchool*(logo,neg)={\GetSchool(logo,neg,en)}}
  {\SetSchool*(logo,neg)={\GetSchool(logo,neg,\@LANG@COVER)}}


%%=======================================================================
%% COMMITTEE
%%=======================================================================

\SetCommitteeOrder*()={c,r,a,ca,m}%


%%=======================================================================
%% FONTS
%%=======================================================================



%%=======================================================================
%% LAYOUT (MARGINS)
%%=======================================================================

% Set margins for "normal" pages
\SetMargin*(screen,top)={3.5cm}
\SetMargin*(screen,bottom)={2.5cm}
\SetMargin*(screen,left)={3.0cm}
\SetMargin*(screen,right)={3.0cm}
\SetMargin*(paper,top)={3.5cm}
\SetMargin*(paper,bottom)={2.5cm}
\SetMargin*(paper,left)={3.0cm}
\SetMargin*(paper,right)={3.0cm}

% Set margins for cover pages
\SetMargin*(cover,top)={8.6cm}
\SetMargin*(cover,bottom)={1.5cm}
\SetMargin*(cover,left)={3.55cm}
\SetMargin*(cover,right)={2.0cm}
\SetMargin*(cover,2-1,top)={6.6cm}


%%=======================================================================
%% SPINE
%%=======================================================================

\SetSpine*(logo,phd)={\GetUniversity(logo,neg)}
\SetSpine*(logo,msc)={\GetSchool(logo,neg)}

\SpineSetup[%
  \def\spnimg{nova-fct-spine-red}%
  \def\spnlogo{\GetSpine(logo,msc)}
  \ifmscdoc{%
    \def\spnimg{nova-fct-spine-blue}%
  }{}%
  \ifphddoc{%
    \def\spnimg{nova-fct-spine-green}%
    \def\spnlogo{\GetSpine(logo,phd)}%
  }{}%
]{%
  bg/image                    = {\spnimg},
  bg/image/angle              = {-90},
  box/logo/bg/image           = {\spnlogo},
  box/logo/bg/image/angle/phd = {-90},
  box/date/fg/color           = {white},
  box/title/fg/color          = {white},
  box/author/fg/color         = {white},
  % debug,
}


%%=======================================================================
%% COVER PAGE SETUP (BACKGROUNDS)
%%=======================================================================

\SetThesisCover*(1-1,textcolor)={white}
\SetThesisCover(textfont)={\sffamily}

% Set cover color (background image)
\ifcsname @novafctcovercolor\endcsname\else
  \def\@novafctcovercolor{red}
  \ifdocclass{msc}{\def\@novafctcovercolor{blue}}{}
  \ifdocclass{phd}{\def\@novafctcovercolor{green}}{}
\fi

\SetThesisCover*(\@DOCTYPE,1-1,image)={nova-fct-cover-\@novafctcovercolor-front}
\SetThesisCover*(\@DOCTYPE,N-2,image)={nova-fct-cover-\@novafctcovercolor-back}
\SetThesisCover*(\@DOCTYPE,spine,image)={nova-fct-\@novafctcovercolor-red}


%%=======================================================================
%% UTILITIES & HOOKS
%%=======================================================================

\newif\if@nt@hasbreak

\newcommand{\printdwithvspace}[2][2pt]{%
  % ---- Phase 1: probe — execute #2 in a discard box; \\ just sets a flag ----
  \@nt@hasbreakfalse
  \setbox\z@\hbox{%
    \def\\{\global\@nt@hasbreaktrue}%
    #2%
  }%
  % ---- Phase 2: typeset for real ----
  \if@nt@hasbreak
    % \\ found: redefine to append [#1] to each line break, then typeset
    \begingroup
      \let\@nt@origcr\\%
      \def\\{\@nt@origcr[#1]}%
      #2%
    \endgroup
  \else
    % No \\ found: prepend \\[#1] before the content
    \\[#1]#2%
  \fi
}

\NTAddToHook{cover/1-1/pre}{%
  % \iftutex
  %     \setsansfont{Inter}[
  %       Scale = 0.95,
  %       Extension = .otf,
  %       UprightFont = *-Regular,
  %       ItalicFont = *-Italic,
  %       BoldFont = *-Bold,
  %       BoldItalicFont = *-BoldItalic,
  %       Ligatures = {NoCommon, TeX}, % This kills the 'oe' ligature while keeping '--'
  %     ]
  % \fi
  \color{white}
}

% \NTAddToHook{cover/text/pre}{%  % superseded by \SetThesisCover(textfont)={\sffamily} above
%   % \iftutex
%   %     \setsansfont{Inter}[
%   %       Scale = 0.95,
%   %       Extension = .otf,
%   %       UprightFont = *-Regular,
%   %       ItalicFont = *-Italic,
%   %       BoldFont = *-Bold,
%   %       BoldItalicFont = *-BoldItalic,
%   %       Ligatures = {NoCommon, TeX} % This kills the 'oe' ligature while keeping '--'
%   %     ]
%   % \fi
%   \sffamily%
% }


%%=======================================================================
%% COVER 1 ELEMENTS
%%=======================================================================

% University and school logo
\ntaddtocover[tikz]{1-1}{%
  \node[anchor=center] at ($(current page.north west) + (20mm,-20mm)$)
    {\includegraphics[width=21mm]{\expanded{\GetUniversity(logo,neg)}}};%
  \draw[thick] ($(current page.north west) + (3.5cm,-1cm)$) -- ++(0cm,-2cm);%
  \node[anchor=west] at ($(current page.north west) + (40mm,-19mm)$)
    {\includegraphics[width=35.3mm]{\expanded{\GetSchool(logo,neg)}}};%
}

% Department
\ntaddtocover[tikz]{1-1,2-1}{%
  \node[anchor=north west, text width=10cm] 
    at ($(current page.north west) + (96.45mm,-11.4mm)$)
    { \fontsize{14}{14}\sffamily%
      \MakeUppercase{\GetDepartmentOfString(\@LANG@COVER)}
      \printdwithvspace{\MakeUppercase{\GetDepartment(\@LANG@COVER)}}
    };
}

% Company logo — only for fct/di-adc bsc documents
\ntaddtocover[tikz]{1-1,2-1}{%
  \ifoptionvoid{/novathesis/nova/fct/company/logo}{}{%
    \ifoptionequal{/novathesis/doctype}{bsc}{%
      \ifoptionequal{/novathesis/schoolgiven}{nova/fct/di-adc}{%
        \node[anchor=east] at ($(current page.north east) + (-1cm,-2cm)$)
              {\includegraphics[width=40mm,height=21mm,keepaspectratio]
                               {\option{/novathesis/nova/fct/company/logo}}};%
      }{}%
    }{}%
  }%
}

% Title of Dissertation (PhD) / The author name (MSc)
\ntaddtocover[halign=l,height=3.0cm,valign=c]{1-1}{%
  \ifphddoc{%
    \fontsize{20}{21}\selectfont%
    \textbf{\MakeUppercase{\GetDocTitle(\@LANG@COVER,main)}}%
    \IfMemVoidF{DocTitle}{\@LANG@COVER,sub}{%
      \\[4mm]%
      \fontsize{14}{14}\selectfont%
      \textbf{\MakeUppercase{\GetDocTitle(\@LANG@COVER,sub)}}%
    }{}%
  }{%
    \fontsize{17}{17}\selectfont%
    \textbf{\MakeUppercase{\GetDocAuthor(name)}}\\[2mm]%
    \fontsize{17}{17}\selectfont%
    \GetDocAuthor(degree,\@LANG@COVER)%
  }%
}

% The author name (PhD) / Title of Dissertation (MSc)
\ntaddtocover[vspace=3.0cm,halign=l,height=3cm,valign=c]{1-1}{%
  \ifphddoc{%
    \fontsize{17}{17}\selectfont%
    \textbf{\MakeUppercase{\GetDocAuthor(name)}}\\[2mm]%
    \fontsize{17}{17}\selectfont%
    \GetDocAuthor(degree,\@LANG@COVER)%
  }{%
    \fontsize{20}{21}\selectfont%
    \textbf{\MakeUppercase{\GetDocTitle(\@LANG@COVER,main)}}%
    \IfMemVoidF{DocTitle}{\@LANG@COVER,sub}{%
      \\[4mm]%
      \fontsize{14}{14}\selectfont%
      \textbf{\MakeUppercase{\GetDocTitle(\@LANG@COVER,sub)}}%
    }{}%
  }%
}

% Degree name, Specialization, Date
\ntaddtocover[vfill=1,halign=l]{1-1}{%
  \fontsize{14}{13}\selectfont%
  \MakeUppercase{\GetMajorField(\@LANG@COVER)}%
  {\IfMemVoidF{Specialization}{\@LANG@COVER}{%
  \fontsize{11}{11}\selectfont
  \\\MakeUppercase{\GetMinorField(\@LANG@COVER)}}{}}%
  \\[3mm]%
  \GetUniversity(\@LANG@COVER)\\[1pt]%
  \iftoggle{/novathesis/print/timestamp}{%
    \ifdocworking{\emph{\color{yellow}\textbf{Draft:} \today}}%
                 {\PrintDateISO{\GetDocDate(submission,year)-\GetDocDate(submission,month)}}%
  }{\PrintDateISO{\GetDocDate(submission,year)-\GetDocDate(submission,month)}}%
}


%%=======================================================================
%% COVER 2 ELEMENTS
%%=======================================================================

\ntaddtocover[tikz]{2-1}{%
  \node[anchor=center] at ($(current page.north west) + (20mm,-20mm)$)
    {\includegraphics[width=21mm]{\expanded{\GetUniversity(logo)}}};%
  \draw[thick] ($(current page.north west) + (3.5cm,-1cm)$) -- ++(0cm,-2cm);%
  \node[anchor=west] at ($(current page.north west) + (40mm,-19mm)$)
    {\includegraphics[width=35.3mm]{\expanded{\GetSchool(logo)}}};%
  \draw[thick] ($(current page.north west) + (1cm,-4.1cm)$) -- ++(\paperwidth-2cm,0cm);%
}

% Title of Dissertation (PhD)
\ntaddtocover[halign=l]{2-1}{%
  \fontsize{17}{17}\selectfont%
  \textbf{\MakeUppercase{\GetDocTitle(\@LANG@COVER,main)}}%
  \IfMemVoidF{DocTitle}{\@LANG@COVER,sub}{%
    \\[4mm]%
    \fontsize{12}{12}\selectfont%
    \textbf{\MakeUppercase{\GetDocTitle(\@LANG@COVER,sub)}}%
  }{}%
}

% The author name
\ntaddtocover[vfill=1,halign=l]{2-1}{%
  \fontsize{14}{14}\selectfont%
  \textbf{\MakeUppercase{\GetDocAuthor(name)}}\\[2mm]%
  \fontsize{14}{14}\selectfont%
  \GetDocAuthor(degree,\@LANG@COVER)%
}

% The advisers
\ntaddtocover[vfill=2,halign=l]{2-1}{%
  \MemSet{adviserstringfont}{}{\bfseries}%
  \fontsize{11}{11}\selectfont%
  \ntprintpersons{0.9}{2}{adviser}{\GetAdviserOrder()}%
}

% % The committee
% \ntaddtocover[vfill=1,hspace=3.5cm,halign=l]{2-1}{%
%   \MemSet{committeetitlestringfont}{}{\bfseries}%
%   \MemSet{committeestringfont}{}{\bfseries}%
%   \fontsize{10}{10}\selectfont%
%   \ntprintpersons{0.9}{2}{committee}{\GetCommitteeOrder()}%
% }

% Date
\ntaddtocover[vfill=1,halign=l]{2-1}{%
  \fontsize{10}{10}\selectfont%
  \MakeUppercase{\GetMajorField(\@LANG@COVER)}%
  {\IfMemVoidF{Specialization}{\@LANG@COVER}{%
  \fontsize{8}{9}\selectfont
  \\\MakeUppercase{\GetSpecialization(\@LANG@COVER)}}{}}%
  \\[1.25ex]%
  \GetUniversity(\@LANG@COVER)\\[1pt]%
  \iftoggle{/novathesis/print/timestamp}{%
    \ifdocworking{\emph{\color{blue}\textbf{Draft:} \today}}%
                 {\PrintDateISO{\GetDocDate(submission,year)-\GetDocDate(submission,month)}}%
  }{\PrintDateISO{\GetDocDate(submission,year)-\GetDocDate(submission,month)}}%
}


%%=======================================================================
%% BACK COVER ELEMENTS
%%=======================================================================

% Print sponsor logos
\ntaddtocover[vfill=1, halign=l]{N-2}{%
  \foreach \myi in {1, ..., 9} {%
    \IfMemVoidF{Sponsor}{\@LANG@COVER,\myi,logo}{%
      \GetSponsor(\@LANG@COVER,\myi,logo)\qquad%
    }{}%
  }%
}
