/*
 * Coastal Ecosystem - Dark Mode Overrides
 * Activates only when <html data-bs-theme="dark"> is present (Bootstrap 5.3+ + dmx-bs5-theme).
 * Preserves the Coastal palette identity by lifting accent tones (mineral, sunset, sea-anemone)
 * and using deeper variants of deep-water for backgrounds + surfaces.
 *
 * Scope: PUBLIC FRONTEND ONLY. Admin layout does NOT load this file.
 */

[data-bs-theme="dark"] {
  /* Surface palette: deep-water family */
  --coastal-dark-bg: #0a1a2a;
  --coastal-dark-surface: #0f2438;
  --coastal-dark-elevated: #143046;
  --coastal-dark-border: #1f4060;
  --coastal-dark-border-soft: #1a3550;

  /* Text palette: cool desaturated to match coastal feel */
  --coastal-dark-text: #cbd9d4;
  --coastal-dark-text-strong: #e8f4f0;
  --coastal-dark-text-muted: #8aa39c;
  --coastal-dark-text-faint: #6b8580;

  /* Re-map Bootstrap tokens */
  --bs-body-bg: var(--coastal-dark-bg);
  --bs-body-color: var(--coastal-dark-text);
  --bs-secondary-color: var(--coastal-dark-text-muted);
  --bs-tertiary-color: var(--coastal-dark-text-faint);
  --bs-tertiary-bg: var(--coastal-dark-surface);
  --bs-border-color: var(--coastal-dark-border);
  --bs-border-color-translucent: rgba(255, 255, 255, 0.1);
  --bs-link-color: var(--coastal-mineral);
  --bs-link-hover-color: #ffffff;
  --bs-link-color-rgb: var(--coastal-mineral-rgb);
  --bs-emphasis-color: var(--coastal-dark-text-strong);
  --bs-emphasis-color-rgb: 232, 244, 240;
  --bs-heading-color: var(--coastal-dark-text-strong);

  /* Verge gray scale flipped for dark */
  --verge-gray-50: #182d42;
  --verge-gray-100: #1c344c;
  --verge-gray-200: var(--coastal-dark-border);
  --verge-gray-300: #2a4f6e;
  --verge-gray-400: #6b8580;
  --verge-gray-500: #8aa39c;
  --verge-gray-600: #a8c0ba;
  --verge-gray-700: #c1d4d0;
  --verge-gray-800: var(--coastal-dark-text-strong);
  --verge-gray-900: #f0f6f4;
}

/* Body
   The explicit background-color is NOT redundant with --bs-body-bg above:
   bootstrap-verge.css `body { background-color: var(--coastal-seafoam); }` is a
   literal, not a --bs-body-bg reference, so the variable remap alone won't flip
   the body background. This rule wins by specificity (0,1,1) + later load order. */
[data-bs-theme="dark"] body {
  background-color: var(--coastal-dark-bg);
  color: var(--coastal-dark-text);
}

