/* Agrar.Klar Designsystem
   Mobil zuerst. Eine Akzentfarbe, ein Radienmaß, zwei Themen (hell und dunkel).
   Schrift: Outfit (SIL Open Font License), selbst gehostet, kein CDN und damit DSGVO-konform. */

@font-face {
  font-family: "Outfit";
  src: url("/static/schrift/Outfit.woff2") format("woff2-variations");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  /* Ein Akzent für die ganze App: das Grün. Kein zweiter Akzent, keine Ausnahme je Ansicht. */
  --gruen: #2f6b3a;
  --gruen-tief: #24552d;
  --gruen-hell: #e7f3e8;
  --gruen-kontur: #bcd9c0;

  --flaeche: #f4f7f2;
  --karte: #ffffff;
  --karte-erhoben: #ffffff;
  --tinte: #1b2419;
  --tinte-leise: #59634f;
  --linie: #dde5d9;
  --linie-stark: #c3cfbd;
  --feld-rand: #7f8c78;   /* 3,54:1 auf Weiß, erfuellt WCAG fuer Bedienelement-Umrisse */

  --warn: #8a4310;
  --warn-flaeche: #fdf1e3;
  --fehler: #96271f;
  --fehler-flaeche: #fbe6e4;
  --ok: #2f6b3a;

  /* Ein Radienmaß: Flächen 14, Bedienelemente 12, Chips voll rund. */
  --radius: 14px;
  --radius-klein: 12px;
  --schatten: 0 1px 2px rgba(27, 36, 25, 0.06), 0 6px 18px rgba(27, 36, 25, 0.05);
  --schatten-hoch: 0 2px 6px rgba(27, 36, 25, 0.10), 0 18px 40px rgba(27, 36, 25, 0.12);
  --ring: 0 0 0 3px rgba(47, 107, 58, 0.28);
}

/* Dunkles Thema. Die App wird abends auf dem Sofa benutzt, nicht nur im Büro.
   Der Akzent bleibt derselbe, nur aufgehellt, damit die Marke erkennbar bleibt. */
