/* ==========================================================================
   FigurGO Feature-Animationen – Stil wie im App-Onboarding
   Einbinden: <link rel="stylesheet" href="figurgo-animationen.css">
   Alle Klassen beginnen mit fg-, damit nichts mit der Website kollidiert.
   ========================================================================== */

/* ── 1. Design-Tokens ───────────────────────────────────────────────────── */
.fg-stage {
  --fg-blue: #3A55E7;        /* Markenblau (Knöpfe, Linien, "Du") */
  --fg-blue-600: #253fcf;
  --fg-blue-700: #1e3a8a;
  --fg-blue-50: #eff3ff;
  --fg-blue-100: #dbe6fe;
  --fg-blue-200: #bfd3fe;
  --fg-indigo-50: #eef2ff;
  --fg-indigo-200: #c7d2fe;
  --fg-sky-50: #f0f9ff;
  --fg-ink: #1e293b;         /* Überschriften, Zahlen */
  --fg-text: #334155;        /* Fließtext in Karten */
  --fg-muted: #64748b;       /* Nebentext */
  --fg-soft: #94a3b8;        /* Zeitangaben, Labels */
  --fg-line: #f1f5f9;        /* Rahmen, Rasterlinien */
  --fg-line-2: #e2e8f0;
  --fg-green: #10b981;       /* Erfolg, Haken */
  --fg-green-50: #ecfdf5;
  --fg-green-100: #d1fae5;
  --fg-green-700: #047857;
  --fg-orange: #f97316;      /* Ziel, Challenge */
  --fg-orange-600: #ea580c;
  --fg-orange-50: #fff7ed;
  --fg-rose: #f43f5e;        /* Herzen */
  --fg-radius-card: 16px;
  --fg-radius-row: 12px;
  --fg-shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, .10), 0 4px 6px -4px rgba(15, 23, 42, .10);
  --fg-shadow-md: 0 4px 6px -1px rgba(15, 23, 42, .10), 0 2px 4px -2px rgba(15, 23, 42, .10);
  --fg-shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --fg-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ── 2. Bühne (ersetzt das bisherige Bild) ──────────────────────────────── */
.fg-stage {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 270px;
  aspect-ratio: 4 / 3;       /* bei Bedarf überschreiben, z. B. 1 / 1 */
  container-type: inline-size;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--fg-blue-50), var(--fg-indigo-50) 50%, var(--fg-sky-50));
  font-family: var(--fg-font);
  color: var(--fg-text);
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}
.fg-stage *, .fg-stage *::before, .fg-stage *::after { box-sizing: border-box; }
.fg-stage p { margin: 0; }
.fg-blob { position: absolute; border-radius: 50%; filter: blur(40px); pointer-events: none; }
.fg-blob--a { top: -40px; left: -40px; width: 160px; height: 160px; background: rgba(191, 211, 254, .45); }
.fg-blob--b { bottom: -48px; right: -32px; width: 180px; height: 180px; background: rgba(199, 210, 254, .45); animation-delay: 1.5s; }
.fg-scale { position: relative; --fg-auto-scale: 1; transform: scale(var(--fg-scale, var(--fg-auto-scale))); }
/* Größe folgt automatisch der Breite der Fläche (nicht des Bildschirms);
   eigene Größe mit style="--fg-scale: 1.3" am .fg-stage */
@container (min-width: 440px) { .fg-scale { --fg-auto-scale: 1.2; } }
@container (min-width: 560px) { .fg-scale { --fg-auto-scale: 1.4; } }
@container (min-width: 720px) { .fg-scale { --fg-auto-scale: 1.6; } }

