/* quik Sites: Bewegung der App (docs/GESTALTUNG.md Abschnitt 16; Logik: public/js/bewegung.js).
   Regeln: kurz (120 bis 280 ms), ease-out beim Eintritt (--ease), nur transform und opacity, nichts verschiebt das Layout,
   nichts, was beim hundertsten Mal stört, alles aus bei prefers-reduced-motion (Block am Ende).
   Länger dürfen nur laufen: Ladezeichen (Schleifen), die Linie oben und das Feiern (bis 1,8 s).
   Farben nur über Variablen aus app.css (heller und dunkler Modus). Geprüft von tests/bewegung-app.test.mjs. */
:root { --bw-kurz: 120ms; --bw: 180ms; --bw-lang: 260ms; }

/* ---------- Knöpfe, Zeilen: gedrückt und Hover ---------- */
.btn { transition: transform var(--bw-kurz) var(--ease), background-color 150ms, border-color 150ms, color 150ms, opacity 150ms; }
.icon-btn, button.chip, a.chip, .toast-btn { transition: transform var(--bw-kurz) var(--ease), background-color 150ms, border-color 150ms, color 150ms; }
.icon-btn:active, button.chip:active, a.chip:active, .toast-btn:active { transform: scale(.96); }
.li, .sb-link, .srow.is-sw { transition: background-color var(--bw-kurz), color var(--bw-kurz); }
.switch:active span { opacity: .86; }

/* ---------- Knopf im Ladezustand (ui.js busy): Spinner im Knopf, Breite bleibt ---------- */
:is(.btn, .icon-btn, .link-btn, .toast-btn)[aria-busy="true"] { position: relative; opacity: .72; cursor: progress; }
:is(.btn, .icon-btn, .link-btn, .toast-btn)[aria-busy="true"]:not(.bw-busy-t) { -webkit-text-fill-color: transparent; }
:is(.btn, .icon-btn, .link-btn, .toast-btn)[aria-busy="true"]:not(.bw-busy-t) > * { opacity: 0; }
:is(.btn, .icon-btn, .link-btn, .toast-btn)[aria-busy="true"]:not(.bw-busy-t)::after { content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 99px; border: 2px solid color-mix(in srgb, currentColor 28%, transparent); border-top-color: currentColor; animation: bwDreh 700ms linear infinite; }
.bw-busy-t[aria-busy="true"]::before { content: ""; flex: none; display: inline-block; width: 13px; height: 13px; border-radius: 99px; border: 2px solid color-mix(in srgb, currentColor 28%, transparent); border-top-color: currentColor; animation: bwDreh 700ms linear infinite; }
@keyframes bwDreh { to { transform: rotate(360deg); } }

/* ---------- Skelette (ui.js skeleton): Form des späteren Inhalts, ein ruhiger Schimmer über den ganzen Block ---------- */
/* Erst nach 120 ms sichtbar: schnelle Antworten flackern nicht. Die Höhe steht sofort (kein Springen). */
.skel-set { position: relative; overflow: hidden; animation: bwDa 200ms 120ms ease-out backwards; }
.skel-set .skel::after { content: none; }
.skel-set::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(100deg, transparent 35%, color-mix(in srgb, var(--surface) 60%, transparent) 50%, transparent 65%); transform: translateX(-100%); animation: bwSchimmer 1800ms 300ms ease-in-out infinite; }
@keyframes bwDa { from { opacity: 0; } }
@keyframes bwSchimmer { to { transform: translateX(100%); } }
.skel-set i.skel, .skel-set span.skel { display: block; }
.skel-set.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.skel-rows { min-height: 56px; }
.skel-li { display: flex; align-items: center; gap: 12px; height: 56px; border-bottom: 1px solid var(--line-soft); }
.skel-li:last-child { border-bottom: 0; }
.skel-ic { flex: none; width: 32px; height: 32px; border-radius: 9px; }
.skel-tx { flex: 1 1 auto; min-width: 0; display: grid; gap: 8px; }
.skel-l1 { height: 12px; width: 42%; border-radius: 6px; }
.skel-l2 { height: 10px; width: 26%; border-radius: 6px; }
.skel-li:nth-child(3n + 2) .skel-l1 { width: 56%; }
.skel-li:nth-child(3n) .skel-l1 { width: 34%; }
.skel-li:nth-child(2n) .skel-l2 { width: 38%; }
.skel-chip { flex: none; width: 64px; height: 20px; border-radius: 99px; }
.skel-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.skel-tile { display: grid; gap: 10px; align-content: start; min-height: 96px; padding: 16px; border-radius: 14px; border: 1px solid var(--line-soft); background: var(--surface); }
.skel-tile .skel-l2 { width: 52%; }
.skel-zahl { width: 44%; height: 26px; border-radius: 8px; }
.skel-table { display: grid; }
.skel-tr { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1fr) 64px; align-items: center; gap: 16px; height: 44px; border-bottom: 1px solid var(--line-soft); }
.skel-tr:last-child { border-bottom: 0; }
.skel-tr > .skel { height: 11px; width: 70%; border-radius: 6px; }
.skel-tr.is-kopf > .skel { height: 9px; width: 44%; }
.skel-tr:nth-child(2n) > .skel:first-child { width: 52%; }
.skel-head { display: grid; gap: 12px; margin-bottom: 28px; }
.skel-titel { width: min(320px, 60%); height: 34px; border-radius: 10px; }
.skel-head .skel-l2 { width: min(220px, 40%); height: 12px; }
.skel-text { display: grid; gap: 10px; }
.skel-text > .skel { height: 12px; border-radius: 6px; }
.skel-text > .skel:nth-child(3n + 1) { width: 92%; }
.skel-text > .skel:nth-child(3n + 2) { width: 84%; }
.skel-text > .skel:nth-child(3n) { width: 58%; }
.skel-form { display: grid; gap: 18px; }
.skel-fld { display: grid; gap: 8px; }
.skel-fld > .skel:first-child { width: 120px; height: 10px; border-radius: 6px; }
.skel-fld > .skel:last-child { height: 40px; border-radius: 10px; }

