%---DOCUMENT MARGINS---
\usepackage{geometry}
\geometry{
	paper=a4paper,
	top=4cm,
	bottom=2cm,
	left=2cm,
	right=2cm,
	headheight=3cm,
	headsep=0.5cm
}

\usepackage{cmap}

%---FONTS AND LANGUAGE---
\usepackage[T2A]{fontenc}
\usepackage[bulgarian]{babel}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\setsansfont{Times New Roman}
\setmonofont{Courier New}

\usepackage[math-style=TeX]{unicode-math}
\setmathfont{Latin Modern Math}

%---SECTION FORMATTING---
\usepackage[nobottomtitles*]{titlesec}

\titleformat
{\section}
{\fontsize{14}{14}\sffamily\bfseries}
{}
{0pt}
{}

\titlespacing{\section}{0pt}{0em}{0em}

\titleformat
{\subsection}
{\fontsize{14}{14}\itshape}
{}
{0pt}
{}
[\vspace{-1em}{\color{LimeGreen}\rule{0.2\textwidth}{0.2em}}\vspace{-0.7em}]

\titlespacing{\subsection}{0pt}{0.5em}{0em}

%---PROBLEM HEADER---
\newcommand{\tl}{}
\newcommand{\ml}{}

\newcommand{\problem}[1]{%
	\section[#1]{#1 \fontsize{12}{12}{\hfill{\normalfont{
		\emoji{hourglass-not-done}\tl \space\space \emoji{floppy-disk} \ml}}}}
}

% Нова страница преди всяка следваща задача, но не и преди първата
\usepackage{etoolbox}
\pretocmd{\section}{\ifnum\value{section}>0 \clearpage\fi}{}{}

%---COLORS---
\usepackage[dvipsnames]{xcolor}

%---DATE/AUTHOR---
\newcommand{\formatdate}[3]{#1#2#3}
\newcommand{\currentdate}{%
	\formatdate{\the\year}{\ifnum\month<10 0\fi\the\month}{\ifnum\day<10 0\fi\the\day}
}

\newcommand{\addauthor}[4]{%
	\ifnum\currentdate>\formatdate{#2}{#3}{#4}
	{\noindent\hfill\bfseries{#1}}
	\fi
}

%---PARAGRAPH STYLE---
\setlength{\parskip}{0.5em}
\setlength{\parindent}{24pt}
\sloppy
\raggedbottom

%---HEADER AND FOOTER---
\usepackage{fancyhdr}
\usepackage{lastpage}

\pagestyle{fancy}
\fancyhead[L]{%
	\begin{minipage}{\textwidth}
		\includegraphics[width=2.5cm]{./logo.jpg}
	\end{minipage}
}

\newcommand{\header}{}

\fancyhead[C]{%
	\begin{minipage}{\textwidth}
		\centering\large\bfseries \header
		\vspace{-0.35cm}
	\end{minipage}
}

\fancyhead[R]{}
\renewcommand{\headrulewidth}{0cm}
\fancyheadoffset[L,R]{1cm}

\fancyfoot[C]{\thepage\ / \pageref*{LastPage}}

%---MATH---
\usepackage{amsmath}
\usepackage{stmaryrd}

%---GRAPHICS---
\usepackage{graphicx}
\graphicspath{{./}}

\usepackage[export]{adjustbox}
\usepackage{wrapfig}

\makeatletter
\patchcmd\WF@putfigmaybe{\lower\intextsep}{}{}{}
\AddToHook{env/wrapfigure/begin}{\setlength{\intextsep}{0pt}}
\makeatother

\usepackage[inkscapearea=page, inkscapepath=./svg-inkscape]{svg}
\svgpath{{./}}

%---TABLES---
\usepackage{makecell}
\usepackage{tabularray}
\usepackage{float}
\usepackage{placeins}
\usepackage{caption}

\AtBeginEnvironment{table}{\vspace{-0.2cm}}
\AtEndEnvironment{table}{\vspace{-0.2cm}}

\captionsetup[table]{
	skip=0.25em,
	font=it,
	singlelinecheck=false,
	justification=justified,
	indention=-24pt,
	margin={24pt, 0pt}
}

%---LISTS---
\usepackage{enumitem}
\setlist{itemsep=-0.4em, leftmargin=\parindent, topsep=-\parskip}
\newcommand{\tabitem}{\indent~~\llap{\textbullet}~~}

%---LINKS---
\usepackage{hyperref}
\hypersetup{
	colorlinks=true,
	citecolor=blue,
	linkcolor=blue,
	urlcolor=cyan,
}

%---EMOJI---
\usepackage{emoji}