/* =====================================================================
   Vignettes — the small animated scene beside a section's copy.

   Markup lives in templates/marketing/vignettes/*.html. Every scene is
   decorative: the root carries role="img" + aria-label, so screen readers
   get one sentence and none of the inner markup.

   One shared timeline. Every animated piece runs on --loop (9s). Pieces
   light on evenly spaced cues (.on1 … .on7), hold together, then reset
   together. Base styles are the FINISHED frame, so with reduced motion
   (animation: none) the completed scene simply sits there. --v is the
   per-piece "lit" amount the cue keyframes drive; it inherits, so a cue
   class on a row lights everything inside it, and a cue on a child
   overrides the row. Do not use animation-delay for cues: a positive delay
   plus fill-mode contradicts base-is-finished, and a negative delay wraps
   the hidden window.

   vignettes.js pauses scenes that are off screen (html.vg-js), so each
   one plays from its first cue when it scrolls into view.

   Type: the scene sits beside 16px body copy, so its text is sized to be
   read, not to look like fine print. Base 1rem; labels 0.9375rem; the
   quietest secondary line is 0.8125rem (13px). Secondary text uses
   --vg-muted (darker than --muted) and nothing unlit drops below 50%
   opacity, so a scene is legible at every point in its loop.
   ===================================================================== */
@property --v {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}

.vg {
  --loop: 9s;
  --vg-bg: #fff;
  --vg-line: var(--line-2);
  --vg-muted: #46586a;
  --v: 1;
  position: relative;
  width: 100%;
  max-width: 30rem;
  margin: 0 auto;
  min-width: 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.4;
}
.section-bg .vg { --vg-bg: var(--navy-25); }
.section-band .vg { --vg-bg: var(--navy-50); }

/* ---------- Frame: head rule / rows / foot rule ---------- */
.vg-head,
.vg-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  color: var(--vg-muted);
}
.vg-head {
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--vg-line);
  font-size: 0.8125rem;
  font-weight: 500;
}
.vg-head > span:first-child {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--navy);
}
.vg-foot {
  flex-wrap: wrap;
  row-gap: 0.4rem;
  margin-top: 0.25rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--vg-line);
  font-size: 0.875rem;
  font-weight: 500;
}
/* The caption keeps at least 10rem; a long status drops to its own line instead of squeezing it. */
.vg-foot > span:first-child { flex: 1 1 10rem; min-width: 0; }
.vg-foot > :last-child { margin-left: auto; }

.vg .orange { color: var(--orange-600); }
.vg .navy { color: var(--navy); font-weight: 600; }
.vg .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.875rem; letter-spacing: 0; text-transform: none; }
.vg .fade { opacity: calc(0.5 + 0.5 * var(--v)); }
.vg .hold { --v: 0; }

.vg-done {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--green);
  font-size: 0.9375rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: var(--v);
}
.vg-done::before {
  content: "";
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M5 12l5 5L20 7' stroke='white' stroke-width='3.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat center / 14px;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M5 12l5 5L20 7' stroke='white' stroke-width='3.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat center / 14px;
}

/* Rows */
.vg-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  min-height: 3.25rem;
  padding: 0.55rem 0;
}
.vg-row + .vg-row { border-top: 1px solid var(--vg-line); }
.vg-row.icon { grid-template-columns: auto minmax(0, 1fr) auto; }
.vg-row.plug { grid-template-columns: auto auto minmax(0, 1fr) auto; }
.vg-row.bars { grid-template-columns: 7.5rem minmax(0, 1fr) auto; }
.vg-row strong { font-weight: 600; color: var(--ink); }
.vg-row em { font-style: normal; color: var(--navy); font-weight: 600; }
.vg-row small {
  display: block;
  margin-top: 2px;
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--vg-muted);
}
.vg-right {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--vg-muted);
  text-align: right;
  white-space: nowrap;
}
.vg .pill { font-size: 0.8125rem; line-height: 1.25; padding: 4px 10px; white-space: nowrap; }

