/*
 * Dark mode overrides.
 *
 * Loaded AFTER tailwind.min.css. The vendored Tailwind v2.2.19 build ships no
 * dark: variants (no prefers-color-scheme, no .dark selectors), so every dark
 * rule is declared here instead. Only utilities actually present in the HTML
 * are overridden -- this list is exhaustive, verified by grep, not guessed.
 *
 * theme.js sets data-theme on <html> synchronously in <head>, before first
 * paint, so there is no flash and no flash-of-light.
 */

:root {
    color-scheme: light;
}

[data-theme="dark"] {
    color-scheme: dark;

    /* Surfaces */
    [class~="bg-gray-100"] { background-color: #111827; } /* page */
    [class~="bg-white"]   { background-color: #1f2937; } /* cards */
    /* matches Prism "tomorrow" code background so <pre> and <code> blend */
    [class~="bg-gray-50"] { background-color: #2d2d2d; }
    [class~="bg-gray-300"] { background-color: #374151; } /* progress track */
    [class~="bg-gray-600"] { background-color: #374151; } /* copy button */

    /* Text */
    [class~="text-gray-800"] { color: #f3f4f6; }
    [class~="text-gray-700"] { color: #e5e7eb; }
    [class~="text-gray-600"] { color: #d1d5db; }
    [class~="text-gray-500"] { color: #9ca3af; }
    [class~="text-gray-400"] { color: #6b7280; }

    /* Borders */
    [class~="border-gray-300"] { border-color: #4b5563; }

    /* Accents: lighten one step so they stay legible on dark surfaces */
    [class~="bg-blue-600"]   { background-color: #3b82f6; }
    [class~="bg-purple-600"] { background-color: #a855f7; }
    [class~="bg-green-600"]  { background-color: #22c55e; }
    [class~="bg-yellow-600"] { background-color: #eab308; }

    /* Hover states: reverse the direction so "hover" still reads as brighter */
    [class~="hover:bg-blue-700"]:hover   { background-color: #2563eb; }
    [class~="hover:bg-purple-700"]:hover { background-color: #9333ea; }
    [class~="hover:bg-green-700"]:hover  { background-color: #16a34a; }
    [class~="hover:bg-yellow-700"]:hover { background-color: #ca8a04; }
    [class~="hover:bg-gray-700"]:hover   { background-color: #4b5563; }

    /* Warning banner */
    [class~="bg-yellow-100"]    { background-color: #422006; }
    [class~="border-yellow-400"] { border-color: #a16207; }
    [class~="text-yellow-700"]  { color: #fde047; }

    /* Error banner */
    [class~="bg-red-100"]    { background-color: #450a0a; }
    [class~="border-red-400"] { border-color: #991b1b; }
    [class~="text-red-700"]  { color: #fca5a5; }

    /* Toasts + inline accent text */
    [class~="bg-red-500"]     { background-color: #dc2626; }
    [class~="bg-green-500"]   { background-color: #16a34a; }
    [class~="text-purple-600"] { color: #c084fc; }

    /* Inputs */
    [class~="border-gray-300"] { border-color: #4b5563; }
    input, textarea, select { background-color: #111827; color: #e5e7eb; }
    input::placeholder, textarea::placeholder { color: #6b7280; }
}

body {
    transition: background-color 0.15s ease, color 0.15s ease;
}

@media (prefers-reduced-motion: reduce) {
    body { transition: none; }
}
