%%%%%%%%
% Théorèmes
%%%%%%%%%%%%%%

\newtcbtheorem{tcbtheorem}{Théorème}
{%
	label={thm:\thechapter.\thetcbcounter},
	enhanced,%
	breakable,
	separator sign none,
	skin = enhancedlast jigsaw,
	attach boxed title to top left = 
	{%
		xshift = -4mm,%
		yshift = -0.5mm
	},
	fonttitle = \fontfamily{lmss}\selectfont\bfseries,
	coltitle = theoremtitle,
	varwidth boxed title = 0.7\linewidth,
	colbacktitle = theorem,
	colframe = theorem,
	interior style = {%
		top color = theorem!10!white,
		bottom color = theorem!30!white
	},
	boxed title style = {%
		empty,arc = 0pt,
		outer arc = 0pt,
		boxrule = 0pt
	},
	underlay boxed title = {%
		\fill[theorem] (title.north west) 
					-- (title.north east)
					-- +(\tcboxedtitleheight-1mm,-\tcboxedtitleheight+1mm)
					-- ([xshift=4mm,yshift=0.5mm]frame.north east) 
					-- +(0mm,-1mm)-- (title.south west) 
					-- cycle;
		\fill[theorem!45!white!50!black] ([yshift=-0.5mm]frame.north west)	-- +(-0.4,0) -- +(0,-0.3) -- cycle;
		\fill[theorem!45!white!50!black] ([yshift=-0.5mm]frame.north east)-- +(0,-0.3) -- +(0.4,0) -- cycle;  
	}
}
{th}

