I'm trying to define a document where I have different levels of it contained in TikZ boxes as shown below; the idea is that each box should get a color depending on the value of the counter (which is displayed inside the circle positioned on the top of each rectangle).
Here is an extract of my code:
documentclass[10pt]{book}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{engrec}
\usepackage{yfonts}
%\usepackage[a4paper, inner=1cm, width=19cm, top=1cm, bottom=2cm, marginpar=0pt, twoside, showframe]{geometry}
\usepackage[a4paper, inner=1cm, width=19cm, top=1cm, bottom=2cm, marginpar=0pt, twoside]{geometry}
\usepackage{xparse}
\usepackage{xcolor}
\usepackage{xspace}
\usepackage{ifthen}
\usepackage{environ}
\usepackage{tikz}
\usetikzlibrary{
positioning,
fit,
arrows,
arrows.meta,
intersections,
decorations,
backgrounds,
calc,
math,
through,
shapes,
shadows,
decorations.pathmorphing
}
\usepackage{lipsum}
\setmainfont{Tisa OT}
\setsansfont{TeX Gyre Heros Cn}
\setdefaultlanguage{italian}
\definecolor{conceptcolor}{RGB}{160,44,90}
\definecolor{subconceptcolora}{RGB}{255,102,0}
\definecolor{subconceptcolorb}{RGB}{95,95,211}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% CONCEPT BOX %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{conceptctr}
\renewcommand{\theconceptctr}{\Alph{conceptctr}}
\tikzstyle{conceptboxtitlesty} =
[
circle,%
draw = conceptcolor,%
line width = 0.7mm,%
node font = \Huge\bfseries\sffamily,%
text = conceptcolor,%
fill = white,%
inner sep = 3pt%
]
\tikzstyle{conceptboxsty} =
[
rectangle,
rounded corners = 10pt,%
draw = conceptcolor,
line width = 0.7mm,%
node font = \small
]
%
\NewEnviron{conceptbox}{
\stepcounter{conceptctr}
\begin{tikzpicture}
\node[conceptboxsty, anchor=north west](concepttext) at (-6,0) {
\begin{minipage}{18cm}
\vspace{20pt}
\BODY
\end{minipage}
\vspace{20pt}
};
\node[conceptboxtitlesty, xshift = 2cm](conecepttitle) at (concepttext.north west){\theconceptctr};
\end{tikzpicture}
}[\newline]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% SUBCONCEPT BOX %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{subconceptctr}[conceptctr]
\renewcommand{\thesubconceptctr}{\arabic{subconceptctr}}
\newcommand{\subconceptcolor}[1]
{%
\ifthenelse{#1 = 1}%
{subconceptcolora}%
{%
\ifthenelse{#1 = 2}%
{subconceptcolorb}%
{}%% &c.
}%
}
\tikzstyle{subconcepttitlesty} =
[
circle,%
draw = \currentcolor,%
line width = 0.5mm,%
node font = \LARGE\bfseries\sffamily,%
text = \currentcolor,%
fill = white,%
inner sep = 3pt%
]
\tikzstyle{subconceptboxsty} =
[
rectangle,
rounded corners = 10pt,%
draw = \currentcolor,
line width = 0.5mm,%
node font = \small%
]
%
\newcommand{\currentcolor}{}
\NewEnviron{subconceptbox}{
\stepcounter{subconceptctr}
\renewcommand{\currentcolor}{\subconceptcolor{\value{subconceptctr}}}
\begin{tikzpicture}
\node[subconceptboxsty,
anchor=north west,
](subconcepttext) at (0,-1) {
\begin{minipage}{17.5cm}
\vspace{20pt}
\BODY
\vspace{10pt}
\end{minipage}
};%
\node[subconcepttitlesty,
anchor = center,
xshift = 2cm, yshift = 0cm](subconecepttitle) at (subconcepttext.north west){\thesubconceptctr};%
\end{tikzpicture}
}[\newline]
\begin{document}
\begin{conceptbox}
Il C. è \textsl{similitudo rei in mente expressa} (cioè la rappresentazione di una cosa espressa nella mente). Infatti, essa è il prodotto dell' \textsl{apprensione}, ovvero della prima operazione della mente che astrae, mediante i sensi, una rappresentazione universale di ciò che si osserva fuori di noi.\\\newline
\begin{subconceptbox}
Il C. ci rimanda immediatamente alla realtà e non allo stesso C. Esso significa ciò che la cosa è secondo un aspetto determinato (i.e., il concetto di "relazione" ci porta a capire cos' è una relazione; quello di "tartaruga", a capire cos' è una tartaruga). Ciò non implica una totale comprensione della natura, né che siamo capaci di definirla, ma senz' altro comporta una certa intellezione.
\end{subconceptbox}
\begin{subconceptbox}
Ciò che caratterizza il C. è la sua \textit{\textbf{Universalità}}: quanto è espresso dal C. vale per tutti e per sempre, grazie al fatto che considera tutte le note essenziali che tutti gl' individui devono possedere. Grazie all' Universalità abbiamo i seguenti risultati:\par%
\end{subconceptbox}
\end{conceptbox}
\end{document}
I had a look at this question:
How to pass parameters to \tikzstyle?; and these If-then-else inside TikZ graph?, If-then-else inside TikZ graph?.
So my understanding is that the \ifthenelse command is not recognized by TikZ; for this reason I've tried to pass the value of the conditional to a variable (\currentcolor) which, I thought, would have been initialized before calling the tikzpicture environment.
Still, what I get is a bunch (166) errors during compilation.
Any suggestion? Thank you for you support.

\begin{document}...\end{document}block showing how you want to use the code. That will spark more interest. – sgmoye Feb 28 '20 at 12:59So
– Guidone Feb 28 '20 at 14:01\ifthen, for some to-me-unknown reason, is called within TikZ (?)