/* Headings keep heavy weight but switch to light tone */
[data-bs-theme="dark"] h1,
[data-bs-theme="dark"] h2,
[data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4,
[data-bs-theme="dark"] h5,
[data-bs-theme="dark"] h6,
[data-bs-theme="dark"] .h1,
[data-bs-theme="dark"] .h2,
[data-bs-theme="dark"] .h3,
[data-bs-theme="dark"] .h4,
[data-bs-theme="dark"] .h5,
[data-bs-theme="dark"] .h6,
[data-bs-theme="dark"] .card-title,
[data-bs-theme="dark"] .card .h5,
[data-bs-theme="dark"] .card .h4 {
  color: var(--coastal-dark-text-strong);
}

[data-bs-theme="dark"] .lead {
  color: var(--coastal-dark-text-muted);
}

/* Links */
[data-bs-theme="dark"] a {
  color: var(--coastal-mineral);
}

[data-bs-theme="dark"] a:hover {
  color: #ffffff;
}

[data-bs-theme="dark"] article a,
[data-bs-theme="dark"] main p a,
[data-bs-theme="dark"] .content-link {
  background-image: linear-gradient(var(--coastal-mineral), var(--coastal-mineral));
}

[data-bs-theme="dark"] article a:hover,
[data-bs-theme="dark"] main p a:hover,
[data-bs-theme="dark"] .content-link:hover {
  color: #ffffff;
}

/* Navbar */
[data-bs-theme="dark"] header .navbar {
  background: var(--coastal-dark-elevated);
  border-bottom-color: var(--coastal-dark-border);
}

[data-bs-theme="dark"] .navbar-brand,
[data-bs-theme="dark"] .navbar-brand:hover {
  color: var(--coastal-dark-text-strong);
}

[data-bs-theme="dark"] .navbar-nav .nav-link {
  color: var(--coastal-dark-text-strong);
}

[data-bs-theme="dark"] .navbar-nav .nav-link:hover,
[data-bs-theme="dark"] .navbar-nav .nav-link.active {
  color: var(--coastal-mineral);
}

[data-bs-theme="dark"] .navbar-nav .nav-link::after {
  background: var(--coastal-mineral);
}

[data-bs-theme="dark"] .navbar-toggler {
  border-color: var(--coastal-mineral);
}

[data-bs-theme="dark"] .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28203, 217, 212, 0.95%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

/* Donate button stays brand pink — accent works on dark too */
[data-bs-theme="dark"] .navbar-nav .nav-link[href="/donations"] {
  background-color: var(--coastal-sea-anemone);
  color: #ffffff;
}

[data-bs-theme="dark"] .navbar-nav .nav-link[href="/donations"]:hover {
  background-color: #f02669;
  color: #ffffff;
}

/* Mobile nav collapse border */
@media (max-width: 991.98px) {
  [data-bs-theme="dark"] .navbar-nav .nav-link {
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }
  [data-bs-theme="dark"] .navbar-collapse {
    border-top-color: rgba(255, 255, 255, 0.12);
  }
}

/* Cards */
[data-bs-theme="dark"] .card {
  background: var(--coastal-dark-surface);
  border-color: var(--coastal-dark-border);
  color: var(--coastal-dark-text);
}

[data-bs-theme="dark"] .card:hover,
[data-bs-theme="dark"] .card.shadow-sm:hover,
[data-bs-theme="dark"] .card.shadow:hover,
[data-bs-theme="dark"] .card.shadow-lg:hover {
  box-shadow: 6px 6px 0 var(--coastal-dark-border);
}

[data-bs-theme="dark"] .card.shadow-sm,
[data-bs-theme="dark"] .card.shadow,
[data-bs-theme="dark"] .card.shadow-lg,
[data-bs-theme="dark"] .card.border-0 {
  border-color: var(--coastal-dark-border);
}

[data-bs-theme="dark"] .card-img-top {
  border-bottom-color: var(--coastal-dark-border);
}

[data-bs-theme="dark"] .card-text {
  color: var(--coastal-dark-text);
}

/* Forms */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: var(--coastal-dark-elevated);
  border-color: var(--coastal-dark-border);
  color: var(--coastal-dark-text-strong);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: var(--coastal-dark-elevated);
  border-color: var(--coastal-mineral);
  color: var(--coastal-dark-text-strong);
  box-shadow: 0 0 0 0.25rem rgba(132, 201, 184, 0.22);
}

[data-bs-theme="dark"] .form-control::placeholder {
  color: var(--coastal-dark-text-faint);
}

[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-select:disabled {
  background-color: var(--coastal-dark-surface);
  color: var(--coastal-dark-text-muted);
}

[data-bs-theme="dark"] .input-group-text {
  background-color: var(--coastal-dark-surface);
  border-color: var(--coastal-dark-border);
  color: var(--coastal-dark-text);
}

[data-bs-theme="dark"] .form-check-input {
  background-color: var(--coastal-dark-surface);
  border-color: var(--coastal-dark-border);
}

[data-bs-theme="dark"] .form-check-input:checked {
  background-color: var(--coastal-kelp);
  border-color: var(--coastal-kelp);
}

[data-bs-theme="dark"] .form-label,
[data-bs-theme="dark"] .col-form-label {
  color: var(--coastal-dark-text-strong);
}

/* Dropdowns */
[data-bs-theme="dark"] .dropdown-menu {
  background-color: var(--coastal-dark-elevated);
  border-color: var(--coastal-dark-border);
  box-shadow: 6px 6px 0 var(--coastal-dark-border);
}

[data-bs-theme="dark"] .dropdown-item {
  color: var(--coastal-dark-text-strong);
  border-bottom-color: var(--coastal-dark-border-soft);
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
  background-color: var(--coastal-dark-bg);
  color: #ffffff;
}

[data-bs-theme="dark"] .dropdown-item:active,
[data-bs-theme="dark"] .dropdown-item.active {
  background-color: var(--coastal-mineral);
  color: var(--coastal-deep-water);
}

[data-bs-theme="dark"] .dropdown-divider {
  border-top-color: var(--coastal-dark-border);
}

/* Language dropdown overrides (uses its own !important rules in main.ejs <style>) */
[data-bs-theme="dark"] .lang-dropdown {
  background: var(--coastal-dark-elevated) !important;
  border-color: var(--coastal-mineral) !important;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .lang-dropdown .dropdown-item {
  color: var(--coastal-dark-text-strong);
  border-bottom-color: var(--coastal-dark-border-soft);
}

[data-bs-theme="dark"] .lang-dropdown .dropdown-item:hover,
[data-bs-theme="dark"] .lang-dropdown .dropdown-item:focus {
  background: var(--coastal-mineral) !important;
  color: var(--coastal-deep-water) !important;
}

/* Theme switch (matches language dropdown style for visual harmony) */
[data-bs-theme="dark"] #theme_switch .dropdown-toggle,
[data-bs-theme="dark"] #theme_switch_mobile .dropdown-toggle {
  background-color: var(--coastal-mineral);
  border: 2px solid var(--coastal-mineral);
  color: var(--coastal-deep-water);
}

[data-bs-theme="dark"] #theme_switch .dropdown-toggle:hover,
[data-bs-theme="dark"] #theme_switch_mobile .dropdown-toggle:hover {
  background-color: var(--coastal-dark-text-strong);
  border-color: var(--coastal-dark-text-strong);
}

