"use client";

import { useEffect } from "react";

/**
 * Sets <html lang> for a landing page in another language. The website has one root
 * layout (lang="en") that can't see the page's URL; hreflang carries the SEO signal.
 * `dir` is left alone so the header and footer keep the current (left-to-right) design;
 * HomePage sets dir="rtl" on <main> for RTL languages instead.
 */
export function DocumentLang({ lang }: { lang: string }) {
  useEffect(() => {
    const html = document.documentElement;
    const before = html.lang;
    html.lang = lang;
    return () => {
      html.lang = before;
    };
  }, [lang]);
  return null;
}
