/* =========================================================================
   SCENY PROCESÓW — jeden panel = jedna animacja

   Każdy panel ma JEDNĄ scenę SVG, która opowiada cały proces od początku do
   końca: elementy pojawiają się w kolejności zdarzeń, przepływ przechodzi
   przez kompozycję, a stan końcowy zostaje wyróżniony akcentem. Scena jest
   dekoracją (aria-hidden) — treść niesie tekst panelu, więc przy wyłączonym
   ruchu wszystkie elementy są widoczne i czytelne.

   Ruch uruchamia assets/js/scenes.js, gdy panel wejdzie w widok (raz).
   Bez JS / bez IntersectionObserver / przy prefers-reduced-motion scena
   zostaje statyczna, ale kompletna.

   Wspólny język: węzły (.nd), panele (.pnl), łączniki (.ln/.ln-d), punkty
   danych (.dt), pakiety (.pk), podpisy (.lb), znaczniki (.chk/.mk).
   Tempo łączników zgodne z resztą strony (wzorzec z Lead Dashboardu:
   6 px wzoru na 1,3 s).
   ========================================================================= */

.scene {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 16px;              /* scena jest pierwszym elementem karty —
                                    odstęp idzie pod nią, przed nagłówek */
  overflow: hidden;              /* nic nie wychodzi poza panel */
  pointer-events: none;
  --sd: 7.2s;                 /* długość pełnego cyklu sceny (4–8 s) */
}

.scene text { font-family: inherit; }
.scene .lb { fill: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 0.02em; }
.scene .lb--s { font-size: 8.6px; font-weight: 500; letter-spacing: 0.01em; }
.scene .lb--a { fill: var(--accent); }

