"use client";

import { useState, useEffect } from "react";
import { generateQueens, QueensPuzzle } from "@/lib/generators/queens";
import { todayISO } from "@/lib/rng";
import QueensBoard from "@/components/QueensBoard";
import DailyPageShell from "@/components/DailyPageShell";

export default function QueensPage() {
  const date = todayISO();
  const [puzzle, setPuzzle] = useState<QueensPuzzle | null>(null);
  useEffect(() => { setPuzzle(generateQueens(date)); }, [date]);

  const dateLabel = new Date(date + "T00:00:00").toLocaleDateString("fr-FR", {
    weekday: "long", day: "numeric", month: "long",
  });

  return (
    <DailyPageShell game="queens" date={date} dateLabel={dateLabel}>
      {puzzle ? (
        <QueensBoard puzzle={puzzle} date={date} />
      ) : (
        <div className="py-20 text-gray-300 text-sm">Chargement…</div>
      )}
    </DailyPageShell>
  );
}
