/* Route motion v0.7 (2026-11-13). The site motion of every page and every theme; assets/route-motion.js sets the class cp-route.
   Idea: the page is a crafting route. The plan is drawn faint from the start; scrolling walks it. A glowing head travels
   the line and each section (home) or h2 heading (other pages) is a step node. On the home page a section's text resolves
   when the walk reaches its node. A lantern of light follows the head over the theme picture. Each node that lights lands
   a hammer blow at the anvil of the theme picture, and sparks fly (a theme with no picture: from the anvil of the logo). A theme change
   opens in a circle from the button that was pressed.
   Without the classes cp-route and cp-js, or with "reduce motion" on, the page shows everything at once. */

.cp-route-svg {
  position: absolute;
  left: 0;
  top: 0;
  z-index: -1;
  overflow: visible;
  pointer-events: none;
}
.cp-route-plan {
  fill: none;
  stroke: var(--cp-accent-text);
  stroke-opacity: 0.16;
  stroke-width: 1.5;
  stroke-dasharray: 2 7;
  stroke-linecap: round;
}
.cp-route-walk {
  fill: none;
  stroke: var(--cp-accent-text);
  stroke-width: 2;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px var(--cp-accent-text));
}
.cp-route-node circle.cp-route-dot {
  fill: var(--md-default-bg-color, #0c0c12);
  stroke: var(--cp-accent-text);
  stroke-opacity: 0.4;
  stroke-width: 1.5;
}
.cp-route-node .cp-route-ring {
  fill: none;
  stroke: var(--cp-accent-text);
  stroke-width: 1.2;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}
.cp-route-node .cp-route-branch {
  fill: none;
  stroke: #ef6a5a;
  stroke-width: 1.4;
  stroke-dasharray: 3 5;
  stroke-linecap: round;
  opacity: 0;
}
.cp-route-node .cp-route-miss {
  fill: #ef6a5a;
  opacity: 0;
}
.cp-route-node.is-on circle.cp-route-dot {
  fill: var(--cp-accent-text);
  stroke-opacity: 1;
}
.cp-route-head {
  pointer-events: none;
}
.cp-route-head .cp-route-core {
  fill: #fff8e8;
  filter: drop-shadow(0 0 5px var(--cp-accent-text)) drop-shadow(0 0 14px var(--cp-accent-text));
}
.cp-route-head .cp-route-halo {
  fill: var(--cp-accent-text);
  opacity: 0.18;
}

/* The lantern: the theme picture darkens except for a soft pool of light around the head. Dark scheme only. */
.cp-route-lantern {
  position: fixed;
  left: 0;
  top: 0;
  width: 240vmax;
  height: 240vmax;
  margin: -120vmax 0 0 -120vmax;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(circle closest-side, transparent 0, transparent 9%, rgba(0, 0, 0, 0.42) 34%, rgba(0, 0, 0, 0.5) 100%);
  opacity: 0;
  transition: opacity 1.2s ease;
  will-change: transform;
}
html.cp-route-dark .cp-route-lantern {
  opacity: 1;
}

/* Anvil sparks and the flash of each blow. They sit over the theme picture and under the page. */
.cp-route-sparks {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}
.cp-route-flash {
  position: fixed;
  z-index: -1;
  left: 0;
  top: 0;
  width: 70vmin;
  height: 70vmin;
  margin: -35vmin 0 0 -35vmin;
  border-radius: 50%;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0;
  background: radial-gradient(closest-side, rgba(var(--cp-route-hot, 255, 190, 110), 0.55), rgba(var(--cp-route-hot, 255, 190, 110), 0.12) 45%, transparent 75%);
}
/* No picture: the sparks leave the logo in the header, so they sit over the header; the flash stays small. */
html.cp-route-logo .cp-route-sparks {
  z-index: 5;
}
html.cp-route-logo .cp-route-flash {
  z-index: 5;
  width: 14rem;
  height: 14rem;
  margin: -7rem 0 0 -7rem;
}

@media (prefers-reduced-motion: no-preference) {
  /* The scroll reveal of site.js steps aside: here the walk decides when a section shows. */
  .cp-route.cp-js .cp-row.cp-reveal:not(.is-in) {
    opacity: 1;
    translate: none;
  }

  .cp-route-node circle.cp-route-dot {
    transition: fill 0.5s ease, stroke-opacity 0.5s ease;
  }
  .cp-route-node.is-on .cp-route-ring {
    animation: cp-route-ping 1.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  .cp-route-node .cp-route-branch,
  .cp-route-node .cp-route-miss {
    transition: opacity 0.9s ease 0.35s;
  }
  .cp-route-node.is-on .cp-route-branch {
    opacity: 0.75;
  }
  .cp-route-node.is-on .cp-route-miss {
    opacity: 0.9;
  }

  /* A section resolves when the walk reaches it: the kicker first, the heading opens from the side of the route,
     then the text, then the picture. */
  .cp-route.cp-js .cp-row:not(.cp-walked) .cp-kicker,
  .cp-route.cp-js .cp-row:not(.cp-walked) .cp-rt-x {
    opacity: 0;
    transform: translateY(6px);
  }
  .cp-route.cp-js .cp-row:not(.cp-walked) .cp-row__text h2 {
    clip-path: inset(-0.2em 100% -0.3em 0);
  }
  .cp-route.cp-js .cp-row:not(.cp-walked) .cp-shot {
    opacity: 0;
  }
  .cp-route .cp-row.cp-walked .cp-kicker {
    transition: opacity 0.6s ease, transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .cp-route .cp-row.cp-walked .cp-row__text h2 {
    clip-path: inset(-0.2em 0 -0.3em 0);
    transition: clip-path 0.9s cubic-bezier(0.65, 0, 0.35, 1) 0.05s;
  }
  .cp-route .cp-row.cp-walked .cp-rt-x {
    transition: opacity 0.8s ease var(--cp-rt-d, 0.3s), transform 1s cubic-bezier(0.22, 1, 0.36, 1) var(--cp-rt-d, 0.5s);
  }
  .cp-route .cp-row.cp-walked .cp-shot {
    transition: opacity 0.8s ease 0.1s;
  }

  /* Pictures float a little slower than the text: the script sets --cp-par from -1 to 1. */
  .cp-route .cp-row .cp-shot a.cp-frame {
    transform: translate3d(0, calc(var(--cp-par, 0) * -22px), 0);
    transition: box-shadow 0.45s, border-color 0.3s;
  }
  /* A light sheen crosses each picture once, when it first shows. */
  .cp-route .cp-row .cp-shot a.cp-frame .cp-route-sheen {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.13) 50%, transparent 65%);
    transform: translateX(-100%);
  }
  .cp-route .cp-row.cp-walked .cp-shot a.cp-frame .cp-route-sheen {
    transform: translateX(100%);
    transition: transform 1.6s cubic-bezier(0.65, 0, 0.35, 1) 0.9s;
  }

  /* Theme change: the new theme opens in a circle from the button. */
  html.cp-route-vt::view-transition-old(root),
  html.cp-route-vt::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
  }
  html.cp-route-vt .md-header {
    view-transition-name: none;
  }
}

@keyframes cp-route-ping {
  0% { opacity: 0.9; transform: scale(1); }
  100% { opacity: 0; transform: scale(3.2); }
}

@media (prefers-reduced-motion: reduce) {
  .cp-route-head,
  .cp-route-lantern,
  .cp-route-sparks,
  .cp-route-flash {
    display: none;
  }
}

@media print {
  .cp-route-svg,
  .cp-route-lantern,
  .cp-route-sparks,
  .cp-route-flash {
    display: none;
  }
}
