import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import { App } from '@/presentation/App'

// OS のライト / ダーク設定に従う (docs/web/spec.md §3.4)。HeroUI は html の .dark クラスを見る。
const darkScheme = window.matchMedia('(prefers-color-scheme: dark)')
const applyColorScheme = () => document.documentElement.classList.toggle('dark', darkScheme.matches)
applyColorScheme()
darkScheme.addEventListener('change', applyColorScheme)

const root = document.getElementById('root')
if (root === null) throw new Error('index.html に #root がありません')

createRoot(root).render(
  <StrictMode>
    <App />
  </StrictMode>,
)
