/* ==========================================================================
   Animace – oddělené od vzhledu, ať jdou snadno vyměnit.
   Scroll scény řídí js/animace.js přes CSS proměnné:
     .jak          --m (sjíždění karet 0→1), --r (odhalení rezervace 0→1)
     .email-sekce  --a (skládání e-mailu 0→1)
   Bez JS nebo při prefers-reduced-motion zůstává konečný stav (= 1).
   ========================================================================== */

/* ---------- konečné stavy (výchozí) ---------- */
.jak { --m: 1; --r: 1; }
.email-sekce { --a: 1; }

/* Bez JS a při omezení pohybu nepotřebujeme dlouhé scroll scény. */
html:not(.js-animace) .jak,
html:not(.js-animace) .email-sekce { height: auto; }
html:not(.js-animace) .jak__lepidlo,
html:not(.js-animace) .email-sekce__lepidlo { position: static; min-height: 0; }

/* ---------- úvod: hned po načtení ---------- */
.js-animace .titulek__radek {
  animation: vyjet .8s cubic-bezier(.2, .7, .2, 1) both;
}
.js-animace .uvod .titulek__radek:nth-child(2) { animation-delay: .12s; }
.js-animace .uvod .perex,
.js-animace .uvod .tlacitka { animation: vyjet .8s .25s cubic-bezier(.2, .7, .2, 1) both; }
.js-animace .karta-hovoru { animation: priletet .9s .2s cubic-bezier(.2, .7, .2, 1) both; }
.js-animace .plovouci-stitek--a { animation: vznaset 5s ease-in-out infinite; }
.js-animace .plovouci-stitek--b { animation: vznaset 6s 1s ease-in-out infinite; }
.js-animace .tecka-zive { animation: pulz-tecka 1.6s ease-in-out infinite; }
.js-animace .akce:not(.je-hotovo) .akce__ikona { animation: tocit 1s linear infinite; }
.js-animace .akce__text.je-zmena { animation: vyjet .35s ease both; }
.js-animace .bublina.je-nova { animation: vyjet .4s ease both; }

/* nadpisy dalších sekcí se animují až při zobrazení */
.js-animace section:not(.uvod) .titulek__radek { animation: none; }
.js-animace section:not(.uvod) .je-videt .titulek__radek,
.js-animace section:not(.uvod) .titulek.je-videt .titulek__radek { animation: vyjet .7s cubic-bezier(.2, .7, .2, 1) both; }
.js-animace section:not(.uvod) .titulek.je-videt .titulek__radek:nth-child(2) { animation-delay: .1s; }

.js-animace .odhal { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .7, .2, 1); }
.js-animace .odhal.je-videt { opacity: 1; transform: none; }

/* ---------- scéna 1: karty kroků se sjedou do jedné rezervace ---------- */
.krok {
  --x0: 0px; --y0: 0px; --rz: 0deg;
  transform:
    translate(calc(var(--x0) * (1 - var(--m))), calc(var(--y0) * (1 - var(--m))))
    rotate(calc(var(--rz) * var(--m)))
    scale(calc(1 - .22 * var(--m)));
  opacity: calc(1 - var(--r));
  will-change: transform, opacity;
}
/* mobil: mřížka 2 × 2 */
.krok:nth-of-type(1) { --x0: -88px; --y0: -98px; --rz: -6deg; }
.krok:nth-of-type(2) { --x0: 88px;  --y0: -98px; --rz: 4deg; }
.krok:nth-of-type(3) { --x0: -88px; --y0: 98px;  --rz: 3deg; }
.krok:nth-of-type(4) { --x0: 88px;  --y0: 98px;  --rz: -3deg; }

@media (min-width: 760px) {
  /* desktop: řada vedle sebe */
  .krok:nth-of-type(1) { --x0: -345px; --y0: 0px; }
  .krok:nth-of-type(2) { --x0: -115px; --y0: 0px; }
  .krok:nth-of-type(3) { --x0: 115px;  --y0: 0px; }
  .krok:nth-of-type(4) { --x0: 345px;  --y0: 0px; }
}

