/* ============================================================
   stats.css — Statistik-Screen (js/screens/stats.js)

   Diagramm-Regeln, die hier als Farbwerte hängen:

   - Sequentielle Rampe (Zeitraster): EIN Farbton, vier Stufen,
     hell → dunkel. Die Stufen sind geprüft (monotone Helligkeit,
     Abstand je Stufe ≥ 0.06, helle Stufe 2.11:1 gegen Weiß) –
     --fando-100/-200 taugen dafür NICHT: Sie liegen nur 0.037
     auseinander und die hellere verschwindet mit 1.17:1 auf Weiß.
     Als Flächen-Tint bleiben sie richtig, als Datenfläche nicht.
   - Divergierende Pole (Direktduell): Fando-Grün gegen #8f2f1f.
     NICHT --danger (#c2462f): das liegt unter Deuteranopie bei
     ΔE 2.7 zum Grün – für Rot-Grün-Blinde dieselbe Farbe. Das
     dunklere Rot kommt auf 14.7 und besteht alle Prüfungen.
   ============================================================ */

:root {
  --st-heat-1: #8fc074;
  --st-heat-2: #5f9e3a;
  --st-heat-3: #417a20;
  --st-heat-4: #2d5415;
  --st-neg:    #8f2f1f;
}

/* ---------------- Zeitraum-Filter ---------------- */

.st-filters {
  display: flex; gap: 6px; margin-bottom: var(--sp-4);
  background: var(--stone-100); padding: 3px; border-radius: var(--r-pill);
}
.st-filters button {
  flex: 1; font-family: inherit; font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  color: var(--text-muted); background: none; border: 0; padding: 8px 4px;
  border-radius: var(--r-pill); cursor: pointer;
  transition: background var(--dur-2) var(--ease-standard), color var(--dur-2) var(--ease-standard);
}
.st-filters button[aria-pressed="true"] {
  background: var(--surface); color: var(--ink-800); box-shadow: var(--shadow-xs);
}

/* ---------------- Karte ---------------- */

.st-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-sm);
  padding: var(--sp-4); margin-bottom: var(--sp-3);
}
.st-t { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); }
.st-t h3 { font-size: var(--fs-md); font-weight: var(--fw-bold); letter-spacing: -0.01em; }
.st-t .meta { font-size: var(--fs-2xs); color: var(--text-subtle); white-space: nowrap; }
.st-s { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.45; margin-top: 3px; margin-bottom: var(--sp-3); }
.st-f {
  font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.45;
  margin-top: var(--sp-3); padding-top: 11px; border-top: 1px solid var(--divider);
}
.st-f b { color: var(--ink-700); font-weight: var(--fw-semibold); }
.st-card .empty { padding: var(--sp-4) 0; }

/* ---------------- Quote + Kennzahlen ---------------- */

.st-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-3); }
.st-hero-v {
  /* Proportionale Ziffern: tabular-nums lässt eine grosse Zahl locker wirken. */
  font-size: 52px; font-weight: var(--fw-black); letter-spacing: -0.035em; line-height: .9;
}
.st-hero-v small { font-size: 22px; font-weight: var(--fw-bold); color: var(--text-subtle); letter-spacing: -0.02em; }
.st-hero-l { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 7px; }
.st-spark { flex: none; }

.st-kpis {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--divider); border-radius: var(--r-sm); overflow: hidden; margin-top: var(--sp-4);
}
.st-kpi { background: var(--surface); padding: 10px 6px; text-align: center; }
.st-kpi .v { font-size: var(--fs-lg); font-weight: var(--fw-bold); letter-spacing: -0.02em; }
.st-kpi .l { font-size: var(--fs-2xs); color: var(--text-subtle); margin-top: 2px; }

/* ---------------- Die letzten Spiele ----------------

   Der Streifen ist die Kurzfassung (ein Strich je Spiel, ältestes links),
   die Liste darunter das Kleingedruckte. Niederlagen bekommen KEIN Rot:
   Es sind zwanzig gewöhnliche Spiele, keine zwanzig Fehler – grau reicht,
   um „kein Sieg“ zu sagen. Ein Minus bei den Punkten steht dagegen sehr
   wohl in Danger, denn dort ist tatsächlich etwas abgegangen. */

.st-strip { display: flex; gap: 3px; margin-top: var(--sp-4); }
.st-strip i {
  flex: 1 1 0; min-width: 0; height: 10px; border-radius: 3px;
  background: var(--stone-200); display: block;
}
.st-strip i.w { background: var(--fando); }
.st-strip-ax {
  display: flex; justify-content: space-between;
  margin-top: 5px; font-size: 10px; color: var(--text-subtle);
}