@media (prefers-color-scheme: dark) {
  :root {
    --gruen: #7cc08a;
    --gruen-tief: #a3d6ad;
    --gruen-hell: #1c2a1f;
    --gruen-kontur: #2f4634;

    --flaeche: #12160f;
    --karte: #1a1f17;
    --karte-erhoben: #212719;
    --tinte: #e8ede4;
    --tinte-leise: #9dab95;
    --linie: #2b332a;
    --linie-stark: #3d4839;
    --feld-rand: #79876f;   /* 4,40:1 auf der dunklen Karte */

    --warn: #e5a25f;
    --warn-flaeche: #2a2015;
    --fehler: #ef9a92;
    --fehler-flaeche: #2c1917;
    --ok: #7cc08a;

    --schatten: 0 1px 2px rgba(0, 0, 0, 0.5), 0 6px 18px rgba(0, 0, 0, 0.35);
    --schatten-hoch: 0 2px 6px rgba(0, 0, 0, 0.55), 0 18px 40px rgba(0, 0, 0, 0.5);
    --ring: 0 0 0 3px rgba(124, 192, 138, 0.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* Lange Wörter und eingefügte Links dürfen das Handy-Layout nicht sprengen. */
body, .karte, p, h1, h2, h3, td, th, .verlauf-eintrag, .kachel, .zeile, .bewertungs-punkt, .streifen,
.dialog, .hinweis, .leer, label.feld { overflow-wrap: anywhere; word-break: break-word; }

body {
  /* Kein Wartezeit-Effekt beim Antippen und keine Doppeltipp-Zoomverzoegerung: die App wird
     mit Handschuhen und in Eile bedient. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(47, 107, 58, 0.14);
  font-family: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  background: var(--flaeche);
  color: var(--tinte);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, video { max-width: 100%; }
a { color: var(--gruen); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; letter-spacing: -0.015em; font-weight: 650; text-wrap: balance; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.1rem); }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 10px; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }

/* Symbole aus dem Phosphor-Sprite (MIT). */
.sym-i { width: 1.4em; height: 1.4em; display: inline-block; vertical-align: -0.25em; fill: currentColor; }

.lade-schirm { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.logo-kreis { width: 74px; height: 74px; border-radius: 50%; background: var(--gruen-hell); display: flex; align-items: center; justify-content: center; font-size: 34px; color: var(--gruen); }

/* Layout */
/* Sprungmarke zum Inhalt, sichtbar sobald sie den Fokus bekommt. */
.zum-inhalt {
  position: absolute; left: 8px; top: -60px; z-index: 70;
  background: var(--karte); color: var(--tinte); border: 1px solid var(--linie-stark);
  border-radius: var(--radius-klein); padding: 10px 14px; text-decoration: none;
  transition: top 0.15s ease;
}
.zum-inhalt:focus { top: 8px; }

.rahmen { max-width: 980px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 800px) { .rahmen { padding-bottom: 32px; } }

.kopf {
  position: sticky; top: 0; z-index: 20;
  background: var(--gruen); color: #fff;
  padding: 10px 16px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}
@media (prefers-color-scheme: dark) {
  .kopf { background: var(--karte-erhoben); color: var(--tinte); border-bottom: 1px solid var(--linie); }
}
.kopf .marke { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; letter-spacing: -0.02em; }
.kopf .platz { flex: 1; }
.kopf .betrieb { font-size: 12.5px; opacity: 0.92; text-align: right; line-height: 1.35; }
.kopf button {
  background: rgba(255, 255, 255, 0.16); border: 0; color: inherit;
  border-radius: var(--radius-klein); padding: 8px 10px; cursor: pointer; position: relative;
  display: inline-flex; align-items: center;
}
@media (prefers-color-scheme: dark) { .kopf button { background: var(--gruen-hell); } }
.kopf .punkt { position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; border-radius: 50%; background: #ffd25e; }

.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--karte); border-top: 1px solid var(--linie);
  display: flex; justify-content: space-around;
  padding: 4px 2px calc(4px + env(safe-area-inset-bottom, 0px));
}
.nav a {
  flex: 1; max-width: 112px; text-decoration: none; color: var(--tinte-leise);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; padding: 6px 2px; border-radius: var(--radius-klein);
}
.nav a .sym-i { width: 22px; height: 22px; }
.nav a.aktiv { color: var(--gruen); font-weight: 650; }
@media (min-width: 800px) {
  .nav { position: sticky; top: 52px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--linie); justify-content: center; gap: 6px; }
  .nav a { flex-direction: row; gap: 8px; font-size: 14px; max-width: none; flex: 0 0 auto; padding: 10px 14px; }
}

/* Flächen */
.karte {
  background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius);
  box-shadow: var(--schatten); padding: 16px; margin-bottom: 12px;
}
.hinweis { color: var(--tinte-leise); font-size: 13.5px; }
.abstand { height: 8px; }

.kachel-gitter { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kachel {
  border: 1px solid var(--linie); border-radius: var(--radius);
  padding: 14px; cursor: pointer; background: var(--karte);
  transition: transform 0.12s ease, border-color 0.12s ease; text-align: left; font: inherit; color: inherit;
}
.kachel:hover { border-color: var(--linie-stark); }
.kachel:active { transform: scale(0.985); }
.kachel:disabled { opacity: 0.5; cursor: not-allowed; }
.kachel .sym { font-size: 26px; line-height: 1.1; }
.kachel .titel { font-weight: 650; margin-top: 6px; }
.kachel .unter { color: var(--tinte-leise); font-size: 12.5px; }

.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--gruen); color: #fff; border: 1px solid transparent; border-radius: var(--radius-klein);
  padding: 11px 16px; font: inherit; font-size: 15px; font-weight: 650; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: transform 0.1s ease, filter 0.12s ease;
}
@media (prefers-color-scheme: dark) { .knopf { color: #0f1410; } }
.knopf:hover { filter: brightness(1.06); }
.knopf:active { transform: translateY(1px); }
.knopf:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.knopf.zweit { background: var(--gruen-hell); color: var(--gruen-tief); border-color: var(--gruen-kontur); }
.knopf.leise { background: transparent; color: var(--tinte); border-color: var(--feld-rand); }
.knopf.warn { background: var(--warn); color: #fff; }
@media (prefers-color-scheme: dark) { .knopf.warn { color: #1b1105; } }
.knopf.klein { padding: 8px 12px; font-size: 13.5px; }
.knopf-zeile { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }

label.feld { display: block; margin-bottom: 12px; font-size: 14px; font-weight: 620; }
label.feld span { display: block; margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--feld-rand); border-radius: var(--radius-klein);
  font: inherit; background: var(--karte); color: var(--tinte);
}
textarea { min-height: 112px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--tinte-leise); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--ring); border-color: var(--gruen); }
.feld-fehler { color: var(--fehler); font-size: 13.5px; margin-top: 5px; }

.leer { text-align: center; color: var(--tinte-leise); padding: 28px 12px; }
.leer .sym { font-size: 32px; display: block; margin-bottom: 8px; }
.leer .sym-i { width: 34px; height: 34px; display: block; margin: 0 auto 8px; color: var(--linie-stark); }

/* Ladezustand: Platzhalter in der Form des späteren Inhalts, kein Kreisel. */
.skelett { border-radius: var(--radius-klein); background: var(--linie); position: relative; overflow: hidden; }
.skelett::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  animation: schimmer 1.3s infinite;
}
@media (prefers-color-scheme: dark) {
  .skelett::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.07), transparent); }
}
.skelett-zeile { height: 14px; margin-bottom: 10px; }
.skelett-block { height: 76px; margin-bottom: 12px; }
@keyframes schimmer { to { transform: translateX(100%); } }

