% ============================================================
%  Preamble for the modular CV (altacv class)
%  - geometry / colors / fonts overrides
%  - compact macros for dense list-style entries (talks, grants, pubs)
% ============================================================

\geometry{left=1.4cm,right=1.4cm,top=1.5cm,bottom=1.5cm,columnsep=1.2cm}

% --- Colors --------------------------------------------------
\definecolor{SlateGrey}{HTML}{2E2E2E}
\definecolor{LightGrey}{HTML}{666666}
\definecolor{Accent}{HTML}{1F4E79}     % deep blue
\definecolor{Subtle}{HTML}{A0A0A0}

\colorlet{name}{SlateGrey}
\colorlet{tagline}{Accent}
\colorlet{heading}{Accent}
\colorlet{headingrule}{Accent}
\colorlet{subheading}{Accent}
\colorlet{accent}{Accent}
\colorlet{emphasis}{SlateGrey}
\colorlet{body}{SlateGrey}

% --- Fonts ---------------------------------------------------
% Use Lato if installed (texlive ships it), otherwise default serif.
\IfFontExistsTF{Lato}{%
  \setmainfont{Lato}[
    Path = ,
    UprightFont = *-Regular,
    BoldFont = *-Bold,
    ItalicFont = *-Italic,
    BoldItalicFont = *-BoldItalic,
  ]
}{}

% --- Tighter section / paragraph spacing ---------------------
% altacv's defaults are already tight; nudge a tiny bit further.
\setlength{\parskip}{2pt}

% --- Extra info fields for the header ------------------------
% \blog{host}     → faBlog  icon + linked https://host
% \orcid{id}      → faOrcid icon + linked https://orcid.org/<id>
\NewInfoField{blog}{\faBlog}[https://]
\NewInfoField{orcid}{\faOrcid}[https://orcid.org/]

% --- Hyperref tweaks (the class loads it via withhyper) ------
\hypersetup{
  colorlinks=true,
  urlcolor=Accent,
  linkcolor=Accent,
  pdfauthor={Giorgio F. Gilestro},
  pdftitle={Curriculum Vitae - Giorgio F. Gilestro},
}

% ============================================================
% Custom semantic macros for dense list-style chapters.
% These complement altacv's \cvevent / \cvachievement / \divider.
% Layout: a left "tag" column (date or amount) baseline-aligned
% with the description on the right.
% ============================================================

% Two-column compact row: left tag (date/amount), right description.
% Baseline-aligned via \parbox[t]+\strut so the date never sits below
% the start of the description.
\newcommand{\cvrow}[2]{%
  \par\noindent
  \parbox[t]{0.16\linewidth}{\raggedright\strut\small\color{LightGrey}#1}%
  \hspace{0.5em}%
  \parbox[t]{0.81\linewidth}{\raggedright\strut #2}%
  \par\vspace{2pt}%
}

% Grant entry: year | amount | description (three columns).
\newcommand{\cvgrant}[3]{%
  \par\noindent
  \parbox[t]{0.07\linewidth}{\raggedright\strut\small\color{LightGrey}#1}%
  \hspace{0.3em}%
  \parbox[t]{0.10\linewidth}{\raggedright\strut\bfseries#2}%
  \hspace{0.3em}%
  \parbox[t]{0.80\linewidth}{\raggedright\strut #3}%
  \par\vspace{2pt}%
}

% Talk entry: date | kind | venue.
\newcommand{\cvtalk}[3]{%
  \par\noindent
  \parbox[t]{0.10\linewidth}{\raggedright\strut\small\color{LightGrey}#1}%
  \hspace{0.3em}%
  \parbox[t]{0.08\linewidth}{\raggedright\strut\small\itshape#2}%
  \hspace{0.3em}%
  \parbox[t]{0.79\linewidth}{\raggedright\strut #3}%
  \par\vspace{2pt}%
}

% Alumnus: name+degree (bold) | current position.
\newcommand{\cvalum}[2]{%
  \par\noindent
  \parbox[t]{0.38\linewidth}{\raggedright\strut\bfseries #1}%
  \hspace{0.5em}%
  \parbox[t]{0.59\linewidth}{\raggedright\strut\small #2}%
  \par\vspace{2pt}%
}

% Senior-author marker for publications (✉)
\newcommand{\senior}{{\color{Accent}\faEnvelope}\,}

% Publication: authors / title / venue / marker (or empty)
\newcommand{\cvpub}[4]{%
  \par\noindent
  \parbox[t]{0.04\linewidth}{\strut #4}%
  \parbox[t]{0.95\linewidth}{\raggedright\strut #1\\
    \textit{#2}\\
    {\small\color{LightGrey}#3}}%
  \par\vspace{4pt}%
}