.st-games { display: flex; flex-direction: column; margin-top: var(--sp-3); }
.st-g {
  display: grid; grid-template-columns: 26px 1fr auto 40px;
  align-items: center; gap: 10px;
  padding: 9px 0; border-top: 1px solid var(--divider);
}
.st-g:first-child { border-top: 0; padding-top: 2px; }
.st-g-r {
  width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center;
  font-size: var(--fs-2xs); font-weight: var(--fw-bold);
  background: var(--stone-100); color: var(--text-muted);
}
.st-g.w .st-g-r { background: var(--fando-100); color: var(--fando-700); }
.st-g-m { min-width: 0; }
.st-g-n { display: block; font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.st-g-s { display: block; font-size: var(--fs-2xs); color: var(--text-subtle); margin-top: 1px; }
.st-g-sc { font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--ink-700); white-space: nowrap; }
.st-g-sc i { font-style: normal; color: var(--stone-300); margin: 0 1px; }
.st-g-sc.empty { color: var(--stone-300); font-weight: var(--fw-semibold); }
/* Die Farbe folgt dem ERGEBNIS, nicht dem Vorzeichen: Auch eine
   Niederlage bringt in der Regel +1, grün gefärbt läse sich das wie ein
   kleiner Sieg. Nur ein echtes Minus ist Danger. */
.st-g-p { text-align: right; font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-muted); }
.st-g.w .st-g-p { color: var(--fando-700); }
.st-g .st-g-p.neg { color: var(--danger); }

.st-more {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  width: 100%; margin-top: 10px; padding: 9px 0;
  font-family: inherit; font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  color: var(--text-muted); background: var(--stone-100); border: 0;
  border-radius: var(--r-sm); cursor: pointer;
}
.st-more .icon-sm { transition: transform var(--dur-2) var(--ease-standard); }
.st-more.open .icon-sm { transform: rotate(180deg); }

/* ---------------- Punkteverlauf ---------------- */

.st-plot { display: block; width: 100%; height: auto; overflow: visible; }
/* Gitter und Achsen: durchgehende Haarlinien, eine Stufe vom Untergrund.
   Gestrichelt läse sich wie „Prognose“, ist aber nur ein Raster. */
.st-grid { stroke: var(--stone-200); stroke-width: 1; }
.st-now  { stroke: var(--stone-300); stroke-width: 1; }
.st-ax   { font-size: 10px; fill: var(--text-subtle); font-family: var(--font-sans); }
.st-lbl  { font-size: 11px; font-weight: 700; fill: var(--ink-700); font-family: var(--font-sans); }

/* ---------------- Balken je Spielart ---------------- */

.st-bars { display: flex; flex-direction: column; gap: 11px; }
.st-bar-row { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 10px; }
.st-bar-k { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--ink-700); }
.st-bar-k i { display: block; font-style: normal; font-size: var(--fs-2xs); color: var(--text-subtle); font-weight: var(--fw-regular); }
.st-bar-track { position: relative; height: 18px; display: flex; align-items: center; min-width: 0; }
/* 4px runde Datenkante, am Nullpunkt eckig – der Balken wächst aus der Achse. */
.st-bar-fill { height: 18px; background: var(--fando); border-radius: 0 4px 4px 0; }
.st-bar-v {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--ink-700);
}
.st-bar-empty { font-size: var(--fs-xs); color: var(--text-subtle); font-style: italic; }

/* ---------------- Direktduell ---------------- */

.st-switch {
  display: inline-flex; align-items: center; gap: 5px; font-family: inherit;
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold); color: var(--text-muted);
  background: none; border: 0; cursor: pointer; padding: 2px 0; white-space: nowrap;
}
.st-duels { display: flex; flex-direction: column; gap: 2px; }
.st-duel { display: grid; grid-template-columns: 96px 1fr 38px; align-items: center; gap: var(--sp-2); padding: 5px 0; }
.st-duel-n { display: flex; align-items: center; gap: 8px; min-width: 0; }
.st-duel-nm { display: flex; flex-direction: column; min-width: 0; }
.st-duel-nm b { font-size: var(--fs-xs); font-weight: var(--fw-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-tag {
  align-self: flex-start; margin-top: 2px; white-space: nowrap;
  font-size: 9px; font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 5px; border-radius: var(--r-xs); background: var(--stone-100); color: var(--ink-600);
}
.st-dv { position: relative; height: 16px; }
.st-dv .zero { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--stone-300); }
.st-dv i { position: absolute; top: 2px; height: 12px; display: block; }
.st-dv i.pos { left: 50%; margin-left: 1px; background: var(--fando); border-radius: 0 4px 4px 0; }
.st-dv i.neg { right: 50%; margin-right: 1px; background: var(--st-neg); border-radius: 4px 0 0 4px; }
.st-duel-b { font-size: var(--fs-xs); font-weight: var(--fw-bold); text-align: right; color: var(--ink-700); }

.st-legend { display: flex; align-items: center; gap: 14px; margin-top: 11px; font-size: var(--fs-2xs); color: var(--text-muted); }
.st-legend span { display: inline-flex; align-items: center; gap: 5px; }
.st-legend i { width: 9px; height: 9px; border-radius: 2px; display: block; }
.st-legend i.pos { background: var(--fando); }
.st-legend i.neg { background: var(--st-neg); }

/* Tabellen-Zwilling: derselbe Inhalt ohne Farbe als Träger. */
.st-tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
.st-tbl th {
  text-align: left; font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-subtle); font-weight: var(--fw-semibold); padding: 6px 4px;
  border-bottom: 1px solid var(--divider);
}
.st-tbl td { padding: 8px 4px; border-bottom: 1px solid var(--stone-100); }
.st-tbl td:first-child { font-weight: var(--fw-semibold); }
.st-tbl th.r, .st-tbl td.r { text-align: right; }
/* Nur in Spalten: gleich breite Ziffern lassen Zahlen untereinander fluchten. */
.st-tbl td.num { font-variant-numeric: tabular-nums; }

