/* ==========================================================================
   Lernapps Style-System
   Gemeinsame Farben, Schrift, Größen und Bausteine für alle Apps.
   Übersicht mit Beispielen: /stil/

   Einbinden:
     <link rel="stylesheet" href="../shared/ui.css">
   Die Schrift Andika liegt selbst gehostet in shared/fonts/ (SIL Open Font License, siehe OFL.txt) –
   bewusst nicht über Google Fonts, damit keine Daten an Google gehen.
   Icons:
     <svg class="i" aria-hidden="true"><use href="../shared/icons.svg#home"/></svg>

   Regeln für einheitliche Größen:
   - Es gibt genau zwei Knopfgrößen: normal (48px) und groß (.lg, 60px).
   - Normal: Kopfzeile, Einstellungen, Pfeile. Groß: nur die Aktionsleiste unten.
   - Knöpfe werden nie mitskaliert. Wenn eine App eine Fläche skaliert (z. B. ein Spielbrett),
     liegen die Knöpfe außerhalb dieser Fläche.
   ========================================================================== */

/* Schrift (selbst gehostet) */
@font-face {
  font-family: 'Andika'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/andika-400-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Andika'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/andika-400-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Andika'; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/andika-700-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Andika'; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/andika-700-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Farben */
  --paper: #FBF7EF;        /* Hintergrund */
  --card: #FFFFFF;         /* Flächen, Knöpfe */
  --line: #E3D9C4;         /* Rahmen von Flächen */
  --line-strong: #D9CFBA;  /* Rahmen von Knöpfen */
  --ink: #1F2A44;          /* Text */
  --muted: #55607A;        /* Nebentext */
  --faint: #B8B0A0;        /* sehr blasser Text */
  --seg-bg: #EFE7D6;       /* Hintergrund von Umschaltern */
  --solid-bg: #1F2A44;     /* Hauptaktion */
  --solid-fg: #FFFFFF;
  --focus: #2F5DA8;

  /* Schrift */
  --font: 'Andika', 'Comic Neue', 'Trebuchet MS', system-ui, sans-serif;
  --text-sm: 14px;
  --text-md: 17px;
  --text-lg: 20px;
  --text-title: 26px;

  /* Größen */
  --control-md: 48px;
  --control-lg: 60px;
  --icon-md: 24px;
  --icon-lg: 28px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --gap: 8px;

  color-scheme: light;
}

/* ---------- Grundlagen ---------- */
/* Kein Zoomen per Doppeltipp (Safari ignoriert user-scalable=no); Elemente mit eigener
   Gestensteuerung (touch-action: none) überschreiben das gezielt. */
* { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); }
button { font-family: inherit; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }

/* ---------- Icon ---------- */
.i {
  width: var(--icon-md); height: var(--icon-md); flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Knopf ----------
   .btn          normal, weiß mit Rand
   .btn.solid    Hauptaktion, dunkel
   .btn.icon     quadratisch, nur Symbol (aria-label nicht vergessen)
   .btn.lg       groß (nur Aktionsleiste unten)
   aria-pressed  Ein/Aus-Knopf, eingeschaltet dunkel */
.btn {
  --h: var(--control-md);
  box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: var(--gap);
  height: var(--h); min-width: var(--h); padding: 0 16px; flex-shrink: 0;
  border-radius: var(--radius-md); border: 2px solid var(--line-strong);
  background: var(--card); color: var(--ink);
  font: inherit; font-size: var(--text-md); font-weight: 700; line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: transform .08s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .35; cursor: default; transform: none; }
.btn.solid, .btn[aria-pressed="true"] { border-color: var(--solid-bg); background: var(--solid-bg); color: var(--solid-fg); }
.btn.icon { width: var(--h); padding: 0; }
.btn.lg { --h: var(--control-lg); padding: 0 22px; border-radius: 18px; font-size: var(--text-lg); }
.btn.lg .i { width: var(--icon-lg); height: var(--icon-lg); }

/* ---------- Umschalter ----------
   <div class="seg" role="group" aria-label="…"><button aria-pressed="true">…</button>…</div>
   Die gewählte Option ist weiß hervorgehoben. */
.seg {
  box-sizing: border-box; display: inline-flex; flex-shrink: 0; gap: 4px;
  height: var(--control-md); padding: 4px;
  background: var(--seg-bg); border-radius: var(--radius-md);
}
.seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 40px; padding: 0 14px;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  font: inherit; font-size: var(--text-md); font-weight: 700; line-height: 1; white-space: nowrap; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(31, 42, 68, .18); }
.seg button:not([aria-pressed="true"]) .i { opacity: .55; }

/* ---------- Karte ---------- */
.card { box-sizing: border-box; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius-lg); }

/* ---------- Kopfzeile einer App ----------
   <header class="app-header">
     <div class="app-name">
       <a class="btn icon" href="../" aria-label="Alle Lernapps">…Haus…</a>
       <div class="app-titles"><h1 class="app-title">Name</h1><p class="app-subtitle">…</p></div>
     </div>
     <div class="toolbar">…Knöpfe…</div>
   </header>
   Wird es eng, verschwinden erst Untertitel und .wide-only-Texte, dann der Titel. */
.app-header {
  box-sizing: border-box; width: 100%; container-type: inline-size;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.app-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.app-titles { min-width: 0; }
.app-title { margin: 0; font-size: var(--text-title); line-height: 1.1; white-space: nowrap; }
.app-subtitle { margin: 2px 0 0; font-size: var(--text-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar { display: flex; align-items: center; gap: var(--gap); }
@container (max-width: 600px) {
  .app-subtitle, .wide-only { display: none; }
  .btn.icon-narrow { width: var(--h); padding: 0; }
}
@container (max-width: 440px) {
  .app-titles { display: none; }
}