/* Inhalt nach einem Skelett: blendet weich ein (bewegung.js setzt bw-fill; am Hauptbereich bleibt der Seitenkopf stehen) */
.bw-fill:not(.main), .main.bw-fill > .page > :not(.page-h), .main.bw-fill > :not(.page), .main.bw-seite > * { animation: bwDa var(--bw) ease-out backwards; }
/* Gestaffelt: nur die ersten 12 Einträge, nur beim ersten Zeichnen einer Seite oder nach dem Laden */
:is(.bw-neu, .bw-fill) :is(.list, .sites, .bw-staffel):not(.skel-set) > :nth-child(-n + 12),
.bw-fill:is(.list, .sites, .bw-staffel):not(.skel-set) > :nth-child(-n + 12) { animation: bwAuf 240ms var(--ease) backwards; }
:is(.bw-neu, .bw-fill) :is(.list, .sites, .bw-staffel) > :nth-child(2), .bw-fill:is(.list, .sites, .bw-staffel) > :nth-child(2) { animation-delay: 20ms; }
:is(.bw-neu, .bw-fill) :is(.list, .sites, .bw-staffel) > :nth-child(3), .bw-fill:is(.list, .sites, .bw-staffel) > :nth-child(3) { animation-delay: 40ms; }
:is(.bw-neu, .bw-fill) :is(.list, .sites, .bw-staffel) > :nth-child(4), .bw-fill:is(.list, .sites, .bw-staffel) > :nth-child(4) { animation-delay: 60ms; }
:is(.bw-neu, .bw-fill) :is(.list, .sites, .bw-staffel) > :nth-child(5), .bw-fill:is(.list, .sites, .bw-staffel) > :nth-child(5) { animation-delay: 80ms; }
:is(.bw-neu, .bw-fill) :is(.list, .sites, .bw-staffel) > :nth-child(6), .bw-fill:is(.list, .sites, .bw-staffel) > :nth-child(6) { animation-delay: 100ms; }
:is(.bw-neu, .bw-fill) :is(.list, .sites, .bw-staffel) > :nth-child(7), .bw-fill:is(.list, .sites, .bw-staffel) > :nth-child(7) { animation-delay: 120ms; }
:is(.bw-neu, .bw-fill) :is(.list, .sites, .bw-staffel) > :nth-child(8), .bw-fill:is(.list, .sites, .bw-staffel) > :nth-child(8) { animation-delay: 140ms; }
:is(.bw-neu, .bw-fill) :is(.list, .sites, .bw-staffel) > :nth-child(9), .bw-fill:is(.list, .sites, .bw-staffel) > :nth-child(9) { animation-delay: 160ms; }
:is(.bw-neu, .bw-fill) :is(.list, .sites, .bw-staffel) > :nth-child(10), .bw-fill:is(.list, .sites, .bw-staffel) > :nth-child(10) { animation-delay: 180ms; }
:is(.bw-neu, .bw-fill) :is(.list, .sites, .bw-staffel) > :nth-child(11), .bw-fill:is(.list, .sites, .bw-staffel) > :nth-child(11) { animation-delay: 200ms; }
:is(.bw-neu, .bw-fill) :is(.list, .sites, .bw-staffel) > :nth-child(12), .bw-fill:is(.list, .sites, .bw-staffel) > :nth-child(12) { animation-delay: 220ms; }
@keyframes bwAuf { from { opacity: 0; transform: translateY(6px); } }
/* Chip, Badge oder Zeile, die neu dazukommt (bewegung.js erscheinen) */
.bw-pop { animation: bwPopIn var(--bw) var(--ease) backwards; }
@keyframes bwPopIn { from { opacity: 0; transform: scale(.88); } }
/* Vorschaubilder: weich da, sobald geladen */
img.bw-bild { opacity: 0; transition: opacity 200ms ease-out; }
img.bw-bild.is-da { opacity: 1; }

