/* RingerDB-Watcher — gemeinsames Stylesheet für Dashboard, Login und Ticker. */

:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #898781;
  --grid: #e1e0d9;
  --line: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);

  --gut: #0ca30c;
  --warn: #fab219;
  --ernst: #ec835a;
  --kritisch: #d03b3b;

  --rot: #d03b3b;
  --blau: #2a78d6;
  --akzent: #2a78d6;

  --r: 10px;
  --schatten: 0 1px 2px rgba(11, 11, 11, .05), 0 4px 12px rgba(11, 11, 11, .04);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --plane: #0d0d0d;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --ink-muted: #898781;
    --grid: #2c2c2a;
    --line: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --rot: #e66767;
    --blau: #3987e5;
    --akzent: #3987e5;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --plane: #0d0d0d;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --ink-muted: #898781;
  --grid: #2c2c2a;
  --line: #383835;
  --ring: rgba(255, 255, 255, 0.10);
  --rot: #e66767;
  --blau: #3987e5;
  --akzent: #3987e5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.15rem; }
h2 { font-size: 1rem; }
h3 { font-size: .875rem; }
a { color: var(--akzent); }

button, select, input {
  font: inherit;
  color: inherit;
}

button {
  background: var(--surface-1);
  border: 1px solid var(--ring);
  border-radius: 8px;
  padding: .4rem .7rem;
  cursor: pointer;
}
button:hover { border-color: var(--line); }
button.primaer {
  background: var(--akzent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
button.primaer:hover { filter: brightness(1.08); }
button.still { background: transparent; border-color: transparent; color: var(--ink-2); }
button.still:hover { background: var(--grid); }
button[aria-pressed="true"] { background: var(--akzent); color: #fff; border-color: transparent; }

input[type="text"], input[type="password"], input[type="search"], input[type="number"], select {
  background: var(--surface-1);
  border: 1px solid var(--ring);
  border-radius: 8px;
  padding: .45rem .6rem;
  min-width: 0;
}
input:focus-visible, button:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--akzent);
  outline-offset: 2px;
}

/* --- Kopfzeile ----------------------------------------------------------- */

.kopf {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
  padding: .6rem 1rem;
  background: var(--surface-1);
  border-bottom: 1px solid var(--grid);
}
.kopf .marke { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.kopf .luecke { flex: 1 1 auto; }

.puls {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-muted);
  flex: none;
}
.puls.live { background: var(--gut); animation: pulsieren 2s ease-in-out infinite; }
.puls.fehler { background: var(--kritisch); }
@keyframes pulsieren { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }

.inhalt { padding: 1rem; max-width: 1600px; margin: 0 auto; }

/* --- Karten & Kacheln ----------------------------------------------------- */

.karte {
  background: var(--surface-1);
  border: 1px solid var(--ring);
  border-radius: var(--r);
  box-shadow: var(--schatten);
}
.karte > header {
  display: flex; align-items: center; gap: .5rem;
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--grid);
}
.karte > header .luecke { flex: 1 1 auto; }
.karte > .rumpf { padding: .9rem; }

.kacheln {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .6rem;
}
.kachel {
  background: var(--surface-1);
  border: 1px solid var(--ring);
  border-radius: var(--r);
  padding: .7rem .8rem;
}
.kachel .wert { font-size: 1.6rem; font-weight: 680; line-height: 1.1; }
.kachel .etikett { color: var(--ink-2); font-size: .78rem; margin-top: .15rem; }

/* --- Abzeichen ------------------------------------------------------------ */