/* Two states stacked in one cell: .off fades out as .on fades in. */
.vg-swap {
  display: inline-grid;
  justify-items: end;
  font-size: 0.9375rem;
  font-weight: 500;
  text-align: right;
}
.vg-swap > span {
  grid-area: 1 / 1;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.vg-swap .off { color: var(--vg-muted); opacity: calc(1 - var(--v)); }
.vg-swap .on { opacity: var(--v); }
.vg-swap.left { justify-items: start; text-align: left; font-size: inherit; font-weight: inherit; }

/* Motion helpers (combine with .fade) */
.vg .vg-pop { transform: scale(calc(0.9 + 0.1 * var(--v))); transform-origin: right center; }
.vg .vg-slide { transform: translateX(calc((1 - var(--v)) * -10px)); }
.vg .vg-drop { transform: translateY(calc((1 - var(--v)) * -8px)); }

/* Big figure */
.vg-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.1;
  color: var(--navy);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Marks: check, lock, dot, doc, avatar ---------- */
.vg-check,
.vg-lock {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--vg-line);
  background: var(--vg-bg);
}
.vg-check::before,
.vg-lock::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: var(--green);
  opacity: var(--v);
}
.vg-lock::before { background: var(--navy); }
.vg-check::after,
.vg-lock::after {
  content: "";
  position: absolute;
  inset: -2px;
  background: #fff;
  opacity: var(--v);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M5 12l5 5L20 7' stroke='white' stroke-width='3.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat center / 11px;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M5 12l5 5L20 7' stroke='white' stroke-width='3.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat center / 11px;
}
.vg-lock::after {
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><rect x='5' y='11' width='14' height='10' rx='2' fill='white'/><path d='M8 11V7a4 4 0 0 1 8 0v4' stroke='white' stroke-width='2.4' fill='none' stroke-linecap='round'/></svg>") no-repeat center / 10px;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><rect x='5' y='11' width='14' height='10' rx='2' fill='white'/><path d='M8 11V7a4 4 0 0 1 8 0v4' stroke='white' stroke-width='2.4' fill='none' stroke-linecap='round'/></svg>") no-repeat center / 10px;
}

.vg-dot {
  position: relative;
  display: inline-block;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--vg-line);
  background: var(--vg-bg);
  z-index: 1;
}
.vg-dot::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: var(--c, var(--navy));
  opacity: var(--v);
}
.vg .is-orange { --c: var(--orange); }
.vg .is-green { --c: var(--green); }

/* A short wire that fills toward the dot ("plugging in"). */
.vg-plug {
  display: block;
  width: 1.25rem;
  height: 2px;
  margin-right: -0.55rem;
  background: var(--vg-line);
  overflow: hidden;
}
.vg-plug i {
  display: block;
  height: 100%;
  background: var(--navy);
  transform-origin: left;
  transform: scaleX(var(--v));
}

/* A small page that slides in as a document lands. */
.vg-doc {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 17px;
  flex-shrink: 0;
  border: 1.5px solid var(--navy);
  border-radius: 2px;
  opacity: var(--v);
  transform: translateX(calc((1 - var(--v)) * -10px));
}
.vg-doc::before {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  top: 5px;
  height: 1.5px;
  background: var(--navy);
  box-shadow: 0 3px 0 var(--navy);
}

.vg-avatar {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--c, var(--navy));
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  font-style: normal;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: var(--v);
  transform: scale(calc(0.6 + 0.4 * var(--v)));
}
.vg-swap .vg-avatar { width: 20px; height: 20px; font-size: 0.55rem; }
.vg-avatars { display: inline-flex; align-items: center; }
.vg-avatars .vg-avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--vg-bg); }
.vg-avatars .vg-avatar:first-child { margin-left: 0; }

/* Live pulse (the only continuous motion; a detail, not the scene) */
.vg-live {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 0.35rem;
  border-radius: 50%;
  background: var(--green);
  vertical-align: 1px;
  animation: vg-live 2.4s ease-in-out infinite;
}
@keyframes vg-live { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ---------- Bars ---------- */
.vg-bar {
  display: block;
  height: 6px;
  border-radius: 3px;
  background: var(--vg-line);
  overflow: hidden;
}
.vg-bar i {
  display: block;
  height: 100%;
  width: var(--w, 100%);
  border-radius: 3px;
  background: var(--navy);
  transform-origin: left;
  transform: scaleX(var(--v));
}
.vg-bar.is-orange i { background: var(--orange); }
.vg-bar.inline { width: 10rem; max-width: 100%; margin-top: 0.45rem; }

/* ---------- Tiles (KPI grid) ---------- */
.vg-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  padding: 0.85rem 0 0.7rem;
}
.vg-tile {
  padding: 0.85rem 1rem 0.8rem;
  border: 1px solid var(--vg-line);
  border-radius: var(--radius-lg);
  background: var(--vg-bg);
  opacity: calc(0.5 + 0.5 * var(--v));
}
.vg-tile .k {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--vg-muted);
}
.vg-tile .v {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  line-height: 1.1;
  color: var(--navy);
  letter-spacing: -0.02em;
  transform-origin: left center;
  transform: scale(calc(0.94 + 0.06 * var(--v)));
}
.vg-tile .d { display: block; margin-top: 0.2rem; font-size: 0.8125rem; color: var(--vg-muted); }

