import 'package:flutter/material.dart';

class YogibookBackground extends StatelessWidget {
  final Widget child;

  const YogibookBackground({super.key, required this.child});

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        // --- SFONDO (gradient)
        Container(
          decoration: const BoxDecoration(
            gradient: LinearGradient(
              begin: Alignment.topLeft,
              end: Alignment.bottomRight,
              colors: [Color(0xFFF4F6FA), Color(0xFFEFF7F3), Color(0xFFF4F6FA)],
            ),
          ),
        ),

        // --- BOLLE decorative
        const _BgBlob(color: Color(0x3310B981), size: 280, top: -70, left: -90),
        const _BgBlob(
          color: Color(0x22F59E0B),
          size: 230,
          bottom: 80,
          right: -70,
        ),
        const _BgBlob(
          color: Color(0x227C3AED),
          size: 190,
          bottom: -55,
          left: 35,
        ),

        // contenuto pagina
        child,
      ],
    );
  }
}

class _BgBlob extends StatelessWidget {
  final Color color;
  final double size;
  final double? top;
  final double? left;
  final double? right;
  final double? bottom;

  const _BgBlob({
    required this.color,
    required this.size,
    this.top,
    this.left,
    this.right,
    this.bottom,
  });

  @override
  Widget build(BuildContext context) {
    return Positioned(
      top: top,
      left: left,
      right: right,
      bottom: bottom,
      child: IgnorePointer(
        child: Container(
          width: size,
          height: size,
          decoration: BoxDecoration(
            color: color,
            shape: BoxShape.circle,
            boxShadow: [
              BoxShadow(
                blurRadius: 70,
                color: color,
                offset: const Offset(0, 18),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
