/* Dark mode: swap the base/contrast palette so backgrounds and text invert
   everywhere they already use var(--wp--preset--color--base/contrast). */
:root.is-dark-mode {
	--wp--preset--color--base: #0A2540;
	--wp--preset--color--contrast: #ffffff;
	--wp--preset--color--secondary: #A9B8CC;
	--wp--preset--color--tertiary: #3A5578;
}

/* The Events Calendar plugin ships its own color tokens (--tec-color-*),
   independent of the theme palette, so they need their own dark-mode overrides. */
:root.is-dark-mode {
	--tec-color-text-primary: #ffffff;
	--tec-color-text-primary-light: #ffffffcc;
	--tec-color-text-secondary: #A9B8CC;
	--tec-color-text-disabled: #5d6b85;
	--tec-color-icon-primary: #A9B8CC;
	--tec-color-icon-primary-alt: #A9B8CC;
	--tec-color-icon-active: #ffffff;
	--tec-color-event-icon: #ffffff;
	--tec-color-accent-secondary: #ffffff;
	--tec-color-border-default: #3A5578;
	--tec-color-border-secondary: #3A5578;
	--tec-color-border-active: #ffffff;
	--tec-color-background: #0A2540;
	--tec-color-background-secondary: #12335c;
	--tec-color-background-secondary-hover: #163a68;
	--tec-color-background-transparent: #0A254099;

	/* Category-color event chips (month/list/week views) keep their own light
	   pastel backgrounds in dark mode, so their text needs to stay dark too —
	   it must not inherit the page-wide white text color above. */
	--tec-color-category-text: #141827;
}

/* Past events get their own (more specific) date-text rule from the plugin
   that reverts to the page-wide text color, undoing the category-text fix
   above just for that one element. Only re-target events that actually have
   a category color (class contains "cat_") so plain past events on the dark
   page background keep their normal light text. */
:root.is-dark-mode .tribe-events-calendar-month__calendar-event[class*="cat_"] .tribe-events-calendar-month__calendar-event-datetime,
:root.is-dark-mode .tribe-events-calendar-list__event[class*="cat_"] .tribe-events-calendar-list__event-datetime,
:root.is-dark-mode .tribe-events-calendar-day__event[class*="cat_"] .tribe-events-calendar-day__event-datetime {
	color: var(--tec-color-category-text);
}

.site-logo-swap {
	align-items: center;
}

.logo-dark {
	display: none;
}

:root.is-dark-mode .logo-light {
	display: none;
}

:root.is-dark-mode .logo-dark {
	display: block;
}

.dark-mode-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid var(--wp--preset--color--tertiary);
	border-radius: 999px;
	background: transparent;
	color: var(--wp--preset--color--contrast);
	cursor: pointer;
}

.dark-mode-toggle:hover,
.dark-mode-toggle:focus {
	border-color: var(--wp--preset--color--contrast);
}

.dark-mode-toggle svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
	display: block;
}

.dark-mode-toggle .icon-sun {
	display: none;
}

:root.is-dark-mode .dark-mode-toggle .icon-moon {
	display: none;
}

:root.is-dark-mode .dark-mode-toggle .icon-sun {
	display: block;
}

/* ==========================================================================
   CatFolders Document Gallery (the Files page)
   The plugin styles itself with an ID selector (#cf-app), so these rules use
   the same ID to win without needing !important.
   ========================================================================== */

/* The page title already says "YMRC Files": hide the gallery's own copy. */
#cf-app .cf-title {
	display: none;
}

:root.is-dark-mode #cf-app table.cf-table,
:root.is-dark-mode #cf-app table.cf-table thead th,
:root.is-dark-mode #cf-app table.cf-table tbody tr,
:root.is-dark-mode #cf-app table.cf-table tbody td {
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	border-color: var(--wp--preset--color--tertiary);
}

:root.is-dark-mode #cf-app table.cf-table tbody td a {
	color: var(--wp--preset--color--contrast);
}

/* Grid view: each file is a card, so lift it slightly off the page. */
:root.is-dark-mode #cf-app table.cf-table-grid tbody td {
	background-color: #12335c;
	color: var(--wp--preset--color--contrast);
	border-color: var(--wp--preset--color--tertiary);
}

/* Search box and the "show N entries" dropdown. */
:root.is-dark-mode #cf-app .cf-table__top .dataTables_filter input,
:root.is-dark-mode #cf-app .cf-table__bottom .dataTables_filter input,
:root.is-dark-mode #cf-app .dataTables_length select {
	background-color: #12335c;
	color: var(--wp--preset--color--contrast);
	border-color: var(--wp--preset--color--tertiary);
}

:root.is-dark-mode #cf-app .dataTables_filter input::placeholder {
	color: var(--wp--preset--color--secondary);
	opacity: 1;
}

/* Quieter text: list/grid switch, counts and paging. */
:root.is-dark-mode #cf-app .cf-options__grid,
:root.is-dark-mode #cf-app .cf-table__bottom,
:root.is-dark-mode #cf-app .cf-pagination,
:root.is-dark-mode #cf-app .dataTables_info,
:root.is-dark-mode #cf-app .dataTables_length,
:root.is-dark-mode #cf-app .dataTables_paginate .paginate_button {
	color: var(--wp--preset--color--secondary);
}
