/* Intro-animationen på startsidan (från Figma, spelas en gång)
   1. Bakgrundsklottret glider upp underifrån och stannar.
   2. Klottret glider ner och försvinner.
   3. Språkväxlare, hero och navigation tonas in.
   Klottret är borta när animationen är klar (beslut i steg 5).
   Förflyttningen är 1000 px i Figma och räknas i scenens --u (se home.css). */

.doodles {
  animation: var(--intro-duration) linear both;
}

.home .lang,
.home .hero,
.home .menu {
  animation: var(--intro-duration) linear both intro-fade;
}

/* ---------- Mobil: 2 s ---------- */

@media not all and (min-aspect-ratio: 1/1) and (min-height: 500px) {
  .home {
    --intro-duration: 2s;
  }

  .doodles {
    animation-name: intro-doodles-mobile;
  }

  .home .lang,
  .home .hero,
  .home .menu {
    animation-name: intro-fade-mobile;
  }
}

/* ---------- Desktop: 1,7 s ---------- */

@media (min-aspect-ratio: 1/1) and (min-height: 500px) {
  .home {
    --intro-duration: 1.7s;
  }

  .doodles {
    animation-name: intro-doodles-desktop;
  }

  .home .lang,
  .home .hero,
  .home .menu {
    animation-name: intro-fade-desktop;
  }
}

@keyframes intro-doodles-desktop {
  0% {
    transform: translateY(calc(1000 * var(--u)));
    animation-timing-function: cubic-bezier(0, 0, 0.147, 0.981);
  }
  29.412% {
    transform: translateY(0);
  }
  59.077% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0.776, 0.011, 0.725, 1.002);
  }
  88.489% {
    transform: translateY(calc(1000 * var(--u)));
  }
  100% {
    transform: translateY(calc(1000 * var(--u)));
    visibility: hidden;
  }
}

@keyframes intro-fade-desktop {
  0% {
    opacity: 0;
  }
  88.235% {
    opacity: 0;
    animation-timing-function: ease-out;
  }
  100% {
    opacity: 1;
  }
}

@keyframes intro-doodles-mobile {
  0% {
    transform: translateY(calc(1000 * var(--u)));
    animation-timing-function: cubic-bezier(0, 0, 0.147, 0.981);
  }
  25% {
    transform: translateY(0);
  }
  50.216% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0.776, 0.011, 0.725, 1.002);
  }
  75.216% {
    transform: translateY(calc(1000 * var(--u)));
  }
  100% {
    transform: translateY(calc(1000 * var(--u)));
    visibility: hidden;
  }
}

@keyframes intro-fade-mobile {
  0% {
    opacity: 0;
  }
  75.216% {
    opacity: 0;
    animation-timing-function: ease-out;
  }
  85.216% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}

/* Ingen intro: vid ”minska rörelse”, eller när introt redan har visats i den här
   webbläsarflikens session (t.ex. efter omladdning, se skriptet i <head>). Språkbyte spelar
   introt igen (js/main.js). */

@media (prefers-reduced-motion: reduce) {
  .doodles {
    display: none;
  }

  .home .lang,
  .home .hero,
  .home .menu {
    animation: none;
  }
}

.intro-seen .doodles {
  display: none;
}

.intro-seen .home .lang,
.intro-seen .home .hero,
.intro-seen .home .menu {
  animation: none;
}
