%% =================================================================================================
%% Styles
%% =================================================================================================

%% Colors
\definecolor{orcidclr}{HTML}{A6CE39}
\definecolor{manclr}{cmyk}{\clr} %% \clr defined for each manual from local settings.tex
\colorlet{manclrshd}{manclr!60} %% Derived color for chapter heading, see below

%% Cover page
\backgroundsetup{
   firstpage=true,scale=1,angle=0,opacity=1,
   contents ={
      \begin{tikzpicture}[remember picture,overlay]
         \path[fill=manclr] (-0.5\paperwidth,7) rectangle (0.5\paperwidth,10);
      \end{tikzpicture}
    }
}

%% Page layout
%\pagestyle{scrheadings}
%\renewcommand{\chapterpagestyle}{empty}
\renewcommand{\chaptermark}[1]{\markboth{ #1}{}} %% Convert mark to lowercase
\renewcommand{\sectionmark}[1]{\markright{#1}{}} %%    "     ""  ""     "  
\ohead{} %% Clear default headings
\lohead{Chap. \thechapter\  \leftmark}
\rehead{Sect. \thesection\ \rightmark}
\ifoot{Page \thepage\ of \pageref*{LastPage}}
%\ifoot[\pagemark]{Page \thepage\ of \lastpageref*{pagesLTS.arabic}}
\ofoot{\eng\ Reference Manual}
\addtokomafont{pagehead}{  \sffamily              }
\addtokomafont{pagefoot}{  \sffamily \footnotesize}
\addtokomafont{pagenumber}{\sffamily \slshape     }
%\addtokomafont{chapter}{\color{white}}

%% Cross-referencing
\hypersetup{
   pdftitle=\hdg,pdfauthor=Gurvan Madec and NEMO System Team,
   pdfsubject=Reference manual of NEMO modelling framework,pdfkeywords=ocean circulation modelling,
   colorlinks,allcolors=manclr
}
\renewcommand{\appendixautorefname}{appendix}          %% `\autoref` uncapitalization
\renewcommand{\equationautorefname}{equation}          %%     ""            ""
\renewcommand{\figureautorefname  }{figure}            %%     ""            ""
\renewcommand{\listingname        }{namelist}          %%     ""            ""
\renewcommand{\listlistingname    }{List of Namelists} %%     ""            ""
\renewcommand{\tableautorefname   }{table}             %%     ""            ""

%% Misc. (caption and footnote)
\captionsetup{font=footnotesize,justification=justified}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}

%% Bibliography
\bibliographystyle{../../global/ametsoc}
\renewcommand{\bibfont}{\small}
\renewcommand{\bibpreamble }{\begin{multicols}{2}}
\renewcommand{\bibpostamble}{  \end{multicols}   }

%% Catcodes (between `\makeatletter` and `\makeatother`)
\makeatletter

%% Apply manual color for chap. headings (original snippets from fncychap.sty)
%% !!! Let trailing percent sign to avoid space insertion
\renewcommand{\DOCH}{% %% Upper box with chapter number
   \settowidth{\py}{\CNoV\thechapter}%
   \addtolength{\py}{-10pt}% %% Amount of space by which the number is shifted right
   \fboxsep=0pt%
   \colorbox{manclr}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}%
   \kern-\py\raise20pt%
   \hbox{\color{manclrshd}\CNoV\thechapter}\\
}
\renewcommand{\DOTI}[1]{% %% Lower box with chapter title
   \nointerlineskip\raggedright%
   \fboxsep=\myhi%
   \vskip-1ex%
   \colorbox{manclr}{\parbox[t]{\mylen}{\color{white}\CTV\FmTi{#1}}}\par\nobreak%
   \vskip 40\p@%
}
\renewcommand{\DOTIS}[1]{% %% Box for unumbered chapter
   \fboxsep=0pt%
   \colorbox{manclr}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}\\
   \nointerlineskip\raggedright%
   \fboxsep=\myhi%
   \vskip-1ex% %% Remove white 1pt line
   \colorbox{manclr}{\parbox[t]{\mylen}{\color{white}\CTV\FmTi{#1}}}\par\nobreak%
   \vskip 40\p@%
}

\makeatother
