/* Non-Profit Hub Theme: dark mode.
 *
 * A designed palette, not an inverted page: deep navy surfaces, soft off-white text, and the brand
 * blue and green lifted so they stay readable. Every palette colour gets a dark value, so blocks
 * coloured from the palette follow automatically. Photos and logos are left alone, except logos
 * with the nfp-logo class, whose dark lettering turns white.
 *
 * The <html> element gets data-theme="dark" from a tiny script in <head> (no white flash).
 */

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

	/* This theme's palette */
	--wp--preset--color--surface: #0f1a24;
	--wp--preset--color--surface-alt: #152331;
	--wp--preset--color--ink: #e3e9ed;
	--wp--preset--color--muted: #a3b2bc;
	--wp--preset--color--line: #2a3a48;
	--wp--preset--color--brand: #1f5fa6;
	--wp--preset--color--brand-text: #8cbbee;
	--wp--preset--color--brand-dark: #0a2846;
	--wp--preset--color--highlight: #3d8a35;
	--wp--preset--color--highlight-text: #8fd486;
	--wp--preset--color--highlight-pale: #bfe3b9;
	--wp--preset--color--highlight-tint: #15291a;
	--wp--preset--color--on-brand: #ffffff;

	/* Twenty Twenty-Five's palette */
	--wp--preset--color--base: #0f1a24;
	--wp--preset--color--contrast: #e3e9ed;
	--wp--preset--color--accent-4: #a3b2bc;
	--wp--preset--color--accent-5: #152331;

	/* The site's older palette, still used in pages */
	--wp--preset--color--custom-primary: #2b78c2;
	--wp--preset--color--custom-primary-light: #6fa6d8;
	--wp--preset--color--custom-primary-dark: #9cc4ec;
	--wp--preset--color--custom-base-contrast: #132130;
	--wp--preset--color--custom-base-light: #ffffff;
	--wp--preset--color--custom-base-dark: #e3e9ed;
	--wp--preset--color--custom-tertiary: #182838;
	--wp--preset--color--custom-content-primary: #e3e9ed;
	--wp--preset--color--custom-content-secondary: #bac6cd;
	--wp--preset--color--custom-content-tertiary: #95a5af;
	--wp--preset--color--custom-content-link: #8cbbee;
	--wp--preset--color--custom-border-neutral: #2a3a48;
	--wp--preset--color--custom-bg-1: #1a2d42;
	--wp--preset--color--custom-bg-2: #1a3021;
	--wp--preset--color--custom-bg-3: #33291a;
	--wp--preset--color--custom-bg-4: #3a2024;
	--wp--preset--color--custom-bg-5: #2a2339;
	--wp--preset--color--custom-bg-6: #35261f;
}

html[data-theme="dark"] body {
	background-color: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--ink);
}

/* Fixed colours typed straight into pages (not from the palette). */
html[data-theme="dark"] :where([style*="background-color:#ffffff"], [style*="background-color:#fff;"], [style*="background-color:#fff\""], [style*="background-color:#fcfcfc"], [style*="background-color:#f4f7f9"], [style*="background-color:#f3f4f6"]) {
	background-color: var(--wp--preset--color--surface-alt) !important;
}
html[data-theme="dark"] :where([style*="color:#000000"], [style*="color:#111111"], [style*="color:#2c3536"], [style*="color:#1f2a2b"], [style*="color:#040316"]):not([style*="background-color:#000"]) {
	color: var(--wp--preset--color--ink) !important;
}
html[data-theme="dark"] :where([style*="border-color:#d9dfdf"], [style*="border-color:#e2e8f0"]) {
	border-color: var(--wp--preset--color--line) !important;
}
html[data-theme="dark"] .wp-block-separator:where([style*="background-color:#d9dfdf"]) {
	background-color: var(--wp--preset--color--line) !important;
	color: var(--wp--preset--color--line) !important;
}

/* Logos: dark lettering turns white, the blue and green stay. Give any logo image the class nfp-logo. */
html[data-theme="dark"] :is(.nfp-logo, .nfp-logo-wide, .nfp-logo-icon) img {
	filter: invert(1) hue-rotate(180deg);
}

/* Photos are slightly softened so they don't glare. */
html[data-theme="dark"] .wp-block-post-content img:not(.nfp-logo img),
html[data-theme="dark"] .wp-block-post-featured-image img {
	filter: brightness(0.92);
}

/* Form fields and the Events Calendar. */
html[data-theme="dark"] :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]) {
	background-color: var(--wp--preset--color--surface-alt);
	color: var(--wp--preset--color--ink);
	border-color: var(--wp--preset--color--line);
}
html[data-theme="dark"] :is(.tribe-common, .tribe-events) {
	--tec-color-background: var(--wp--preset--color--surface);
	--tec-color-background-events: var(--wp--preset--color--surface);
	--tec-color-background-secondary: var(--wp--preset--color--surface-alt);
	--tec-color-text-primary: var(--wp--preset--color--ink);
	--tec-color-text-secondary: var(--wp--preset--color--muted);
	--tec-color-text-event-title: var(--wp--preset--color--ink);
	--tec-color-text-event-date: var(--wp--preset--color--muted);
	--tec-color-border-default: var(--wp--preset--color--line);
	--tec-color-border-secondary: var(--wp--preset--color--line);
	--tec-color-icon-primary: var(--wp--preset--color--muted);
	--tec-color-link-primary: var(--wp--preset--color--brand-text);
	--tec-color-accent-primary: var(--wp--preset--color--brand-text);
}
html[data-theme="dark"] .tribe-events-widget .tribe-events-widget-events-list__event-date-tag-month {
	color: var(--wp--preset--color--highlight-text) !important;
}

/* Sponsor and photo carousels from the plugins. */
html[data-theme="dark"] {
	--site-tools-accent: var(--wp--preset--color--brand-text);
}

/* A gentle fade when someone flips the switch (not on page load, and not for reduced motion). */
@media (prefers-reduced-motion: no-preference) {
	html.nfp-scheme-changing,
	html.nfp-scheme-changing *,
	html.nfp-scheme-changing *::before,
	html.nfp-scheme-changing *::after {
		transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease !important;
	}
}

/* ---- The switch itself (light mode shows the moon, dark mode the sun) ---- */
.nfp-scheme-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
}
.nfp-scheme-toggle:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.nfp-scheme-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.nfp-scheme-toggle__sun { display: none; }

/* The floating switch in the bottom corner. */
.nfp-scheme-toggle--floating {
	position: fixed;
	right: 16px;
	bottom: 16px;
	z-index: 9990;
	width: 44px;
	height: 44px;
	background: var(--wp--preset--color--surface-alt, #f4f7f9);
	color: var(--wp--preset--color--ink, #1f2a2b);
	border: 1px solid var(--wp--preset--color--line, #d9dfdf);
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.nfp-scheme-toggle--floating:hover { background: var(--wp--preset--color--surface-alt, #f4f7f9); filter: brightness(0.95); }
@media print { .nfp-scheme-toggle--floating { display: none; } }
html[data-theme="dark"] .nfp-scheme-toggle__sun { display: block; }
html[data-theme="dark"] .nfp-scheme-toggle__moon { display: none; }
