/* Gemeinsame Grundlage aller Apps im Hub: Schriften, Tokens, Grundstile, Kopfzeile mit Menü-Pille
   und Konto-Menü. Jede App lädt diese Datei vor ihrem eigenen Stylesheet; dieselbe Reihenfolge wie
   früher am Anfang von OPTIRANDOs app.css, damit sich dort nichts verschiebt. */

/* Geist und Geist Mono (SIL OFL 1.1, Lizenz in fonts/OFL.txt) liegen bei der App selbst: Keine
   Schriftanfrage verlässt den Server. Eine variable Datei je Familie deckt alle Gewichte ab. */
@font-face {
  font-family: "Geist";
  src: url("../fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("../fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-sans: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --color-text: #1c1c1c;
  --color-muted: #5c5c5c;
  --color-border: #d8d8d8;
  --color-surface: #ffffff;
  --color-background: #f5f5f3;
  --color-accent: #6fb52c;
  --color-accent-hover: #64a327;
  /* Grün in Textstärke: erreicht 4,5:1 auf Weiß und auf der Grüntönung. */
  --color-accent-text: #276b29;
  --color-accent-tint: #e4f0d8;
  /* Die vier Akzentwerte oben sind das Grün des Hubs und nur Vorgabe: Jede App setzt ihre eigenen
     in ihrem :root (plattform/DESIGN.html, Kapitel 9). Alles darunter gilt für alle Apps gleich. */
  /* Rahmen, der als Fläche trägt: Schalter-Spur, Schrittkreise, gestrichelte Ablage. */
  --color-border-strong: #b3b3b0;
  --color-neutral-tint: #ebebe9;
  /* Gefahr: lässt sich nicht zurücknehmen oder ist schiefgegangen. 6,5:1 auf Weiß. */
  --color-danger: #aa3333;
  --color-danger-tint: #f3e2e2;
  /* Warnung: hängt oder gibt etwas ab. Die Schrift erreicht 6,1:1 auf der Tönung. */
  --color-warning: #ca8a10;
  --color-warning-tint: #fceedb;
  --color-warning-text: #7b5100;
  --shadow-karte: 0 1px 2px rgba(28, 28, 28, 0.06), 0 16px 40px rgba(28, 28, 28, 0.1);
  /* Karten im Fluss; schwebende Flächen tragen --shadow-karte. */
  --shadow-flach: 0 1px 2px rgba(28, 28, 28, 0.06);
  /* Hintergrundmuster; ohne eigenes Muster bleibt nur die Grundfarbe. Apps setzen es in ihrem :root. */
  --pattern: none;
}

* {
  box-sizing: border-box;
}

/* Eigene display-Werte (etwa .knopf) sollen das hidden-Attribut nicht aushebeln. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--pattern), var(--color-background);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Kopfbereich: Marke links, Menü als schwebende Pille exakt mittig, Konto rechts. */
.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 1rem 2rem;
  padding: 1.25rem 1.5rem 0;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--color-muted);
}

.app-brand img {
  display: block;
  height: 32px;
  width: auto;
}

/* Kopf links: der Weg zurück zum Hub, daneben die Marke. */
.app-kopf-start {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-self: start;
  min-width: 0;
}

.hub-zurueck {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 44px;
  box-sizing: border-box;
  padding: 0 0.875rem 0 0.625rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  box-shadow: var(--shadow-karte);
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  color: var(--color-text);
}

.hub-zurueck:hover {
  background: var(--color-background);
}

.hub-zurueck:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.hub-zurueck svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-nav {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  box-shadow: var(--shadow-karte);
}

.app-nav a {
  display: flex;
  align-items: center;
  padding: 0.375rem 1rem;
  border-radius: 999px;
  font-size: 0.9375rem;
  white-space: nowrap;
  text-decoration: none;
  color: var(--color-muted);
  transition: background-color 0.15s, color 0.15s;
}

.app-nav a:hover {
  background: var(--color-background);
  color: var(--color-text);
}

.app-nav a[aria-current="page"] {
  background: var(--color-accent);
  color: var(--color-text);
  font-weight: 600;
}

.app-nav svg {
  display: none;
}

:where(.app-nav a, .app-konto-menue a):focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Immer rechts, auch in Apps oder auf Seiten ohne Menü-Pille in der Mitte. */
.app-konto {
  grid-column: 3;
  justify-self: end;
}

.app-konto-knopf {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  box-shadow: var(--shadow-karte);
  font: inherit;
  cursor: pointer;
}

.app-konto-knopf:hover {
  background: var(--color-background);
}

