/* RS-DM06.4 — Manual Light/Dark and dark-green foreground normalization.
   Loaded last. It targets text-bearing content on known dark-green surfaces
   and deliberately keeps explicitly light controls readable with dark ink. */

html[data-theme="dark"] body:is(.admin-body, .public-shell, .auth-shell, .theme-scope-standalone) {
  --theme-text: #ffffff;
  --theme-text-soft: #ffffff;
  --theme-muted: #ffffff;
  --theme-placeholder: #ffffff;
  --theme-link: #ffffff;
  --theme-link-hover: #ffffff;
}

html[data-theme="dark"] body.admin-body :is(
  .app-sidebar-col, .app-top-controls, .sys-page-hero, .page-hero, .admin-hero,
  .hero-panel, .hero-card, .vc-hero, .sh-hero, .dq-hero, .filter-panel,
  .summary-panel, .status-card, .card, .panel, .modal-content, .dropdown-menu,
  .offcanvas, .table, table.dataTable, .dataTables_wrapper, pre, code
),
html[data-theme="dark"] body.public-shell :is(
  .public-navbar, .public-mobile-sheet, .public-footer, .public-page-hero,
  .page-hero, .hero, .hero-card, .content-card, .section-card, .panel, .card,
  .map-shell, .herb-viz-status, .public-map-sidebar, .public-search-panel
),
html[data-theme="dark"] body.auth-shell :is(
  .login-showcase, .login-card, .system-state-main, .system-state-aside
),
html[data-theme="dark"] body.theme-scope-standalone :is(
  .dashboard-head, .dashboard-filter, .card, .panel, .kpi, .table, .modal-content
) {
  color: #ffffff;
}

html[data-theme="dark"] body.admin-body :is(
  .app-sidebar-col, .app-top-controls, .sys-page-hero, .page-hero, .admin-hero,
  .hero-panel, .hero-card, .vc-hero, .sh-hero, .dq-hero, .filter-panel,
  .summary-panel, .status-card, .card, .panel, .modal-content, .dropdown-menu,
  .offcanvas, .table, table.dataTable, .dataTables_wrapper, pre, code
) :is(
  h1,h2,h3,h4,h5,h6,p,span,small,label,legend,a,button,input,select,textarea,option,
  li,dt,dd,th,td,strong,b,em,i,.fa,.fa-solid,.fa-regular,.fa-brands,
  .text-muted,.text-secondary,.form-text,.help-text,.description,.subtitle,.caption,
  .form-control,.form-select,.input-group-text,.page-link,.dropdown-item
) {
  color: #ffffff;
}

html[data-theme="dark"] body.public-shell :is(
  .public-navbar, .public-mobile-sheet, .public-footer, .public-page-hero,
  .page-hero, .hero, .hero-card, .content-card, .section-card, .panel, .card,
  .map-shell, .herb-viz-status, .public-map-sidebar, .public-search-panel
) :is(
  h1,h2,h3,h4,h5,h6,p,span,small,label,legend,a,button,input,select,textarea,option,
  li,dt,dd,th,td,strong,b,em,i,.fa,.fa-solid,.fa-regular,.fa-brands,
  .text-muted,.text-secondary,.form-text,.help-text,.description,.subtitle,.caption,
  .form-control,.form-select,.input-group-text,.page-link,.dropdown-item
) {
  color: #ffffff;
}

html[data-theme="dark"] body.auth-shell :is(
  .login-showcase, .login-card, .system-state-main, .system-state-aside
) :is(
  h1,h2,h3,h4,h5,h6,p,span,small,label,legend,a,button,input,select,textarea,
  li,strong,b,em,i,.fa,.fa-solid,.fa-regular,.fa-brands,
  .login-showcase__desc,.login-feature__desc,.login-card__desc,.login-helper,.login-meta,
  .form-control,.form-select,.input-group-text
) {
  color: #ffffff;
}

html[data-theme="dark"] body.theme-scope-standalone :is(
  .dashboard-head, .dashboard-filter, .card, .panel, .kpi, .table, .modal-content
) :is(
  h1,h2,h3,h4,h5,h6,p,span,small,label,legend,a,button,input,select,textarea,option,
  li,dt,dd,th,td,strong,b,em,i,.text-muted,.text-secondary,.form-text,.page-link
) {
  color: #ffffff;
}

html[data-theme="dark"] body:is(.admin-body, .public-shell, .auth-shell, .theme-scope-standalone) :is(input, textarea)::placeholder {
  color: #ffffff;
  opacity: 1;
}

/* Preserve readable dark ink only when the component owns a light/bright
   background rather than inheriting the surrounding dark-green surface. */
html[data-theme="dark"] body:is(.admin-body, .public-shell, .auth-shell, .theme-scope-standalone) :is(
  .btn-light, .btn-warning, .badge.text-bg-light, .badge.text-bg-warning,
  .bg-light, .bg-warning, .alert-warning, .alert-light,
  .dropdown-item.active, .page-item.active .page-link
),
html[data-theme="dark"] body:is(.admin-body, .public-shell, .auth-shell, .theme-scope-standalone) :is(
  .btn-light, .btn-warning, .badge.text-bg-light, .badge.text-bg-warning,
  .bg-light, .bg-warning, .alert-warning, .alert-light,
  .dropdown-item.active, .page-item.active .page-link
) * {
 /* color: #10251b; */
}

body.public-shell.page-public-home #main-content .sh-hero__caption {
  background: linear-gradient(135deg, #0b4a33, #146c4e);
  color: #ffffff;
}

html[data-theme="dark"] body.public-shell.page-public-home #main-content .sh-hero__caption,
body.public-shell.page-public-home.theme-dark #main-content .sh-hero__caption {
  background: #0b3025;
  color: #ffffff;
}

/* Public mobile sheet: the selected theme and login card use a bright mint
   surface in dark mode. Keep every nested text node on the same dark-ink
   contract as its parent instead of inheriting the global white override. */
body.public-shell .public-mobile-sheet
  .public-theme-segmented button[aria-pressed="true"] :is(strong, span) {
  color: inherit;
}

html[data-theme="dark"] body.public-shell .public-mobile-sheet
  a.public-mobile-sheet__login :is(strong, small, span),
body.public-shell.theme-dark .public-mobile-sheet
  a.public-mobile-sheet__login :is(strong, small, span) {
  color: #061f16;
}
