/* Workforce Pipeline widget (v2).
   Light card. Three-stage pipeline (SOURCED → TRAINED → PLACED) with
   a single teal pulse traveling the rail and the three Watts-to-
   Workers source programs named below. Matches the vocabulary of
   stage-path + sovereign-enclave: white card, tinted panel inside,
   mono labels, brand teal accents, soft shadow stack. CSS-only
   motion. Reduced-motion parks the pulse and keeps all counters
   visible. */

.widget-workforce-pipeline {
  --wwp-teal: var(--brand-teal);
  --wwp-blue: var(--brand-blue);
  --wwp-surface: var(--color-card, #fff);
  --wwp-fg: var(--color-foreground);
  --wwp-muted: var(--color-muted-foreground);
  --wwp-line: var(--color-border);
  --wwp-panel: color-mix(in oklch, var(--wwp-fg) 3%, var(--wwp-surface));
  --wwp-cycle: 6s; /* overridden per-instance inline */

  min-width: 0;
  width: 100%;
}

.widget-workforce-pipeline__card {
  display: grid;
  grid-template-rows: auto auto auto;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.875rem;
  padding: 0.875rem 0.875rem 0.75rem;
  background: var(--wwp-surface);
  border: 1px solid var(--wwp-line);
  border-radius: var(--radius-lg);
  box-shadow:
    0 1px 2px rgb(16 17 20 / 4%),
    0 10px 28px -14px rgb(16 17 20 / 14%),
    0 22px 48px -24px rgb(16 17 20 / 10%);
  color: var(--wwp-fg);
  --color-foreground: var(--wwp-fg);
  --color-muted-foreground: var(--wwp-muted);
  --color-border: var(--wwp-line);
}

/* --- Head row ----------------------------------------------------- */

.widget-workforce-pipeline__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.125rem 0.25rem;
}

.widget-workforce-pipeline__tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--wwp-fg);
}

.widget-workforce-pipeline__tag-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--wwp-teal);
  box-shadow:
    0 0 0 3px color-mix(in oklch, var(--wwp-teal) 35%, var(--wwp-surface)),
    0 0 10px color-mix(in oklch, var(--wwp-teal) 45%, transparent);
  animation: wwp-tag-breathe 2.6s ease-in-out infinite;
}

.widget-workforce-pipeline__status {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--wwp-muted);
}

/* --- Stage: horizontal 3-node pipeline ---------------------------- */

.widget-workforce-pipeline__stage {
  position: relative;
  padding: 1.5rem 1rem 1.25rem;
  background: var(--wwp-panel);
  border: 1px solid color-mix(in oklch, var(--wwp-fg) 9%, transparent);
  border-radius: var(--radius-md);
}

.widget-workforce-pipeline__rail {
  position: absolute;
  top: 2.5rem;
  left: 2.25rem;
  right: 2.25rem;
  height: 2px;
  background: color-mix(in oklch, var(--wwp-fg) 12%, transparent);
  border-radius: 999px;
  overflow: hidden;
}
.widget-workforce-pipeline__rail-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    var(--wwp-teal) 0%,
    var(--wwp-blue) 100%
  );
  opacity: 0.5;
}

.widget-workforce-pipeline__stages {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  z-index: 1;
}

.widget-workforce-pipeline__stage-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  /* Stage active state: when the pulse lands here, the node border
     brightens, label + value gain teal tint. Driven by the same
     --i-staggered cycle as the pulse so everything reads in sync. */
  --stage-tint: 0;
  animation: wwp-stage-active var(--wwp-cycle) ease-in-out infinite;
  animation-delay: calc((var(--i) / 3) * var(--wwp-cycle));
}

.widget-workforce-pipeline__node {
  position: relative;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: var(--wwp-surface);
  border: 1px solid color-mix(in oklch, var(--wwp-fg) 18%, transparent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 4px var(--wwp-panel);
  animation: wwp-node-active var(--wwp-cycle) ease-in-out infinite;
  animation-delay: calc((var(--i) / 3) * var(--wwp-cycle));
}

.widget-workforce-pipeline__node-dot {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--wwp-fg) 22%, transparent);
}

.widget-workforce-pipeline__stage-label {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: color-mix(
    in oklch,
    var(--wwp-teal) calc(var(--stage-tint, 0) * 80%),
    var(--wwp-muted)
  );
  white-space: nowrap;
}

.widget-workforce-pipeline__stage-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: var(--font-weight-display);
  line-height: 1;
  letter-spacing: -0.01em;
  color: color-mix(
    in oklch,
    var(--wwp-teal) calc(var(--stage-tint, 0) * 100%),
    var(--wwp-fg)
  );
}

