/* ============================================================
   Day / Night theme for the public home layout.
   The toggle in _HomeLayout.cshtml adds .dark to <html> and saves
   the choice to localStorage. These overrides keep the existing
   Tailwind utility markup readable in night mode.
   ============================================================ */

html.dark {
    color-scheme: dark;
}

html.dark body {
    background-color: #0B1120;
    color: #CBD5E1;
}

/* Headings and mono text inherit the body color unless overridden */
html.dark h1,
html.dark h2,
html.dark h3,
html.dark h4 {
    color: #E2E8F0;
}

/* Toggle icons ------------------------------------------------ */
.theme-icon-sun {
    display: none;
}

html.dark .theme-icon-moon {
    display: none;
}

html.dark .theme-icon-sun {
    display: block;
}

/* Subtle grid backdrop ---------------------------------------- */
html.dark .bg-grid-pattern {
    background-image:
        linear-gradient(to right, rgba(148, 163, 184, 0.10) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(148, 163, 184, 0.10) 1px, transparent 1px);
}

/* Scrollbar --------------------------------------------------- */
html.dark ::-webkit-scrollbar-track {
    background: #0B1120;
}

html.dark ::-webkit-scrollbar-thumb {
    background: #334155;
}

html.dark ::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Surfaces ---------------------------------------------------- */
html.dark [class~="bg-white"] {
    background-color: #111C2F !important;
}

html.dark [class~="bg-white/90"],
html.dark [class~="bg-white/95"] {
    background-color: rgba(17, 28, 47, 0.95) !important;
}

html.dark [class~="bg-slate-50"],
html.dark [class~="bg-slate-50/70"],
html.dark [class~="bg-slate-50/80"],
html.dark [class~="bg-slate-50/90"] {
    background-color: #0E192A !important;
}

html.dark [class~="bg-slate-100"],
html.dark [class~="bg-slate-100/50"],
html.dark [class~="bg-slate-100/60"],
html.dark [class~="bg-slate-100/70"] {
    background-color: #0C1626 !important;
}

html.dark [class~="bg-slate-200"],
html.dark [class~="bg-slate-200/70"] {
    background-color: #1F2D42 !important;
}

html.dark [class~="bg-ink"] {
    background-color: #0A1220 !important;
}

/* Tinted chips / badges --------------------------------------- */
html.dark [class~="bg-cobalt-50"],
html.dark [class~="bg-cobalt-50/60"],
html.dark [class~="bg-cobalt-50/70"],
html.dark [class~="bg-cobalt-50/80"],
html.dark [class~="bg-cobalt-50/90"] {
    background-color: rgba(59, 130, 246, 0.16) !important;
}

html.dark [class~="bg-cobalt-100"],
html.dark [class~="bg-cobalt-100/70"],
html.dark [class~="bg-cobalt-100/80"],
html.dark [class~="bg-cobalt-100/90"] {
    background-color: rgba(59, 130, 246, 0.24) !important;
}

html.dark [class~="bg-emerald-50"] {
    background-color: rgba(16, 185, 129, 0.14) !important;
}

html.dark [class~="bg-sky-50"] {
    background-color: rgba(14, 165, 233, 0.14) !important;
}

html.dark [class~="bg-purple-50"] {
    background-color: rgba(168, 85, 247, 0.14) !important;
}

html.dark [class~="bg-indigo-50"],
html.dark [class~="bg-indigo-50/70"],
html.dark [class~="bg-indigo-50/80"],
html.dark [class~="bg-indigo-50/90"] {
    background-color: rgba(99, 102, 241, 0.14) !important;
}

html.dark [class~="bg-amber-50"],
html.dark [class~="bg-amber-50/70"],
html.dark [class~="bg-amber-50/80"],
html.dark [class~="bg-amber-50/90"] {
    background-color: rgba(245, 158, 11, 0.14) !important;
}

html.dark [class~="bg-rose-50"] {
    background-color: rgba(244, 63, 94, 0.14) !important;
}

