/* ==========================================================================
   SpellTo — Base: Reset, Layout-Shell, Statusbar, Bottom-Nav, Buttons, Cards
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
ul, ol { list-style: none; }
a { color: var(--color-primary); }

h1, h2, h3, h4 { font-family: var(--font-headline); font-weight: var(--font-bold); line-height: var(--leading-tight); color: var(--color-text); }
h1 { font-size: var(--text-3xl); } h2 { font-size: var(--text-2xl); } h3 { font-size: var(--text-xl); }
p { color: var(--color-text-secondary); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 50%; transform: translateX(-50%) translateY(-150%);
  top: 6px; z-index: 1000; background: var(--color-primary); color: #fff;
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-md); transition: transform var(--transition-fast);
}
.skip-link:focus { transform: translateX(-50%) translateY(0); }
.skip-link:focus-visible { outline: var(--focus-width) solid var(--focus-halo); outline-offset: 2px; }

/* ── Fokus sichtbar (WCAG 2.4.7 / 2.4.11) ──
   Konsistenter Ring für ALLE fokussierbaren Elemente: farbiger Kern (outline) +
   heller/dunkler Halo (box-shadow), damit der Ring auf jedem Hintergrund ≥3:1
   absetzt — auch über farbigen Zell-/Gruppenrändern und im Hochkontrast-Thema.
   KEIN outline:none ohne Ersatz. */
:focus-visible {
  outline: var(--focus-width) solid var(--focus-ring);
  outline-offset: var(--focus-offset);
  box-shadow: 0 0 0 calc(var(--focus-offset) + var(--focus-width)) var(--focus-halo);
}
/* Board-Zellen/Gruppen/Chips: Ring nach innen NICHT verdecken — overflow:hidden
   würde den äußeren Ring abschneiden, daher hier ein gut sichtbarer Innen+Außen-Ring. */
.bb-group:focus-visible, .bb-cell:focus-visible, .bb-center:focus-visible,
.bb-predict__btn:focus-visible, .bb-iconbtn:focus-visible {
  outline: var(--focus-width) solid var(--focus-ring);
  outline-offset: calc(-1 * var(--focus-width));
  box-shadow: 0 0 0 var(--focus-width) var(--focus-halo),
              0 0 0 calc(var(--focus-width) * 2) var(--focus-ring);
}
/* Fallback für Browser ohne :focus-visible (alte WebViews der Zielgruppe): sichtbarer
   Ring bei Tastatur-/synthetischem Fokus; Maus-Fokus blendet ihn via :focus:not(...) nicht aus,
   aber das ist akzeptabel (Sichtbarkeit > Ästhetik bei dieser Zielgruppe). */
:focus { outline: var(--focus-width) solid var(--focus-ring); outline-offset: var(--focus-offset); }
@supports selector(:focus-visible) {
  :focus:not(:focus-visible) { outline: none; box-shadow: none; }
}

/* ── App-Shell ── */
/* height (nicht min-height): die Hülle ist auf die Viewport-Höhe GEDECKELT, damit
   Fit-Screens (Tafel/Üben) schrumpfen statt unten aus dem Bild zu laufen. Lange
   Inhaltsseiten scrollen innerhalb von #app-content (Kopf + Fußnav bleiben fix). */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.statusbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.statusbar__brand {
  display: flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-headline); font-weight: var(--font-bold);
  font-size: var(--text-lg); color: var(--color-primary); padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
}
.statusbar__brand-logo {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: var(--color-primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: var(--font-black);
}
.statusbar__btn {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: var(--space-2); border-radius: var(--radius-md);
  color: var(--color-text-secondary); font-size: var(--text-xs); font-weight: var(--font-medium);
  min-width: 44px; min-height: 44px; justify-content: center;   /* a11y 2.5.5: ≥44×44 */
}
.statusbar__btn:hover { background: var(--color-surface-alt); color: var(--color-text); }
.statusbar__btn svg { width: 22px; height: 22px; }
.statusbar__btn-label { display: none; }
.statusbar__btn--font { font-weight: var(--font-bold); font-size: var(--text-sm); }
.statusbar__spacer { flex: 1; }
@media (min-width: 768px) { .statusbar__btn-label { display: inline; } }

/* ── Bottom-Nav ── */
.bottom-nav {
  position: sticky; bottom: 0; z-index: 50;
  display: flex; align-items: stretch; justify-content: space-around;
  background: var(--color-surface); border-top: 1px solid var(--color-border);
  padding: var(--space-1) var(--space-1) calc(var(--space-1) + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
.bottom-nav__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: var(--space-2) var(--space-1); border-radius: var(--radius-md);
  color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--font-medium);
  min-height: 56px;   /* a11y 2.5.5 + Projekt-Norm Dwell-Ziele großzügig */
}
.bottom-nav__item svg { width: 24px; height: 24px; }
/* Aktive Seite: Farbe + (redundant, WCAG 1.4.1) dickere Icon-Linie, Fettschrift
   und Unterstrich-Indikator — nicht allein über Farbe erkennbar. */
.bottom-nav__item[aria-current="page"] { color: var(--color-primary); font-weight: var(--font-bold); }
.bottom-nav__item[aria-current="page"] svg { stroke-width: 2.4; }
.bottom-nav__item[aria-current="page"] .bottom-nav__label {
  box-shadow: inset 0 -2px 0 0 currentColor;
}
.bottom-nav__item:hover { color: var(--color-text); }
.bottom-nav__label { line-height: 1.1; }

/* ── Main ── */
#app-content { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; }
.screen { padding: var(--space-5) var(--space-4) var(--space-8); }
.screen--full { padding: 0; max-width: none; }
.screen__head { margin-bottom: var(--space-5); }
.screen__title { font-family: var(--font-headline); font-size: var(--text-3xl); }
.screen__sub { color: var(--color-text-muted); font-size: var(--text-base); margin-top: var(--space-1); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-md);
  font-weight: var(--font-bold); font-size: var(--text-base);
  background: var(--color-surface-alt); color: var(--color-text);
  border: 2px solid var(--color-border); min-height: 48px; transition: all var(--transition-fast);
}
.btn:hover { border-color: var(--color-border-strong); }
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--color-surface-alt); }
.btn-sm { padding: var(--space-2) var(--space-3); min-height: 44px; font-size: var(--text-sm); }  /* a11y 2.5.5 */
.btn-block { width: 100%; }

/* ── Cards ── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--space-4); }
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: var(--space-5);
  box-shadow: var(--shadow-sm); transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  text-align: left; display: flex; flex-direction: column; gap: var(--space-2);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card__icon {
  width: 52px; height: 52px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; color: #fff; margin-bottom: var(--space-1);
}
.card__icon svg { width: 28px; height: 28px; }
.card__title { font-family: var(--font-headline); font-size: var(--text-xl); font-weight: var(--font-bold); }
.card__desc { color: var(--color-text-muted); font-size: var(--text-sm); line-height: var(--leading-normal); }

/* ── Hilfs-Klassen ── */
.chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2); border-radius: var(--radius-full);
  background: var(--color-primary-bg); color: var(--color-primary-dark);
  font-size: var(--text-xs); font-weight: var(--font-bold);
}
.note {
  background: var(--color-primary-bg); border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); color: var(--color-text-secondary);
  font-size: var(--text-sm);
}
.stack > * + * { margin-top: var(--space-4); }
.muted { color: var(--color-text-muted); }
.center { text-align: center; }
.wrap-narrow { max-width: 720px; margin: 0 auto; }
