/*
  Optional motion layer.
  Remove this file (and its <link> in index.html) together with script/animations.js
  to return to the original static site. No layout rules live here.
*/

:root {
  --motion-fast: 180ms;
  --motion-base: 360ms;
  --motion-enter: 620ms;
  --motion-media: 780ms;
  --motion-distance-sm: 8px;
  --motion-distance-md: 16px;
  --motion-ease: cubic-bezier(.22, 1, .36, 1);
}

/* Nothing is hidden until JS explicitly enables the optional motion layer. */
html.motion-enabled .motion-reveal {
  opacity: 0;
  transform: translate3d(0, var(--motion-distance-md), 0);
  transition:
    opacity var(--motion-enter) var(--motion-ease),
    transform var(--motion-enter) var(--motion-ease);
  transition-delay: var(--motion-delay, 0ms);
  will-change: opacity, transform;
}

html.motion-enabled .motion-reveal--soft {
  transform: translate3d(0, var(--motion-distance-sm), 0);
}

html.motion-enabled .motion-reveal--media {
  opacity: 0;
  transform: scale(.985);
  transform-origin: center center;
  transition:
    opacity var(--motion-media) var(--motion-ease),
    transform var(--motion-media) var(--motion-ease);
  transition-delay: var(--motion-delay, 0ms);
  will-change: opacity, transform;
}

html.motion-enabled .motion-reveal.is-visible,
html.motion-enabled .motion-reveal--media.is-visible {
  opacity: 1;
  transform: none;
  will-change: auto;
}

/* First screen: short, calm entrance, without waiting for a scroll event. */
html.motion-enabled .motion-hero {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition:
    opacity 620ms var(--motion-ease),
    transform 620ms var(--motion-ease);
  transition-delay: var(--motion-delay, 0ms);
}

html.motion-enabled .motion-hero--media {
  opacity: 0;
  transform: scale(1.018);
  transition:
    opacity 850ms var(--motion-ease),
    transform 1100ms var(--motion-ease);
}

html.motion-enabled .motion-hero.is-visible,
html.motion-enabled .motion-hero--media.is-visible {
  opacity: 1;
  transform: none;
}

/* -------------------------------------------------------------------------- */
/* 07 — process timeline                                                     */
/* One slow progression from 01 to 04: point -> rail -> next point -> copy.  */
/* -------------------------------------------------------------------------- */
html.motion-enabled .motion-timeline .step {
  --rail-delay: 0ms;
  --dot-delay: 0ms;
  --copy-delay: 150ms;
}

html.motion-enabled .motion-timeline .step:nth-child(2) {
  --rail-delay: 520ms;
  --dot-delay: 480ms;
  --copy-delay: 650ms;
}

html.motion-enabled .motion-timeline .step:nth-child(3) {
  --rail-delay: 1040ms;
  --dot-delay: 1000ms;
  --copy-delay: 1170ms;
}

html.motion-enabled .motion-timeline .step:nth-child(4) {
  --rail-delay: 1560ms;
  --dot-delay: 1520ms;
  --copy-delay: 1690ms;
}

/* The real 1px rail lives on .step-rail's background. */
html.motion-enabled .motion-timeline .step-rail {
  background-size: 0% 1px !important;
  transition: background-size 720ms cubic-bezier(.3, .05, .2, 1);
  transition-delay: var(--rail-delay);
}

html.motion-enabled .motion-timeline .step-rail i {
  opacity: 0;
  transform: scale(.45);
  transition:
    opacity 260ms var(--motion-ease),
    transform 360ms var(--motion-ease);
  transition-delay: var(--dot-delay);
}

html.motion-enabled .motion-timeline .step small,
html.motion-enabled .motion-timeline .step-copy {
  opacity: 0;
  transform: translate3d(0, 8px, 0);
  transition:
    opacity 520ms var(--motion-ease),
    transform 620ms var(--motion-ease);
  transition-delay: var(--copy-delay);
}

html.motion-enabled .motion-timeline.is-visible .step-rail {
  background-size: 100% 1px !important;
}

html.motion-enabled .motion-timeline.is-visible .step-rail i,
html.motion-enabled .motion-timeline.is-visible .step small,
html.motion-enabled .motion-timeline.is-visible .step-copy {
  opacity: 1;
  transform: none;
}

/* -------------------------------------------------------------------------- */
/* Scheme changes: a soft settle-in instead of a hard swap.                   */
/* The existing project JS still owns which image/panel is active.            */
/* -------------------------------------------------------------------------- */
html.motion-enabled .system__image,
html.motion-enabled .scheme-panel,
html.motion-enabled .tab-description {
  transform-origin: 50% 50%;
}

html.motion-enabled .motion-scheme-in {
  animation: motion-scheme-in 480ms var(--motion-ease) both;
}

html.motion-enabled .motion-scheme-copy-in {
  animation: motion-scheme-copy-in 360ms var(--motion-ease) both;
}

@keyframes motion-scheme-in {
  0% {
    opacity: .18;
    transform: translate3d(0, 5px, 0) scale(.992);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes motion-scheme-copy-in {
  0% {
    opacity: .2;
    transform: translate3d(0, 4px, 0);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

/* Keep the motion smaller on compact screens. */
@media (max-width: 760px) {
  html.motion-enabled .motion-reveal {
    transform: translate3d(0, 10px, 0);
  }

  html.motion-enabled .motion-reveal--soft {
    transform: translate3d(0, 6px, 0);
  }

  html.motion-enabled .motion-reveal.is-visible,
  html.motion-enabled .motion-reveal--media.is-visible {
    transform: none;
  }
}

/* On phones the same timeline runs vertically from the first dot downward. */
@media (max-width: 460px) {
  html.motion-enabled .motion-timeline .step-rail {
    background-size: 1px 0% !important;
  }

  html.motion-enabled .motion-timeline.is-visible .step-rail {
    background-size: 1px 100% !important;
  }
}

/* Respect the OS/browser accessibility preference. */
@media (prefers-reduced-motion: reduce) {
  html.motion-enabled .motion-reveal,
  html.motion-enabled .motion-reveal--media,
  html.motion-enabled .motion-hero,
  html.motion-enabled .motion-hero--media,
  html.motion-enabled .motion-timeline .step-rail,
  html.motion-enabled .motion-timeline .step-rail i,
  html.motion-enabled .motion-timeline .step small,
  html.motion-enabled .motion-timeline .step-copy,
  html.motion-enabled .motion-scheme-in,
  html.motion-enabled .motion-scheme-copy-in {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    animation: none !important;
  }

  html.motion-enabled .motion-timeline .step-rail {
    background-size: 100% 1px !important;
  }

  @media (max-width: 460px) {
    html.motion-enabled .motion-timeline .step-rail {
      background-size: 1px 100% !important;
    }
  }
}

/* Responsive stabilization v14: keep sequential timeline drawing continuous. */
@media (min-width: 341px) and (max-width: 760px) {
  html.motion-enabled .motion-timeline .step-rail {
    background-position: center center !important;
  }
}