.status-chip { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 650; }
.status-entwurf { background: var(--linie); color: var(--tinte-leise); }
.status-eingereicht { background: var(--warn-flaeche); color: var(--warn); }
.status-freigegeben { background: var(--gruen-hell); color: var(--gruen-tief); }
.status-korrektur { background: var(--fehler-flaeche); color: var(--fehler); }
.status-offen { background: var(--warn-flaeche); color: var(--warn); }
.status-fertig { background: var(--gruen-hell); color: var(--gruen-tief); }

.zeilen-liste { display: flex; flex-direction: column; gap: 8px; }
.zeile {
  display: flex; align-items: center; gap: 10px; text-align: left; font: inherit; color: inherit;
  border: 1px solid var(--linie); background: var(--karte); border-radius: var(--radius-klein);
  padding: 12px; cursor: pointer; transition: border-color 0.12s ease;
}
.zeile:hover { border-color: var(--linie-stark); }
.zeile .mitte { flex: 1; min-width: 0; }
/* display:block ist noetig, sonst greift overflow bei den inline-Spans nicht und die Zeile sprengt das Handy-Layout. */
.zeile .titel { display: block; font-weight: 650; overflow-wrap: anywhere; }
.zeile .unter { display: block; color: var(--tinte-leise); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zeile .sym-i { color: var(--tinte-leise); flex: 0 0 auto; }

/* Dashboard */
.gruss { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.gruss .ring { position: relative; width: 76px; height: 76px; flex: 0 0 auto; }
.gruss .ring svg { transform: rotate(-90deg); }
.gruss .ring .wert { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.statistik-zeile { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.statistik { background: var(--gruen-hell); border-radius: var(--radius-klein); padding: 11px; text-align: center; }
.statistik .zahl { font-size: 19px; font-weight: 720; color: var(--gruen-tief); font-variant-numeric: tabular-nums; }
.statistik .name { font-size: 11.5px; color: var(--tinte-leise); }
.balken { background: var(--linie); border-radius: 999px; height: 8px; overflow: hidden; }
.balken > div { height: 100%; background: var(--gruen); border-radius: 999px; transition: width 0.4s ease; }

/* Lernkarten */
.lernkarte { perspective: 1200px; cursor: pointer; min-height: 252px; position: relative; margin-bottom: 10px; }
.lernkarte .innen { position: absolute; inset: 0; transition: transform 0.45s; transform-style: preserve-3d; }
.lernkarte.gedreht .innen { transform: rotateY(180deg); }
.lernkarte .seite {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius); box-shadow: var(--schatten);
  padding: 18px; display: flex; flex-direction: column; justify-content: center; overflow: auto;
}
.lernkarte .seite.hinten { transform: rotateY(180deg); background: var(--gruen-hell); border-color: var(--gruen-kontur); }
.lernkarte .gruppe { font-size: 12px; color: var(--tinte-leise); font-weight: 650; text-transform: uppercase; letter-spacing: 0.4px; }

.quiz-option {
  display: block; width: 100%; text-align: left; font: inherit; margin-bottom: 8px;
  border: 1.5px solid var(--feld-rand); background: var(--karte); color: var(--tinte);
  border-radius: var(--radius-klein); padding: 12px 13px; cursor: pointer;
}
.quiz-option.gewaehlt { border-color: var(--gruen); background: var(--gruen-hell); }
.quiz-option.richtig { border-color: var(--ok); background: var(--gruen-hell); }
.quiz-option.falsch { border-color: var(--fehler); background: var(--fehler-flaeche); }
.quiz-option:disabled { cursor: default; }

.note-kreis {
  width: 66px; height: 66px; border-radius: 50%; background: var(--gruen); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 720; margin: 0 auto 10px;
}
@media (prefers-color-scheme: dark) { .note-kreis { color: #0f1410; } }
.bewertungs-punkt { display: flex; gap: 8px; align-items: baseline; margin-bottom: 6px; font-size: 14px; }

/* Meldungen */
.meldungen { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 60; width: min(480px, 92vw); }
.meldung {
  background: var(--tinte); color: var(--flaeche); border-radius: var(--radius-klein); padding: 12px 14px; margin-bottom: 8px;
  box-shadow: var(--schatten-hoch); font-size: 14.5px; animation: einblenden 0.2s ease;
}
.meldung.fehler { background: var(--fehler); color: #fff; }
.meldung.ok { background: var(--gruen); color: #fff; }
@media (prefers-color-scheme: dark) {
  .meldung.ok, .meldung.fehler { color: #0f1410; }
}
@keyframes einblenden { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Dialog */
.dialog-hintergrund { position: fixed; inset: 0; background: rgba(12, 18, 11, 0.5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .dialog-hintergrund { align-items: center; } }
.dialog {
  background: var(--flaeche); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  /* Scrollen im Dialog darf nicht die Seite dahinter mitziehen. */
  overscroll-behavior: contain;
  border-radius: 18px 18px 0 0; padding: 18px; border: 1px solid var(--linie);
}
@media (min-width: 640px) { .dialog { border-radius: 18px; } }
.dialog h2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dialog .schliessen { background: none; border: 0; font-size: 24px; line-height: 1; cursor: pointer; color: var(--tinte-leise); padding: 4px 8px; }

/* Anmeldung */
.auth-rahmen { max-width: 430px; margin: 0 auto; padding: 40px 18px; }
.auth-kopf { text-align: center; margin-bottom: 20px; }
.auth-kopf .logo-kreis { margin: 0 auto 12px; }

table.tabelle { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tabelle th, table.tabelle td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--linie); }
table.tabelle td:not(:first-child) { font-variant-numeric: tabular-nums; }
.tabellen-rolle { overflow-x: auto; }

.qr-bild { text-align: center; }
.qr-bild img { width: 220px; height: 220px; image-rendering: pixelated; border: 1px solid var(--linie); border-radius: var(--radius-klein); background: #fff; }

.foto-reihe { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.foto-reihe img { width: 84px; height: 84px; object-fit: cover; border-radius: var(--radius-klein); border: 1px solid var(--linie); }

.streifen { border-left: 3px solid var(--gruen); padding-left: 11px; margin: 8px 0; }
.verlauf-eintrag { font-size: 13.5px; margin-bottom: 7px; }
.verlauf-eintrag .zeit { color: var(--tinte-leise); font-size: 12px; }

/* Beschriften und Zuordnen */
.zuordnung-flaeche { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--gruen-hell); }
.zuordnung-flaeche svg { display: block; width: 100%; height: auto; }
.zuordnung-punkt {
  position: absolute; transform: translate(-50%, -50%);
  border-radius: 999px; border: 1.5px dashed var(--gruen); padding: 6px 10px;
  font: inherit; font-size: 12.5px; cursor: pointer; background: var(--karte); color: var(--tinte);
  max-width: 40%;
}
.zuordnung-punkt.belegt { border-style: solid; }
.zuordnung-punkt.richtig { background: var(--gruen-hell); border-color: var(--ok); }
.zuordnung-punkt.falsch { background: var(--fehler-flaeche); border-color: var(--fehler); }

/* Wer Bewegung reduziert haben will, bekommt sie nicht. Gilt fuer alles, auch den Kartendreher. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .lernkarte .innen { transition: none; }
  .lernkarte.gedreht .innen { transform: rotateY(180deg); }
}