\newenvironment{thm}[1][]
{%
	\itemclass{theorem}
	\arrayrulecolor{theorem}
	\begin{tcbtheorem}{\if\@empty#1\else(#1)\fi}{}
}
{%
	\end{tcbtheorem}
	\itemclass{black}
}

%%%%%%%%
% Définitions
%%%%%%%%%%%%%%%%

\newtcbtheorem{tcbdef}{Définition}
{%
	enhanced,
	breakable,
	separator sign none,
	before skip = 2mm,
	after skip = 2mm,
	colback = defin!30,
	colframe = defin,
	boxrule = 0.2mm,
	attach boxed title to top left = { xshift = 1cm , yshift*=1mm-\tcboxedtitleheight },
	varwidth boxed title*=-3cm,
	boxed title style = {
		frame code = {
			\path[fill = defin!30!black] ([yshift=-1mm,xshift=-1mm]frame.north west)
				arc[start angle=0,end angle=180,radius=1mm] ([yshift=-1mm,xshift=1mm]frame.north east)
				arc[start angle=180,end angle=0,radius=1mm];
			\path[left color=defin!60!black,right color=defin!60!black,middle color=defin!80!black] ([xshift=-2mm]frame.north west) 
				-- ([xshift=2mm]frame.north east)[rounded corners=1mm]
				-- ([xshift=1mm,yshift=-1mm]frame.north east)
				-- (frame.south east) -- (frame.south west)-- ([xshift=-1mm,yshift=-1mm]frame.north west)[sharp corners]-- cycle;
		},
		interior engine=empty
	},
	fonttitle = \fontfamily{lmss}\selectfont\bfseries
}
{def}

\newenvironment{defin}[1][]
{%
	\itemclass{defin}
	\arrayrulecolor{defin}
	\begin{tcbdef}{\if\@empty#1\else(#1)\fi}{}
}
{%
	\end{tcbdef}
	\itemclass{black}
}

%%%%%%%%
% Propriétés
%%%%%%%%%%%%%%%

\newtcbtheorem{tcbprop}{Propriété}
{%
	enhanced jigsaw,
	breakable,
	separator sign none,
	label={prop:\thechapter.\thetcbcounter},
	fonttitle = \fontfamily{lmss}\selectfont\bfseries,
	opacityback = 0.5,
	colback = prop,
	frame style = {left color=prop,right color=prop!50},
}
{prop}

\newenvironment{prop}[1][]
{%
	\itemclass{prop}
	\arrayrulecolor{prop}
	\begin{tcbprop}{\if\@empty#1\else(#1)\fi}{#1}
}
{%
	\end{tcbprop}
	\itemclass{black}
}

%%%%%%%
% Exemple
%%%%%%%%%%%%%%

\newtcbtheorem{tcbexemple}{Exemple}
{%
	enhanced,
	label={exemple:\thechapter.\thetcbcounter},
	breakable,
	separator sign none,
	before skip=2mm,
	after skip=3mm,
	boxrule=0.4pt,
	left=5mm,
	right=2mm,
	top=1mm,
	bottom=1mm,
	colback = exemple!20,
	colframe = exemple,
	fonttitle = \fontfamily{lmss}\selectfont\bfseries,
	sharp corners,rounded corners=southeast,arc is angular,arc=3mm,
	drop fuzzy shadow,
	underlay={
		\begin{tcbclipinterior}
			\draw[help lines,step=5mm,exemple,shift={(interior.north west)},opacity=0.15] (interior.south west) grid (interior.north east);
		\end{tcbclipinterior},
		\path[fill=exemple,draw=exemple,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
	}
}
{exemple}

\newenvironment{exemple}[1][]
{%
	\itemclass{exemple}
	\arrayrulecolor{exemple}
	\begin{tcbexemple}{\if\@empty#1\else(#1)\fi}{#1}
}
{%
	\end{tcbexemple}
	\itemclass{black}
}


%%%%%%%
% Remarque
%%%%%%%%%%%%%%

\newtcbtheorem{tcbrem}{Remarque}
{%
	enhanced,
	breakable,
	label={rem:\thetcbcounter},
	separator sign none,
	before skip=2mm,
	after skip=3mm,
	boxrule=0.4pt,
	left=5mm,
	right=2mm,
	top=1mm,
	bottom=1mm,
	colback = yellow!20,
	colframe = rem,
	fonttitle = \fontfamily{lmss}\selectfont\bfseries,
	sharp corners,rounded corners=southeast,arc is angular,arc=3mm,
	drop fuzzy shadow,
	underlay={
		\begin{tcbclipinterior}
			\draw[help lines,step=5mm,rem,shift={(interior.north west)},opacity=0.15] (interior.south west) grid (interior.north east);
		\end{tcbclipinterior},
		\path[fill=rem,draw=rem,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
	}
}
{rem}

\newenvironment{rem}[1][]
{%
	\itemclass{rem}
	\arrayrulecolor{rem}
	\begin{tcbrem}{\if\@empty#1\else(#1)\fi}{}
}
{%
	\end{tcbrem}
	\itemclass{black}
}

%%%%%%%
% Attention
%%%%%%%%%%%%%%

\newtcbtheorem{tcbwarning}{Attention}
{%
	enhanced,	
	breakable,
	separator sign none,
	before skip = 2mm,
	after skip = 3mm,
	boxrule = 0.4pt,
	left = 12mm,
	right = 2mm,
	top = 1mm,
	bottom = 1mm,
	colback = warning!20,
	colframe = warning,
	sharp corners,
	rounded corners = southeast,
	arc is angular,
	arc=3mm,
	fonttitle = \fontfamily{lmss}\selectfont\bfseries,
	underlay={%
		\path[fill=warning!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
		\path[draw=warning,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
		\path[fill=warning,draw=none] (interior.south west) rectangle node[white]{\Huge\bfseries \warning} ([xshift=11mm]interior.north west);
    },
	drop fuzzy shadow
}
{warning}

\newenvironment{attention}[1][]
{%
	\itemclass{warning}
	\arrayrulecolor{warning}
	\begin{tcbwarning}{\if\@empty#1\else(#1)\fi}{}
}
{%
	\end{tcbwarning}
	\itemclass{black}
}

%%%%%%%%%
% Demo
%%%%%%%%%%%%%

\newtcbtheorem{tcbdemo}{Démonstration}
{%
	enhanced,
	breakable,
	separator sign none,
	before skip = 2mm,
	after skip = 3mm,
	boxrule = 0.4pt,
	left = 5mm,
	right = 2mm,
	top = 1mm,
	bottom = 1mm,
	colback = demo!20,
	colframe = demo,
	fonttitle = \fontfamily{lmss}\selectfont\bfseries,
	sharp corners,rounded corners=southeast,arc is angular,arc=3mm,
	drop fuzzy shadow,
	underlay={
		\begin{tcbclipinterior}
			\draw[help lines,step=5mm,demo,shift={(interior.north west)},opacity=0.15] (interior.south west) grid (interior.north east);
		\end{tcbclipinterior},
		\path[fill=demo,draw=demo,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
	}
}
{demo}

\newenvironment{demo}[1][]
{%
	\itemclass{demo}
	\arrayrulecolor{demo}
	\begin{tcbdemo}{\if\@empty#1\else(#1)\fi}{}
}
{%
	\end{tcbdemo}
	\itemclass{black}
}