/* ---------- Laden: Linie oben, Start der App, Ladeansicht (Editor), Balken ---------- */
#bw-linie { position: fixed; left: 0; right: 0; top: 0; z-index: 500; height: 2px; pointer-events: none; transition: opacity 200ms 160ms; }
#bw-linie i { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; }
#bw-linie.laeuft i { transform: scaleX(.82); transition: transform 8000ms cubic-bezier(.08, .6, .2, 1); }
#bw-linie.fertig i { transform: scaleX(1); transition: transform 160ms ease-out; }
#bw-linie.fertig { opacity: 0; }
/* Start der App (index.html .boot): kein Spinner, eine schmale Linie mit ruhigem Lauf; erst nach 150 ms sichtbar */
.boot { min-height: 100vh; min-height: 100dvh; }
.boot::before, .boot::after { content: ""; grid-area: 1 / 1; height: 3px; border-radius: 99px; border: 0; }
.boot::before { width: 64px; background: var(--surface-3); animation: bwDa 200ms 150ms backwards; }
.boot::after { width: 24px; background: var(--ink-soft); animation: bwPendel 900ms ease-in-out infinite alternate, bwDa 200ms 150ms backwards; }
@keyframes bwPendel { from { transform: translateX(-20px); } to { transform: translateX(20px); } }
.bw-lade { height: 100%; min-height: 220px; display: grid; place-items: center; place-content: center; gap: 20px; animation: bwDa 200ms 120ms ease-out backwards; }
.bw-lade-z { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--fg); font-size: var(--fs-lg); }
.bw-lade-z:empty { display: none; }
.bw-lade-b { display: block; width: 72px; height: 3px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bw-lade-b i { display: block; width: 40%; height: 100%; border-radius: inherit; background: var(--ink-soft); animation: bwLauf 1100ms ease-in-out infinite; }
@keyframes bwLauf { from { transform: translateX(-110%); } to { transform: translateX(260%); } }
.qe-boot > .bw-lade { min-height: 0; }
#app > .bw-lade { min-height: 100vh; min-height: 100dvh; }
.bw-balken { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bw-balken i { display: block; height: 100%; border-radius: inherit; background: var(--fg); transform: scaleX(0); transform-origin: 0 50%; transition: transform 200ms ease-out; }
.bw-balken.voll i { background: var(--green-dot); }

/* ---------- Seitenwechsel: kurzes Überblenden (View Transitions), Klicks gehen währenddessen durch ---------- */
::view-transition { pointer-events: none; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 160ms; animation-timing-function: ease-out; }

/* ---------- Menüs, Dialoge, Toasts ---------- */
/* Menü und Popover skalieren aus dem Anker (ui.js placePop setzt transform-origin) */
.pop:not(.pop-sub):not(.sheet) { animation: bwMenue 140ms var(--ease); }
@keyframes bwMenue { from { opacity: 0; transform: scale(.96); } }
/* Dialog: leicht von unten, der Hintergrund blendet (app.css fadeIn) */
.modal:not(.side):not(.libx) { animation: bwDialog 220ms var(--ease); }
@keyframes bwDialog { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal-wrap { animation-duration: 160ms; }
.toast { animation: bwToast 220ms var(--ease); }
@keyframes bwToast { from { opacity: 0; transform: translateX(16px); } }
.toast.out { opacity: 0; transform: translateX(16px); transition: opacity 160ms ease-in, transform 160ms ease-in; }

/* ---------- Segment: gleitender Hintergrund; Reiter: gleitende Linie (bewegung.js gleiten) ---------- */
.seg.bw-gleitet > button { transition: none; }
.seg > button.bw-gl { position: relative; isolation: isolate; background: transparent; box-shadow: none; }
.seg > button.bw-gl::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--seg-on); box-shadow: 0 1px 2px color-mix(in srgb, var(--shadow-c) 40%, transparent); transform-origin: 0 50%; animation: bwGleit 220ms var(--ease) backwards; }
.tabs.bw-gleitet .tab::after { transition: none; }
.tab.on.bw-gl::after { transform-origin: 0 50%; animation: bwGleit 220ms var(--ease) backwards; }
@keyframes bwGleit { from { transform: translate(var(--bw-dx, 0), var(--bw-dy, 0)) scaleX(var(--bw-sx, 1)); } }

/* ---------- Speichern: kurzer Haken an der Speicherleiste, Punkt im Editor ---------- */
.sb2-st.bw-ok > .ic { animation: bwHakenKurz 260ms var(--ease) backwards; }
@keyframes bwHakenKurz { from { opacity: 0; transform: scale(.4) rotate(-20deg); } }
.qe-save:not(.saving):not(.err):not(.ro)::before { animation: bwPunkt 280ms var(--ease); }
@keyframes bwPunkt { 0% { transform: scale(1); } 45% { transform: scale(1.8); } 100% { transform: scale(1); } }

/* ---------- Feiern (bewegung.js feiern): Konfetti, Haken, Puls ---------- */
.bw-konfetti { position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; z-index: 398; pointer-events: none; }
.bw-puls { position: fixed; z-index: 399; border-radius: 99px; border: 2px solid var(--green-dot); pointer-events: none; animation: bwPuls 700ms ease-out both; }
@keyframes bwPuls { from { opacity: .6; transform: scale(.85); } to { opacity: 0; transform: scale(1.9); } }
.bw-haken { position: fixed; z-index: 400; width: 34px; height: 34px; border-radius: 99px; display: grid; place-items: center; background: var(--green-tint); border: 1px solid var(--green-line); pointer-events: none; animation: bwHaken 1000ms var(--ease) both; }
.bw-haken svg { width: 20px; height: 20px; fill: none; stroke: var(--green-dot); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.bw-haken path { stroke-dasharray: 18; stroke-dashoffset: 18; animation: bwZeichnen 280ms 140ms var(--ease) forwards; }
@keyframes bwHaken { 0% { opacity: 0; transform: scale(.6); } 20% { opacity: 1; transform: scale(1); } 76% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: translateY(-4px); } }
/* Einzige Ausnahme zu „nur transform und opacity“: Der Strich des Hakens zeichnet sich (kleines SVG, kein Layout) */
@keyframes bwZeichnen { to { stroke-dashoffset: 0; } }
.bw-haken.still { animation: bwStill 1000ms linear both; }
.bw-haken.still path { animation: none; stroke-dashoffset: 0; }
@keyframes bwStill { 0% { opacity: 0; } 10% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Weniger Bewegung: alles aus. Ladezeichen bleiben als ruhiger Hinweis (langsam bzw. stehend). ---------- */
@media (prefers-reduced-motion: reduce) {
  .btn, .icon-btn, button.chip, a.chip, .toast-btn, .li, .sb-link, .srow.is-sw, img.bw-bild, .bw-balken i, .toast.out { transition: none !important; }
  .btn:active, .icon-btn:active, button.chip:active, a.chip:active, .toast-btn:active { transform: none; }
  img.bw-bild { opacity: 1; }
  .skel-set, .skel-set::after, .bw-fill, .bw-fill *, .bw-neu *, .bw-seite > *, .bw-pop, .pop, .modal, .toast, .bw-lade,
  .seg > button.bw-gl::before, .tab.on.bw-gl::after, .sb2-st.bw-ok > .ic, .qe-save::before, .boot::before, .boot::after, .bw-lade-b i { animation: none !important; }
  .skel-set::after { content: none; }
  .bw-lade-b i { width: 100%; opacity: .5; }
  .boot::after { width: 64px; }
  :is(.btn, .icon-btn, .link-btn, .toast-btn)[aria-busy="true"]::after, .bw-busy-t[aria-busy="true"]::before { animation-duration: 1600ms !important; }
  #bw-linie, #bw-linie i { transition: none !important; }
  .bw-konfetti, .bw-puls { display: none !important; }
  .bw-haken:not(.still) { animation: none !important; }
  .bw-haken path { animation: none !important; stroke-dashoffset: 0; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
