/*
  injoy home — motion.
  1) Launch splash «Почерк». Starts from the static system splash (sky + the sign in the centre).
     The roof hops hello, the sign rises; under it «injoy home» is written with one pen, letter by letter
     (the smile in the «o» in coral), the dots over i and j pop in, then the account's family name rises.
     Then the sky lifts like a blind and shows the screen the user left last time.
  2) Loader: the sign as a loading indicator (smile draws and leaves, roof lifts).

  Markup comes from react/InjoySplash.tsx, react/InjoyLoader.tsx or injoy-splash.js.
  Exact timings for native ports: timeline.json.
*/

:root {
  --ij-ease-draw: cubic-bezier(0.65, 0, 0.35, 1);
  --ij-ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------- Splash: layout ---------- */
.ij-splash {
  /* sign box: the same size and place as on the static splash images (splash/) */
  --ij-s: min(37.2vw, 180px);
  /* how far the sign rises so that sign + name + family end up centred together */
  --ij-up: calc(var(--ij-s) * 0.287 + 16px);
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(180deg, #F2C3B9 0%, #FADFBF 100%);
  overflow: hidden;
}
.ij-splash--no-family { --ij-up: calc(var(--ij-s) * 0.287); }

.ij-splash__sign {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--ij-s);
  height: var(--ij-s);
  margin: calc(var(--ij-s) / -2) 0 0 calc(var(--ij-s) / -2);
  transform: translateY(calc(-1 * var(--ij-up)));
  display: block;
  overflow: visible;
}
.ij-splash__sign path { fill: none; stroke-width: 26; stroke-linecap: round; stroke-linejoin: round; }
.ij-splash__roof { stroke: #1B1B3A; transform-box: view-box; }
.ij-splash__smile { stroke: #FF5A3C; }

/* name block: logo width = sign box / 0.6, its top 0.195 × sign box under the sign box */
.ij-splash__name {
  position: absolute;
  left: 50%;
  top: calc(50% - var(--ij-up) + var(--ij-s) * 0.695);
  width: calc(var(--ij-s) / 0.6);
  margin-left: calc(var(--ij-s) / -1.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.ij-splash__logo { display: block; width: 100%; height: auto; overflow: visible; }
.ij-splash__logo .ij-s { fill: none; stroke-width: 24; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1 1.02; }
.ij-splash__logo .ij-w { stroke: #1B1B3A; }
.ij-splash__logo .ij-sm { stroke: #FF5A3C; }
.ij-splash__logo .ij-dot { fill: #1B1B3A; transform-box: fill-box; transform-origin: center; }
/* Family name: as stored in the account, max two lines. Not on the static system splash — it is the same image for everyone. */
.ij-splash__family {
  margin: 0;
  width: 130%;
  font: 500 17px/22px var(--ij-font-ui, 'Geologica', system-ui, sans-serif);
  letter-spacing: -0.01em;
  color: #3A3A55;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.ij-splash__loader { margin-top: 12px; }
.ij-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Splash: «Почерк», 2.07 s from mount; runs once, the final state is the plain lockup ---------- */
@keyframes ij-hop { 0% { transform: translateY(0); } 40% { transform: translateY(-18px); } 72% { transform: translateY(4px); } 100% { transform: translateY(0); } }
@keyframes ij-sign-up { from { transform: translateY(0); } to { transform: translateY(calc(-1 * var(--ij-up))); } }
@keyframes ij-draw { from { stroke-dashoffset: 1.01; } to { stroke-dashoffset: 0; } }
@keyframes ij-pop { 0% { transform: scale(0); } 65% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes ij-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.ij-splash .ij-splash__roof { animation: ij-hop 0.55s var(--ij-ease-out) 0s both; }
.ij-splash .ij-splash__sign { animation: ij-sign-up 0.6s var(--ij-ease-draw) 0.2s both; }
/* injoy home written with one pen */
.ij-splash .ij-l-i      { animation: ij-draw 0.16s var(--ij-ease-draw) 0.45s both; }
.ij-splash .ij-l-n      { animation: ij-draw 0.24s var(--ij-ease-draw) 0.52s both; }
.ij-splash .ij-l-j      { animation: ij-draw 0.22s var(--ij-ease-draw) 0.62s both; }
.ij-splash .ij-l-otop   { animation: ij-draw 0.18s var(--ij-ease-draw) 0.72s both; }
.ij-splash .ij-l-osmile { animation: ij-draw 0.22s var(--ij-ease-draw) 0.8s both; }
.ij-splash .ij-l-y1     { animation: ij-draw 0.18s var(--ij-ease-draw) 0.9s both; }
.ij-splash .ij-l-y2     { animation: ij-draw 0.22s var(--ij-ease-draw) 0.97s both; }
.ij-splash .ij-l-h1     { animation: ij-draw 0.13s var(--ij-ease-draw) 1.07s both; }
.ij-splash .ij-l-h2     { animation: ij-draw 0.17s var(--ij-ease-draw) 1.12s both; }
.ij-splash .ij-l-ho     { animation: ij-draw 0.22s var(--ij-ease-draw) 1.2s both; }
.ij-splash .ij-l-m1     { animation: ij-draw 0.15s var(--ij-ease-draw) 1.32s both; }
.ij-splash .ij-l-m2     { animation: ij-draw 0.15s var(--ij-ease-draw) 1.39s both; }
.ij-splash .ij-l-e      { animation: ij-draw 0.22s var(--ij-ease-draw) 1.47s both; }
.ij-splash .ij-l-di     { animation: ij-pop 0.4s var(--ij-ease-out) 1.5s both; }
.ij-splash .ij-l-dj     { animation: ij-pop 0.4s var(--ij-ease-out) 1.57s both; }
.ij-splash .ij-splash__family { animation: ij-rise 0.45s var(--ij-ease-out) 1.62s both; }

/* ---------- Splash: exit ---------- */
@keyframes ij-curtain { from { transform: translateY(0); } to { transform: translateY(-100%); } }
@keyframes ij-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes ij-reveal { from { opacity: 0.4; transform: scale(0.965); } to { opacity: 1; transform: scale(1); } }

/* the sky lifts like a blind (0.55 s) */
.ij-splash--leaving { animation: ij-curtain 0.55s var(--ij-ease-draw) both; pointer-events: none; }
/* optional: add to the app root when the blind starts lifting — the screen underneath settles in */
.ij-app-reveal { animation: ij-reveal 0.55s var(--ij-ease-out) 0.1s both; transform-origin: 50% 40%; }

/* ---------- Loader ---------- */
.ij-loader { display: block; overflow: visible; }
.ij-loader__roof,
.ij-loader__smile { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ij-loader__roof { stroke: var(--ij-loader-ink, #1B1B3A); transform-box: view-box; animation: ij-ld-roof 1.6s ease-in-out infinite; }
.ij-loader__smile { stroke: var(--ij-loader-smile, #FF5A3C); stroke-dasharray: 1 1.02; animation: ij-ld-smile 1.6s var(--ij-ease-draw) infinite; }
.ij-loader--on-dark { --ij-loader-ink: #FFFFFF; }
@keyframes ij-ld-smile { 0% { stroke-dashoffset: 1.01; } 50% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -1.01; } }
@keyframes ij-ld-roof { 0%, 30%, 70%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

/* ---------- Reduced motion: the final lockup at once, quick fade, still loader ---------- */
@media (prefers-reduced-motion: reduce) {
  .ij-splash .ij-splash__roof, .ij-splash .ij-splash__sign, .ij-splash .ij-s, .ij-splash .ij-dot,
  .ij-splash .ij-splash__family { animation: none; }
  .ij-splash--leaving { animation: ij-fade-out 0.2s linear both; }
  .ij-app-reveal { animation: none; }
  .ij-loader__roof, .ij-loader__smile { animation: none; }
}
