/* Dunkelmodus „Hüttenabend“ für den Bestand (Designkonzept 1.0, Freigabe Oliver
   06.11.: sofort, über prefers-color-scheme). Die Token selbst stehen in
   tokens.css. Diese Datei fängt fest eingetragene helle Farben aus älteren
   Vorlagen ab (Inline-Styles, Divi-Rahmen), bis sie auf Token umgestellt sind.
   Abschalten: Konstante EMOVE_DARK_MODE false (Klasse em-no-dark am <html>). */

@media (prefers-color-scheme: dark) {
  /* Divi-Rahmen */
  html:not(.em-no-dark) body,
  html:not(.em-no-dark) #page-container,
  html:not(.em-no-dark) #main-content,
  html:not(.em-no-dark) .et_pb_section,
  html:not(.em-no-dark) .et-l--footer .et_pb_section,
  html:not(.em-no-dark) .et_pb_row { background-color: transparent; }
  html:not(.em-no-dark) body { background: var(--em-bg) !important; color: var(--em-text); }
  html:not(.em-no-dark) #main-content .entry-content,
  html:not(.em-no-dark) .et_pb_text_inner { color: var(--em-text); }
  html:not(.em-no-dark) .et-l--footer { background: var(--em-surface); }
  html:not(.em-no-dark) .et-l--footer a { color: var(--em-muted) !important; }

  /* Inline-Styles älterer Vorlagen: helle Flächen → Flächen-Token */
  html:not(.em-no-dark) [style*="background:#fff;"], html:not(.em-no-dark) [style*="background: #fff;"],
  html:not(.em-no-dark) [style*="background:#fff\""], html:not(.em-no-dark) [style*="background:#ffffff"],
  html:not(.em-no-dark) [style*="background: #ffffff"], html:not(.em-no-dark) [style*="background:white"],
  html:not(.em-no-dark) [style*="background-color:#fff"], html:not(.em-no-dark) [style*="background: white"] {
    background: var(--em-surface) !important;
  }
  html:not(.em-no-dark) [style*="background:#f8fafc"], html:not(.em-no-dark) [style*="background: #f8fafc"],
  html:not(.em-no-dark) [style*="background:#f1f5f9"], html:not(.em-no-dark) [style*="background: #f1f5f9"],
  html:not(.em-no-dark) [style*="background:#f9fafb"], html:not(.em-no-dark) [style*="background:#f3f4f6"],
  html:not(.em-no-dark) [style*="background:#f6f7f8"], html:not(.em-no-dark) [style*="background:#fafafa"] {
    background: var(--em-surface2) !important;
  }
  html:not(.em-no-dark) [style*="background:#f0fdf4"], html:not(.em-no-dark) [style*="background:#ecfdf3"],
  html:not(.em-no-dark) [style*="background:#dcfce7"] { background: var(--em-green-soft) !important; }
  html:not(.em-no-dark) [style*="background:#fef3c7"], html:not(.em-no-dark) [style*="background:#fffbeb"],
  html:not(.em-no-dark) [style*="background:#fff7ed"] { background: var(--em-notice-soft) !important; }
  html:not(.em-no-dark) [style*="background:#fef2f2"], html:not(.em-no-dark) [style*="background:#fee2e2"] { background: var(--em-danger-soft) !important; }
  html:not(.em-no-dark) [style*="background:#eff6ff"], html:not(.em-no-dark) [style*="background:#e6ecf5"] { background: var(--em-surface2) !important; }

  /* Inline-Schriftfarben: dunkle Töne → Tinte/Text, Grautöne → gedämpft */
  html:not(.em-no-dark) [style*="color:#0f172a"], html:not(.em-no-dark) [style*="color: #0f172a"],
  html:not(.em-no-dark) [style*="color:#1e293b"], html:not(.em-no-dark) [style*="color: #1e293b"],
  html:not(.em-no-dark) [style*="color:#0f2a57"], html:not(.em-no-dark) [style*="color:#0F2A57"],
  html:not(.em-no-dark) [style*="color:#1a2d5a"], html:not(.em-no-dark) [style*="color:#050047"],
  html:not(.em-no-dark) [style*="color:#111"], html:not(.em-no-dark) [style*="color:#16264F"] { color: var(--em-ink) !important; }
  html:not(.em-no-dark) [style*="color:#334155"], html:not(.em-no-dark) [style*="color: #334155"],
  html:not(.em-no-dark) [style*="color:#374151"], html:not(.em-no-dark) [style*="color:#333"],
  html:not(.em-no-dark) [style*="color:#444"], html:not(.em-no-dark) [style*="color:#475569"] { color: var(--em-text) !important; }
  html:not(.em-no-dark) [style*="color:#64748b"], html:not(.em-no-dark) [style*="color: #64748b"],
  html:not(.em-no-dark) [style*="color:#94a3b8"], html:not(.em-no-dark) [style*="color: #94a3b8"],
  html:not(.em-no-dark) [style*="color:#666"], html:not(.em-no-dark) [style*="color:#888"],
  html:not(.em-no-dark) [style*="color:#6b7280"], html:not(.em-no-dark) [style*="color:#9ca3af"],
  html:not(.em-no-dark) [style*="color:#647067"] { color: var(--em-muted) !important; }
  html:not(.em-no-dark) [style*="border:1px solid #e2e8f0"], html:not(.em-no-dark) [style*="border: 1px solid #e2e8f0"],
  html:not(.em-no-dark) [style*="border:1px solid #e5e7eb"], html:not(.em-no-dark) [style*="border-bottom:1px solid #f1f5f9"],
  html:not(.em-no-dark) [style*="border-bottom:1px solid #e2e8f0"], html:not(.em-no-dark) [style*="border:1px solid #dfe7e2"] { border-color: var(--em-line) !important; }

  /* Tabellen und Formulare */
  html:not(.em-no-dark) table, html:not(.em-no-dark) th, html:not(.em-no-dark) td { border-color: var(--em-line); }
  html:not(.em-no-dark) input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]),
  html:not(.em-no-dark) select, html:not(.em-no-dark) textarea {
    background: var(--em-surface); color: var(--em-text); border-color: var(--em-line-strong);
  }
  /* Karten-Kacheln (MapLibre) nicht einfärben, Bilder nicht abdunkeln */
  html:not(.em-no-dark) .maplibregl-map { color-scheme: light; }

  /* Cookie-Banner (Complianz): Das Plugin setzt seine Farben als Variablen auf
     :root (uploads/complianz/css/banner-*.css). Hier im Dunkelmodus auf Token
     umbiegen (html:not(...) ist spezifischer als :root); hell bleibt unverändert. */
  html:not(.em-no-dark) {
    --cmplz_banner_background_color: var(--em-surface);
    --cmplz_banner_border_color: var(--em-line);
    --cmplz_text_color: var(--em-text);
    --cmplz_hyperlink_color: var(--em-green-text);
    --cmplz_button_deny_background_color: var(--em-surface2);
    --cmplz_button_deny_border_color: var(--em-line-strong);
    --cmplz_button_deny_text_color: var(--em-text);
    --cmplz_button_settings_background_color: var(--em-surface2);
    --cmplz_button_settings_border_color: var(--em-line-strong);
    --cmplz_button_settings_text_color: var(--em-text);
    --cmplz_category_header_always_active_color: var(--em-green-text);
  }
  html:not(.em-no-dark) .cmplz-cookiebanner { background: var(--em-surface) !important; color: var(--em-text) !important; box-shadow: 0 0 0 1px var(--em-line); }
  html:not(.em-no-dark) .cmplz-cookiebanner .cmplz-categories .cmplz-category { background-color: var(--em-surface2); }
  html:not(.em-no-dark) .cmplz-cookiebanner .cmplz-close,
  html:not(.em-no-dark) .cmplz-cookiebanner .cmplz-icon { color: var(--em-text); }
  html:not(.em-no-dark) .cmplz-cookiebanner .cmplz-icon svg path { fill: currentColor; }
}