html.dark [class~="bg-emerald-100"] {
    background-color: rgba(16, 185, 129, 0.22) !important;
}

html.dark [class~="bg-sky-100"] {
    background-color: rgba(14, 165, 233, 0.22) !important;
}

html.dark [class~="bg-purple-100"] {
    background-color: rgba(168, 85, 247, 0.22) !important;
}

html.dark [class~="bg-amber-100"] {
    background-color: rgba(245, 158, 11, 0.22) !important;
}

html.dark [class~="bg-rose-100"] {
    background-color: rgba(244, 63, 94, 0.22) !important;
}

/* Borders ----------------------------------------------------- */
html.dark [class~="border-slate-100"],
html.dark [class~="border-slate-200"],
html.dark [class~="border-slate-200/70"],
html.dark [class~="border-slate-200/80"],
html.dark [class~="border-slate-300"] {
    border-color: #23334A !important;
}

html.dark [class~="border-cobalt-100"],
html.dark [class~="border-cobalt-100/80"],
html.dark [class~="border-cobalt-200"],
html.dark [class~="border-cobalt-200/70"],
html.dark [class~="border-cobalt-200/80"] {
    border-color: rgba(96, 165, 250, 0.30) !important;
}

html.dark [class~="border-emerald-100"],
html.dark [class~="border-emerald-200"],
html.dark [class~="border-emerald-500/30"] {
    border-color: rgba(52, 211, 153, 0.30) !important;
}

html.dark [class~="border-sky-200"] {
    border-color: rgba(56, 189, 248, 0.30) !important;
}

html.dark [class~="border-purple-100"],
html.dark [class~="border-purple-200"] {
    border-color: rgba(192, 132, 252, 0.30) !important;
}

html.dark [class~="border-amber-200"],
html.dark [class~="border-amber-200/90"] {
    border-color: rgba(251, 191, 36, 0.30) !important;
}

html.dark [class~="border-indigo-200"],
html.dark [class~="border-indigo-200/80"] {
    border-color: rgba(165, 180, 252, 0.32) !important;
}

html.dark [class~="border-rose-200"] {
    border-color: rgba(251, 113, 133, 0.30) !important;
}

/* Divider utilities apply their color to child elements */
html.dark [class~="divide-slate-100"] > :not([hidden]) ~ :not([hidden]),
html.dark [class~="divide-slate-200"] > :not([hidden]) ~ :not([hidden]),
html.dark [class~="divide-slate-200/80"] > :not([hidden]) ~ :not([hidden]) {
    border-color: #23334A !important;
}

/* Text -------------------------------------------------------- */
html.dark [class~="text-ink"] {
    color: #E2E8F0 !important;
}

html.dark [class~="text-slate-900"],
html.dark [class~="text-slate-800"],
html.dark [class~="text-slate-700"],
html.dark [class~="text-slate-600"] {
    color: #CBD5E1 !important;
}

html.dark [class~="text-slate-500"],
html.dark [class~="text-slate-400"] {
    color: #94A3B8 !important;
}

html.dark [class~="text-slate-300"],
html.dark [class~="text-slate-200"] {
    color: #CBD5E1 !important;
}

html.dark [class~="text-cobalt-700"],
html.dark [class~="text-cobalt-700/80"],
html.dark [class~="text-cobalt-800"],
html.dark [class~="text-cobalt-800/80"] {
    color: #60A5FA !important;
}

html.dark [class~="text-cobalt-900"] {
    color: #93C5FD !important;
}

html.dark [class~="text-emerald-600"],
html.dark [class~="text-emerald-700"] {
    color: #34D399 !important;
}

html.dark [class~="text-emerald-800"] {
    color: #6EE7B7 !important;
}

html.dark [class~="text-amber-600"],
html.dark [class~="text-amber-700"],
html.dark [class~="text-amber-800"],
html.dark [class~="text-amber-900"] {
    color: #FBBF24 !important;
}

html.dark [class~="text-rose-600"],
html.dark [class~="text-rose-700"],
html.dark [class~="text-rose-800"] {
    color: #FB7185 !important;
}

