:root {
  --motion-out:  260ms;
  --motion-in:   460ms;
  --motion-swap: 220ms;

  --ease:     cubic-bezier(0.16, 1, 0.3, 1);

  --ease-out: cubic-bezier(0.4, 0, 0.9, 0.6);
}

.page > * {
  animation: rise var(--rise-motion) var(--ease) both;
  animation-delay: calc(var(--rise-base) + 6 * var(--rise-step));
}

.page > *:nth-child(1) { animation-delay: var(--rise-base); }
.page > *:nth-child(2) { animation-delay: calc(var(--rise-base) + 1 * var(--rise-step)); }
.page > *:nth-child(3) { animation-delay: calc(var(--rise-base) + 2 * var(--rise-step)); }
.page > *:nth-child(4) { animation-delay: calc(var(--rise-base) + 3 * var(--rise-step)); }
.page > *:nth-child(5) { animation-delay: calc(var(--rise-base) + 4 * var(--rise-step)); }
.page > *:nth-child(6) { animation-delay: calc(var(--rise-base) + 5 * var(--rise-step)); }

@keyframes rise {
  from { opacity: 0; transform: translateY(var(--rise-shift)); }
  to   { opacity: 1; transform: none; }
}

.is-entering :where(.projects, .contact-list, .summaries) > * {
  animation: appear var(--rise-motion) var(--ease) both;
  animation-delay: calc(var(--rise-nested) + 5 * var(--rise-step));
}

.is-entering :where(.projects, .contact-list, .summaries) > *:nth-child(1) {
  animation-delay: var(--rise-nested);
}
.is-entering :where(.projects, .contact-list, .summaries) > *:nth-child(2) {
  animation-delay: calc(var(--rise-nested) + 1 * var(--rise-step));
}
.is-entering :where(.projects, .contact-list, .summaries) > *:nth-child(3) {
  animation-delay: calc(var(--rise-nested) + 2 * var(--rise-step));
}
.is-entering :where(.projects, .contact-list, .summaries) > *:nth-child(4) {
  animation-delay: calc(var(--rise-nested) + 3 * var(--rise-step));
}
.is-entering :where(.projects, .contact-list, .summaries) > *:nth-child(5) {
  animation-delay: calc(var(--rise-nested) + 4 * var(--rise-step));
}

@keyframes appear {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.is-leaving .page {
  animation: page-out var(--motion-out) var(--ease-out) both;
}

@keyframes page-out {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateY(-8px); }
}

.site-header {
  animation: header-in var(--rise-motion) var(--ease) both;
}

.is-leaving .site-header {
  animation: header-out var(--motion-out) var(--ease-out) both;
}

@keyframes header-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes header-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.projects {
  transition: opacity var(--motion-swap) var(--ease),
              transform var(--motion-swap) var(--ease);
}

.projects.is-swapping {
  opacity: 0;
  transform: translateY(6px);
}

.project {
  transition: transform var(--motion-swap) var(--ease);
}

.project:hover {
  transform: translateY(-2px);
}

.contact-tile {
  transition: border-color 0.2s ease, background-color 0.2s ease,
              transform var(--motion-swap) var(--ease);
}

.contact-tile:hover {
  transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
  .page > *,
  .is-entering :where(.projects, .contact-list, .summaries) > *,
  .site-header {
    animation: none;
  }

  .is-leaving .page,
  .is-leaving .site-header,
  .projects,
  .projects.is-swapping,
  .project,
  .project:hover,
  .contact-tile,
  .contact-tile:hover {
    transition: none;
    transform: none;
    opacity: 1;
  }
}