/* Light-mode theme switch should match language dropdown's outline-primary look */
#theme_switch .dropdown-toggle,
#theme_switch_mobile .dropdown-toggle {
  border: 2px solid var(--coastal-kelp);
  border-radius: 0;
  background-color: var(--coastal-kelp);
  color: var(--verge-white, #ffffff);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  padding: 0.5rem 1rem;
}

#theme_switch .dropdown-toggle:hover,
#theme_switch_mobile .dropdown-toggle:hover {
  background-color: var(--coastal-deep-water);
  border-color: var(--coastal-deep-water);
  color: #ffffff;
}

/* Tables */
[data-bs-theme="dark"] .table {
  --bs-table-bg: var(--coastal-dark-surface);
  --bs-table-color: var(--coastal-dark-text);
  --bs-table-striped-bg: var(--coastal-dark-elevated);
  --bs-table-striped-color: var(--coastal-dark-text-strong);
  --bs-table-hover-bg: var(--coastal-dark-elevated);
  --bs-table-hover-color: var(--coastal-dark-text-strong);
  --bs-table-border-color: var(--coastal-dark-border);
  border-color: var(--coastal-dark-border);
  color: var(--coastal-dark-text);
}

[data-bs-theme="dark"] .table th {
  background-color: var(--coastal-dark-elevated);
  color: var(--coastal-dark-text-strong);
}

[data-bs-theme="dark"] .table td {
  border-color: var(--coastal-dark-border-soft);
}

[data-bs-theme="dark"] .table-striped tbody tr:nth-of-type(odd) {
  background-color: var(--coastal-dark-elevated);
}

/* Modals (keep deep-water header — it works on both themes) */
[data-bs-theme="dark"] .modal-content {
  background-color: var(--coastal-dark-surface);
  color: var(--coastal-dark-text);
  border-color: var(--coastal-dark-border);
}

[data-bs-theme="dark"] .modal-header {
  background-color: var(--coastal-dark-elevated);
  color: var(--coastal-dark-text-strong);
  border-bottom-color: var(--coastal-dark-border);
}

[data-bs-theme="dark"] .modal-footer {
  border-top-color: var(--coastal-dark-border);
}

[data-bs-theme="dark"] .modal-title {
  color: var(--coastal-dark-text-strong);
}

/* List groups */
[data-bs-theme="dark"] .list-group-item {
  background-color: var(--coastal-dark-surface);
  border-color: var(--coastal-dark-border-soft);
  color: var(--coastal-dark-text);
}

[data-bs-theme="dark"] .list-group-item:hover {
  background-color: var(--coastal-dark-elevated);
}

/* Pagination */
[data-bs-theme="dark"] .page-link {
  background-color: var(--coastal-dark-surface);
  border-color: var(--coastal-dark-border);
  color: var(--coastal-dark-text-strong);
}

[data-bs-theme="dark"] .page-link:hover {
  background-color: var(--coastal-mineral);
  border-color: var(--coastal-mineral);
  color: var(--coastal-deep-water);
}

[data-bs-theme="dark"] .page-item.active .page-link {
  background-color: var(--coastal-mineral);
  border-color: var(--coastal-mineral);
  color: var(--coastal-deep-water);
}

[data-bs-theme="dark"] .page-item.disabled .page-link {
  background-color: var(--coastal-dark-surface);
  border-color: var(--coastal-dark-border-soft);
  color: var(--coastal-dark-text-faint);
}

/* Alerts */
[data-bs-theme="dark"] .alert {
  background-color: var(--coastal-dark-surface);
  color: var(--coastal-dark-text-strong);
  border-color: var(--coastal-dark-border);
}

[data-bs-theme="dark"] .alert-primary {
  background-color: rgba(132, 201, 184, 0.1);
  border-left-color: var(--coastal-mineral);
  color: var(--coastal-dark-text-strong);
}

