[Tex/LaTex] Custom shadow – border effect with TikZ

shadowstikz-pgf

I would like to draw a box like this:

enter image description here

I'm especially interested in both

  1. how to draw a shadow that comes out from the sides only (not also top or bottom) and
  2. how to draw two shadows, the bigger left-right shadow and the smaller outline border one.

I've tried many approaches but it seems I'm completely off track here since I can't even draw the left-right bigger shadow, so I would appreciate if someone could explain me where to start here.

Clarifications. I think the picture is compose by 4 parts:

1) the background (uninteresting here)

2) the white rectangle

3) the rectangle borders-edges (what I previously referred as the smaller shadow) with a ridge like effect

4) the left and right shadows

I'm trying to draw parts 3 and 4.

Best Answer

Some ideas, lots of hardcoded magic numbers (found by trial and error):

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{backgrounds, calc, shadows, shadows.blur}

\newcommand\addcurlyshadow[2][]{
    % #1: Optional aditional tikz options
    % #2: Name of the node to "decorate"
    \begin{pgfonlayer}{background}
        \path[
           rounded corners=1pt,
           blur shadow={shadow xshift=0pt,
           shadow yshift=-0.3pt,
           shadow blur steps=6,
           shadow blur radius=.6pt}, #1]
            ($(#2.north west)+( 0.3pt,0)$) --
            ($(#2.south west)+( 0.3pt,0)$) --
            ($(#2.south east)+(-0.3pt,0)$) --
            ($(#2.north east)+(-0.3pt,0)$) --
        cycle;
        \path[rounded corners,
           blur shadow={shadow xshift=0pt,
           shadow yshift=0pt,
           shadow blur steps=8,
           shadow blur radius=2pt}, #1]
            ($(#2.north west)+(-1pt,-2pt)$) --
            ($(#2.south west)+(-1pt, 2pt)$) --
            ($(#2.south east)+( 1pt, 2pt)$) --
            ($(#2.north east)+( 1pt,-2pt)$) --
            cycle;
    \end{pgfonlayer}
}

\begin{document}
\begin{tikzpicture}
    \begin{pgfonlayer}{background}
    \fill[black!20] (-3,-1) rectangle (3,1);
    \end{pgfonlayer}
    \node[fill=white, rectangle, minimum width=3cm, minimum height=1cm]
       (example) {Test};
    \addcurlyshadow{example}
\end{tikzpicture}
\end{document}

Result:

Result