\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{craftofficial}[CraftLaw for the CraftFuze Legal Project, Official Look]

\LoadClass[a4paper,8pt,oneside]{article}
\RequirePackage[left=2cm, right=2cm, top=2cm]{geometry}
\RequirePackage[utf8]{inputenc}
\RequirePackage[english]{babel}
\RequirePackage{blindtext}
\RequirePackage{titling}
\RequirePackage{fancyhdr}
\RequirePackage{tikz}
\RequirePackage[shortlabels]{enumitem}
\RequirePackage{needspace}
\RequirePackage[document]{ragged2e}

% Margins
%\RequirePackage[inner=5cm,outer=1.5cm,bottom=3cm,marginparsep=6mm]{geometry}
%\setlength{\marginparwidth}{2.8cm}
%\reversemarginpar

% Indent
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
\newcommand{\articleindent}{\leavevmode{\parindent=3em\indent}}
\setlist[enumerate,1]{leftmargin=1.5em,topsep=-1ex,itemsep=-1ex,partopsep=1ex,parsep=1ex,style=sameline}
\setlist[enumerate,2]{leftmargin=1.5em,topsep=-1ex,itemsep=-1ex,partopsep=1ex,parsep=1ex,style=sameline}
\setenumerate[0]{label=\arabic*.}

% New title layout
\newcommand{\settitle}[1]{%
	\noindent%
	\begin{figure}
		\centering
		\includegraphics[width=20mm]{crown}
	\end{figure}
	\centering%
	\textbf{\large\fontfamily{phv}\fontseries{b}%
        \selectfont #1}%
    \medskip%
}

\newcommand{\setheader}[1]{
	\fancyhead[LE,LO]{#1}%
	\fancyhead[CE,CO]{Official Journal of the Crafty Table}%
}

% Introduction
\newcommand{\introduction}[1]{%
	\vbox{%
		\begin{flushleft}
			\noindent{#1}%
		\end{flushleft}
	}%
}

% About Articles
\newcounter{BookCounter}
\newcounter{TitleCounter}[BookCounter]
\newcounter{ChapterCounter}[TitleCounter]
\newcounter{ParagraphCounter}[ChapterCounter]
\newcounter{SubParagraphCounter}[ParagraphCounter]
\newcounter{ArticleCounter}[BookCounter]
\newcounter{ArticleSubCounter}[ArticleCounter]
\newcommand{\book}[1]{%
	\newpage%
	\bigskip%
	\stepcounter{BookCounter}%
	\centering%
	\noindent{BOOK \Roman{BookCounter}}\newline\medskip%
	\textbf{#1}%
}
\renewcommand{\title}[1]{
	\bigskip%
	\stepcounter{TitleCounter}%
	\needspace{15\baselineskip}%
	\centering%
	\noindent{TITLE \Roman{TitleCounter}}\newline\medskip%
	\textbf{#1}%
}
\newcommand{\chapter}[1]{%
	\bigskip%
	\stepcounter{ChapterCounter}%
	\needspace{10\baselineskip}%
	\centering%
	\noindent{CHAPTER \Roman{ChapterCounter}}\newline\medskip%
	\textbf{#1}%
}
\renewcommand{\paragraph}[1]{%
	\bigskip%
	\stepcounter{ParagraphCounter}%
	\needspace{10\baselineskip}%
	\noindent{Paragraph §\arabic{ParagraphCounter}.\arabic{SubParagraphCounter}}\newline\medskip%
	\textbf{#1}%
}
\renewcommand{\subparagraph}[1]{%
	\bigskip%
	\stepcounter{SubParagraphCounter}%
	\needspace{10\baselineskip}%
	\noindent{Paragraph §\arabic{ParagraphCounter}.\arabic{SubParagraphCounter}}\newline\medskip%
	\textbf{#1}%
}
\newcommand{\article}[2]{%
	\bigskip%
	\stepcounter{ArticleCounter}%
	\needspace{5\baselineskip}%
	\centering%
	\ifnum\value{BookCounter}>0
		\textit{Article \arabic{BookCounter}:\arabic{ArticleCounter}}\newline%
	\else
		\textit{Article \arabic{ArticleCounter}}\newline%
	\fi
	\textbf{#1}\newline%
	\begin{flushleft}
		\par{#2}%
	\end{flushleft}
}
\newcommand{\subarticle}[2]{%
	\bigskip%
	\stepcounter{ArticleSubCounter}%
	\needspace{5\baselineskip}%
	\centering%
	\ifnum\value{BookCounter}>0
			\textit{Article \arabic{BookCounter}:\arabic{ArticleCounter}\alph{ArticleSubCounter}}\newline\medskip%
	\else
		\textit{Article \arabic{ArticleCounter}\alph{ArticleSubCounter}}\newline\medskip%
	\fi
	\textbf{#1}\newline\smallskip%
	\begin{flushleft}
		\par{#2}%
	\end{flushleft}
}
\newcommand{\signature}[1]{
	\bigskip%
	\needspace{5\baselineskip}%
	\begin{flushleft}
		\textit{SIGNED, the #1:}\newline%
		\textbf{Her Royal Majesty Queen Rachel the First}
		\medskip%
		\begin{figure}[h]
			\includegraphics[width=60mm]{rachel_signature}
		\end{figure}
	\end{flushleft}
}

% Header and footer
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[LE,RO]{\thepage}