using Godot;
namespace Theriapolis.GodotHost.Scenes;
///
/// Character creation wizard shell. Mirrors src/app.jsx per
/// GODOT_PORTING_GUIDE.md §4: header + stepper + page (step + aside) +
/// nav bar. Owns the resource and dispatches
/// each step's content into the StepHost.
///
/// Default theme only at this layer — per guide §12 (build order),
/// the parchment Theme lands as a final pass once structural correctness
/// is verified. Until then, font/colour issues are clearly font/colour
/// issues, not layout issues.
///
public partial class Wizard : Control
{
[Signal] public delegate void BackToTitleEventHandler();
private static readonly string[] StepKeys =
{ "clade", "species", "class", "subclass", "background", "stats", "skills", "review" };
private static readonly string[] StepNames =
{ "Clade", "Species", "Calling", "Subclass", "History", "Abilities", "Skills", "Sign" };
public UI.CharacterDraft Character { get; private set; } = null!;
private UI.Widgets.CodexStepper _stepper = null!;
private Control _stepHost = null!;
private Label _folioLabel = null!;
private Label _validation = null!;
private Label _navProgress = null!;
private Button _backBtn = null!;
private Button _nextBtn = null!;
// Scroll preservation: snapshot scroll position when the draft changes
// (which fires before the active step's Refresh tears down + rebuilds
// child nodes), then restore on the next _Process frame so the user
// doesn't get punted to the top of the page when selecting a card.
private ScrollContainer? _scroll;
private int _savedScroll = -1;
private bool _scrollPending;
private int _step;
private Steps.IStep? _activeStep;
private static readonly System.Type?[] StepTypes =
{
typeof(Steps.StepClade), // 0 Clade
typeof(Steps.StepSpecies), // 1 Species
typeof(Steps.StepClass), // 2 Calling
typeof(Steps.StepSubclass), // 3 Subclass
typeof(Steps.StepBackground), // 4 History
typeof(Steps.StepStats), // 5 Abilities
typeof(Steps.StepSkills), // 6 Skills
null, // 7 Sign — M6.6
};
public override void _Ready()
{
Character = new UI.CharacterDraft();
_stepper = GetNode("%Stepper");
_stepHost = GetNode("%StepHost");
_folioLabel = GetNode