[data-bs-theme="dark"] .alert-info {
  background-color: rgba(132, 201, 184, 0.15);
  border-color: var(--coastal-mineral);
  border-left-color: var(--coastal-mineral);
  color: var(--coastal-dark-text-strong);
}

[data-bs-theme="dark"] .alert-success {
  background-color: rgba(16, 185, 129, 0.15);
  border-left-color: var(--bs-success);
  color: var(--coastal-dark-text-strong);
}

[data-bs-theme="dark"] .alert-warning {
  background-color: rgba(245, 158, 11, 0.15);
  border-left-color: var(--bs-warning);
  color: var(--coastal-dark-text-strong);
}

[data-bs-theme="dark"] .alert-danger {
  background-color: rgba(239, 68, 68, 0.18);
  border-left-color: var(--bs-danger);
  color: var(--coastal-dark-text-strong);
}

/* Buttons that use light/dark utilities */
[data-bs-theme="dark"] .btn-light {
  background-color: var(--coastal-dark-elevated);
  border-color: var(--coastal-dark-border);
  color: var(--coastal-dark-text-strong);
}

[data-bs-theme="dark"] .btn-light:hover,
[data-bs-theme="dark"] .btn-light:focus {
  background-color: var(--coastal-mineral);
  border-color: var(--coastal-mineral);
  color: var(--coastal-deep-water);
}

[data-bs-theme="dark"] .btn-outline-primary {
  border-color: var(--coastal-mineral);
  color: var(--coastal-mineral);
}

[data-bs-theme="dark"] .btn-outline-primary:hover,
[data-bs-theme="dark"] .btn-outline-primary:focus {
  background-color: var(--coastal-mineral);
  color: var(--coastal-deep-water);
}

[data-bs-theme="dark"] .btn-outline-light {
  border-color: var(--coastal-dark-text);
  color: var(--coastal-dark-text-strong);
}

[data-bs-theme="dark"] .btn-outline-light:hover {
  background-color: var(--coastal-dark-text-strong);
  color: var(--coastal-deep-water);
}

/* Background utility overrides — only flip the ones that imply "light/neutral surface" */
[data-bs-theme="dark"] .bg-white {
  background-color: var(--coastal-dark-surface) !important;
  color: var(--coastal-dark-text);
}

[data-bs-theme="dark"] .bg-light,
[data-bs-theme="dark"] .bg-seafoam,
[data-bs-theme="dark"] .bg-shallow {
  background-color: var(--coastal-dark-elevated) !important;
  color: var(--coastal-dark-text-strong) !important;
}

[data-bs-theme="dark"] .bg-verge-gray {
  background-color: var(--coastal-dark-elevated) !important;
}

/* bg-dark / bg-primary / bg-deep-water stay dark on dark — they are intentional dark surfaces.
   Just ensure text inside reads correctly. */

/* Text utility overrides for readability on dark surfaces */
[data-bs-theme="dark"] .text-dark {
  color: var(--coastal-dark-text-strong) !important;
}

[data-bs-theme="dark"] .text-muted,
[data-bs-theme="dark"] .text-body-secondary {
  color: var(--coastal-dark-text-muted) !important;
}

[data-bs-theme="dark"] .text-brine {
  color: var(--coastal-dark-text) !important;
}

[data-bs-theme="dark"] .text-deep-water {
  color: var(--coastal-dark-text-strong) !important;
}

/* Borders */
[data-bs-theme="dark"] .border,
[data-bs-theme="dark"] .border-top,
[data-bs-theme="dark"] .border-end,
[data-bs-theme="dark"] .border-bottom,
[data-bs-theme="dark"] .border-start {
  border-color: var(--coastal-dark-border) !important;
}

/* Footer keeps the same deep-water tone — already dark-friendly */
[data-bs-theme="dark"] footer {
  background-color: var(--coastal-dark-bg);
  border-top-color: var(--coastal-mineral);
}

/* Supporters strip (uses .bg-deep-water) — slightly lift on dark to differentiate */
[data-bs-theme="dark"] .footer-supporters.bg-deep-water {
  background-color: var(--coastal-dark-elevated) !important;
}

/* HR / divider */
[data-bs-theme="dark"] hr {
  border-color: var(--coastal-dark-border);
  opacity: 0.4;
}

/* Code / pre */
[data-bs-theme="dark"] code,
[data-bs-theme="dark"] kbd {
  background-color: var(--coastal-dark-elevated);
  color: var(--coastal-mineral);
}

/* Validator + form-feedback states */
[data-bs-theme="dark"] .invalid-feedback {
  color: #ff7c7c;
}

[data-bs-theme="dark"] .valid-feedback {
  color: #67e8a8;
}

/* Geo-block banner stays the loud red — visibility matters more than theme */

