/*
 * serialkompat animated pipeline.
 * Pure CSS, no JS, no external assets. Dark-mode aware via Material for
 * MkDocs CSS custom properties. Honors prefers-reduced-motion.
 */

.sk-pipeline {
  --sk-stage-bg: var(--md-code-bg-color);
  --sk-stage-border: var(--md-default-fg-color--lightest);
  --sk-stage-fg: var(--md-default-fg-color);
  --sk-accent: var(--md-primary-fg-color);

  /* Never wrap: a wrapped row strands connectors mid-air. Stages shrink to
     their labels and connectors absorb the slack; below the media-query
     breakpoint the whole pipeline stacks vertically instead. */
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.25rem;
  margin: 1.5rem 0;
  padding: 1rem 0.5rem;
  border-radius: 0.5rem;
  background: var(--md-default-bg-color);
  overflow-x: auto;
}

.sk-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0.65rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--sk-stage-border);
  background: var(--sk-stage-bg);
  color: var(--sk-stage-fg);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  white-space: nowrap;
}

.sk-stage code {
  background: transparent;
  padding: 0;
  font-size: 0.85em;
}

.sk-connector {
  position: relative;
  flex: 1 1 1rem;
  min-width: 0.5rem;
  height: 2px;
  background: var(--sk-stage-border);
  overflow: hidden;
}

/* Traveling pulse: a small gradient dot that sweeps left-to-right along
   each connector, staggered per connector for a left-to-right flow read. */
.sk-connector::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -20%;
  width: 20%;
  height: 4px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--sk-accent);
  animation: sk-flow 2.4s ease-in-out infinite;
}

/* .sk-stage and .sk-connector are both <div>s and alternate as siblings,
   so :nth-of-type counts position among ALL divs, not just connectors.
   The 5 connectors sit at div positions 2, 4, 6, 8, 10 (stages take the
   odd positions 1, 3, 5, 7, 9, 11) — target those positions directly so
   the stagger increases left-to-right in document order. */
.sk-connector:nth-of-type(2)::after {
  animation-delay: 0s;
}
.sk-connector:nth-of-type(4)::after {
  animation-delay: 0.4s;
}
.sk-connector:nth-of-type(6)::after {
  animation-delay: 0.8s;
}
.sk-connector:nth-of-type(8)::after {
  animation-delay: 1.2s;
}
.sk-connector:nth-of-type(10)::after {
  animation-delay: 1.6s;
}

@keyframes sk-flow {
  0% {
    left: -20%;
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    left: 100%;
    opacity: 0;
  }
}

/* Narrow screens: stack stages vertically, connectors become short
   vertical rules instead of horizontal flow lines. 45rem is where six
   shrunk stages stop fitting one row inside Material's content column. */
@media (max-width: 45rem) {
  .sk-pipeline {
    flex-direction: column;
    align-items: stretch;
  }

  .sk-stage {
    width: 100%;
  }

  .sk-connector {
    width: 2px;
    height: 1.25rem;
    flex: none;
    margin: 0 auto;
  }

  .sk-connector::after {
    top: -20%;
    left: 50%;
    width: 4px;
    height: 20%;
    transform: translateX(-50%);
    animation-name: sk-flow-vertical;
  }

  @keyframes sk-flow-vertical {
    0% {
      top: -20%;
      opacity: 0;
    }
    15% {
      opacity: 1;
    }
    85% {
      opacity: 1;
    }
    100% {
      top: 100%;
      opacity: 0;
    }
  }
}

/* Respect user motion preference: freeze the pulse, keep the static
   pipeline fully visible and legible. */
@media (prefers-reduced-motion: reduce) {
  .sk-connector::after {
    animation: none;
    left: 40%;
    opacity: 1;
  }

  @media (max-width: 45rem) {
    .sk-connector::after {
      top: 40%;
      left: 50%;
    }
  }
}

/*
 * Landing-page hero: a model diff flows down into a terminal that fails the
 * build. Same constraints as the pipeline: pure CSS, no JS, no external
 * assets, dark-mode aware, honors prefers-reduced-motion.
 */

.sk-hero {
  margin: 1.5rem 0 0;
}

.sk-hero .highlight {
  margin: 0;
}

.sk-hero-caption {
  margin: 0 0 0.4rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--md-default-fg-color--light);
}

/* Vertical connector between the diff and the terminal: a rule with a
   traveling pulse (the diff "flowing into" the gate) and an arrowhead. */
.sk-hero-flow {
  position: relative;
  width: 2px;
  height: 2rem;
  margin: 0.4rem auto;
  background: var(--md-default-fg-color--lighter);
}

.sk-hero-flow::before {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--md-default-fg-color--lighter);
}

.sk-hero-flow span {
  position: absolute;
  top: -20%;
  left: 50%;
  width: 4px;
  height: 30%;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--md-primary-fg-color);
  animation: sk-hero-drop 1.8s ease-in-out infinite;
}

@keyframes sk-hero-drop {
  0% {
    top: -30%;
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    top: 100%;
    opacity: 0;
  }
}

/* The terminal window. Deliberately dark in both color schemes — it reads
   as a terminal, and the fixed palette keeps contrast identical under
   Material's default and slate schemes. */
.sk-terminal {
  margin: 0 0 1.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  background: #1a1e26;
  overflow: hidden;
}

.sk-terminal-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  background: #262c38;
}

.sk-terminal-bar i {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: #ff5f57;
}

.sk-terminal-bar i:nth-of-type(2) {
  background: #febc2e;
}

.sk-terminal-bar i:nth-of-type(3) {
  background: #28c840;
}

.sk-terminal-bar b {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #7b8496;
}

.sk-terminal pre {
  margin: 0;
  padding: 0.85rem 1rem;
  background: transparent;
}

/* The terminal is an illustration, not copyable config — drop the copy
   button Material injects into every code block (.md-code__nav in current
   Material, .md-clipboard in older versions). */
.sk-terminal .md-code__nav,
.sk-terminal .md-clipboard {
  display: none;
}

.sk-terminal code {
  display: block;
  padding: 0;
  background: transparent;
  color: #d8dee9;
  font-size: 0.7rem;
  line-height: 1.55;
  /* Wrap long report lines the way a real terminal soft-wraps them,
     instead of forcing horizontal scroll on the hero. */
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.sk-t-prompt {
  color: #28c840;
  font-weight: 700;
}

.sk-t-break,
.sk-t-fail {
  color: #ff6b6b;
  font-weight: 700;
}

.sk-t-dim {
  color: #8b93a5;
}

@media (prefers-reduced-motion: reduce) {
  .sk-hero-flow span {
    animation: none;
    top: 35%;
    opacity: 1;
  }
}
