/* ===========================================================================
   basis.css — gemeinsames Grundgerüst für alle 24ws-Projekte
   ---------------------------------------------------------------------------
   Diese Datei enthält NUR Bausteine, die in jedem Projekt gleich sind:
   Knöpfe, Formularfelder, Listen, Meldungen, Bottom-Tabs, Overlays.

   Sie benutzt ausschliesslich die Variablen, die eine Farbwelt setzt
   (farbwelt/*.css) und die Dichte, die ein Aufbau setzt (aufbau/*.css).
   Deshalb wirkt jede Farbwelt auf jeden Aufbau, ohne dass hier etwas
   geändert werden muss.

   Einbindereihenfolge — wichtig, sonst greifen Überschreibungen nicht:
     1. farbwelt/<name>.css
     2. basis.css
     3. aufbau/<name>.css

   Kein Build-Step, keine externen Schriften, keine CDNs.
   ========================================================================= */

/* ---------------------------------------------------------------------------
   Fallback-Werte. Eine Farbwelt überschreibt sie; fehlt sie, sieht es trotzdem
   ordentlich aus statt kaputt.

   Warum :where(:root) und nicht einfach :root?
   :where() hat die Gewichtung null. Damit gewinnt JEDE Farbwelt, egal in
   welcher Reihenfolge die Dateien eingebunden sind. Mit einem normalen :root
   hätten beide dieselbe Gewichtung und die zuletzt geladene Datei würde
   gewinnen - dann wäre die Farbwelt je nach Reihenfolge wirkungslos, und der
   Fehler sieht aus wie "das Design lädt nicht".
   ------------------------------------------------------------------------- */
:where(:root) {
  --hg:            #f4f5f6;
  --flaeche:       #ffffff;
  --flaeche2:      #f7f9fa;
  --rand:          #d3d7db;
  --rand-fein:     #e8ebee;
  --text:          #1c2126;
  --schwach:       #5d666e;
  --akzent:        #0b5cab;
  --akzent-text:   #ffffff;

  /* Für dunkle Zonen: Seitenleiste (Konsole), Kopfband (Werkbank),
     Kontextspalte (Formularstrasse). In dunklen Farbwelten sind das die
     noch dunkleren Töne. */
  --dunkel:         #1a1f24;
  --dunkel-flaeche: #262d34;
  --dunkel-text:    #ffffff;
  --dunkel-schwach: #98a3ad;

  --erfolg: #1c7a45;
  --warn:   #c2740a;
  --fehler: #c0392b;

  --radius:       4px;
  --radius-gross: 8px;
  --schatten:     none;

  /* Schriften immer selbst hosten (woff2 im Projekt) und hier eintragen.
     Nie Google Fonts – sonst fliessen Besucher-IPs zu Dritten (DSG/GDPR). */
  --schrift:       system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --schrift-titel: var(--schrift);
  --mono:          ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Grunddichte. Der Aufbau setzt sie: Datenblatt eng, Magazin luftig. */
  --luft: 16px;

  /* Ab hier wechseln Tabellen in die Kartenansicht. Ein Wert, überall. */
  --umbruch: 640px;
}

/* ---------------------------------------------------------------------------
   Grundlagen
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--hg);
  color: var(--text);
  font-family: var(--schrift);
  font-size: 16px;
  line-height: 1.55;
  /* KEIN overscroll-behavior — bricht das Scrollen in manchen WebViews. */
}

h1, h2, h3, h4 {
  font-family: var(--schrift-titel);
  line-height: 1.25;
  margin: 0 0 calc(var(--luft) * .55);
}
h1 { font-size: 1.7rem; letter-spacing: -.02em; }
h2 { font-size: 1.3rem; letter-spacing: -.01em; }
h3 { font-size: 1.1rem; }
p  { margin: 0 0 calc(var(--luft) * .75); }

a { color: var(--akzent); }

img, svg, video { max-width: 100%; height: auto; }

/* Sichtbarer Fokusrahmen – nie wegnehmen, sonst ist die Seite per Tastatur
   nicht mehr bedienbar. */
:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

/* Kleine Überzeile über einer Überschrift */
.uz {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--schwach); margin: 0 0 4px;
}