/* Close button (in modals etc) needs inversion when sitting on dark surfaces */
[data-bs-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Tabs */
[data-bs-theme="dark"] .nav-tabs {
  border-bottom-color: var(--coastal-dark-border);
}

[data-bs-theme="dark"] .nav-tabs .nav-link {
  color: var(--coastal-dark-text);
  border-color: transparent;
}

[data-bs-theme="dark"] .nav-tabs .nav-link:hover,
[data-bs-theme="dark"] .nav-tabs .nav-link:focus {
  border-color: var(--coastal-dark-border) var(--coastal-dark-border) transparent;
  color: var(--coastal-mineral);
}

[data-bs-theme="dark"] .nav-tabs .nav-link.active {
  background-color: var(--coastal-dark-surface);
  border-color: var(--coastal-dark-border) var(--coastal-dark-border) var(--coastal-dark-surface);
  color: var(--coastal-dark-text-strong);
}

/* Bootstrap helper text + small text on dark */
[data-bs-theme="dark"] .form-text,
[data-bs-theme="dark"] small.text-muted {
  color: var(--coastal-dark-text-muted) !important;
}

/* Date picker (daterangepicker) — common form widget */
[data-bs-theme="dark"] .daterangepicker {
  background-color: var(--coastal-dark-elevated);
  color: var(--coastal-dark-text);
  border-color: var(--coastal-dark-border);
}

[data-bs-theme="dark"] .daterangepicker td.available:hover,
[data-bs-theme="dark"] .daterangepicker th.available:hover {
  background-color: var(--coastal-dark-bg);
  color: var(--coastal-mineral);
}

[data-bs-theme="dark"] .daterangepicker td.in-range {
  background-color: rgba(132, 201, 184, 0.15);
  color: var(--coastal-dark-text-strong);
}

[data-bs-theme="dark"] .daterangepicker td.active,
[data-bs-theme="dark"] .daterangepicker td.active:hover {
  background-color: var(--coastal-mineral);
  color: var(--coastal-deep-water);
}

/* Navbar logo swap: white stacked variant in dark mode */
.navbar-logo-dark { display: none; }
[data-bs-theme="dark"] .navbar-logo-light { display: none; }
[data-bs-theme="dark"] .navbar-logo-dark { display: inline-block; }

/* Theme switch dropdown — override bootstrap-verge.css .dropdown-item.active
   (which applies coastal-deep-water bg + verge-white text). At the small
   dropdown item size the white label renders illegibly against the dark fill.
   Use a soft mineral tint + native text color + bold weight, and let the
   right-side check icon carry the "active" signal. Loaded on every public
   page so applies in both light and dark mode. */
#theme_switch .dropdown-item.active,
#theme_switch .dropdown-item:active,
#theme_switch_mobile .dropdown-item.active,
#theme_switch_mobile .dropdown-item:active {
  background-color: rgba(132, 201, 184, 0.18);
  color: inherit;
  font-weight: 600;
}

#theme_switch .dropdown-item.active .fa-check,
#theme_switch_mobile .dropdown-item.active .fa-check {
  color: var(--coastal-mineral, #84c9b8);
}

[data-bs-theme="dark"] #theme_switch .dropdown-item.active,
[data-bs-theme="dark"] #theme_switch .dropdown-item:active,
[data-bs-theme="dark"] #theme_switch_mobile .dropdown-item.active,
[data-bs-theme="dark"] #theme_switch_mobile .dropdown-item:active {
  background-color: rgba(132, 201, 184, 0.12);
  color: var(--coastal-dark-text-strong);
}

/* ============================================================================
 * Page-specific dark-mode text/contrast fixes
 * (debug session: dark-mode-text-readability, 2026-06-03)
 *
 * Each area below carried its own colors (page-local <style>, inline styles,
 * fixed brand-color boxes, or high-specificity verge ID rules) that the generic
 * overrides above never selected, so they rendered dark-on-dark or light-on-light
 * once dark mode was toggled. Every rule here is scoped to [data-bs-theme="dark"]
 * so LIGHT MODE IS UNCHANGED. All fixes live in this committed file so they
 * survive Wappler Publish/deploy (no new files, no <style> blocks, no config).
 * ============================================================================ */

/* ---- 1. Events: FullCalendar grid (views/events.ejs) ----------------------
 * The page-local <style> hardcodes #052642 on the toolbar title, column headers
 * and day numbers, and FullCalendar keeps white day cells while the dark body
 * color leaks light text into them. Theme the grid: lift text + give the cells a
 * dark surface so both the #052642 literals and the inherited light text read.
 * Selectors are more specific than the page-local `.fc .fc-...` rules AND scoped
 * to dark, so they win in dark mode only. */