/* ---------------- Zeitraster ---------------- */

.st-hm { display: grid; grid-template-columns: 34px repeat(7, 1fr); gap: 2px; }
.st-hm-d { font-size: 9px; color: var(--text-subtle); text-align: center; padding-bottom: 2px; font-weight: var(--fw-semibold); }
.st-hm-r { font-size: 9px; color: var(--text-subtle); display: flex; align-items: center; }
.st-hm-c {
  aspect-ratio: 1; border-radius: 3px; display: grid; place-items: center;
  font-size: 10px; font-weight: var(--fw-bold); color: #fff;
  font-variant-numeric: tabular-nums;
}
/* Leer heisst leer: nur ein Rahmen, keine Füllung. */
.st-hm-c.e0, .st-hm-scale i.e0 { background: none; box-shadow: inset 0 0 0 1px var(--stone-200); }
.st-hm-c.e1, .st-hm-scale i.e1 { background: var(--st-heat-1); }
.st-hm-c.e2, .st-hm-scale i.e2 { background: var(--st-heat-2); }
.st-hm-c.e3, .st-hm-scale i.e3 { background: var(--st-heat-3); }
.st-hm-c.e4, .st-hm-scale i.e4 { background: var(--st-heat-4); }
/* Auf der hellsten Stufe wäre Weiss unlesbar – dort Tinte. */
.st-hm-c.e1 { color: var(--ink-800); }

.st-hm-scale { display: flex; align-items: center; gap: 4px; margin-top: 10px; font-size: var(--fs-2xs); color: var(--text-muted); }
.st-hm-scale i { width: 14px; height: 9px; border-radius: 2px; display: block; }

/* ---------------- Rekorde ---------------- */

.st-recs { display: flex; flex-direction: column; }
.st-rec { display: flex; align-items: center; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--stone-100); }
.st-rec:first-child { padding-top: 0; }
.st-rec:last-child { border-bottom: 0; padding-bottom: 0; }
.st-rec-i {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--fando-100); color: var(--fando-700); display: grid; place-items: center;
}
.st-rec-i .icon { width: 17px; height: 17px; }
.st-rec-palm { width: 15px; height: 18px; object-fit: contain; }
.st-rec-g { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.st-rec-t {
  font-size: var(--fs-2xs); color: var(--text-subtle); text-transform: uppercase;
  letter-spacing: .06em; font-weight: var(--fw-semibold);
}
.st-rec-v { font-size: var(--fs-sm); font-weight: var(--fw-bold); margin-top: 2px; }
.st-rec-v em { font-style: normal; font-weight: var(--fw-regular); color: var(--text-muted); }

/* ---------------- Einstieg vom Homescreen ----------------
   Die Bühnen-Scorecard ist jetzt ein Knopf. Sie soll aber NICHT wie
   einer aussehen – nur der Pfeil verrät, dass es weitergeht. */
.d5-score.tapable {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit;
  border: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* Der Pfeil ist eine eigene schmale Spalte am Ende der Reihe, NICHT
   absolut in die Ecke gesetzt: Dort lag er auf den Form-Punkten, die in
   der letzten Spalte bis an den Rand reichen. Als Spalte rückt die Reihe
   um seine Breite zusammen und er kann nie überlappen – auch nicht, wenn
   jemand fünf Formpunkte und eine vierstellige Zahl hat.
   Keine Trennlinie: `.d5-stat + .d5-stat` greift hier nicht, weil der
   Pfeil kein .d5-stat ist. */
.d5-score.tapable .d5-more {
  flex: none; display: flex; align-items: center; padding-left: 2px;
  color: rgba(255, 255, 255, 0.45);
}
.d5-score.tapable .d5-more .icon-sm { width: 15px; height: 15px; }
