/// Shared shell for Wolf3D-style menu screens.
library;

import 'package:flutter/material.dart';
import 'package:wolf_3d_dart/wolf_3d_data_types.dart';
import 'package:wolf_3d_renderer/wolf_3d_asset_painter.dart';

/// Provides a common menu layout with panel framing and optional bottom art.
class WolfMenuShell extends StatelessWidget {
  /// Full-screen background color behind the panel.
  final Color backgroundColor;

  /// Solid panel fill used for the menu content area.
  final Color panelColor;

  /// Optional heading shown above the panel (text or image).
  final Widget? header;

  /// Primary menu content rendered inside the panel.
  final Widget panelChild;

  /// Optional centered VGA image anchored near the bottom of the screen.
  final VgaImage? bottomSprite;

  /// Width of the menu panel.
  final double panelWidth;

  /// Padding applied around [panelChild] inside the panel.
  final EdgeInsets panelPadding;

  /// Scale factor for [bottomSprite].
  final double bottomSpriteScale;

  /// Distance from the bottom edge for [bottomSprite].
  final double bottomOffset;

  /// Vertical spacing between [header] and the panel.
  final double headerSpacing;

  const WolfMenuShell({
    super.key,
    required this.backgroundColor,
    required this.panelColor,
    required this.panelChild,
    this.header,
    this.bottomSprite,
    this.panelWidth = 520,
    this.panelPadding = const EdgeInsets.symmetric(
      horizontal: 20,
      vertical: 16,
    ),
    this.bottomSpriteScale = 3,
    this.bottomOffset = 20,
    this.headerSpacing = 14,
  });

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Positioned.fill(
          child: ColoredBox(color: backgroundColor),
        ),
        Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              ?header,
              if (header != null) SizedBox(height: headerSpacing),
              Container(
                width: panelWidth,
                padding: panelPadding,
                color: panelColor,
                child: panelChild,
              ),
            ],
          ),
        ),
        if (bottomSprite != null)
          Positioned(
            left: 0,
            right: 0,
            bottom: bottomOffset,
            child: Center(
              child: SizedBox(
                width: bottomSprite!.width * bottomSpriteScale,
                height: bottomSprite!.height * bottomSpriteScale,
                child: WolfAssetPainter.vga(bottomSprite),
              ),
            ),
          ),
      ],
    );
  }
}
