/* Scroll motion (js/motion.js). Base rules are the final state; ".mo-wait" is the state before an element plays,
   ".mo-go" carries the staggered transitions while it plays. Reduced motion never gets "mo-wait". */

/* Pipeline: six numbered nodes joined by a line. Horizontal on desktop, vertical on phones. */
.pipeline {
  --node: 40px;
  --gap: 16px;
  --step: 0.42s; /* keep in step with PIPE_STEP in motion.js */
  --glint: color-mix(in srgb, var(--accent) 30%, #ffffff);
  list-style: none;
  counter-reset: gm-step;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--gap);
  margin-top: 48px;
  position: relative;
  isolation: isolate;
}
.pipeline li { counter-increment: gm-step; position: relative; padding-top: calc(var(--node) + 20px); padding-right: 8px; }
.pipeline li::before {
  content: counter(gm-step, decimal-leading-zero);
  position: absolute; top: 0; left: 0; z-index: 2;
  width: var(--node); height: var(--node); border-radius: 50%;
  display: grid; place-items: center;
  font: 600 13px/1 var(--mono);
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 0 0 6px var(--accent-soft);
}
.pipeline li:not(:last-child)::after {
  content: "";
  position: absolute; z-index: 1;
  top: calc(var(--node) / 2 - 1px);
  left: calc(var(--node) + 10px);
  width: calc(100% + var(--gap) - var(--node) - 20px);
  height: 2px; border-radius: 2px;
  background-color: var(--line);
  background-image: linear-gradient(90deg, transparent, var(--glint), transparent), linear-gradient(var(--accent), var(--accent));
  background-size: 56px 100%, 100% 100%;
  background-position: -56px 0, 0 0;
  background-repeat: no-repeat;
}
.pipeline b { display: block; font-family: var(--display); font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.pipeline span { display: block; font-size: 14px; color: var(--soft); margin-top: 4px; line-height: 1.45; }

.pipeline.mo-wait li::before { background: var(--surface); color: var(--mute); box-shadow: 0 0 0 1.5px var(--line); }
.pipeline.mo-wait li:not(:last-child)::after { background-size: 56px 100%, 0% 100%; }
.pipeline.mo-wait b, .pipeline.mo-wait span { opacity: 0.45; }
.pipeline.mo-go li::before { transition: background 0.3s ease, color 0.3s ease, box-shadow 0.45s ease; transition-delay: calc(var(--i) * var(--step)); }
.pipeline.mo-go li:not(:last-child)::after { transition: background-size var(--step) linear; transition-delay: calc(var(--i) * var(--step) + 0.12s); }
.pipeline.mo-go b, .pipeline.mo-go span { transition: opacity 0.4s ease; transition-delay: calc(var(--i) * var(--step)); }

/* After the fill: a glint runs node to node every few seconds and each node pings as it arrives. */
.pipeline.is-flowing li:not(:last-child)::after { animation: gm-pipe-glint 5s linear infinite; animation-delay: calc(var(--i) * 0.34s + 1s); }
.pipeline.is-flowing li::before { animation: gm-pipe-ping 5s ease-out infinite; animation-delay: calc(var(--i) * 0.34s + 1s); }
@keyframes gm-pipe-glint {
  0% { background-position: -56px 0, 0 0; }
  6.8%, 100% { background-position: calc(100% + 56px) 0, 0 0; }
}
@keyframes gm-pipe-ping {
  0% { box-shadow: 0 0 0 6px var(--accent-soft); }
  3% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--accent) 28%, transparent); }
  12%, 100% { box-shadow: 0 0 0 6px var(--accent-soft); }
}

