/*
 * shared-fig.css — Whipscribe shared visual-block styles
 * Extracted from /blog posts · t-site-wide-fig-visual-block-pattern-04240100
 *
 * Usage: <link rel="stylesheet" href="/shared-fig.css?v=20260424a">
 *
 * Tokens consumed (defined per-page in :root or from the v4 system):
 *   --v4-accent   (falls back to --violet-700: #6d28d9)
 *   --v4-ink      (falls back to --ink-900: #0f172a)
 *   --v4-ink-muted (falls back to --ink-500: #64748b)
 *   --violet-50, --violet-100, --violet-600, --violet-700
 *   --ink-200, --ink-500, --ink-900, --white
 *
 * All fallbacks are defined below so this file is self-contained when
 * loaded on a page that only defines the v4 tokens.
 */

/* ── Token fallback bridge ──────────────────────────────────────────────── */
:root {
  --fig-accent:       var(--v4-accent,      var(--violet-700, #6d28d9));
  --fig-ink:          var(--v4-ink,         var(--ink-900,    #0f172a));
  --fig-ink-muted:    var(--v4-ink-muted,   var(--ink-500,    #64748b));
  --fig-border:       var(--ink-200,        #e2e8f0);
  --fig-bg-tint-from: var(--violet-50,      #f5f3ff);
  --fig-bg-tint-to:   var(--white,          #ffffff);
  --fig-tint-border:  var(--violet-100,     #ede9fe);
  --fig-accent-h:     var(--violet-600,     #7c3aed);
  --fig-rail-done:    var(--violet-700,     #6d28d9);
  --fig-rail-track:   var(--ink-200,        #e2e8f0);
  --fig-bar-fill:     var(--violet-600,     #7c3aed);
  --fig-bar-bg:       var(--ink-200,        #e2e8f0);
}

/* ── Core figure wrapper ────────────────────────────────────────────────── */
.fig {
  margin: 22px 0 26px;
}

.fig svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.fig figcaption {
  font-size: 13px;
  color: var(--fig-ink-muted);
  margin-top: 8px;
  text-align: center;
  line-height: 1.5;
}

/* ── Modifier: bordered card ─────────────────────────────────────────────── */
.fig.bordered {
  border: 1px solid var(--fig-border);
  border-radius: 12px;
  padding: 18px 16px 14px;
  background: var(--fig-bg-tint-to);
}

/* ── Modifier: violet tint card ─────────────────────────────────────────── */
.fig.tinted {
  background: linear-gradient(180deg, var(--fig-bg-tint-from), var(--fig-bg-tint-to));
  border: 1px solid var(--fig-tint-border);
  border-radius: 12px;
  padding: 18px 16px 14px;
}

/* ── Bar chart component ─────────────────────────────────────────────────── */
.fig-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0;
}

.fig-bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 48px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro", "Inter", system-ui, sans-serif;
}

@media (max-width: 520px) {
  .fig-bar-row {
    grid-template-columns: 90px 1fr 44px;
    font-size: 12px;
  }
}

.fig-label {
  color: var(--fig-ink);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fig-track {
  background: var(--fig-bar-bg);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.fig-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--fig-bar-fill);
  transform-origin: left;
  animation: fig-bar-grow 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.fig-fill.accent {
  background: linear-gradient(90deg, var(--fig-accent-h), var(--fig-accent));
}

.fig-fill.muted {
  background: var(--fig-ink-muted, #94a3b8);
  opacity: 0.45;
}

.fig-value {
  text-align: right;
  color: var(--fig-ink);
  font-weight: 700;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ── Workflow rail component ─────────────────────────────────────────────── */
.fig-rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0;
  padding: 10px 0 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.fig-rail-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 64px;
  position: relative;
}

.fig-rail-node + .fig-rail-node::before {
  content: "";
  position: absolute;
  left: calc(-50% + 16px);
  right: calc(50% + 16px);
  top: 16px;
  height: 2px;
  background: var(--fig-rail-track);
  pointer-events: none;
}

.fig-rail-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--fig-rail-track);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.fig-rail-dot.done {
  background: var(--fig-rail-done);
}

.fig-rail-dot.done svg {
  width: 14px;
  height: 14px;
  color: #fff;
}

.fig-rail-dot svg {
  width: 14px;
  height: 14px;
  color: var(--fig-ink-muted);
}

.fig-rail-step {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fig-ink-muted);
  text-align: center;
  line-height: 1.3;
}

.fig-rail-step.done {
  color: var(--fig-ink);
}

/* ── Animation keyframes ─────────────────────────────────────────────────── */
@keyframes fig-bar-grow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@keyframes fig-draw-line {
  from { stroke-dashoffset: 900; }
  to   { stroke-dashoffset: 0; }
}

@keyframes fig-pulse-dot {
  0%, 100% { r: 4; opacity: 0.8; }
  50%      { r: 6; opacity: 1; }
}

.fig-chart-line {
  stroke-dasharray: 900;
  animation: fig-draw-line 2.2s ease-out forwards;
}

.fig-pulse-dot {
  animation: fig-pulse-dot 2.2s ease-in-out infinite;
}

/* ── Accessibility: honour reduced-motion ───────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .fig-fill          { animation: none; transform: scaleX(1); }
  .fig-chart-line    { animation: none; stroke-dashoffset: 0; }
  .fig-pulse-dot     { animation: none; }
}