/* ── 3. Bausteine ───────────────────────────────────────────────────────── */
.fg-card { background: #fff; border: 1px solid var(--fg-line); border-radius: var(--fg-radius-card); box-shadow: var(--fg-shadow-lg); padding: 16px; }
.fg-card--sm { box-shadow: var(--fg-shadow-sm); padding: 10px 12px; border-radius: var(--fg-radius-row); }
.fg-w220 { width: 220px; } .fg-w240 { width: 240px; }
.fg-eyebrow { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-soft); }
.fg-title-xs { font-size: 12px; font-weight: 700; color: var(--fg-ink); }
.fg-small { font-size: 12px; color: var(--fg-muted); }
.fg-text { font-size: 14px; color: var(--fg-text); }
.fg-row { display: flex; align-items: center; gap: 10px; }
.fg-stack > * + * { margin-top: 8px; }
.fg-avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.fg-avatar--pink { background: linear-gradient(135deg, #f472b6, #f43f5e); }
.fg-avatar--sky { background: linear-gradient(135deg, #38bdf8, #3b82f6); width: 24px; height: 24px; font-size: 10px; }
.fg-avatar--brand { background: var(--fg-blue); font-weight: 800; }
.fg-appicon { width: 32px; height: 32px; border-radius: 8px; background: var(--fg-blue); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800; flex-shrink: 0; }
.fg-pill { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 4px 10px; }
.fg-pill--blue { color: var(--fg-blue); background: var(--fg-blue-50); }
.fg-pill--green { color: var(--fg-green-700); background: var(--fg-green-50); border: 1px solid var(--fg-green-100); font-size: 12px; padding: 2px 10px; }
.fg-btn { height: 40px; border-radius: 12px; background: var(--fg-blue); color: #fff; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.fg-bubble { font-size: 14px; border-radius: 16px; padding: 8px 12px; box-shadow: var(--fg-shadow-sm); width: fit-content; max-width: 100%; }
.fg-bubble--in { background: #fff; border: 1px solid var(--fg-line); color: var(--fg-text); border-bottom-left-radius: 6px; }
.fg-bubble--out { background: var(--fg-blue); color: #fff; border-bottom-right-radius: 6px; margin-left: auto; }

/* Szene: Gewicht eintragen */
.fg-digits { display: flex; align-items: flex-end; gap: 2px; margin-top: 4px; }
.fg-digit { font-size: 36px; line-height: 1; font-weight: 800; color: var(--fg-ink); font-variant-numeric: tabular-nums; }
.fg-unit { font-size: 18px; font-weight: 700; color: var(--fg-soft); margin: 0 0 3px 4px; }
.fg-check { position: absolute; right: -8px; top: -8px; width: 28px; height: 28px; border-radius: 50%; background: var(--fg-green); color: #fff; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: var(--fg-shadow-md); }

/* Szene: Bestenliste */
.fg-lb-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--fg-line); border-radius: var(--fg-radius-row); padding: 10px 12px; box-shadow: var(--fg-shadow-sm); font-size: 14px; }
.fg-lb-row b { flex: 1; font-weight: 600; color: var(--fg-muted); }
.fg-lb-row span:last-child { font-weight: 700; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.fg-lb-row.is-me { background: var(--fg-blue-50); border-color: var(--fg-blue-200); }
.fg-lb-row.is-me b, .fg-lb-row.is-me span:last-child { color: var(--fg-blue-600); }
.fg-medal { font-size: 18px; line-height: 1; }
.fg-clap { position: absolute; right: -20px; top: 44px; font-size: 22px; }

/* Szene: Einkaufsliste */
.fg-todo { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 14px; color: var(--fg-muted); }
.fg-box { position: relative; width: 20px; height: 20px; border: 2px solid var(--fg-line-2); border-radius: 6px; flex-shrink: 0; }
.fg-box > span { position: absolute; inset: -2px; border-radius: 6px; background: var(--fg-green); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.fg-strike-wrap { position: relative; }
.fg-strike { position: absolute; left: 0; top: 50%; width: 100%; height: 1.5px; background: var(--fg-soft); transform-origin: left; }

/* Szene: Rezepte */
.fg-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 240px; }
.fg-tile { background: #fff; border: 1px solid var(--fg-line); border-radius: var(--fg-radius-row); padding: 8px; text-align: center; box-shadow: var(--fg-shadow-sm); }
.fg-tile div { height: 48px; border-radius: 8px; background: linear-gradient(135deg, var(--fg-green-50), #fffbeb); display: flex; align-items: center; justify-content: center; font-size: 24px; }
.fg-tile p { font-size: 11px; font-weight: 600; color: var(--fg-muted); margin-top: 6px; }

/* Szene: Tages-Check / Challenge (Erweiterungen) */
.fg-habits { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.fg-habit { position: relative; height: 52px; border-radius: 12px; border: 2px solid var(--fg-line-2); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.fg-habit > span { position: absolute; inset: -2px; border-radius: 12px; background: var(--fg-blue-50); border: 2px solid var(--fg-blue); }
.fg-habit > i { position: relative; font-style: normal; }
.fg-bar { position: relative; height: 12px; border-radius: 999px; background: #ffedd5; overflow: hidden; margin-top: 8px; }
.fg-bar > span { position: absolute; inset: 0 auto 0 0; width: 68%; border-radius: 999px; background: linear-gradient(90deg, #fb923c, var(--fg-orange-600)); transform-origin: left; }
.fg-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: 240px; }
.fg-kpi { background: #fff; border: 1px solid var(--fg-line); border-radius: var(--fg-radius-row); padding: 10px 12px; box-shadow: var(--fg-shadow-sm); }
.fg-kpi b { display: block; font-size: 22px; font-weight: 800; color: var(--fg-ink); font-variant-numeric: tabular-nums; }
.fg-kpi span { font-size: 11px; color: var(--fg-soft); font-weight: 600; }

/* ── 4. Bewegung ─────────────────────────────────────────────────────────
   Regel: nur "from"-Keyframes. Ohne Animation (oder bei "weniger
   Bewegung") steht jedes Element sofort im fertigen Zustand.
   Die Einmal-Effekte laufen nur, solange die Bühne die Klasse fg-play hat
   (setzt das Skript, sobald die Bühne sichtbar wird).                    */
.fg-play .fg-in     { animation: fg-in .45s cubic-bezier(.2,.8,.2,1) both; }
.fg-play .fg-slide  { animation: fg-slide .5s cubic-bezier(.2,.8,.2,1) both; }
.fg-play .fg-drop   { animation: fg-drop .55s cubic-bezier(.2,.9,.25,1.15) both; }
.fg-play .fg-pop    { animation: fg-pop .45s cubic-bezier(.2,.9,.3,1.4) both; }
.fg-play .fg-fade   { animation: fg-fade .8s ease-out both; }
.fg-play .fg-press  { animation: fg-press .35s ease-in-out both; }
.fg-play .fg-strike { animation: fg-strike .35s ease-out both; }
.fg-play .fg-grow   { animation: fg-grow 1.2s cubic-bezier(.45,.05,.35,1) both; }
.fg-play .fg-draw   { stroke-dasharray: 100; animation: fg-draw 1.4s cubic-bezier(.45,.05,.35,1) both; }
.fg-play .fg-ring   { display: inline-block; transform-origin: 50% 10%; animation: fg-ring 1.2s ease-in-out both; }
.fg-play .fg-scene  { animation: fg-scene .45s cubic-bezier(.2,.8,.2,1) both; }
.fg-pop, .fg-ping { transform-box: fill-box; transform-origin: center; }
/* Dauerschleifen (dezent, laufen immer) */
.fg-ping  { animation: fg-ping 1.6s ease-out infinite; }
.fg-float { animation: fg-float 6s ease-in-out infinite; }
.fg-dot   { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--fg-soft); animation: fg-dot 1s ease-in-out infinite; }

@keyframes fg-in     { from { opacity: 0; transform: translateY(8px); } }
@keyframes fg-slide  { from { opacity: 0; transform: translateX(-18px); } }
@keyframes fg-drop   { from { opacity: 0; transform: translateY(-28px) scale(.96); } }
@keyframes fg-pop    { from { opacity: 0; transform: scale(.3); } }
@keyframes fg-fade   { from { opacity: 0; } }
@keyframes fg-press  { 50% { transform: scale(.93); filter: brightness(.92); } }
@keyframes fg-strike { from { transform: scaleX(0); } }
@keyframes fg-grow   { from { transform: scaleX(0); } }
@keyframes fg-draw   { from { stroke-dashoffset: 100; } }
@keyframes fg-ring   { 10% { transform: rotate(16deg); } 20% { transform: rotate(-14deg); } 30% { transform: rotate(10deg); } 40% { transform: rotate(-8deg); } 50% { transform: rotate(4deg); } 60% { transform: rotate(0); } }
@keyframes fg-scene  { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes fg-ping   { 0% { transform: scale(.6); opacity: .35; } 80%, 100% { transform: scale(2); opacity: 0; } }
@keyframes fg-float  { 50% { transform: translate(12px, 10px) scale(1.06); } }
@keyframes fg-dot    { 30% { transform: translateY(-4px); opacity: 1; } 0%, 60%, 100% { opacity: .5; } }

/* Mit Skript: Szene bis zum ersten Abspielen verstecken (kein Aufblitzen) */
.fg-js .fg-stage:not(.fg-play):not(.fg-done) .fg-scene { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .fg-stage *, .fg-stage *::before, .fg-stage *::after { animation: none !important; }
  .fg-js .fg-stage .fg-scene { opacity: 1 !important; }
}
.fg-rel { position: relative; }
