import { useId } from 'react';
import { FaceDrawing, facePoints } from '@/site/components/art/face-map';
import { depth, turn } from '@/site/components/art/kit';

/**
 * Hero drawing of a treatment that is applied to one place of the face
 * (`treatments.zone`): the face draws itself, then two fine lines cross at
 * the place and it lights up. "full-face" rings the whole face instead.
 *
 * Only for zones the drawing knows — check with `hasFacePoint` first. It
 * shows where, never a result.
 */
export function ZoneArt({ zone }: { zone: string }) {
    const glow = useId();
    const point = facePoints[zone];
    const { x, y } = point ?? { x: 200, y: 190 };

    return (
        <svg
            viewBox="0 20 400 500"
            aria-hidden="true"
            className="art size-full"
        >
            <defs>
                <radialGradient id={glow}>
                    <stop
                        offset="0"
                        stopColor="var(--accent)"
                        stopOpacity="0.6"
                    />
                    <stop
                        offset="1"
                        stopColor="var(--accent)"
                        stopOpacity="0"
                    />
                </radialGradient>
            </defs>

            {/* Corner marks of the frame */}
            <g data-depth="" style={depth(-1)}>
                <path
                    pathLength={1}
                    className="ln sk"
                    opacity="0.7"
                    d="M8 62V30h32M360 30h32v32M392 478v32h-32M40 510H8v-32"
                />
            </g>

            <g data-depth="" style={depth(1.5)}>
                <circle
                    cx={x}
                    cy={y}
                    r={point ? 84 : 170}
                    fill={`url(#${glow})`}
                    className="so"
                    style={turn(12)}
                />
                <g className="ln face-lines text-fg">
                    <FaceDrawing />
                </g>

                {point ? (
                    <>
                        {/* Two fine lines cross at the place */}
                        <path
                            className="ac so"
                            style={turn(12)}
                            opacity="0.75"
                            strokeDasharray="1 7"
                            d={`M44 ${y}H356M${x} 44V496`}
                        />
                        <g className="so" style={turn(16)}>
                            <circle
                                cx={x}
                                cy={y}
                                r="10"
                                className="ac box animate-pulse-ring"
                            />
                        </g>
                        <circle
                            cx={x}
                            cy={y}
                            r="16"
                            className="ac sf"
                            style={turn(14)}
                        />
                        <circle
                            cx={x}
                            cy={y}
                            r="5"
                            className="af sf"
                            style={turn(15)}
                        />
                    </>
                ) : (
                    <ellipse
                        cx="200"
                        cy="184"
                        rx="108"
                        ry="152"
                        className="ac so"
                        style={turn(14)}
                        strokeDasharray="2 7"
                    />
                )}
            </g>
        </svg>
    );
}
