
%  ▄▄·       ▄• ▄▌ ▐ ▄ ▄▄▄▄▄▄▄▄ .▄▄▄  
% ▐█ ▌▪ ▄█▀▄ █▪██▌•█▌▐█•██  ▀▄.▀·▀▄ █·
% ██ ▄▄▐█▌.▐▌█▌▐█▌▐█▐▐▌ ▐█.▪▐▀▀▪▄▐▀▀▄ 
% ▐███▌▐█▌.▐▌▐█▄█▌██▐█▌ ▐█▌·▐█▄▄▌▐█•█▌
% ·▀▀▀  ▀█▄▀▪ ▀▀▀ ▀▀ █▪ ▀▀▀  ▀▀▀ .▀  ▀

% tcolorbox and other stylistic elements (i.e. inline versions of them) that have counters
\newcounter{lemmas}
\newcounter{definitions}
\newcounter{corollaries}
\newcounter{theorems}
\newcounter{axioms}
\newcounter{examples}
\newcounter{facts}
\newcounter{propositions}
\newcounter{formulas}
\newcounter{all}

\newcommand{\definitions}{definitions}
\newcommand{\useSubsection}{\ifnum\value{numberSubsections}>0{\arabic{subsection}.}\else{}\fi}
\newcommand{\useSubsubsection}{\ifnum\value{numberSubsections}>1{\arabic{subsubsection}.}\else{}\fi}
\newcommand{\usenumberArabic}[1]{\ifnum\value{numberingConfig}<4{\arabic{section}.\useSubsection\useSubsubsection\ifnum\value{numberingConfig}<3{\ifnum\value{numberingConfig}<2{\arabic{#1}\stepcounter{#1}}\else{
\ifx#1\definitions
    \arabic{#1}\stepcounter{#1}
\else
    \arabic{all}\stepcounter{all}
\fi}\fi}\else{\arabic{all}\stepcounter{all}}\fi}\else{}\fi}


% Reset definition, lemma, etc counters, add a new page
\newcommand{\newsection}{
    \newpage
    \newsectionNoPB
}

% Reset definitions, lemma, etc counters, do not add new page
\newcommand{\newsectionNoPB}{
    \setcounter{lemmas}{1}
    \setcounter{definitions}{1}
    \setcounter{corollaries}{1}
    \setcounter{theorems}{1}
    \setcounter{axioms}{1}
    \setcounter{examples}{1}
    \setcounter{facts}{1}
    \setcounter{propositions}{1}
    \setcounter{formulas}{1}
    \setcounter{all}{1}
}
\newsectionNoPB


% Definitions
\newtcolorbox{definition}[2][]{mainboxstyle,colback=blue!5!white,colframe=blue!75!black,colbacktitle=blue!75!black,title={\large #2},overlay={\node[overlaystyle,draw=blue!75!black,fill=blue!75!black] at (frame.north east) {\large Definition \usenumberArabic{definitions}};},#1}

% Theorems
\newtcolorbox{theorem}[2][]{mainboxstyle,colback=ForestGreen!5!white,colframe=ForestGreen!75!black,colbacktitle=ForestGreen!75!black,title={\large #2},
overlay={\node[overlaystyle,draw=ForestGreen!75!black,fill=ForestGreen!75!black] at (frame.north east) {\large Theorem \usenumberArabic{theorems}};},#1}

% Lemmas
\newtcolorbox{lemma}[2][]{mainboxstyle,colback=Aquamarine!5!white,colframe=Aquamarine!75!black,colbacktitle=Aquamarine!75!black,title={\large #2},
overlay={\node[overlaystyle,draw=Aquamarine!75!black,fill=Aquamarine!75!black] at (frame.north east) {\large Lemma \usenumberArabic{lemmas}};},#1}

% Corollaries
\newtcolorbox{corollary}[2][]{mainboxstyle,colback=teal!5!white,colframe=teal!75!black,colbacktitle=teal!75!black,title={\large #2},
overlay={\node[overlaystyle,draw=teal!75!black,fill=teal!75!black] at (frame.north east) {\large \translate{Corollary}{Korollar} \usenumberArabic{corollaries}};},#1}

% Axioms
\newtcolorbox{axiom}[2][]{mainboxstyle,colback=JungleGreen!5!white,colframe=JungleGreen!75!black,colbacktitle=JungleGreen!75!black,title={\large #2},
overlay={\node[overlaystyle,draw=JungleGreen!75!black,fill=JungleGreen!75!black] at (frame.north east) {\large Axiom \usenumberArabic{axioms}};},#1}

% Facts
\newtcolorbox{fact}[2][]{mainboxstyle,colback=SeaGreen!5!white,colframe=SeaGreen!75!black,colbacktitle=SeaGreen!75!black,title={\large #2},
overlay={\node[overlaystyle,draw=SeaGreen!75!black,fill=SeaGreen!75!black] at (frame.north east) {\large \translate{Fact}{Fakt} \usenumberArabic{facts}};},#1}

% Propositions
\newtcolorbox{proposition}[2][]{mainboxstyle,colback=Cyan!5!white,colframe=Cyan!75!black,colbacktitle=Cyan!75!black,title={\large #2},
overlay={\node[overlaystyle,draw=Cyan!75!black,fill=Cyan!75!black] at (frame.north east) {\large \translate{Proposition}{Satz} \usenumberArabic{propositions}};},#1}

% Examples
\newtcolorbox{example}[2][]{mainboxstyle,colback=gray!5!white,colframe=gray!75!black,colbacktitle=gray!75!black,title={\large #2},
overlay={\node[overlaystyle,draw=gray!75!black,fill=gray!75!black] at (frame.north east) {\large \translate{Example}{Beispiel} \usenumberArabic{examples}};},#1}

% Formula
\newtcolorbox{formula}[2][]{mainboxstyle,colback=red!5!white,colframe=red!75!black,colbacktitle=red!75!black,title={\large #2},
overlay={\node[overlaystyle,draw=red!75!black,fill=red!75!black] at (frame.north east) {\large \translate{Formula}{Formel} \usenumberArabic{formulas}};},#1}

% Inline environments (inline)
\newcommand{\inlineex}{\textbf{\translate{Example}{Beispiel} \usenumberArabic{examples}:}}
\newcommand{\inlinedef}{\bg{blue}{Definition \usenumberArabic{definitions}:}}
\newcommand{\inlineformula}{\bg{red}{\translate{Formula}{Formel} \usenumberArabic{formulas}:}}
\newcommand{\inlinelemma}{\bg{Aquamarine}{Lemma \usenumberArabic{lemmas}:}}
\newcommand{\inlinetheorem}{\bg{ForestGreen}{Theorem \usenumberArabic{theorems}:}}
\newcommand{\inlineaxiom}{\bg{JungleGreen}{Axiom \usenumberArabic{axioms}:}}
\newcommand{\inlinecorollary}{\bg{teal}{\translate{Corollary}{Korollar} \usenumberArabic{corollaries}:}}
\newcommand{\inlinefact}{\bg{SeaGreen}{\translate{Fact}{Fakt} \usenumberArabic{facts}:}}
\newcommand{\inlineproposition}{\bg{Cyan}{\translate{Proposition}{Satz} \usenumberArabic{propositions}:}}
\newcommand{\inlineproof}{\bg{magenta}{\translate{Proof}{Beweis}:}}

% Enhanced inline environments
\newcommand{\compactexample}[1]{\bg{gray}{\translate{Example}{Beispiel} \usenumberArabic{examples}:} \textit{#1}}
\newcommand{\compactdefinition}[1]{\bg{blue}{Definition \usenumberArabic{definitions}:} \textit{#1}}
\newcommand{\compactformula}[1]{\bg{red}{\translate{Formula}{Formel} \usenumberArabic{formulas}:} \textit{#1}}
\newcommand{\compactlemma}[1]{\bg{Aquamarine}{Lemma \usenumberArabic{lemmas}:} \textit{#1}}
\newcommand{\compacttheorem}[1]{\bg{ForestGreen}{Theorem \usenumberArabic{theorems}:} \textit{#1}}
\newcommand{\compactaxiom}[1]{\bg{JungleGreen}{Axiom \usenumberArabic{axioms}:} \textit{#1}}
\newcommand{\compactcorollary}[1]{\bg{teal}{\translate{Corollary}{Korollar} \usenumberArabic{corollaries}:} \textit{#1}}
\newcommand{\compactfact}[1]{\bg{SeaGreen}{\translate{Fact}{Fakt} \usenumberArabic{facts}:} \textit{#1}}
\newcommand{\compactproposition}[1]{\bg{Cyan}{\translate{Proposition}{Satz} \usenumberArabic{propositions}:} \textit{#1}}
\newcommand{\compactproof}[1]{\bg{magenta}{\translate{Proof}{Beweis}: \textit{#1}}}

% short environments (abbreviated)
\newcommand{\shortex}{\textbf{\translate{Ex}{Bsp} \usenumberArabic{examples}:}}
\newcommand{\shortdef}{\bg{blue}{D \usenumberArabic{definitions}:}}
\newcommand{\short}{\bg{red}{F \usenumberArabic{formulas}:}}
\newcommand{\shortlemma}{\bg{Aquamarine}{L \usenumberArabic{lemmas}:}}
\newcommand{\shorttheorem}{\bg{ForestGreen}{T \usenumberArabic{theorems}:}}
\newcommand{\shortaxiom}{\bg{JungleGreen}{A \usenumberArabic{axioms}:}}
\newcommand{\shortcorollary}{\bg{teal}{\translate{C}{K} \usenumberArabic{corollaries}:}}
\newcommand{\shortfact}{\bg{SeaGreen}{F \usenumberArabic{facts}:}}
\newcommand{\shortproposition}{\bg{Cyan}{\translate{P}{S} \usenumberArabic{propositions}:}}
\newcommand{\shortproof}{\bg{magenta}{\translate{Proof}{Beweis}:}}