.app-konto-knopf svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--color-muted);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Auf der Profilseite ist kein Menüpunkt aktiv; stattdessen zeigt der Avatar, wo man ist. */
.app-konto-knopf.aktiv .avatar {
  box-shadow: 0 0 0 2px var(--color-accent);
}

/* Natives Popover im Top-Layer: schließt per Escape und Klick daneben ohne JavaScript. Es hängt
   nicht am Knopf, steht aber rechts oben, wo der Knopf immer steht. */
.app-konto-menue {
  position: fixed;
  inset: 4.5rem 1.5rem auto auto;
  width: 15.5rem;
  margin: 0;
  padding: 0.375rem;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: var(--shadow-karte);
}

.app-konto-kopf {
  display: flex;
  flex-direction: column;
  margin: 0 0 0.375rem;
  padding: 0.5rem 0.625rem 0.625rem;
  border-bottom: 1px solid var(--color-border);
}

.app-konto-kopf strong {
  font-size: 0.9375rem;
}

.app-konto-kopf span {
  font-size: 0.875rem;
  color: var(--color-muted);
  overflow-wrap: anywhere;
}

.app-konto-menue a,
.app-konto-menue button {
  display: block;
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: none;
  border-radius: 4px;
  background: none;
  font: inherit;
  font-size: 0.9375rem;
  text-align: left;
  text-decoration: none;
  color: var(--color-text);
  cursor: pointer;
}

.app-konto-menue form {
  margin: 0;
}

.app-konto-menue a:hover,
.app-konto-menue button:hover {
  background: var(--color-background);
  color: var(--color-text);
}

/* Exakte Mitte braucht links Platz für das Logo. Wird es enger, nimmt das Menü den Raum zwischen
   Logo und Konto; reicht auch der nicht, scrollt es. */
@media (max-width: 62rem) {
  .app-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .app-nav {
    justify-self: center;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
}

.app-main {
  width: calc(100% - 3rem);
  max-width: 60rem;
  margin: 1.5rem auto 0;
  padding: 2rem 2.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: var(--shadow-karte);
}

.app-footer {
  margin-top: auto;
  padding: 1.5rem;
  text-align: center;
  color: var(--color-muted);
  font-size: 0.875rem;
}

/* Am Handy: oben Marke und Konto, das Menü wird zur Tab-Leiste am unteren Rand, das Blatt fast
   randlos. Mit nur einem Menüpunkt entfällt die Leiste (Prototyp „Handy“ von OPTICHARGE). */
@media (max-width: 30rem) {
  body:has(.app-nav > a + a) {
    padding-bottom: 5rem;
  }

  .app-nav:not(:has(> a + a)) {
    display: none;
  }

  .app-header {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.75rem 0 1rem;
  }

  .app-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    justify-self: stretch;
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 0;
    padding: 0.25rem 0.5rem 0.75rem;
    border: none;
    border-top: 1px solid var(--color-border);
    border-radius: 0;
    box-shadow: none;
  }

  .app-nav a,
  .app-nav a:hover,
  .app-nav a[aria-current="page"] {
    flex-direction: column;
    gap: 0.25rem;
    min-height: 4rem;
    padding: 0.5rem 0 0.25rem;
    background: none;
    font-size: 0.75rem;
  }

  .app-nav a[aria-current="page"] {
    color: var(--color-accent-text);
  }

  .app-nav svg {
    display: block;
    box-sizing: content-box;
    width: 24px;
    height: 24px;
    padding: 4px 16px;
    border-radius: 999px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .app-nav a:hover svg {
    background: var(--color-background);
  }

  .app-nav a[aria-current="page"] svg {
    background: var(--color-accent);
    color: var(--color-text);
  }

  .app-konto-knopf {
    padding: 0.25rem;
    border: none;
    background: none;
    box-shadow: none;
  }

  .app-konto-knopf svg {
    display: none;
  }

  .app-konto-menue {
    inset: 3.5rem 0.75rem auto auto;
  }

  .app-main {
    width: calc(100% - 1.5rem);
    margin-top: 0.75rem;
    padding: 1.5rem 1rem;
  }
}

h1 {
  margin-top: 0;
  font-size: 1.75rem;
  line-height: 1.2;
}

a {
  color: var(--color-accent-text);
}

a:hover {
  color: var(--color-text);
}

:where(a, input, select, textarea, button):focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

:where(input, select, textarea):focus-visible {
  outline-offset: 0;
}

/* Nur für Vorlesewerkzeuge: sichtbar wäre die Beschriftung neben dem Feld doppelt. */
.nur-vorleser {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
