/** Enter browser fullscreen (must run inside a user-gesture handler, e.g. link click). */
export function requestViewerFullscreen(): void {
  if (document.fullscreenElement) return;
  void document.documentElement.requestFullscreen().catch(() => {});
}

export function exitViewerFullscreen(): void {
  if (document.fullscreenElement !== document.documentElement) return;
  void document.exitFullscreen().catch(() => {});
}

export function toggleViewerFullscreen(): void {
  if (document.fullscreenElement) {
    exitViewerFullscreen();
  } else {
    requestViewerFullscreen();
  }
}

export function isViewerFullscreen(): boolean {
  return document.fullscreenElement === document.documentElement;
}
