/* Motion only: original colors, typography, geometry and artwork stay intact. */
:root {
  --motion-ease: cubic-bezier(.22, 1, .36, 1);
}

@media (prefers-reduced-motion: no-preference) {
  /* Only JS-prepared, offscreen elements receive this state. Keep their
     starting pose until the observer starts the matching animation. */
  .motion-pending {
    opacity: 0;
    transform: translate3d(0, 28px, 0);
  }

  .motion-pending.section-index {
    transform: translate3d(0, 16px, 0) scale(.94);
  }

  .footer > .motion-pending:not(.section-index) {
    transform: translate3d(0, 12px, 0);
  }

  .motion-rule-pending {
    border-top-color: transparent;
  }

  .hero-link, .hero-message, .button:not(:disabled), .header-control {
    transition: translate .34s var(--motion-ease), scale .22s var(--motion-ease),
      color .2s ease, border-color .2s ease, background .2s ease;
  }

  .hero-link span, .hero-message span, .button:not(:disabled) span,
  .footer-nav a span, .social-icon svg, .brand-mark, .language-trigger svg {
    transition: transform .42s var(--motion-ease);
  }

  .menu-line {
    transition: transform .36s var(--motion-ease);
  }

  .language-switcher[open] .language-trigger svg {
    transform: rotate(180deg);
  }

  .header-dropdown {
    transform-origin: top right;
  }

  details[open]:not(.is-closing) > .header-dropdown {
    animation: menu-unfold .34s var(--motion-ease) both;
  }

  details[open]:not(.is-closing) > .header-dropdown a {
    animation: menu-item-in .32s var(--motion-ease) both;
  }

  details[open] > .header-dropdown a:nth-child(2) {
    animation-delay: .045s;
  }

  details[open] > .header-dropdown a:nth-child(3) {
    animation-delay: .09s;
  }

  .navigation-menu[open].is-closing .menu-line:first-child,
  .navigation-menu[open].is-closing .menu-line:last-child {
    transform: translateX(-50%);
  }

  .language-switcher.is-closing .language-trigger svg {
    transform: none;
  }

  .is-closing > .header-dropdown {
    pointer-events: none;
  }

  /* Temporarily draw the existing border; its color and final position match. */
  .motion-rule {
    position: relative;
    animation: section-border .9s linear;
  }

  .motion-rule::after {
    content: "";
    position: absolute;
    top: -1px;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--line);
    pointer-events: none;
    transform-origin: left center;
    animation: rule-draw .9s var(--motion-ease) both;
  }

  .header-dropdown a {
    transition: translate .3s var(--motion-ease), color .2s ease, background .2s ease;
  }

  .hero-scroll {
    transition: scale .35s var(--motion-ease), color .2s ease, border-color .2s ease;
  }

  /* A short invitation to scroll; no perpetual movement while reading. */
  .motion-started .hero-scroll span {
    animation: scroll-invitation 1.45s .3s 3;
  }

  /* The existing background gently settles in; no new colors or artwork. */
  .motion-started .hero::before {
    animation: hero-atmosphere 3.8s ease-out;
  }

  .hero-link:active, .hero-message:active, .button:not(:disabled):active,
  .header-control:active {
    translate: 0 1px;
    scale: .97;
    transition-duration: .12s;
  }

  .hero-scroll:active {
    scale: .94;
  }

  /* Keyboard focus never waits for decorative entrance animations. */
  .header-dropdown:focus-within, .header-dropdown a:focus-visible {
    animation: none;
  }

  .motion-started .hero-scroll:focus-visible span {
    animation: none;
  }

  .hero-link:focus-visible span {
    transform: translateY(3px);
  }

  .hero-message:focus-visible span, .button:not(:disabled):focus-visible span,
  .footer-nav a:focus-visible span {
    transform: translate(2px, -2px);
  }

  .footer-nav a[href="#top"]:focus-visible span {
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  .hero-link:hover, .hero-message:hover, .button:not(:disabled):hover {
    translate: var(--motion-x, 0px) calc(-3px + var(--motion-y, 0px));
  }

  [data-motion-pointer] {
    transition-duration: .18s, .22s, .2s, .2s, .2s;
  }

  .header-control:hover {
    translate: 0 -2px;
  }

  .hero-link:hover span {
    transform: translateY(4px);
  }

  .hero-message:hover span, .button:not(:disabled):hover span,
  .footer-nav a:hover span {
    transform: translate(3px, -3px);
  }

  .footer-nav a[href="#top"]:hover span {
    transform: translateY(-4px);
  }

  .social-icon:hover svg {
    transform: rotate(-7deg) scale(1.08);
  }

  .brand:hover .brand-mark {
    transform: translateY(-2px) rotate(-4deg) scale(1.04);
  }

  .header-dropdown a:hover {
    translate: 3px 0;
  }

  .hero-scroll:hover {
    scale: 1.08;
  }

  .motion-started .hero-scroll:hover span {
    animation: none;
    transform: translateY(3px);
  }

  .hero-link:hover:active, .hero-message:hover:active,
  .button:not(:disabled):hover:active, .header-control:hover:active {
    translate: 0 1px;
  }
}

@keyframes menu-unfold {
  from { opacity: 0; transform: translateY(-8px) scale(.975); }
  to { opacity: 1; transform: none; }
}

@keyframes menu-item-in {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: none; }
}

@keyframes scroll-invitation {
  0%, 65%, 100% { transform: translateY(0); }
  32% { transform: translateY(4px); }
}

@keyframes section-border {
  from, to { border-top-color: transparent; }
}

@keyframes rule-draw {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes hero-atmosphere {
  from { opacity: .35; }
  60% { opacity: .9; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: no-preference) and (max-width: 650px) {
  .motion-pending:not(.section-index) {
    transform: translate3d(0, 20px, 0);
  }

  .motion-rule, .motion-rule::after {
    animation-duration: .65s;
  }
}

/* Stop decorative CSS motion immediately when the page is backgrounded. */
.motion-paused .hero-scroll span,
.motion-paused .hero::before,
.motion-paused details[open] > .header-dropdown,
.motion-paused details[open] > .header-dropdown a {
  animation-play-state: paused;
}

@media print {
  .motion-pending {
    opacity: 1 !important;
    transform: none !important;
  }

  .motion-rule-pending {
    border-top-color: var(--line) !important;
  }

  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