.listek {
  opacity: var(--r);
  transform: translateY(calc(28px * (1 - var(--r)))) scale(calc(.9 + .1 * var(--r)));
  will-change: transform, opacity;
}
.listek__radky div {
  opacity: clamp(0, calc((var(--r) - .25 * var(--j, 0)) * 2), 1);
}
.listek__radky div:nth-child(1) { --j: 0; }
.listek__radky div:nth-child(2) { --j: 1; }
.listek__radky div:nth-child(3) { --j: 2; }
.listek__radky div:nth-child(4) { --j: 3; }

/* ---------- scéna 2: e-mail se poskládá z dílků ---------- */
.dilek {
  --dx: 0px; --dy: 0px; --rot: 0deg; --d: 0;
  --k: clamp(0, calc((var(--a) - var(--d)) / .45), 1);
  transform:
    translate(calc(var(--dx) * (1 - var(--k))), calc(var(--dy) * (1 - var(--k))))
    rotate(calc(var(--rot) * (1 - var(--k))));
  opacity: calc(.12 + .88 * var(--k));
  will-change: transform, opacity;
}

/* ---------- úvodní karta: vlna hovoru a průběh akce ---------- */
.js-animace .vlnka i { animation: vlnka 1.1s ease-in-out infinite alternate; }
.js-animace .vlnka i:nth-child(2n) { animation-duration: .8s; animation-delay: -.3s; }
.js-animace .vlnka i:nth-child(3n) { animation-duration: 1.3s; animation-delay: -.6s; }
.js-animace .vlnka i:nth-child(5n+1) { animation-duration: .9s; animation-delay: -.15s; }
.js-animace .akce:not(.je-hotovo) .akce__text.je-zmena ~ .akce__prubeh span { animation: prubeh 2.5s linear both; }
.js-animace .karta-hovoru { transition: transform .6s cubic-bezier(.2, .7, .2, 1); }
.js-animace .mini-kalendar.je-videt .mini-kalendar__radek--novy b { animation: zapis .6s .15s cubic-bezier(.2, .7, .2, 1) both; }
.kolo__stitek.je-zmena { animation: vyjet .35s ease both; }

/* ---------- chat ---------- */
.zprava { animation: vyjet .3s ease both; }
.zprava--pise span { animation: tecky 1.2s ease-in-out infinite; }
.zprava--pise span:nth-child(2) { animation-delay: .15s; }
.zprava--pise span:nth-child(3) { animation-delay: .3s; }
.oznameni:not([hidden]) { animation: priletet .6s cubic-bezier(.2, .7, .2, 1) both; }
.email.je-zvyrazneny { animation: zvyraznit 1.2s ease 1; }

/* ---------- kulaté tlačítko ---------- */
.kulate-tlacitko::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--fialova-2);
  animation: pulz-kruh 2.2s ease-out infinite;
}

/* ---------- klíčové snímky ---------- */
@keyframes vyjet { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes priletet { from { opacity: 0; transform: translateY(30px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes vznaset { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pulz-tecka { 0%, 100% { box-shadow: 0 0 0 0 rgba(30, 158, 106, .5); } 50% { box-shadow: 0 0 0 6px rgba(30, 158, 106, 0); } }
@keyframes pulz-kruh { from { transform: scale(1); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }
@keyframes tocit { to { transform: rotate(360deg); } }
@keyframes tecky { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
@keyframes vlnka { from { transform: scaleY(.18); } to { transform: scaleY(1); } }
@keyframes prubeh { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes zapis { from { clip-path: inset(0 100% 0 0 round 8px); } to { clip-path: inset(0 0 0 0 round 8px); } }
@keyframes zvyraznit { 0% { box-shadow: 0 0 0 0 rgba(123, 63, 228, .5); } 100% { box-shadow: 0 0 0 18px rgba(123, 63, 228, 0); } }

/* ---------- omezení pohybu: rovnou konečný stav ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .jak { --m: 1 !important; --r: 1 !important; height: auto; }
  .email-sekce { --a: 1 !important; height: auto; }
  .jak__lepidlo, .email-sekce__lepidlo { position: static; min-height: 0; }
  .odhal { opacity: 1 !important; transform: none !important; }
  .kolo { --zima: 1 !important; --rot: 0deg !important; --posun: 0px !important; }
  .vlnka i { transform: scaleY(.55); }
  .mini-kalendar { opacity: 1; transform: none; }
}