/* ---------- Rail: a pulse travels a line and lights each stop ---------- */
.vg-rail { --inset: 10%; position: relative; padding: 0.9rem 0 0.5rem; }
.vg-rail.s3 { --inset: 16.667%; }
.vg-rail.s4 { --inset: 12.5%; }
.vg-rail-line {
  position: absolute;
  left: var(--inset);
  right: var(--inset);
  top: calc(0.9rem + 5px);
  height: 2px;
  background: var(--vg-line);
}
.vg-rail-fill {
  position: absolute;
  inset: 0;
  transform-origin: left;
  background: linear-gradient(90deg, var(--orange) 0 18%, var(--navy) 32%);
  animation: vg-fill-5 var(--loop) linear infinite;
}
.vg-rail-pulse {
  position: absolute;
  top: calc(0.9rem + 2px);
  left: var(--inset);
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--navy);
  box-shadow: 0 0 10px rgba(16, 72, 98, 0.45);
  z-index: 2;
  animation: vg-travel-5 var(--loop) linear infinite;
}
.vg-rail.s4 .vg-rail-fill { animation-name: vg-fill-4; }
.vg-rail.s4 .vg-rail-pulse { animation-name: vg-travel-4; }
.vg-rail.s3 .vg-rail-fill { animation-name: vg-fill-3; }
.vg-rail.s3 .vg-rail-pulse { animation-name: vg-travel-3; }
/* The pulse reaches the last stop as that stop's cue fires (48 / 38 / 28%). */
@keyframes vg-fill-5 {
  0%, 4% { transform: scaleX(0); opacity: 1; }
  48%, 86% { transform: scaleX(1); opacity: 1; }
  91% { transform: scaleX(1); opacity: 0; }
  92%, 100% { transform: scaleX(0); opacity: 0; }
}
@keyframes vg-travel-5 {
  0%, 4% { left: var(--inset); opacity: 1; }
  48%, 86% { left: calc(100% - var(--inset)); opacity: 1; }
  91% { left: calc(100% - var(--inset)); opacity: 0; }
  92%, 100% { left: var(--inset); opacity: 0; }
}
@keyframes vg-fill-4 {
  0%, 4% { transform: scaleX(0); opacity: 1; }
  38%, 86% { transform: scaleX(1); opacity: 1; }
  91% { transform: scaleX(1); opacity: 0; }
  92%, 100% { transform: scaleX(0); opacity: 0; }
}
@keyframes vg-travel-4 {
  0%, 4% { left: var(--inset); opacity: 1; }
  38%, 86% { left: calc(100% - var(--inset)); opacity: 1; }
  91% { left: calc(100% - var(--inset)); opacity: 0; }
  92%, 100% { left: var(--inset); opacity: 0; }
}
@keyframes vg-fill-3 {
  0%, 4% { transform: scaleX(0); opacity: 1; }
  28%, 86% { transform: scaleX(1); opacity: 1; }
  91% { transform: scaleX(1); opacity: 0; }
  92%, 100% { transform: scaleX(0); opacity: 0; }
}
@keyframes vg-travel-3 {
  0%, 4% { left: var(--inset); opacity: 1; }
  28%, 86% { left: calc(100% - var(--inset)); opacity: 1; }
  91% { left: calc(100% - var(--inset)); opacity: 0; }
  92%, 100% { left: var(--inset); opacity: 0; }
}
.vg-stops {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  text-align: center;
}
.vg-stop { min-width: 0; padding: 0 0.15rem; }
.vg-stop .vg-dot { display: block; margin: 0 auto 0.6rem; }
.vg-stop strong,
.vg-stop small {
  display: block;
  opacity: calc(0.5 + 0.5 * var(--v));
}
.vg-stop strong { font-size: 0.875rem; font-weight: 600; color: var(--ink); }
.vg-stop small { margin-top: 2px; font-size: 0.8125rem; line-height: 1.3; color: var(--vg-muted); }
.vg-stop .vg-num { display: block; margin-top: 3px; font-size: 1.125rem; }
.vg-stop.you { --c: var(--orange); }
.vg-stop.you strong { color: var(--orange-600); }