[data-bs-theme="dark"] .fc {
  --fc-border-color: var(--coastal-dark-border);
  --fc-page-bg-color: var(--coastal-dark-surface);
  --fc-neutral-bg-color: var(--coastal-dark-elevated);
  --fc-today-bg-color: rgba(218, 27, 93, 0.22);
  color: var(--coastal-dark-text);
}
[data-bs-theme="dark"] .fc .fc-toolbar-title {
  color: var(--coastal-dark-text-strong);
}
[data-bs-theme="dark"] .fc .fc-col-header-cell {
  background-color: var(--coastal-dark-elevated);
}
[data-bs-theme="dark"] .fc .fc-col-header-cell-cushion,
[data-bs-theme="dark"] .fc .fc-daygrid-day-number {
  color: var(--coastal-dark-text-strong);
}
[data-bs-theme="dark"] .fc .fc-daygrid-day {
  background-color: var(--coastal-dark-surface);
}
[data-bs-theme="dark"] .fc .fc-scrollgrid,
[data-bs-theme="dark"] .fc .fc-scrollgrid td,
[data-bs-theme="dark"] .fc .fc-scrollgrid th {
  border-color: var(--coastal-dark-border);
}
/* Calendar prev/next nav buttons readable on the dark grid (their page-local
 * #052642 fill is invisible against the dark surface). */
[data-bs-theme="dark"] .fc .fc-button-primary {
  background-color: var(--coastal-dark-elevated) !important;
  border-color: var(--coastal-dark-border) !important;
  color: var(--coastal-dark-text-strong) !important;
}
[data-bs-theme="dark"] .fc .fc-button-primary:hover {
  background-color: var(--coastal-mineral) !important;
  border-color: var(--coastal-mineral) !important;
  color: var(--coastal-deep-water) !important;
}

/* ---- 2. FAQ accordion (views/faq.ejs) -------------------------------------
 * bootstrap-verge sets `.accordion-body { color: var(--coastal-brine) }` with a
 * transparent bg, so the answer text inherits the dark page bg = dark-on-dark.
 * Give the accordion a dark surface + light text, and flip the collapsed chevron
 * (hardcoded dark SVG) to a light one so it is visible on the dark button. */
[data-bs-theme="dark"] .accordion {
  --bs-accordion-bg: var(--coastal-dark-surface);
  --bs-accordion-color: var(--coastal-dark-text);
  --bs-accordion-border-color: var(--coastal-dark-border);
  --bs-accordion-btn-color: var(--coastal-dark-text-strong);
  --bs-accordion-btn-bg: var(--coastal-dark-surface);
  --bs-accordion-active-color: var(--coastal-dark-text-strong);
  --bs-accordion-active-bg: var(--coastal-dark-elevated);
}
[data-bs-theme="dark"] .accordion-item {
  background-color: var(--coastal-dark-surface);
  border-color: var(--coastal-dark-border);
}
[data-bs-theme="dark"] .accordion-button {
  background-color: var(--coastal-dark-surface);
  color: var(--coastal-dark-text-strong);
}
[data-bs-theme="dark"] .accordion-button:not(.collapsed) {
  background-color: var(--coastal-dark-elevated);
  color: var(--coastal-dark-text-strong);
  box-shadow: none;
}
[data-bs-theme="dark"] .accordion-body {
  color: var(--coastal-dark-text);
}
/* Light chevron so the collapse arrow is visible against the dark button. */
[data-bs-theme="dark"] .accordion-button::after,
[data-bs-theme="dark"] .accordion-button:not(.collapsed)::after {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23cbd9d4'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}
/* FAQ answer links keep an accent (verge gives them sea-anemone); lift to mineral.
 * Container id is #faq_accordion (the page directive id "faq" is NOT applied at runtime —
 * the layout hardcodes <body id="main">), so scope to #faq_accordion. */
[data-bs-theme="dark"] #faq_accordion .accordion-body a {
  color: var(--coastal-mineral);
}
[data-bs-theme="dark"] #faq_accordion .accordion-body a:hover {
  color: #ffffff;
}

/* ---- 3. Media kit brand swatches (views/media_kit.ejs) --------------------
 * The palette demo cards have FIXED brand-color backgrounds (they ARE the swatch
 * colors) and label the hex with `.text-deep-water`. The generic dark override
 * flips `.text-deep-water` to light text, so on the LIGHT swatches (seafoam,
 * shallow, mineral, patina, sunset) the label goes light-on-light. The swatch
 * backgrounds must NOT change (they demonstrate the brand color), so force the
 * label back to the dark brand ink on exactly those light swatches. */