html.dark [class~="text-purple-700"],
html.dark [class~="text-purple-800"] {
    color: #C084FC !important;
}

html.dark [class~="text-indigo-700"],
html.dark [class~="text-indigo-800"],
html.dark [class~="text-indigo-900"] {
    color: #A5B4FC !important;
}

html.dark [class~="text-sky-700"],
html.dark [class~="text-sky-800"] {
    color: #38BDF8 !important;
}

/* Placeholders and interactive states ------------------------- */
html.dark [class~="placeholder-slate-400"]::placeholder,
html.dark [class~="placeholder-slate-500"]::placeholder {
    color: #64748B !important;
}

html.dark [class~="hover:bg-slate-50"]:hover,
html.dark [class~="hover:bg-slate-100"]:hover,
html.dark [class~="hover:bg-white"]:hover {
    background-color: #18273C !important;
}

html.dark [class~="focus:bg-white"]:focus {
    background-color: #152136 !important;
}

html.dark [class~="hover:border-slate-400"]:hover {
    border-color: #3A4B63 !important;
}

/* Article detail: Tailwind Typography sets its own colours on .prose, so the
   utility overrides above are not enough. Override the prose palette too. */
html.dark .prose {
    color: #CBD5E1 !important;
}

html.dark .prose :is(h1, h2, h3, h4, h5, h6, strong, b, th, summary) {
    color: #F1F5F9 !important;
}

html.dark .prose :is(p, li, span, div, td, dd, dt, figcaption, label, small, em) {
    color: #CBD5E1 !important;
}

html.dark .prose a {
    color: #60A5FA !important;
    text-decoration-color: rgba(96, 165, 250, 0.55) !important;
}

html.dark .prose a:hover {
    color: #93C5FD !important;
}

html.dark .prose hr {
    border-color: #23334A !important;
}

html.dark .prose blockquote {
    color: #CBD5E1 !important;
    background-color: rgba(30, 41, 59, 0.55) !important;
    border-left-color: #475569 !important;
}

html.dark .prose :is(table, thead, tbody, tfoot, tr, th, td) {
    border-color: #23334A !important;
}

html.dark .prose thead,
html.dark .prose tr:nth-child(even) {
    background-color: #111C2F !important;
}

html.dark .prose :not(pre) > code {
    color: #93C5FD !important;
    background-color: #1F2D42 !important;
    border: 1px solid #23334A !important;
}

html.dark .prose pre {
    color: #E2E8F0 !important;
    background-color: #0A1220 !important;
    border: 1px solid #23334A !important;
}

html.dark .prose pre code {
    color: inherit !important;
    background: transparent !important;
    border: 0 !important;
}

html.dark .prose :is(img, video, iframe) {
    background-color: #111C2F !important;
}

html.dark .prose :is(ul, ol) li::marker {
    color: #64748B !important;
}

/* Article HTML can contain inline colours from the editor. Keep it readable. */
html.dark .prose [style*="color"] {
    color: #CBD5E1 !important;
}

/* Editor HTML often uses inline light callout backgrounds. In night mode those
   need a dark surface; otherwise the light prose text above has no contrast. */
html.dark .prose [style*="background"],
html.dark .prose [class*="bg-[#"] {
    background: #111C2F !important;
    background-color: #111C2F !important;
    border-color: #23334A !important;
}

html.dark .prose [style*="background"] :is(p, li, span, div, strong, b, em, a, h1, h2, h3, h4, h5, h6) {
    color: #CBD5E1 !important;
}

/* Inputs and code blocks inside the article detail layout */
html.dark textarea,
html.dark input[type="text"],
html.dark input[type="email"],
html.dark input[type="search"] {
    background-color: #111C2F !important;
    color: #E2E8F0 !important;
    border-color: #23334A !important;
}

html.dark input[type="checkbox"],
html.dark input[type="radio"] {
    accent-color: #60A5FA;
}

html.dark .bg-grid-pattern {
    background-color: transparent;
}
