/* The length belongs to each divider. Child rows can enter on their own beat. */
@property --arrival-line-end {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 100%;
}

/* A registered guide/login preview uses its scroll entrance when it arrives. */
:root :is(.guide-start, .signin-visual)[data-arrival="window"] { animation: none; }

/* Paint just the existing horizontal borders. The same taper grows with the
   scroll entrance and stays in place when the entrance finishes. */
@media screen and (forced-colors: none) {
  :root :is(
    .rank-section, .site-footer, .cap-footnotes,
    .rank-plans:not(.cap-overview) > article:not(.offer-card--trial),
    .pf-more > details, .analytics-story-tabs, .guide-topic, .guide-topic li + li,
    .question, .faq-list, .guide-masthead, .guide-reading-head, .guide-reading-rail,
    .guide-library-list, .guide-library-list > li, .guide-instructions:only-child .guide-steps li,
    .article-access, .signin-help
  ) {
    --divider-ink: var(--divider-tone, var(--rank-hair, var(--edge)));
    --divider-length: calc(var(--arrival-line-end, 100%) * var(--divider-scale, 1));
    border-image: linear-gradient(to right,
      var(--divider-ink) 0%,
      var(--divider-ink) calc(var(--divider-length) * .18),
      color-mix(in srgb, var(--divider-ink) 62%, transparent) calc(var(--divider-length) * .53),
      color-mix(in srgb, var(--divider-ink) 18%, transparent) calc(var(--divider-length) * .81),
      transparent calc(var(--divider-length) * .97)) 1;
  }
  .analytics-story-tabs { --divider-tone: var(--analytics-seam); }
  .cart-checklist { --divider-scale: .44; }
  .guide-topic li + li { --divider-tone: color-mix(in srgb, var(--rank-hair) 52%, transparent); }
  .rank-faq .question:first-child { --divider-tone: color-mix(in srgb, var(--rank-text) 38%, transparent); }
}

@media screen and (prefers-reduced-motion: no-preference) and (forced-colors: none) {
  :root:not(.is-lite) [data-entering][data-arrival]:not(:focus-within) {
    animation: var(--arrival-effect) var(--arrival-duration) cubic-bezier(.2,.73,.2,1)
      var(--arrival-delay, 0ms) backwards;
  }
  [data-arrival="title"] {
    --arrival-effect: arrival-title;
    --arrival-duration: 650ms;
  }
  [data-arrival="text"], [data-arrival="action"] {
    --arrival-effect: arrival-copy;
    --arrival-duration: 520ms;
    --arrival-rise: .62em;
  }
  [data-arrival="action"] { --arrival-rise: .4em; }
  [data-arrival="window"] {
    --arrival-effect: arrival-window;
    --arrival-duration: 690ms;
  }
  [data-arrival="row"] {
    --arrival-effect: arrival-row;
    --arrival-duration: 530ms;
  }
  [data-arrival="rule"] {
    --arrival-effect: arrival-divider;
    --arrival-duration: 720ms;
  }

  :root:not(.is-lite) .guide-rail ul[data-arrival="rule"][data-entering]:not(:focus-within) {
    border-image: linear-gradient(to bottom, var(--edge) var(--arrival-line-end), transparent var(--arrival-line-end)) 1;
  }
  .workflow-wires[data-arrival="rule"],
  .search-example-plot svg[data-arrival="rule"] { --arrival-effect: arrival-trace; }

  /* The layout-sized section stays static; only its thin dividing line moves. */
  .page-home :is(.rank-section, .cap-footnotes, .faq-list)[data-arrival="rule"] { position: relative; }
  :root:not(.is-lite) .page-home :is(.rank-section, .cap-footnotes, .faq-list)[data-arrival="rule"][data-entering]:not(:focus-within) {
    animation: none;
    border-top-color: transparent;
    border-image: none;
  }
  :root:not(.is-lite) .page-home :is(.rank-section, .cap-footnotes, .faq-list)[data-arrival="rule"][data-entering]:not(:focus-within)::after {
    content: "";
    position: absolute;
    inset: -1px 0 auto;
    height: 1px;
    pointer-events: none;
    background: linear-gradient(to right, var(--divider-ink) 18%, color-mix(in srgb, var(--divider-ink) 62%, transparent) 53%,
      color-mix(in srgb, var(--divider-ink) 18%, transparent) 81%, transparent 97%);
    transform-origin: left;
    animation: arrival-home-divider var(--arrival-duration) cubic-bezier(.2,.73,.2,1) var(--arrival-delay, 0ms) backwards;
  }
  .page-home [data-arrival="row"] { --arrival-effect: arrival-home-row; }
  .page-home [data-arrival="window"] { --arrival-effect: arrival-home-window; }
  @keyframes arrival-home-divider { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  @keyframes arrival-home-row {
    from { opacity: .18; translate: 0 7px; }
    to { opacity: 1; translate: none; }
  }

  @keyframes arrival-home-window {
    from { opacity: .12; translate: 0 clamp(14px, 1.5vw, 30px); }
    to { opacity: 1; translate: none; }
  }

  @keyframes arrival-title {
    from { opacity: .14; translate: 0 .26em; }
    to { opacity: 1; translate: none; }
  }
  @keyframes arrival-copy {
    from { opacity: .1; translate: 0 var(--arrival-rise); }
    to { opacity: 1; translate: none; }
  }
  @keyframes arrival-window {
    from { opacity: .12; translate: 0 clamp(14px, 1.5vw, 30px); scale: .976; }
    to { opacity: 1; translate: none; scale: 1; }
  }
  @keyframes arrival-row {
    from { opacity: .18; translate: 0 7px; --arrival-line-end: 0%; }
    to { opacity: 1; translate: none; --arrival-line-end: 100%; }
  }
  @keyframes arrival-divider {
    from { --arrival-line-end: 0%; }
    to { --arrival-line-end: 100%; }
  }
  @keyframes arrival-trace {
    from { clip-path: inset(-3px 100% -3px -3px); }
    to { clip-path: inset(-3px); }
  }
}