[data-bs-theme="dark"] .card.bg-seafoam .text-deep-water,
[data-bs-theme="dark"] .card.bg-shallow .text-deep-water,
[data-bs-theme="dark"] .card.bg-patina .text-deep-water,
[data-bs-theme="dark"] .card.bg-sunset .text-deep-water,
[data-bs-theme="dark"] .card[style*="background-color: var(--coastal-seafoam"] .text-deep-water,
[data-bs-theme="dark"] .card[style*="background-color: var(--coastal-shallow"] .text-deep-water,
[data-bs-theme="dark"] .card[style*="background-color: var(--coastal-mineral"] .text-deep-water,
[data-bs-theme="dark"] .card[style*="background-color: var(--coastal-patina"] .text-deep-water {
  color: var(--coastal-deep-water) !important;
}

/* ---- 4. Adoptable pet detail modal (views/shelter_animals.ejs) ------------
 * bootstrap-verge.css forces this modal WHITE with brine ink via high-specificity
 * ID + !important rules (#modal_animal_details .modal-content / .modal-body) so it
 * stayed a jarring white panel with the wrong text colors in dark mode. (The view
 * also carried a redundant inline `#ffffff!important` on .modal-body that beat ALL
 * stylesheet !important — removed in this fix; light mode is unchanged because the
 * verge !important rules already paint it white+brine.) Repaint the modal surfaces
 * dark and lift the text. These dark rules out-specify the verge ID rules (extra
 * [data-bs-theme] attribute) AND load later, so they win in dark mode only. */
[data-bs-theme="dark"] #modal_animal_details .modal-content {
  background-color: var(--coastal-dark-surface) !important;
  color: var(--coastal-dark-text) !important;
}
/* Header: verge forces a light shallow (teal) bg + deep-water title + filter:none on
 * the close button via #modal_animal_details ID rules, so the header stayed light with
 * a near-invisible dark close-X sitting over the now-dark body. Repaint the header dark,
 * lift the title, and invert the close icon so it reads on the dark header. */
[data-bs-theme="dark"] #modal_animal_details .modal-header {
  background-color: var(--coastal-dark-elevated) !important;
  border-bottom-color: var(--coastal-dark-border) !important;
}
[data-bs-theme="dark"] #modal_animal_details .modal-title {
  color: var(--coastal-dark-text-strong) !important;
}
[data-bs-theme="dark"] #modal_animal_details .modal-header .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%) !important;
}
[data-bs-theme="dark"] #modal_animal_details .modal-body {
  background-color: var(--coastal-dark-surface) !important;
  color: var(--coastal-dark-text) !important;
}
/* verge ships high-specificity ID rules that force dark ink on these even in dark mode:
 *   `.modal-body .text-brine { color: brine !important }` (line 2653) and
 *   `.modal-body .fw-bold   { color: deep-water !important }` (line 2669, the "Adoption
 *    Fee" heading + bold labels). Both out-rank the generic dark overrides, so beat them
 * here with the matching #id specificity. (The fee AMOUNT span is governed by verge's
 * even-higher `span:not(.badge):not(.text-white){color:inherit}` rule and inherits the
 * dark body color, so it lifts automatically.) */
[data-bs-theme="dark"] #modal_animal_details .modal-body p,
[data-bs-theme="dark"] #modal_animal_details .modal-body h3,
[data-bs-theme="dark"] #modal_animal_details .modal-body h4,
[data-bs-theme="dark"] #modal_animal_details .modal-body h5,
[data-bs-theme="dark"] #modal_animal_details .modal-body h6,
[data-bs-theme="dark"] #modal_animal_details .modal-body strong,
[data-bs-theme="dark"] #modal_animal_details .modal-body small,
[data-bs-theme="dark"] #modal_animal_details .modal-body label,
[data-bs-theme="dark"] #modal_animal_details .modal-body .text-brine,
[data-bs-theme="dark"] #modal_animal_details .modal-body small.text-brine,
[data-bs-theme="dark"] #modal_animal_details .modal-body .fw-bold {
  color: var(--coastal-dark-text) !important;
}
/* Adoption-fee box (.bg-light) keeps a slightly elevated dark surface + light text. */
[data-bs-theme="dark"] #modal_animal_details .modal-body .bg-light {
  background-color: var(--coastal-dark-elevated) !important;
  color: var(--coastal-dark-text) !important;
}
[data-bs-theme="dark"] #modal_animal_details .modal-footer.bg-light {
  background-color: var(--coastal-dark-elevated) !important;
}

/* ---- 5. Google Maps InfoWindow / directions box (views/partials/map_partial.ejs)
 * Google renders the InfoWindow with its own WHITE background but the injected
 * content inherits the page text color (light in dark mode) and the "Get Directions"
 * <a> inherits the dark-mode mineral link color - both light-on-white. Google keeps
 * the box white, so force the InfoWindow text + link back to dark ink. */