.abz {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .12rem .45rem;
  border-radius: 999px;
  font-size: .75rem; font-weight: 600;
  border: 1px solid var(--ring);
  white-space: nowrap;
}
.abz.gut { color: #006300; border-color: color-mix(in oklab, var(--gut) 45%, transparent); background: color-mix(in oklab, var(--gut) 12%, transparent); }
.abz.warn { color: #7a5200; border-color: color-mix(in oklab, var(--warn) 55%, transparent); background: color-mix(in oklab, var(--warn) 18%, transparent); }
.abz.kritisch { color: var(--kritisch); border-color: color-mix(in oklab, var(--kritisch) 45%, transparent); background: color-mix(in oklab, var(--kritisch) 12%, transparent); }
.abz.neutral { color: var(--ink-2); background: var(--grid); }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .abz.gut { color: var(--gut); }
  :root:where(:not([data-theme="light"])) .abz.warn { color: var(--warn); }
}
:root[data-theme="dark"] .abz.gut { color: var(--gut); }
:root[data-theme="dark"] .abz.warn { color: var(--warn); }

/* --- Ringer-Karten (Watchlist) ------------------------------------------- */

.ringer-gitter {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: .7rem;
}

.ringer {
  background: var(--surface-1);
  border: 1px solid var(--ring);
  border-left: 4px solid var(--line);
  border-radius: var(--r);
  padding: .7rem .8rem;
  box-shadow: var(--schatten);
}
.ringer.aufMatte { border-left-color: var(--kritisch); }
.ringer.gleich { border-left-color: var(--warn); }
.ringer.wartet { border-left-color: var(--blau); }
.ringer.fertig { border-left-color: var(--gut); }
.ringer.ungeplant, .ringer.ohneKampf { border-left-color: var(--line); }

.ringer.aufMatte { animation: aufmerksam 1.6s ease-in-out infinite; }
@keyframes aufmerksam {
  0%, 100% { box-shadow: var(--schatten); }
  50% { box-shadow: 0 0 0 3px color-mix(in oklab, var(--kritisch) 30%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .ringer.aufMatte { animation: none; box-shadow: 0 0 0 2px color-mix(in oklab, var(--kritisch) 40%, transparent); }
  .puls.live { animation: none; }
}

.ringer .name { font-weight: 650; }
.ringer .meta { color: var(--ink-2); font-size: .8rem; }
.ringer .zeile { display: flex; align-items: baseline; gap: .4rem; flex-wrap: wrap; }
.ringer .einsatz {
  margin-top: .5rem; padding-top: .5rem;
  border-top: 1px dashed var(--grid);
  font-size: .85rem;
}
.ringer .gross { font-size: 1.25rem; font-weight: 680; }

/* --- Kampfzeilen ---------------------------------------------------------- */

.kampf {
  display: grid;
  grid-template-columns: 3.2rem 1fr auto 1fr 4.2rem;
  gap: .5rem;
  align-items: center;
  padding: .4rem .5rem;
  border-bottom: 1px solid var(--grid);
  font-size: .875rem;
}
.kampf:last-child { border-bottom: 0; }
.kampf .nr { color: var(--ink-muted); font-variant-numeric: tabular-nums; font-size: .8rem; }
.kampf .seite { min-width: 0; }
.kampf .seite.r { color: var(--rot); }
.kampf .seite.b { color: var(--blau); text-align: right; }
.kampf .seite .n { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kampf .seite .v { color: var(--ink-2); font-size: .78rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kampf .stand { font-variant-numeric: tabular-nums; font-weight: 650; text-align: center; white-space: nowrap; }
.kampf .info { color: var(--ink-muted); font-size: .75rem; text-align: right; }
.kampf .sieg { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.kampf.beobachtet { background: color-mix(in oklab, var(--warn) 10%, transparent); }
.kampf.laeuft { background: color-mix(in oklab, var(--kritisch) 8%, transparent); }

/* --- Matten --------------------------------------------------------------- */

.matten { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .7rem; }
.matte header { display: flex; align-items: center; gap: .5rem; }
.matte .mattenNr {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.8rem; height: 1.8rem; border-radius: 8px;
  background: var(--akzent); color: #fff; font-weight: 700;
}
.matte .liste { max-height: 320px; overflow: auto; }

/* --- Tabellen ------------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--grid); }
th { color: var(--ink-2); font-weight: 600; font-size: .78rem; }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; }
tr.beobachtet td { background: color-mix(in oklab, var(--warn) 10%, transparent); font-weight: 600; }

.scrollbar { overflow-x: auto; }

/* --- Reiter --------------------------------------------------------------- */

.reiter { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--grid); margin-bottom: 1rem; }
.reiter button {
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  border-radius: 0; padding: .5rem .7rem; color: var(--ink-2); font-weight: 600;
}
.reiter button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--akzent); }

/* --- Sonstiges ------------------------------------------------------------ */

.stapel { display: grid; gap: 1rem; }
.reihe { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.leer { color: var(--ink-2); padding: 1.2rem; text-align: center; }
.klein { font-size: .8rem; color: var(--ink-2); }
.hinweis {
  border-left: 3px solid var(--warn);
  background: color-mix(in oklab, var(--warn) 10%, transparent);
  padding: .6rem .8rem; border-radius: 0 8px 8px 0;
}
.fehlerbox {
  border-left: 3px solid var(--kritisch);
  background: color-mix(in oklab, var(--kritisch) 10%, transparent);
  padding: .6rem .8rem; border-radius: 0 8px 8px 0;
}
.versteckt { display: none !important; }

.fortschritt { height: 6px; background: var(--grid); border-radius: 999px; overflow: hidden; }
.fortschritt > i { display: block; height: 100%; background: var(--akzent); border-radius: 999px; }

/* Login */
.login-huelle { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.login-karte { width: min(380px, 100%); }
