/* Mathe-Abenteuer — globales Stylesheet (Design-Grundlage + Navigation).
   Zielgruppe: Kinder Klasse 1–4 → große Schrift/Knöpfe, freundliche Farben,
   Touch-Targets ≥ 44px, mobile-first. Seitenspezifische Komponenten (Karten,
   PIN-Pad, Aufgaben-Optionen …) kommen mit den jeweiligen Seiten-PRs dazu. */

:root {
  /* Farben */
  --c-gelb: #F7D45C;          /* Header/App-Leiste, Akzent */
  --c-gruen: #2E7D1E;         /* Primär-Buttons, aktiv */
  --c-gruen-dunkel: #245F17;  /* Hover/Fokus, Links */
  --c-mandarine: #C8631A;     /* Akzent */
  --c-grau: #9E9E9E;          /* Rahmen, neutral */
  --c-grau-btn: #6E6E6E;      /* Sekundär-Buttons (WCAG-tauglich) */
  --c-grau-btn-dunkel: #565656;
  --c-grau-hell: #D8D8D8;
  --c-fokus: #1565C0;         /* Tastatur-Fokus-Ring */
  --c-bg: #EEEEEE;
  --c-flaeche: #ffffff;
  --c-text: #333333;

  /* Typografie */
  --font: "Baloo 2", "Nunito", "Segoe UI", system-ui, sans-serif;
  --fs-h2: 1.75rem;   /* ~28px */
  --fs-body: 1.2rem;  /* ~19px */
  --fs-btn: 1.35rem;  /* ~22px */
  --lh: 1.45;

  /* Maße */
  --touch: 44px;      /* Mindest-Touch-Target */
  --radius: 14px;
  --gap: 1.25rem;
  --maxw: 900px;      /* maximale Inhaltsbreite */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh);
  color: var(--c-text);
  /* Kariertes Matheheft als Hintergrund */
  background-color: #fcfcf5;
  background-image:
    linear-gradient(to right, rgba(96, 150, 210, 0.18) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(96, 150, 210, 0.18) 1px, transparent 1px);
  background-size: 26px 26px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Header / App-Leiste ===== */
.site-header { background: var(--c-gelb); }
.appbar {
  display: grid;
  grid-template-columns: auto 1fr auto;  /* links: Zurück · Mitte: Titel · rechts: Kind/Logout */
  align-items: center;
  gap: 0.5rem 1rem;
  width: 100%;
  padding: 0.7rem clamp(1rem, 3vw, 2.5rem);
  min-height: 60px;
}
.appbar-side { display: flex; align-items: center; min-width: 0; }
.appbar-left  { grid-column: 1; justify-content: flex-start; }
.appbar-right { grid-column: 3; justify-content: flex-end; }
.appbar-title {
  grid-column: 2;
  margin: 0;
  font-size: clamp(1.35rem, 4.5vw, 2.6rem);
  line-height: 1.1;
  font-weight: 700;
  color: var(--c-text);
  text-decoration: none;
  letter-spacing: 0.5px;
  text-align: center;
  white-space: nowrap;
}
.appbar-title:hover { text-decoration: none; }

/* Kind-Kontext rechts (Avatar + Name) — von eingeloggten Seiten genutzt */
.appbar-kind { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 700; color: var(--c-text); }
.appbar-kind-emoji {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--c-flaeche); border: 2px solid rgba(0, 0, 0, 0.18);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem;
}

/* Zurück-Link — gehört in .appbar-left (linke Fensterecke).
   Beim Hover wird nur der Text unterstrichen, nicht der Pfeil. */
.back {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 1.05rem; font-weight: 700;
  color: var(--c-text); text-decoration: none; white-space: nowrap;
}
.back:hover { text-decoration: none; }
.back:hover .back-text { text-decoration: underline; }
.back-pfeil { font-size: 1.3rem; line-height: 1; }

/* ===== Inhalt ===== */
main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
  text-align: center;
}
h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); margin: 0.5rem 0; }
h2 { font-size: var(--fs-h2); margin: 0.5rem 0; }
p  { margin: 0.5rem 0; }
.hint { color: #555; }
a { color: var(--c-gruen-dunkel); }

/* ===== Buttons & Links ===== */
.btn {
  display: inline-block;
  min-height: var(--touch); min-width: var(--touch);
  padding: 0.9rem 2rem; margin: 0.6rem 0;
  font-family: var(--font); font-size: var(--fs-btn); font-weight: 700;
  color: #fff; background: var(--c-gruen);
  border: none; border-radius: var(--radius); cursor: pointer; text-decoration: none;
}
.btn:hover, .btn:focus { background: var(--c-gruen-dunkel); }
.btn--block { display: block; width: 100%; max-width: 480px; margin: 1rem auto; }
.btn--grau { background: var(--c-grau-btn); }
.btn--grau:hover, .btn--grau:focus { background: var(--c-grau-btn-dunkel); }
.link { color: var(--c-text); font-weight: 700; }

/* ===== Formularfelder (Basis) ===== */
form { max-width: 480px; margin: 1rem auto; text-align: left; }
label { display: block; font-weight: 700; margin: 0.9rem 0 0.3rem; }
input[type="text"], input[type="email"], input[type="password"] {
  width: 100%; min-height: var(--touch);
  padding: 0.7rem; font-size: var(--fs-body); font-family: var(--font);
  border: 2px solid var(--c-grau); border-radius: 10px;
}

/* Sichtbarer Tastatur-Fokus (nicht bei Maus/Touch) */
.btn:focus-visible, .back:focus-visible, .link:focus-visible,
.appbar-title:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid var(--c-fokus);
  outline-offset: 3px;
}

/* ===== Login / Formular-Fehler ===== */
.form-error {
  max-width: 480px;
  margin: 0 auto 1rem;
  padding: 0.7rem 1rem;
  background: #fdecea;
  border: 2px solid #b3261e;
  border-radius: 10px;
  color: #b3261e;
  font-weight: 700;
  text-align: left;
}

/* ===== Login-Tabs: Einloggen / Konto erstellen ===== */
.auth-tabs {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  max-width: 480px;
  margin: 1.5rem auto 0;
}
.auth-tab {
  flex: 1;
  min-height: var(--touch);
  padding: 0.5rem 1rem;
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--c-text);
  background: var(--c-flaeche);
  border: 3px solid var(--c-grau-hell);
  border-radius: var(--radius);
  cursor: pointer;
}
.auth-tab:hover { border-color: var(--c-grau); }
.auth-tab--active {
  background: var(--c-gelb);
  border-color: #d9a83b;
}
.auth-panel form { margin-top: 1rem; }

/* ===== Startseiten-Navigation ===== */
.home-nav {
  display: grid;
  gap: 0.75rem;
  max-width: 480px;
  margin: 1.5rem auto;
}
.home-nav .btn { margin: 0; }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--c-grau-hell);
  background: rgba(252, 252, 245, 0.7);
  color: #777; font-size: 0.95rem;
}
.site-footer nav ul {
  list-style: none; margin: 0; padding: 1rem;
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; justify-content: center;
}
.site-footer a { color: #777; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ===== Desktop ===== */
@media (min-width: 900px) {
  /* gleich breite Seiten-Slots → Titel exakt in der Fenstermitte */
  .appbar { grid-template-columns: 1fr auto 1fr; }
}
