/* =========================================================================
   animations.css — keyframes and entrance animations (staggered with --i)
   ========================================================================= */
@keyframes greetTextRoll {
  from {
    transform: translateY(30vw);
    opacity: 0;
  }
  to {
    transform: translateY(-30vw);
    opacity: 1;
  }
}

@keyframes textRoll {
  from {
    transform: translateY(10vw);
    opacity: 0;
  }
  to {
    transform: translateY(-10vw);
    opacity: 1;
  }
}

@keyframes pageRoll {
  to {
    visibility: hidden;
    transform: translateY(-100vh);
  }
}

@keyframes lgTextRoll {
  from {
    opacity: 0;
    transform: translateY(90%);
  }
  to {
    opacity: 1;
  }
}

@keyframes smTextRoll {
  from {
    transform: translateY(1em);
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes infScroll {
  to {
    transform: translateX(calc(var(--skill-count, 12) * -11em));
  }
}

.splash {
  animation: pageRoll 1.5s ease-in both 1.2s;
}

.greet .cont > * {
  animation: greetTextRoll 2s cubic-bezier(0, 0.59, 1, 0.6) calc(var(--i, 0) * 0.05s) both;
}

.intro .firstName .cont > *,
.intro .lastName .cont > * {
  animation: lgTextRoll 1.5s cubic-bezier(0.35, 1, 0.77, 1.01) calc(2s + var(--i, 0) * 0.05s) both;
}

.desc .cont .el1 > span {
  animation: smTextRoll 1.5s both calc(2.3s + var(--i, 0) * 0.15s);
}

.desc .cont .el2 > span {
  animation: smTextRoll 1.5s both calc(2.95s + var(--i, 0) * 0.15s);
}

.desc .cont .el3 > span {
  animation: smTextRoll 1.5s both calc(3.35s + var(--i, 0) * 0.15s);
}

.desc .el4 a {
  animation: smTextRoll 1.5s both 4s;
}

@keyframes scrollCue {
  0% {
    opacity: 0;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(0.5em);
  }
}

.scroll-cue::after {
  animation: scrollCue 1.6s ease-in-out infinite;
}

/* ---- Scroll reveals ----------------------------------------------------
   js/app.js adds .is-revealed once per element (never removed), so each
   animation plays a single time. Content is only hidden beforehand when JS
   runs (html.js), so nothing is lost without it.
   fadeIn has no "to" frame: it ends on the element's own opacity, so faded
   counters (0.35) stay faded. */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(105%);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes letterRise {
  from {
    opacity: 0;
    transform: translateY(45%);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Highlight slides: title letters rise in, word by word; the rest fades */
.split__word:nth-child(2) { --w: 1; }
.split__word:nth-child(3) { --w: 2; }
.split__word:nth-child(4) { --w: 3; }
.split__word:nth-child(5) { --w: 4; }
.split__word:nth-child(6) { --w: 5; }

.js .highlight:not(.is-revealed) .name .split__word > span,
.js .highlight:not(.is-revealed) :is(.info, .count) {
  opacity: 0;
}

.highlight.is-revealed .name .split__word > span {
  animation: letterRise 1.3s cubic-bezier(0.22, 1, 0.36, 1) calc(0.1s + var(--w, 0) * 0.14s + var(--i, 0) * 0.035s) both;
}

.highlight.is-revealed .info {
  animation: fadeIn 1.2s ease 0.1s both;
}

.highlight.is-revealed .count {
  animation: fadeIn 1.6s ease 0.35s both;
}

/* About: each line slides up out of its own clipping box; the rest fades */
.line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.04em;
}

.line__inner {
  display: block;
}

.js [data-reveal-lines]:not(.is-revealed) .line__inner,
.js .about:not(.is-revealed) > .pre {
  opacity: 0;
}

[data-reveal-lines].is-revealed .line__inner {
  animation: riseIn 1.2s cubic-bezier(0.22, 1, 0.36, 1) calc(var(--i, 0) * 0.11s) both;
}

.about.is-revealed > .pre {
  animation: fadeIn 1.2s ease both;
}

/* Projects: heading, title and list fade in one after another */
.js .projects:not(.is-revealed) > * {
  opacity: 0;
}

.projects.is-revealed > * {
  animation: fadeIn 1.2s ease calc(var(--i, 0) * 0.18s) both;
}

/* Detail page: everything simply fades in, top to bottom, once loaded */
.detail__top,
:is(.detail__count, .detail__info, .detail__name, .detail__preview, .detail__body, .detail__pager) {
  animation: fadeIn 1.4s ease both;
}

.detail__count { animation-delay: 0.2s; }
.detail__info { animation-delay: 0.1s; }
.detail__name { animation-delay: 0.25s; }
.detail__preview { animation-delay: 0.45s; }
.detail__body { animation-delay: 0.6s; }
.detail__pager { animation-delay: 0.75s; }

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .splash {
    display: none;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