/* Tint keyframe drives a CSS custom property that the label + value
   both consume. One animation, two properties take the tint. */
@keyframes wwp-stage-active {
  0%, 4%    { --stage-tint: 0; }
  6%, 28%   { --stage-tint: 1; }
  33.33%    { --stage-tint: 0; }
  100%      { --stage-tint: 0; }
}

@keyframes wwp-node-active {
  0%, 4% {
    border-color: color-mix(in oklch, var(--wwp-fg) 18%, transparent);
    box-shadow: 0 0 0 4px var(--wwp-panel);
  }
  6%, 28% {
    border-color: var(--wwp-teal);
    box-shadow:
      0 0 0 4px var(--wwp-panel),
      0 0 0 6px color-mix(in oklch, var(--wwp-teal) 14%, transparent),
      0 0 18px -4px color-mix(in oklch, var(--wwp-teal) 45%, transparent);
  }
  33.33%, 100% {
    border-color: color-mix(in oklch, var(--wwp-fg) 18%, transparent);
    box-shadow: 0 0 0 4px var(--wwp-panel);
  }
}

/* --- Traveling pulse ----------------------------------------------
   Lives inside .__stages (3-col grid) so percentage stops map to
   column centers without any padding math. Same geometry + step
   timing as the stage-path indicator. */

.widget-workforce-pipeline__pulse {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1.75rem; /* match node height */
  pointer-events: none;
  z-index: 2;
  grid-column: 1 / -1;
  animation: wwp-pulse-slide var(--wwp-cycle) steps(3, jump-none) infinite;
}

.widget-workforce-pipeline__pulse::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.125rem;
  height: 1.125rem;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: var(--wwp-teal);
  box-shadow:
    0 0 0 4px color-mix(in oklch, var(--wwp-teal) 26%, var(--wwp-surface)),
    0 0 18px color-mix(in oklch, var(--wwp-teal) 55%, transparent);
}

@keyframes wwp-pulse-slide {
  0%   { left: calc(100% / 6 * 1); }   /* ~16.67%, column 1 center */
  100% { left: calc(100% / 6 * 5); }   /* ~83.33%, column 3 center */
}

/* --- Sources row -------------------------------------------------- */

.widget-workforce-pipeline__sources {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.375rem 0;
  border-top: 1px solid color-mix(in oklch, var(--wwp-fg) 9%, transparent);
  flex-wrap: wrap;
}

.widget-workforce-pipeline__sources-label {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--wwp-muted);
}

.widget-workforce-pipeline__sources-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.625rem;
}

.widget-workforce-pipeline__source {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
  color: var(--wwp-fg);
}

.widget-workforce-pipeline__source-dot {
  width: 0.3125rem;
  height: 0.3125rem;
  border-radius: 999px;
  background: var(--wwp-teal);
  flex-shrink: 0;
}

/* --- Shared tag-dot breathe -------------------------------------- */

@keyframes wwp-tag-breathe {
  0%, 100% {
    box-shadow:
      0 0 0 3px color-mix(in oklch, var(--wwp-teal) 35%, var(--wwp-surface)),
      0 0 10px color-mix(in oklch, var(--wwp-teal) 45%, transparent);
  }
  50% {
    box-shadow:
      0 0 0 5px color-mix(in oklch, var(--wwp-teal) 22%, var(--wwp-surface)),
      0 0 16px color-mix(in oklch, var(--wwp-teal) 60%, transparent);
  }
}

/* --- Responsive --------------------------------------------------- */

@media (max-width: 480px) {
  .widget-workforce-pipeline__stage-value {
    font-size: 1.25rem;
  }
  .widget-workforce-pipeline__stage-label {
    font-size: 0.5625rem;
  }
  .widget-workforce-pipeline__source {
    font-size: 0.625rem;
  }
}

/* --- Reduced motion ---------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .widget-workforce-pipeline__tag-dot,
  .widget-workforce-pipeline__pulse,
  .widget-workforce-pipeline__stage-item,
  .widget-workforce-pipeline__node {
    animation: none;
  }
  /* Park the pulse between Sourced and Trained. */
  .widget-workforce-pipeline__pulse {
    left: calc(100% / 6 * 3);
  }
  .widget-workforce-pipeline__stage-item {
    --stage-tint: 0.35;
  }
  .widget-workforce-pipeline__node {
    border-color: color-mix(in oklch, var(--wwp-teal) 30%, transparent);
  }
}
