/* features/theme.css — Besitzer: Feature "theme-undo" (Dark Mode + Undo-Toast).
   SSoT für die dunklen Farb-Tokens: hier werden NUR die CSS-Variablen aus
   style.css (:root) überschrieben. Das wirksame Theme setzt features/theme-boot.js
   vor dem ersten Paint als <html data-theme="light|dark"> (auch "System" wird dort
   über prefers-color-scheme aufgelöst) — deshalb genügt ein einziger Selektor und
   die Werte existieren nur einmal.
   Kontrast (WCAG, gegen --card #18181a): --ink 15.9:1, --ink-2 11.7:1,
   --muted 6.3:1, --good 8.5:1, --debt 7.5:1; auf --good-soft/--debt-soft/--bg-soft
   jeweils ≥ 5.6:1; Schrift auf Akzent/Grün/Rot ≥ 8.2:1 — alles ≥ AA (4.5:1). */

:root {
  /* Schrift auf Akzentflächen (schwarzer Button → weiße Schrift). Im Dark Mode
     wird der Akzent hell, die Schrift darauf dunkel. */
  --on-accent: #ffffff;
  --accent-hover: #000000;
  --line-strong: #d9d9d4;   /* Hover-Rahmen (style.css nutzt hier feste Farben) */
  --good-line: #cfe0d4;
  --debt-line: #e3c4be;
  --scrim: rgba(10, 10, 10, 0.45);
}

:root[data-theme="dark"] {
  color-scheme: dark;       /* native Formular-Elemente, Scrollbars, Datumswähler */

  --bg: #0e0e0f;
  --bg-soft: #1f1f21;
  --card: #18181a;
  --ink: #f3f3f0;
  --ink-2: #d2d2cd;
  --muted: #9a9a95;
  --line: #2c2c2f;

  --accent: #f3f3f0;        /* monochromer Akzent kehrt sich um: hell auf dunkel */
  --accent-soft: #2a2a2d;
  --on-accent: #0e0e0f;
  --accent-hover: #ffffff;
  --line-strong: #45454a;

  --good: #74c48f;
  --good-soft: #15261b;
  --good-line: #2b4a36;
  --debt: #ef8f80;
  --debt-soft: #2e1916;
  --debt-line: #5c2f28;

  --scrim: rgba(0, 0, 0, 0.62);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 18px 40px -28px rgba(0, 0, 0, 0.9);
}

/* ===== Gezielte Überschreibungen fester Farben aus style.css (nur Dark Mode) ===== */
/* Text auf Akzent-/Statusflächen */
:root[data-theme="dark"] .nav-btn.active .side-ico,
:root[data-theme="dark"] .btn.primary,
:root[data-theme="dark"] .toast-action { color: var(--on-accent); }
:root[data-theme="dark"] .btn.primary:hover,
:root[data-theme="dark"] .toast-action:hover { background: var(--accent-hover); }
/* Grün/Rot sind im Dark Mode heller → dunkle Schrift statt weißer (Kontrast > 7:1). */
:root[data-theme="dark"] .btn.good,
:root[data-theme="dark"] .btn.danger,
:root[data-theme="dark"] .sync-toast.error .toast-action { color: var(--on-accent); }

/* Hover-Rahmen */
:root[data-theme="dark"] .btn:hover,
:root[data-theme="dark"] .lang-trigger:hover,
:root[data-theme="dark"] .lang-opt:hover { border-color: var(--line-strong); }

/* Statusrahmen */
:root[data-theme="dark"] .btn.is-done,
:root[data-theme="dark"] .cal-cell.walked { border-color: var(--good-line); }
/* background hier erneut setzen: die Dark-Regel für .sync-toast weiter unten ist
   spezifischer als style.css' .sync-toast.error und würde sonst das Rot überdecken. */
:root[data-theme="dark"] .sync-toast.error { background: var(--debt-soft); border-color: var(--debt-line); }

/* Dialog-Hintergrund und Sidebar-Schatten */
:root[data-theme="dark"] .overlay,
:root[data-theme="dark"] .backdate-overlay { background: var(--scrim); }
:root[data-theme="dark"] .sidebar:hover { box-shadow: 28px 0 56px -34px rgba(0, 0, 0, 0.85); }

/* Toast hebt sich auf dunklem Grund sonst kaum ab */
:root[data-theme="dark"] .sync-toast { background: var(--bg-soft); border-color: var(--line-strong); }

/* Autofill (Chrome/Safari färbt sonst hellgelb) */
:root[data-theme="dark"] input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
  caret-color: var(--ink);
}

/* ===== Profil-Karte "Darstellung": Segment-Schalter System / Hell / Dunkel ===== */
.theme-seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 13px;
  margin-bottom: 12px;
}
.theme-opt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.theme-opt:hover { color: var(--ink); }
.theme-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-opt[aria-checked="true"] {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.theme-opt svg { width: 17px; height: 17px; flex: 0 0 auto; display: block; }
.theme-opt-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Schmale Geräte: Icon über dem Text, damit lange Übersetzungen nicht abschneiden. */
@media (max-width: 400px) {
  .theme-opt { flex-direction: column; gap: 4px; font-size: 12.5px; padding: 9px 4px; }
}

/* ===== Undo-Toast ===== */
/* Langer Text darf umbrechen, der Button bleibt rechts (Toast ist max. 100vw − 44px). */
.sync-toast.has-action .toast-text { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) {
  /* Phone: Toast über die volle Breite mit 16-px-Rändern (kein horizontales Scrollen). */
  .sync-toast.has-action { left: 16px; right: 16px; bottom: 16px; max-width: none; justify-content: space-between; }
}
