\hduthesis_provide_module:n {hdu.stationery}

\keys_define:nn { hdu.stationery / docinfo }
  {
    watermark .bool_set:N  = \g__docinfo_watermark_bool,
      watermark .initial:n = false,
      watermark .default:n = true,
    title .tl_set:N        = \@title,
    author .tl_set:N       = \@author,
    mail .tl_set:N         = \l__docinfo_mail_tl,
    date .tl_set:N         = \@date
  }

\RequirePackage{ hyperref, geometry, tikz, twemojis, fancyhdr }
\NewDocumentCommand \DocInfo { m }
  {
    \keys_set:nn { hdu.stationery / docinfo } {#1}
    \hypersetup { hidelinks, pdftitle = \@title, pdfauthor = \@author }
  }
\geometry
  { hmargin = .8in, bottom = .75in, top = 1.95in, footskip = 15.87pt,
    headheight = 1.2in, headsep = .3in, footskip = .3in }
\linespread{1.25}
\RequirePackage [ skip = \baselineskip ] { parskip }
\renewcommand* \familydefault { \sfdefault }
\definecolor{hdu}{HTML}{214395}

\renewcommand* \headrulewidth {2pt}
\renewcommand* \footrulewidth {2pt}
\hook_gput_code:nnn { cmd/headrule/before } { . } { \color{hdu!80} }
\hook_gput_code:nnn { cmd/footrule/before } { . } { \color{hdu!80} }
\lhead
  { {}~
    \minipage{.6\linewidth}
      \medskip \leavevmode \lower -.111in
      \hbox { \includegraphics [ height = .75in ] {hdubadge} }
    \endminipage \medskip \hfill
    \minipage{.36\linewidth}
      \medskip \vbox
        { \linespread{1.2}
          \raggedright \small \color{hdu}
          \texttwemoji{1f4cd}~ 1158~No.2~St.,~ Hangzhou,~ 310018\\
          \texttwemoji{1f4de}~ (86)~0571-86915072\\
          \texttwemoji{1f310}~ \url{www.hdu.edu.cn}
        } \medskip
    \endminipage
  }
\lfoot
  {
    \small{}~ \texttwemoji{1f4cd}~
    1158~No.2~Street,~ Qiantang~District,~
    Hangzhou,~ Zhejiang~Province,~ 310018,~ P.R.China
  }
\cfoot {}
\rfoot { \small \texttwemoji{1f310}~ www.hdu.edu.cn~ }
\pagestyle{fancy}

\renewcommand* \maketitle
  {
    \group_begin: \small
    \bool_if:nF
      { \tl_if_empty_p:N \@author && \tl_if_empty_p:N \l__docinfo_mail_tl }
      { \makebox [ 4em ] [ l ] { \scshape From } }
    \tl_if_empty:NTF \@author
      { \@latex@warning@no@line {No \noexpand \author given} } { \@author{}~ }
    \tl_if_empty:NF \l__docinfo_mail_tl
      { \texttt { <\l__docinfo_mail_tl> } }
    \bool_if:nT
      { !\tl_if_empty_p:N \@author || !\tl_if_empty_p:N \l__docinfo_mail_tl }
      { \\ }
    \makebox [ 4em ] [ l ] { \scshape Date }
      \tl_if_empty:NTF \@date \today \@date \\
    \tl_if_empty:NTF \@title
      { \@latex@error {No \noexpand \title given}\@ehc }
      { \makebox [ 4em ] [ l ] { \scshape Subject } \@title }
    \par \vspace{.5\baselineskip}
    \group_end:
  }

\AtBeginDocument { \color_select:n {black!80} }
\DeclareHookRule { shipout / background } { hduthesis / stationery }
  { before } { pgfrcs }
\AddToHook { shipout / background } [ hduthesis / stationery ]
  {
    \bool_if:NT \g__docinfo_watermark_bool
      {
        \tikz [ remember~picture, overlay ]
          \node [ opacity = .2 ] at (current~page)
            { \includegraphics [ width = .4\linewidth ] {hdulogo} };
      }
  }

\RequirePackage{tikzpagenodes}
\NewDocumentCommand \notelines {O{20}}
  {
    \tikz [ remember~picture, overlay ]
      {
        \int_step_inline:nn { #1 - 1 }
          {
            \draw [ hdu, very~thick, opacity = .6 ]
              ([yshift = -##1 * (\textheight + .6in - 15.87pt ) / #1 + .3in]
                current~page~text~area.north~west) --++ (\linewidth, 0);
          }
      }
  }

\newcommand \meta[1]
  {
    \ensuremath \langle
      \ifmmode \expandafter \nfss@text \fi
      {
        \itshape\ttfamily \edef \meta@hyphen@restore
          { \hyphenchar \the \font \the \hyphenchar \font }
        \hyphenchar \font \m@ne \language
        \l@nohyphenation #1\/\meta@hyphen@restore
      }
    \ensuremath \rangle 
  }

\endinput
