import { useEffect } from "react";
import type { ReadingSettings } from "@/types/reader";

export function useReaderOrientationCss(orientationLock: ReadingSettings["orientation_lock"]): void {
  useEffect(() => {
    const root = document.documentElement;
    if (orientationLock !== "auto") {
      root.style.setProperty(
        "--reader-orientation",
        orientationLock === "portrait" ? "portrait" : "landscape",
      );
    } else {
      root.style.removeProperty("--reader-orientation");
    }
  }, [orientationLock]);
}