[data-bs-theme="dark"] .gm-style .gm-style-iw,
[data-bs-theme="dark"] .gm-style .gm-style-iw-d,
[data-bs-theme="dark"] .gm-style .gm-style-iw * {
  color: var(--coastal-deep-water);
}
[data-bs-theme="dark"] .gm-style .gm-style-iw a {
  color: var(--coastal-sea-anemone);
}
[data-bs-theme="dark"] .gm-style .gm-style-iw a:hover {
  color: #c2174f;
}

/* ---- 6. [project-wide sweep] Donation amount/type buttons (views/donations.ejs)
 * Page-local <style> hardcodes `background:#fff` + deep-water ink on the resting
 * `.donation-type-btn / .amount-btn / .monthly-btn`, so in dark mode they render as
 * jarring bright-white pills. Repaint the resting buttons to a dark surface + light
 * text. NOTE: the page-local <style> loads AFTER this file, so its equal-specificity
 * `.btn.active` rules would otherwise win by load order — re-assert the active states
 * here (dark-scoped → higher specificity) so the selected button stays readable no
 * matter the load order. Amount/monthly active is deep-water-on-white in light mode,
 * which blends into the dark page, so swap to a bright mineral pill on dark. */
[data-bs-theme="dark"] .donation-type-btn,
[data-bs-theme="dark"] .amount-btn,
[data-bs-theme="dark"] .monthly-btn {
  background: var(--coastal-dark-elevated);
  border-color: var(--coastal-dark-border);
  color: var(--coastal-dark-text-strong);
}
[data-bs-theme="dark"] .donation-type-btn:hover,
[data-bs-theme="dark"] .amount-btn:hover,
[data-bs-theme="dark"] .monthly-btn:hover {
  border-color: var(--coastal-mineral);
  color: var(--coastal-mineral);
  background: var(--coastal-dark-surface);
}
[data-bs-theme="dark"] .donation-type-btn.active {
  background: var(--coastal-sea-anemone);
  border-color: var(--coastal-sea-anemone);
  color: #ffffff;
}
[data-bs-theme="dark"] .amount-btn.active,
[data-bs-theme="dark"] .monthly-btn.active {
  background: var(--coastal-mineral);
  border-color: var(--coastal-mineral);
  color: var(--coastal-deep-water);
}

/* ---- 6b. [project-wide sweep] White success/error alert cards -------------
 * pet_alert_signup.ejs + newsletter_signup.ejs force `background-color:#ffffff`
 * with dark ink on their success/error alerts - readable but a jarring white card
 * in dark mode. Repaint to a dark surface; the status icons keep their own colors. */
[data-bs-theme="dark"] #alert_success,
[data-bs-theme="dark"] #alert_error,
[data-bs-theme="dark"] #newsletter_success,
[data-bs-theme="dark"] #newsletter_error {
  background-color: var(--coastal-dark-surface) !important;
  color: var(--coastal-dark-text-strong) !important;
  border: 1px solid var(--coastal-dark-border) !important;
}

/* ---- 6c. [quick 260603-oqt] 404 page coastal restyle ----------------------
 * views/404.ejs frames its rotating ASCII art in a hardcoded white panel
 * (#ffffff) with deep-water (#042642) ink, sitting on a light seafoam->shallow
 * gradient. In dark mode the white panel + deep-water text would be a glaring
 * light card and the heading/art ink would be near-invisible on dark chrome.
 * Repaint the surface to a dark panel, lift the ink to the strong text token,
 * and dim the light gradient to the dark surface so the page reads cleanly.
 * The .btn .btn-primary home button is already theme-handled globally. */
[data-bs-theme="dark"] .pet-404 {
  background: linear-gradient(180deg, var(--coastal-dark-bg) 0%, var(--coastal-dark-surface) 100%);
}
[data-bs-theme="dark"] .pet-404 h1,
[data-bs-theme="dark"] .pet-404 h2,
[data-bs-theme="dark"] .pet-404 .ascii-art {
  color: var(--coastal-dark-text-strong);
}
[data-bs-theme="dark"] .pet-404 .subtitle,
[data-bs-theme="dark"] .pet-404 .ascii-caption {
  color: var(--coastal-dark-text-muted);
}
[data-bs-theme="dark"] .pet-404 .ascii-panel {
  background: var(--coastal-dark-elevated);
  border-color: var(--coastal-dark-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
[data-bs-theme="dark"] .pet-404 .shuffle-btn {
  background: var(--coastal-dark-surface);
  border-color: var(--coastal-kelp);
  color: var(--coastal-dark-text);
}
[data-bs-theme="dark"] .pet-404 .shuffle-btn:hover {
  background: var(--coastal-kelp);
  border-color: var(--coastal-kelp);
  color: #fff;
}