/* ---------- Scan: a line sweeps down the rows ---------- */
.vg-rows { position: relative; }
.vg-scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--orange) 25%, var(--orange) 75%, transparent);
  box-shadow: 0 0 12px rgba(231, 135, 36, 0.55);
  animation: vg-scan var(--loop) linear infinite;
}
@keyframes vg-scan {
  0% { top: 0; opacity: 0; }
  2% { opacity: 1; }
  40% { top: calc(100% - 2px); opacity: 1; }
  46% { top: calc(100% - 2px); opacity: 0; }
  100% { top: 0; opacity: 0; }
}

/* ---------- Chart: the line draws, then the marks light ---------- */
.vg-chart { position: relative; padding: 0.85rem 0 0.35rem; }
.vg-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.vg-chart .grid { stroke: var(--vg-line); stroke-width: 1; }
.vg-chart .line {
  fill: none;
  stroke: var(--navy);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: vg-draw var(--loop) linear infinite;
}
@keyframes vg-draw {
  0%, 4% { stroke-dashoffset: 1; opacity: 1; }
  44%, 86% { stroke-dashoffset: 0; opacity: 1; }
  91% { stroke-dashoffset: 0; opacity: 0; }
  92%, 100% { stroke-dashoffset: 1; opacity: 0; }
}
.vg-chart .window { fill: rgba(31, 122, 77, 0.10); opacity: var(--v); }
.vg-chart .vline { stroke: var(--green); stroke-width: 1.5; stroke-dasharray: 4 4; opacity: var(--v); }
.vg-chart .mark { fill: var(--vg-bg); stroke: var(--c, var(--navy)); stroke-width: 2.5; opacity: var(--v); }
.vg-callout {
  position: absolute;
  display: grid;
  gap: 1px;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--vg-line);
  border-radius: var(--radius);
  background: var(--vg-bg);
  font-size: 0.8125rem;
  line-height: 1.3;
  color: var(--vg-muted);
  white-space: nowrap;
  opacity: var(--v);
  transform: translateY(calc((1 - var(--v)) * 4px));
}
.vg-callout strong { font-size: 0.875rem; color: var(--navy); font-weight: 700; }
.vg-callout.is-green strong { color: var(--green); }
.vg-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--vg-muted);
}

/* ---------- Cues: piece N lights at 8 + 10(N-1)%, all hold to 86%, all reset by 91%. ---------- */
.vg .on1 { animation: vg-on1 var(--loop) ease-out infinite; }
.vg .on2 { animation: vg-on2 var(--loop) ease-out infinite; }
.vg .on3 { animation: vg-on3 var(--loop) ease-out infinite; }
.vg .on4 { animation: vg-on4 var(--loop) ease-out infinite; }
.vg .on5 { animation: vg-on5 var(--loop) ease-out infinite; }
.vg .on6 { animation: vg-on6 var(--loop) ease-out infinite; }
.vg .on7 { animation: vg-on7 var(--loop) ease-out infinite; }
@keyframes vg-on1 { 0%, 4% { --v: 0; } 8%, 86% { --v: 1; } 91%, 100% { --v: 0; } }
@keyframes vg-on2 { 0%, 14% { --v: 0; } 18%, 86% { --v: 1; } 91%, 100% { --v: 0; } }
@keyframes vg-on3 { 0%, 24% { --v: 0; } 28%, 86% { --v: 1; } 91%, 100% { --v: 0; } }
@keyframes vg-on4 { 0%, 34% { --v: 0; } 38%, 86% { --v: 1; } 91%, 100% { --v: 0; } }
@keyframes vg-on5 { 0%, 44% { --v: 0; } 48%, 86% { --v: 1; } 91%, 100% { --v: 0; } }
@keyframes vg-on6 { 0%, 54% { --v: 0; } 58%, 86% { --v: 1; } 91%, 100% { --v: 0; } }
@keyframes vg-on7 { 0%, 64% { --v: 0; } 68%, 86% { --v: 1; } 91%, 100% { --v: 0; } }

/* Narrow screens: a notch smaller so five rail stops and label + pill rows still fit. */
@media (max-width: 480px) {
  .vg { font-size: 0.9375rem; }
  .vg-row.bars { grid-template-columns: 6.5rem minmax(0, 1fr) auto; }
  .vg-stop small { font-size: 0.75rem; }
  .vg-swap.left > span { white-space: normal; }
}

/* Off-screen scenes wait at their first frame (vignettes.js toggles .is-playing). */
.vg-js .vg:not(.is-playing) * { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  .vg *,
  .vg *::before,
  .vg *::after { animation: none !important; }
  .vg-scan,
  .vg-rail-pulse { display: none; }
}
