/**
 * 플랫폼·능력 감지 헬퍼 (수정사항-019)
 *
 * iOS Safari는 요소 전체화면(Fullscreen API)과 screen.orientation.lock()을 지원하지 않아,
 * 이를 시도하면 검사 중 반복 호출 시 Safari가 프리즈되어 백색 화면이 되는 문제가 있다.
 * → iOS에서는 해당 API를 아예 시도하지 않고, 브라우저 크롬(주소창·탭)이 보인 상태로 동작한다.
 */

/** iOS(iPhone/iPad/iPod) 여부 — iPadOS는 MacIntel + 터치로 판별 */
export function isIOS(): boolean {
  return (
    /iP(hone|ad|od)/.test(navigator.userAgent) ||
    (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)
  );
}

/** 요소 전체화면(Element Fullscreen) 가능 여부 — iOS는 비디오 한정 지원이라 제외 */
export function supportsElementFullscreen(): boolean {
  return (
    !isIOS() &&
    typeof document.documentElement?.requestFullscreen === 'function'
  );
}

/** OS 레벨 가로잠금(screen.orientation.lock) 가능 여부 — iOS는 미지원 */
export function supportsOrientationLock(): boolean {
  return (
    !isIOS() &&
    typeof (screen as any).orientation?.lock === 'function'
  );
}