.scene .nd { fill: var(--bg-2); stroke: var(--line-2); stroke-width: 1; }
.scene .nd--b { fill: var(--bg-3); stroke: var(--line); }
.scene .nd--a { fill: var(--bg-2); stroke: var(--accent); }
.scene .pnl { fill: var(--bg-2); stroke: var(--line); stroke-width: 1; }
.scene .ln { stroke: var(--line-2); stroke-width: 1; fill: none; stroke-dasharray: 3 3; }
.scene .ln-d { stroke: var(--line-2); stroke-width: 1; fill: none; }
.scene .ln-d--a { stroke: var(--accent); }
.scene .tx { stroke: var(--line-2); stroke-width: 1.4; stroke-linecap: round; fill: none; }
.scene .tx--a { stroke: var(--accent); }
.scene .dt { fill: var(--accent); }
.scene .pk { fill: var(--accent); }
.scene .ring { fill: none; stroke: var(--accent); stroke-width: 1.4; }
.scene .chk { stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.scene .mk { fill: var(--accent); font-size: 11px; font-weight: 700; }
.scene .mk--bad { fill: #e08585; }
.scene .bad { fill: #e08585; fill-opacity: 0.14; stroke: #e08585; stroke-opacity: 0.55; stroke-width: 1; }
.scene .gr { fill: var(--line-2); }
.scene .gr--a { fill: var(--accent); }

/* --- Animacje wspólne ---------------------------------------------------- */
@keyframes sIn {
  0%, 4% { opacity: 0; }
  12%, 86% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes sInUp {
  0% { opacity: 0; transform: translateY(6px); }
  12%, 86% { opacity: 1; transform: none; }
  100% { opacity: 0; }
}
/* Rozproszone elementy ustawiają się w uporządkowany ciąg. */
@keyframes sAlign {
  0% { opacity: 0; transform: translateY(var(--dy, 0)); }
  8% { opacity: 1; }
  22% { opacity: 1; transform: translateY(var(--dy, 0)); }
  44%, 86% { opacity: 1; transform: none; }
  100% { opacity: 0; }
}
/* Punkt danych płynie przez kompozycję. */
@keyframes sFlow {
  0% { opacity: 0; transform: translate(0, 0); }
  7% { opacity: 1; }
  46%, 64% { opacity: 1; transform: translate(var(--dx, 0), var(--dy, 0)); }
  74% { opacity: 0; transform: translate(var(--dx, 0), var(--dy, 0)); }
  100% { opacity: 0; transform: translate(0, 0); }
}
/* Jak wyżej, ale z przystankiem w połowie drogi (np. przejście przez hub). */
@keyframes sFlow2 {
  0% { opacity: 0; transform: translate(0, 0); }
  6% { opacity: 1; }
  28% { opacity: 1; transform: translate(var(--mx, 0), var(--my, 0)); }
  60%, 70% { opacity: 1; transform: translate(var(--dx, 0), var(--dy, 0)); }
  80% { opacity: 0; transform: translate(var(--dx, 0), var(--dy, 0)); }
  100% { opacity: 0; transform: translate(0, 0); }
}
/* Linia rysuje się po swojej kolejności i tak zostaje; zwijanie na końcu
   cyklu jest szybkie (96–100%), więc nie rzuca się w oczy. */
@keyframes sDraw {
  0%, 6% { stroke-dashoffset: var(--len, 60); }
  26%, 96% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: var(--len, 60); }
}
@keyframes sAct {
  0%, 100% { stroke: var(--line-2); }
  12% { stroke: var(--accent); }
  46% { stroke: var(--line-2); }
}
@keyframes sGrow {
  0%, 4% { transform: scaleY(0.12); }
  22%, 86% { transform: scaleY(1); }
  100% { transform: scaleY(0.12); }
}
@keyframes sRing {
  0%, 5% { opacity: 0; }
  14% { opacity: 1; }
  26% { opacity: 0.38; }
  38%, 86% { opacity: 1; }
  96%, 100% { opacity: 0; }
}
/* Element wypada z procesu (odrzucona próba, anulowany wiersz). */
@keyframes sOut {
  0%, 44% { opacity: 1; transform: none; }
  58%, 86% { opacity: 0.3; transform: translate(var(--ox, 0), var(--oy, 0)); }
  100% { opacity: 0; }
}
@keyframes sDim {
  0%, 44% { opacity: 1; }
  58%, 86% { opacity: 0.34; }
  100% { opacity: 0; }
}
/* Element wchodzi do sceny, a potem wypada z procesu (np. odrzucona próba
   rezerwacji albo nieaktualny termin). */
@keyframes sAppearOut {
  0%, 16% { opacity: 0; transform: none; }
  26%, 46% { opacity: 1; transform: none; }
  58% { opacity: 0.34; transform: translate(var(--ox, 0), var(--oy, 0)); }
  80%, 100% { opacity: 0; transform: translate(var(--ox, 0), var(--oy, 0)); }
}

/* Animacje działają dopiero po wejściu panelu w widok (klasa z scenes.js),
   więc przewijanie strony nie odtwarza sekwencji w kółko.

   Uwaga na przyszłość: tu MUSZĄ być właściwości pojedyncze, nie skrót
   `animation`. Skrót ustawia też animation-delay: 0 i jako reguła o wyższej
   specyficzności kasowałby opóźnienia przypisane poszczególnym elementom
   scen (cała choreografia grałaby w jednej fazie).
   fill-mode: backwards sprawia, że element czeka na swoją kolej w stanie
   początkowym klatki (np. ukryty), a nie widoczny od razu. */
.scene.is-on .an-in, .scene.is-on .an-up, .scene.is-on .an-align,
.scene.is-on .an-flow, .scene.is-on .an-flow2, .scene.is-on .an-ring,
.scene.is-on .an-out, .scene.is-on .an-dim, .scene.is-on .an-ao,
.scene.is-on .an-grow, .scene.is-on .an-draw, .scene.is-on .an-act {
  animation-duration: var(--sd);
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-fill-mode: backwards;
}
.scene.is-on .an-grow, .scene.is-on .an-draw { animation-timing-function: ease-out; }
.scene.is-on .an-in { animation-name: sIn; }
.scene.is-on .an-up { animation-name: sInUp; }
.scene.is-on .an-align { animation-name: sAlign; }
.scene.is-on .an-flow { animation-name: sFlow; }
.scene.is-on .an-flow2 { animation-name: sFlow2; }
.scene.is-on .an-draw { animation-name: sDraw; }
.scene.is-on .an-act { animation-name: sAct; }
.scene.is-on .an-grow { animation-name: sGrow; }
.scene.is-on .an-ring { animation-name: sRing; }
.scene.is-on .an-out { animation-name: sOut; }
.scene.is-on .an-dim { animation-name: sDim; }
.scene.is-on .an-ao { animation-name: sAppearOut; }
/* Poza ekranem scena jest wstrzymana (nie zatrzymuje procesora i nie
   odtwarza się od początku przy powrocie — wznawia się w tym samym miejscu). */
.scene.is-on:not(.in-view), .scene.is-on:not(.in-view) * { animation-play-state: paused; }

/* Linie akcentu płyną wolno i jednostajnie — jak łączniki na stronie. */
.scene.is-on .ln--a { stroke: var(--accent); animation: sDashFlow 1.3s linear infinite; }
@keyframes sDashFlow { to { stroke-dashoffset: -12; } }

.scene .draw { stroke-dasharray: var(--len, 60); stroke-dashoffset: var(--len, 60); }
.scene .gr { transform-box: fill-box; transform-origin: 50% 100%; }

/* =========================== 1. Rozumiemy proces ========================= */
/* Cztery etapy pracy startują rozproszone i układają się w jeden ciąg,
   przez który przechodzi impuls; pod nimi powstaje wspólny plan wdrożenia. */
.s1 .n1 { --dy: -12px; animation-delay: 0s; }
.s1 .n2 { --dy: 16px; animation-delay: 0.1s; }
.s1 .n3 { --dy: -7px; animation-delay: 0.2s; }
.s1 .n4 { --dy: 20px; animation-delay: 0.3s; }
/* Łącznik i przepływ dopiero wtedy, gdy etapy się ułożą — inaczej linia
   wisiałaby między elementami, które jeszcze nie stoją w jednym ciągu. */
.s1 .l1 { --len: 164; animation-delay: 2.6s; }
.s1 .d1 { --dx: 164px; animation-delay: 3.2s; }
.s1 .p1, .s1 .t1 { animation-delay: 3.8s; }

/* =========================== 2. AI tam, gdzie ma sens ==================== */
/* Zgłoszenie wchodzi na wspólny etap analizy (słupki przetwarzania), a potem
   impuls trafia do jednej z kategorii — ta zostaje wyróżniona. */
.s2 .n1, .s2 .x1, .s2 .x2, .s2 .x3, .s2 .t1 { animation-delay: 0s; }
.s2 .x2 { animation-delay: 0.1s; }
.s2 .x3 { animation-delay: 0.2s; }
.s2 .n2, .s2 .t2 { animation-delay: 0.5s; }
.s2 .b1 { animation-delay: 1.0s; }
.s2 .b2 { animation-delay: 1.2s; }
.s2 .b3 { animation-delay: 1.4s; }
.s2 .n3, .s2 .t3 { animation-delay: 1.8s; }
.s2 .n4, .s2 .t4 { animation-delay: 1.9s; }
.s2 .n5, .s2 .t5 { animation-delay: 2.0s; }
.s2 .d1 { --dx: 46px; animation-delay: 0.3s; }
.s2 .d2 { --dx: 42px; --dy: -2px; animation-delay: 2.4s; }
.s2 .r1 { animation-delay: 2.9s; }

/* =========================== 3. Integracje ============================== */
/* Trzy istniejące systemy; informacja przechodzi przez cały łańcuch,
   a każdy kolejny system rozświetla się w chwili dotarcia danych. */
.s3 .n1 { animation-delay: 0s; }
.s3 .n2 { animation-delay: 0.3s; }
.s3 .n3 { animation-delay: 0.6s; }
.s3 .l1 { --len: 60; animation-delay: 1.1s; }
.s3 .l2 { --len: 60; animation-delay: 2.4s; }
.s3 .d1 { --dx: 60px; animation-delay: 1.6s; }
.s3 .d2 { --dx: 60px; animation-delay: 2.9s; }
.s3 .t1, .s3 .t2, .s3 .t3 { animation-delay: 0.2s; }
.s3 .act1 { animation-delay: 2.6s; }
.s3 .act2 { animation-delay: 3.9s; }

/* =========================== 4. Kontrola u człowieka ==================== */
/* Zgłoszenie → system przygotowuje propozycję → człowiek sprawdza
   i zatwierdza; moment zgody jest wyróżniony rysowanym znacznikiem. */
.s4 .n1, .s4 .t1 { animation-delay: 0s; }
.s4 .n2, .s4 .t2 { animation-delay: 0.6s; }
.s4 .y1 { animation-delay: 1.0s; }
.s4 .y2 { animation-delay: 1.2s; }
.s4 .y3 { animation-delay: 1.4s; }
.s4 .d1 { --dx: 20px; animation-delay: 1.8s; }
.s4 .n3, .s4 .t3 { animation-delay: 2.1s; }
.s4 .hd, .s4 .hb { animation-delay: 2.4s; }
.s4 .ch { --len: 26; animation-delay: 3.4s; }
.s4 .r1 { animation-delay: 3.6s; }

/* =========================== 5. Kwalifikacja zapytań ==================== */
/* Trzy kanały → jedna wspólna kolejka → uporządkowane kategorie. */
.s5 .n1, .s5 .t1 { animation-delay: 0s; }
.s5 .n2, .s5 .t2 { animation-delay: 0.12s; }
.s5 .n3, .s5 .t3 { animation-delay: 0.24s; }
.s5 .p1, .s5 .t4 { animation-delay: 0.8s; }
.s5 .d1 { --dx: 26px; --dy: 15px; animation-delay: 0.6s; }
.s5 .d2 { --dx: 26px; animation-delay: 0.9s; }
.s5 .d3 { --dx: 26px; --dy: -15px; animation-delay: 1.2s; }
.s5 .q1 { animation-delay: 1.6s; }
.s5 .q2 { animation-delay: 1.75s; }
.s5 .q3 { animation-delay: 1.9s; }
.s5 .n4, .s5 .t5 { animation-delay: 2.6s; }
.s5 .n5, .s5 .t6 { animation-delay: 2.75s; }
.s5 .n6, .s5 .t7 { animation-delay: 2.9s; }
.s5 .d4 { --dx: 64px; --dy: -14px; animation-delay: 2.4s; }
.s5 .d5 { --dx: 64px; --dy: 6px; animation-delay: 3.1s; }

/* =========================== 6. Przygotowywanie odpowiedzi ============== */
/* Zgłoszenie → powstaje propozycja odpowiedzi → człowiek zatwierdza,
   a zatwierdzona treść wychodzi z procesu. */
.s6 .n1, .s6 .t1 { animation-delay: 0s; }
.s6 .d1 { --dx: 16px; animation-delay: 0.2s; }
.s6 .n2, .s6 .t2 { animation-delay: 0.7s; }
.s6 .y1 { animation-delay: 1.1s; }
.s6 .y2 { animation-delay: 1.35s; }
.s6 .y3 { animation-delay: 1.6s; }
.s6 .y4 { animation-delay: 1.85s; }
.s6 .n3, .s6 .t3 { animation-delay: 2.5s; }
.s6 .ch { --len: 26; animation-delay: 3.4s; }
.s6 .q1 { --dx: 40px; --dy: -2px; animation-delay: 3.9s; }

/* =========================== 7. Przepływ między narzędziami ============= */
/* Dane ze źródła przechodzą przez integrację i aktualizują kolejny system. */
.s7 .n1, .s7 .t1 { animation-delay: 0s; }
.s7 .l1 { --len: 56; animation-delay: 0.6s; }
.s7 .d1 { --dx: 56px; animation-delay: 1.1s; }
.s7 .n2, .s7 .t2 { animation-delay: 1.4s; }
.s7 .g1 { animation-delay: 2.2s; }
.s7 .l2 { --len: 56; animation-delay: 2.6s; }
.s7 .d2 { --dx: 56px; animation-delay: 3.0s; }
.s7 .n3, .s7 .t3 { animation-delay: 3.3s; }
.s7 .u1 { animation-delay: 4.0s; }
.s7 .u2 { animation-delay: 4.3s; }

/* =========================== 8. Dokumenty i zadania ===================== */
/* Dokument → odczyt pól → uporządkowany rekord przekazany dalej. */
.s8 .n1, .s8 .t1 { animation-delay: 0s; }
.s8 .f1 { animation-delay: 0.15s; }
.s8 .f2 { animation-delay: 0.3s; }
.s8 .f3 { animation-delay: 0.45s; }
.s8 .f4 { animation-delay: 0.6s; }
.s8 .f5 { animation-delay: 0.75s; }
.s8 .m1 { --dx: 24px; animation-delay: 1.1s; }
.s8 .m2 { --dx: 24px; animation-delay: 1.5s; }
.s8 .m3 { --dx: 24px; animation-delay: 1.9s; }
.s8 .p1, .s8 .t2 { animation-delay: 1.4s; }
.s8 .p2, .s8 .t3 { animation-delay: 1.8s; }
.s8 .p3, .s8 .t4 { animation-delay: 2.2s; }
.s8 .d1, .s8 .t5 { animation-delay: 2.9s; }
.s8 .r1 { animation-delay: 3.2s; }
.s8 .r2 { animation-delay: 3.4s; }
.s8 .r3 { animation-delay: 3.6s; }

/* =========================== 9. Raportowanie =========================== */
/* Rozproszone rekordy układają się w jeden zbiór, z którego powstaje raport. */
.s9 .a1 { --dy: -20px; animation-delay: 0s; }
.s9 .a2 { --dy: 14px; animation-delay: 0.12s; }
.s9 .a3 { --dy: -9px; animation-delay: 0.24s; }
.s9 .a4 { --dy: 22px; animation-delay: 0.36s; }
.s9 .t1 { animation-delay: 0.2s; }
.s9 .d1 { --dx: 66px; --dy: 6px; animation-delay: 1.1s; }
.s9 .d2 { --dx: 66px; --dy: -4px; animation-delay: 1.6s; }
.s9 .p1, .s9 .t2 { animation-delay: 1.6s; }
.s9 .g1 { animation-delay: 2.4s; }
.s9 .g2 { animation-delay: 2.6s; }
.s9 .g3 { animation-delay: 2.8s; }
.s9 .s1 { animation-delay: 3.4s; }
.s9 .s2 { animation-delay: 3.6s; }
.s9 .s3 { animation-delay: 3.8s; }

/* =========================== 10. Procesy szyte na miarę ================= */
/* Dwa osobne przebiegi; między nimi dorysowuje się połączenie i informacja
   przechodzi już wspólną, zintegrowaną ścieżką. */
.s10 .n1, .s10 .t1 { animation-delay: 0s; }
.s10 .n2, .s10 .t2 { animation-delay: 0.15s; }
.s10 .l1, .s10 .l2 { --len: 148; animation-delay: 0.7s; }
.s10 .d1 { --dx: 148px; animation-delay: 1.1s; }
.s10 .d2 { --dx: 148px; animation-delay: 1.6s; }
.s10 .bd { --len: 46; animation-delay: 2.6s; }
.s10 .d3 { --mx: 0; --my: 4px; --dx: 0; --dy: 46px; animation-delay: 3.6s; }
.s10 .t3 { animation-delay: 4.2s; }

/* =========================== 11. Komfort gościa ======================== */
/* Plan sali → wybrany stolik zostaje wyróżniony → pojawia się jego numer,
   liczba miejsc i potwierdzony termin. */
.s11 .plan { animation-delay: 0s; }
.s11 .tb1 { animation-delay: 0.1s; }
.s11 .tb2 { animation-delay: 0.2s; }
.s11 .tb3 { animation-delay: 0.3s; }
.s11 .tb4 { animation-delay: 0.4s; }
.s11 .tb5 { animation-delay: 0.5s; }
.s11 .tb6 { animation-delay: 0.6s; }
.s11 .r1 { animation-delay: 1.5s; }
.s11 .c1 { animation-delay: 2.2s; }
.s11 .k1 { animation-delay: 2.5s; }
.s11 .k2 { animation-delay: 2.75s; }
.s11 .k3 { animation-delay: 3.0s; }

/* =========================== 12. Sprawna obsługa ======================== */
/* Jeden panel obsługi: nowa rezerwacja, zmiana terminu, anulowanie. */
.s12 .p1 { animation-delay: 0s; }
.s12 .w1 { animation-delay: 0.4s; }
.s12 .w2 { animation-delay: 1.5s; }
.s12 .w3 { animation-delay: 3.0s; }
.s12 .t1 { animation-delay: 0.2s; }
.s12 .old { --ox: -26px; animation-delay: 1.6s; }   /* an-ao: wchodzi z wierszem, potem wypada */
.s12 .new { animation-delay: 2.4s; }
.s12 .cut { --len: 96; animation-delay: 3.6s; }
.s12 .d1 { animation-delay: 0.9s; }

/* =========================== 13. Spójna informacja ====================== */
/* Jeden zapis zasila powiązane widoki — sala i kuchnia pokazują dokładnie
   te same dane w tym samym momencie. */
.s13 .c1 { animation-delay: 0s; }
.s13 .k1 { animation-delay: 0.3s; }
.s13 .k2 { animation-delay: 0.45s; }
.s13 .l1, .s13 .l2 { --len: 30; animation-delay: 0.9s; }
.s13 .v1 { animation-delay: 1.6s; }
.s13 .v2 { animation-delay: 1.6s; }
.s13 .ra { animation-delay: 2.1s; }
.s13 .rb { animation-delay: 2.1s; }
.s13 .rc { animation-delay: 2.35s; }
.s13 .rd { animation-delay: 2.35s; }
.s13 .lk { --dx: 0; --dy: 0; animation-delay: 3.2s; }

/* =========================== 14. Kontrola dostępności ================== */
/* Pierwsza rezerwacja zajmuje stolik; próba na nakładający się termin
   zostaje wykryta jako konflikt i odrzucona, a pierwsza rezerwacja zostaje. */
.s14 .ax1 { animation-delay: 0s; }
.s14 .ax2 { animation-delay: 0.2s; }
.s14 .bar-a { animation-delay: 0.6s; }
.s14 .la { animation-delay: 0.8s; }
.s14 .bar-b { --ox: 0; --oy: 18px; animation-delay: 1.8s; }   /* an-ao */
.s14 .lb2 { --ox: 0; --oy: 18px; animation-delay: 1.8s; }      /* an-ao */
.s14 .cf { animation-delay: 2.8s; }
.s14 .xm { animation-delay: 3.0s; }
.s14 .lb3 { animation-delay: 3.9s; }
.s14 .ok { --len: 24; animation-delay: 4.2s; }

/* ======================= Ograniczenie ruchu i małe ekrany ============== */
@media (prefers-reduced-motion: reduce) {
  .scene.is-on .an-in, .scene.is-on .an-up, .scene.is-on .an-align,
  .scene.is-on .an-flow, .scene.is-on .an-flow2, .scene.is-on .an-draw,
  .scene.is-on .an-act, .scene.is-on .an-grow, .scene.is-on .an-ring,
  .scene.is-on .an-out, .scene.is-on .an-dim,
  .scene.is-on .ln--a { animation: none !important; }
  .scene .draw { stroke-dashoffset: 0 !important; }
}
/* Przy ~240 px szerokości podpisy w scenach spadają do ~7 px, więc ich nie
   pokazujemy — układ, przepływ i wyróżnienia zostają, a opis panelu obok
   nie traci ani jednego słowa. */
@media (max-width: 620px) {
  .scene { margin-top: 12px; }
  .scene .lb, .scene .lb--s { display: none; }
}
