import { useEffect, useState, type ReactNode } from "react";

export function Logo({ className = "" }: { className?: string }) {
  return (
    <span className={`inline-flex flex-col leading-none ${className}`}>
      <span className="font-black italic tracking-tight">LOTUS<span className="text-gold">365</span></span>
      <span className="text-[0.32em] font-semibold tracking-[0.2em] opacity-70">MOST TRUSTED SINCE 2015</span>
    </span>
  );
}

/** Lotus365 splash with yellow progress bar shown before each game opens. */
export function GameLoader({ children, ms = 1300 }: { children: ReactNode; ms?: number }) {
  const [done, setDone] = useState(false);
  useEffect(() => { const t = setTimeout(() => setDone(true), ms); return () => clearTimeout(t); }, [ms]);
  if (done) return <>{children}</>;
  return (
    <div className="app-frame flex flex-col items-center justify-center gap-4 bg-ink">
      <Logo className="text-3xl text-foreground" />
      <div className="h-1.5 w-56 overflow-hidden rounded-full bg-ink-3">
        <div className="h-full animate-loadbar rounded-full bg-gold" />
      </div>
      <p className="text-sm text-muted-foreground">Loading...</p>
    </div>
  );
}
