using System;
using Gtk;

class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        Console.WriteLine("argv = [" + string.Join(" | ", args) + "]");

        // --- flags first, before any UI construction ---
        AppMode.Legacy = Array.IndexOf(args, "--legacy") >= 0;
        // ... existing --debug handling stays here too ...
        Console.WriteLine("AppMode.Legacy = " + AppMode.Legacy +
                          "  cases=" + AppMode.CasesCsv);

        Application.Init();

        var app = new MainWindow();
        app.ShowAll();

        // Tell the kiosk the window is drawn, so the splash video can close
        GLib.Timeout.Add(300, () =>
        {
            try { System.IO.File.WriteAllText("/tmp/kiosk-ready", ""); } catch { }
            return false;
        });

        Application.Run();
    }
}
