/**
 * App entry.
 *
 * `next-themes` is configured with `attribute="data-theme"` because that is
 * what `tailwind.config.js` darkMode and every `:root[data-theme='dark']` block
 * in `index.css` key off. Switch it to the default `class` and the site
 * compiles, runs, and is stuck in light mode forever with no error anywhere.
 */

import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { ThemeProvider } from 'next-themes';
import { RouterProvider } from 'react-router-dom';
import { router } from '@/router';
import './index.css';

const container = document.getElementById('root');
if (!container) {
  throw new Error('No #root element — index.html and main.tsx disagree.');
}

createRoot(container).render(
  <StrictMode>
    <ThemeProvider
      attribute="data-theme"
      defaultTheme="system"
      enableSystem
      /* Without this, switching theme animates every colour on the page at once
         because half the site has a `transition-colors` on it. */
      disableTransitionOnChange
    >
      <RouterProvider router={router} />
    </ThemeProvider>
  </StrictMode>,
);