.schwach { color: var(--schwach); }
.zahl    { font-variant-numeric: tabular-nums; }   /* gleich breite Ziffern */
.mono    { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------------
   Karte — der Standard-Container
   ------------------------------------------------------------------------- */
.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: calc(var(--luft) * 1.15);
  margin-bottom: var(--luft);
}
.karte > :last-child { margin-bottom: 0; }

/* Kennzahl-Kacheln */
.kacheln { display: grid; grid-template-columns: repeat(3, 1fr); gap: calc(var(--luft) * .7); }
.kachel {
  background: var(--flaeche2); border: 1px solid var(--rand-fein);
  border-radius: var(--radius); padding: var(--luft);
}
.kachel__wert {
  font-family: var(--schrift-titel); font-size: 1.7rem; font-weight: 700;
  line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.kachel__wert--akzent { color: var(--akzent); }
@media (max-width: 640px) { .kacheln { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------------------
   Knöpfe
   Mindestens 44 px hoch: darunter trifft man auf dem Telefon daneben.
   ------------------------------------------------------------------------- */
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer;
  min-height: 44px; padding: 11px 18px;
  border: 1px solid var(--akzent); border-radius: var(--radius);
  background: var(--akzent); color: var(--akzent-text);
  text-decoration: none;
}
.knopf:hover  { filter: brightness(1.08); }
.knopf:active { filter: brightness(.94); }
.knopf[disabled] { opacity: .5; cursor: not-allowed; filter: none; }

.knopf--schwach { background: var(--flaeche2); color: var(--text); border-color: var(--rand); }
.knopf--gefahr  { background: var(--fehler);  color: #fff;        border-color: var(--fehler); } /* feste-farbe-ok: Weiss auf Fehlerrot */
.knopf--leer    { background: transparent;    color: var(--akzent); }
.knopf--voll    { width: 100%; }

.knopfreihe { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------------------------------------------------------------------
   Formularfelder
   16 px Schriftgrösse ist Pflicht: darunter zoomt iOS beim Antippen hinein
   und der Nutzer muss danach von Hand zurückzoomen.
   ------------------------------------------------------------------------- */
.feld { display: block; margin-bottom: var(--luft); }
.feld__name  { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 5px; }
.feld__hilfe { display: block; font-size: .85rem; color: var(--schwach); margin-bottom: 6px; }
.feld__fehler{ display: block; font-size: .82rem; color: var(--fehler); margin-top: 5px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="tel"], input[type="url"], input[type="date"], input[type="search"],
select, textarea {
  width: 100%; font: inherit; font-size: 16px;
  color: var(--text); background: var(--flaeche);
  border: 1px solid var(--rand); border-radius: var(--radius);
  padding: 11px 13px; min-height: 44px;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--akzent); outline-offset: 0; border-color: var(--akzent);
}
.feld--fehlerhaft input, .feld--fehlerhaft select, .feld--fehlerhaft textarea {
  border-color: var(--fehler);
}
::placeholder { color: var(--schwach); opacity: .75; }

/* Auswahl als grosse Flächen statt Radio-Knöpfchen — auf dem Telefon
   deutlich leichter zu treffen. */
.wahl { display: grid; gap: 9px; }
.wahl--zwei { grid-template-columns: 1fr 1fr; }
.wahl button {
  text-align: left; font: inherit; cursor: pointer; padding: 13px;
  border: 1.5px solid var(--rand); border-radius: var(--radius);
  background: var(--flaeche); color: var(--text); min-height: 44px;
}
.wahl button[aria-pressed="true"] { border-color: var(--akzent); background: var(--flaeche2); }
.wahl button b     { display: block; font-size: .95rem; }
.wahl button small { color: var(--schwach); }

/* Honeypot gegen Bots: für Menschen unsichtbar, für Bots ausfüllbar.
   NICHT display:none — manche Bots erkennen das. */
.honig { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------------------------------------------------------------------------
   Meldungen
   ------------------------------------------------------------------------- */
.hinweis {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: .95rem; padding: 11px 13px; margin-bottom: 9px;
  border: 1px solid var(--rand); border-radius: var(--radius);
  background: var(--flaeche2);
}
.hinweis::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  margin-top: 7px; flex: none; background: var(--schwach);
}
.hinweis--erfolg { border-color: var(--erfolg); }
.hinweis--erfolg::before { background: var(--erfolg); }
.hinweis--warn   { border-color: var(--warn); }
.hinweis--warn::before   { background: var(--warn); }
.hinweis--fehler { border-color: var(--fehler); }
.hinweis--fehler::before { background: var(--fehler); }

.pille {
  display: inline-block; font-size: .78rem; white-space: nowrap;
  padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--rand); background: var(--flaeche2); color: var(--schwach);
}
.pille--ok     { color: var(--erfolg); }
.pille--lauf   { color: var(--akzent); }
.pille--fehler { color: var(--fehler); }

/* ---------------------------------------------------------------------------
   Listen: Tabelle am Desktop, Karten am Telefon
   Eine Datenquelle, ein Markup. Jede Zelle braucht data-label="…".
   ------------------------------------------------------------------------- */
table.liste { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.liste th {
  text-align: left; font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--schwach);
  padding: calc(var(--luft) * .45) calc(var(--luft) * .55);
  background: var(--flaeche2); border-bottom: 1px solid var(--rand);
}
table.liste td {
  padding: calc(var(--luft) * .6) calc(var(--luft) * .55);
  border-bottom: 1px solid var(--rand-fein);
}
table.liste tbody tr:hover td { background: var(--flaeche2); }

@media (max-width: 640px) {
  table.liste thead { display: none; }
  table.liste tr {
    display: block; background: var(--flaeche);
    border: 1px solid var(--rand); border-radius: var(--radius);
    box-shadow: var(--schatten);
    margin-bottom: calc(var(--luft) * .6); padding: calc(var(--luft) * .5);
  }
  table.liste td {
    display: flex; justify-content: space-between; gap: 12px;
    border: 0; padding: 4px 0; text-align: right;
  }
  table.liste td::before {
    content: attr(data-label); font-weight: 600; color: var(--schwach);
    font-size: .82rem; text-align: left;
  }
  table.liste tbody tr:hover td { background: transparent; }
}

/* Leerzustand — nie eine leere Seite ohne Erklärung zeigen */
.leer {
  text-align: center; padding: calc(var(--luft) * 2.2) var(--luft);
  color: var(--schwach);
}
.leer b { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: 5px; }

/* ---------------------------------------------------------------------------
   Bottom-Tab-Bar (App-Navigation) — kein Hamburger-Menü
   ------------------------------------------------------------------------- */
.tabbar {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--flaeche); border-top: 1px solid var(--rand);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabbar a {
  display: grid; place-items: center; gap: 3px;
  padding: 9px 0 10px; min-height: 52px;
  font-size: .66rem; color: var(--schwach); text-decoration: none;
}
.tabbar a[aria-current="page"] { color: var(--akzent); font-weight: 700; }
.tabbar svg { width: 21px; height: 21px; }

/* ---------------------------------------------------------------------------
   Overlay (Menü, "Mehr"-Blatt, Modal)
   ACHTUNG: KEINE Höhe in vh oder dvh! In der als App verpackten WebView sind
   beide oft 0 — das Overlay ist dann unsichtbar, während es im Browser
   einwandfrei aussieht. Die Höhe setzt app.js aus window.innerHeight.
   ------------------------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0 0 auto 0;
  display: none; flex-direction: column;
  background: var(--flaeche); z-index: 100;
  /* height wird von app.js gesetzt */
}
.overlay[data-offen="1"] { display: flex; }
.overlay__kopf {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--luft) * .7) var(--luft);
  border-bottom: 1px solid var(--rand); flex: none;
}
.overlay__inhalt {
  flex: 1; min-height: 0;           /* ohne min-height:0 scrollt es nicht */
  overflow-y: auto; padding: var(--luft);
  padding-bottom: calc(var(--luft) + env(safe-area-inset-bottom, 0px));
}

/* ---------------------------------------------------------------------------
   Sichtbarkeit
   ------------------------------------------------------------------------- */
@media (max-width: 640px)     { .nur-desktop { display: none !important; } }
@media (min-width: 640.02px)  { .nur-mobil   { display: none !important; } }

/* Nur für Screenreader */
.nur-vorlesen {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Druck
   ------------------------------------------------------------------------- */
@media print {
  .tabbar, .overlay, .knopfreihe, .nav-seitlich { display: none !important; }
  body { background: #fff; color: #000; } /* feste-farbe-ok: Druckansicht */
  .karte { border: 1px solid #999; box-shadow: none; }
}