@media (max-width: 960px) {
  .pipeline { --gap: 12px; }
  .pipeline b { font-size: 15.5px; }
  .pipeline span { font-size: 13px; }
}
@media (max-width: 759px) {
  .pipeline { grid-template-columns: 1fr; gap: 0; margin-top: 36px; }
  .pipeline li { padding: 8px 0 28px calc(var(--node) + 18px); min-height: calc(var(--node) + 28px); }
  .pipeline li:last-child { padding-bottom: 0; }
  .pipeline li:not(:last-child)::after {
    top: calc(var(--node) + 8px);
    left: calc(var(--node) / 2 - 1px);
    width: 2px;
    height: calc(100% - var(--node) - 16px);
    background-image: linear-gradient(180deg, transparent, var(--glint), transparent), linear-gradient(var(--accent), var(--accent));
    background-size: 100% 40px, 100% 100%;
    background-position: 0 -40px, 0 0;
  }
  .pipeline.mo-wait li:not(:last-child)::after { background-size: 100% 40px, 100% 0%; }
  .pipeline.is-flowing li:not(:last-child)::after { animation-name: gm-pipe-glint-y; }
  @keyframes gm-pipe-glint-y {
    0% { background-position: 0 -40px, 0 0; }
    6.8%, 100% { background-position: 0 calc(100% + 40px), 0 0; }
  }
}

/* Compliance checks: dimmed and undrawn, then each circle and tick draws in turn. */
[data-tick] svg circle, [data-tick] svg path { stroke-dasharray: 1; stroke-dashoffset: 0; }
[data-tick].mo-wait { opacity: 0.35; }
[data-tick].mo-wait svg circle, [data-tick].mo-wait svg path { stroke-dashoffset: 1; }
[data-tick].mo-go { transition: opacity 0.45s ease calc(var(--i) * 180ms); }
[data-tick].mo-go svg circle { transition: stroke-dashoffset 0.5s cubic-bezier(0.4, 0, 0.2, 1) calc(var(--i) * 180ms); }
[data-tick].mo-go svg path { transition: stroke-dashoffset 0.3s ease-out calc(var(--i) * 180ms + 0.38s); }

/* Payout gauge (dark tech band in both themes). */
.gauge {
  justify-self: center;
  width: 100%; max-width: 340px;
  margin-top: 40px;
  padding: 26px 24px 24px;
  border: 1px solid var(--tech-line);
  border-radius: 20px;
  background: color-mix(in srgb, var(--tech-panel) 85%, transparent);
  text-align: center;
  min-height: 420px;
}
.gauge-label { font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--tech-ink); line-height: 1.35; text-wrap: balance; }
.gauge svg { display: block; width: 100%; max-width: 280px; height: auto; margin: 14px auto 6px; overflow: visible; }
.gauge-note { font-size: 13px; color: var(--tech-soft); line-height: 1.5; text-wrap: balance; }
.gauge-track { fill: none; stroke: rgba(255, 255, 255, 0.08); stroke-width: 12; stroke-linecap: round; }
.gauge-arc { fill: none; stroke-width: 12; stroke-linecap: round; filter: drop-shadow(0 0 6px var(--tech-glow)) drop-shadow(0 0 14px var(--tech-glow)); }
.gauge-stop-a { stop-color: var(--accent); }
.gauge-stop-b { stop-color: var(--tech-accent); }
.gauge-head { fill: var(--tech-ink); filter: drop-shadow(0 0 5px var(--tech-accent)); }
.gauge-tick { stroke: rgba(255, 255, 255, 0.14); stroke-width: 1; }
.gauge-tick.major { stroke: rgba(255, 255, 255, 0.28); stroke-width: 1.4; }
.gauge-mark { stroke: var(--tech-soft); stroke-width: 1.4; stroke-dasharray: 2 2.5; }
.gauge-end { font: 600 8.5px var(--mono); fill: var(--tech-soft); letter-spacing: 0.04em; }
.gauge-num { font-family: var(--display); font-weight: 800; font-size: 46px; letter-spacing: -0.03em; fill: var(--tech-ink); font-variant-numeric: tabular-nums; }
.gauge-sub { font: 600 8.5px var(--mono); fill: var(--tech-soft); letter-spacing: 0.18em; text-transform: uppercase; }
@media (max-width: 960px) {
  .gauge { max-width: 320px; margin-top: 0; }
}

/* Reveal */
[data-reveal] { transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); }
[data-reveal].mo-wait { opacity: 0; transform: translateY(16px); }
