/* Animated figures for "Orca, OpenRig and Herdr" (ry-ops.dev).
   Everything is scoped under .afl and drawn as dark cards, so the figures read the
   same in the blog's light and dark themes. The !important rules at the bottom keep
   the post's .prose styles from restyling text inside the figures. */
.afl {
  --bg: #0b1020; --bg2: #111833; --bg3: #18214a; --line: #26306a; --line2: #3a4590;
  --ink: #f4f6ff; --mute: #aab3dc; --dim: #737db0;
  --orca: #22d3ee; --rig: #a78bfa; --herdr: #fbbf24; --gap: #fb7185;
  --ok: #34d399; --no: #fb7185; --warn: #fbbf24; --idle: #94a3b8;
  --k8s: #60a5fa;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
  position: relative; margin: 2.4rem 0; padding: 16px; border-radius: 18px;
  background: radial-gradient(120% 90% at 0% 0%, #1b1f4a 0%, var(--bg) 58%), var(--bg);
  border: 1px solid var(--line); color: var(--ink); font: 15px/1.5 var(--sans);
  box-shadow: 0 22px 50px -22px rgba(76, 29, 149, .55);
  overflow: hidden; max-width: 100%; isolation: isolate;
}
.afl::before {
  content: ""; position: absolute; inset: -45%; z-index: -1; opacity: .28; pointer-events: none;
  background: conic-gradient(from 0deg, transparent 0 62%, rgba(139,92,246,.35) 72%, rgba(34,211,238,.22) 82%, transparent 92%);
  animation: afl-spin 26s linear infinite;
}
@keyframes afl-spin { to { transform: rotate(360deg); } }
.afl-fallback { color: var(--mute); font-size: 14px; }
.afl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.afl-title { font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.afl-chip { font: 600 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; padding: 5px 8px; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid var(--line2); color: var(--mute); }
.afl-chip.live { color: var(--ok); border-color: rgba(52,211,153,.45); }
.afl-chip.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); margin-right: 6px; vertical-align: 1px; animation: afl-blink 1.4s ease-in-out infinite; }
@keyframes afl-blink { 50% { opacity: .25; } }
.afl svg { display: block; width: 100%; height: auto; overflow: visible; }
.afl svg text { font-family: var(--sans); fill: var(--ink); }
.afl svg .mono { font-family: var(--mono); }
.afl svg .mute { fill: var(--mute); }
.afl svg .dim { fill: var(--dim); }
.afl-cap { margin-top: 10px; font-size: 13.5px; color: var(--mute); }
.afl-cap b { color: var(--ink); }
.afl-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.afl-btn { appearance: none; cursor: pointer; font: 600 13px/1 var(--sans); color: var(--mute); background: rgba(255,255,255,.04); border: 1px solid var(--line2); border-radius: 10px; padding: 9px 12px; transition: background .2s, color .2s, border-color .2s; }
.afl-btn:hover { color: var(--ink); border-color: #5865c4; }
.afl-btn[aria-pressed="true"] { color: #0b1020; background: var(--ink); border-color: var(--ink); }
.afl-btn:focus-visible { outline: 2px solid var(--orca); outline-offset: 2px; }
.afl-panel { background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 14px; min-height: 3.2em; }
.afl-panel b { color: var(--ink); }
.afl-term { font: 12.5px/1.55 var(--mono); background: #070b18; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; white-space: pre-wrap; word-break: break-word; color: #d7defc; min-height: 9.5em; }
.afl-term .c { color: var(--dim); }
.afl-term .p { color: var(--orca); }
.afl-term .g { color: var(--ok); }
.afl-term .y { color: var(--warn); }
.afl-term .r { color: var(--no); }
.afl-term .v { color: var(--rig); }

/* step rail used by the replay figures */
.afl-rail { display: grid; grid-template-columns: repeat(var(--n, 8), 1fr); gap: 6px; margin: 4px 0 12px; }
.afl-rail button { appearance: none; cursor: pointer; height: 34px; border-radius: 8px; border: 1px solid var(--line2); background: rgba(255,255,255,.03); color: var(--dim); font: 700 12px/1 var(--mono); position: relative; overflow: hidden; }
.afl-rail button[aria-current="step"] { color: #0b1020; background: var(--rig); border-color: var(--rig); }
.afl-rail button.done { color: var(--ink); border-color: rgba(167,139,250,.6); }
.afl-step-title { font-weight: 700; margin-bottom: 6px; }
.afl-step-title small { font-weight: 500; color: var(--mute); margin-left: 6px; }
.afl-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 10px; }
.afl-count { font: 600 12px/1.3 var(--mono); color: var(--mute); }
.afl-count b { color: var(--warn); }

/* the k8s mapping notes */
.afl-map { display: grid; gap: 8px; margin-top: 12px; }
.afl-map div { display: grid; grid-template-columns: 9.5em 1fr; gap: 10px; align-items: start; padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.03); border: 1px solid var(--line); font-size: 14px; }
.afl-map div > span { font-weight: 700; }
.afl-map .fit { color: var(--ok); font-weight: 700; }
.afl-map .brk { color: var(--no); font-weight: 700; }
.afl-map [hidden] { display: none; }

/* decision helper */
.afl-q { font-weight: 700; margin: 2px 0 8px; }
.afl-out { margin-top: 12px; padding: 14px; border-radius: 12px; border: 1px solid var(--line2); background: rgba(255,255,255,.04); }
.afl-out h4 { margin: 0 0 6px !important; font-size: 16px !important; color: var(--ink) !important; }
.afl-out ul { margin: 6px 0 0 1.1em !important; padding: 0 !important; }
.afl-out li { list-style: disc !important; margin: 3px 0 !important; color: var(--mute) !important; }

/* gap matrix */
.afl-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--mute); margin-top: 8px; }
.afl-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* svg animation helpers: everything waits for .on (set when the figure scrolls into view) */
.afl .draw { stroke-dasharray: var(--len, 600); stroke-dashoffset: var(--len, 600); }
.afl.on .draw { animation: afl-draw 1.2s cubic-bezier(.6,.1,.2,1) forwards; animation-delay: var(--d, 0s); }
@keyframes afl-draw { to { stroke-dashoffset: 0; } }
.afl .rise { opacity: 0; transform: translateY(10px); transform-box: fill-box; }
.afl.on .rise { animation: afl-rise .7s ease forwards; animation-delay: var(--d, 0s); }
@keyframes afl-rise { to { opacity: 1; transform: none; } }
.afl .pulse { transform-box: fill-box; transform-origin: center; animation: afl-pulse 2.2s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes afl-pulse { 50% { transform: scale(1.18); opacity: .55; } }
.afl .blink { animation: afl-blink 1.6s ease-in-out infinite; animation-delay: var(--d, 0s); }
.afl .flow { stroke-dasharray: 4 9; animation: afl-flow 1.1s linear infinite; }
@keyframes afl-flow { to { stroke-dashoffset: -26; } }
.afl .ghost { stroke-dasharray: 7 7; animation: afl-flow 2.4s linear infinite; }
.afl .float { transform-box: fill-box; animation: afl-float 5s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes afl-float { 50% { transform: translateY(-5px); } }
.afl .shake { transform-box: fill-box; transform-origin: center; animation: afl-shake .5s ease-in-out 3; }
@keyframes afl-shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.afl .hl { transition: opacity .35s ease, filter .35s ease; }
.afl .fade { opacity: .22; }

@media (max-width: 560px) {
  .afl { padding: 12px; border-radius: 14px; }
  .afl-map div { grid-template-columns: 1fr; gap: 4px; }
  .afl-rail button { height: 30px; font-size: 11px; }
  .afl-term { font-size: 11.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .afl *, .afl::before, .afl *::before, .afl *::after { animation: none !important; transition: none !important; }
  .afl .draw { stroke-dashoffset: 0 !important; }
  .afl .rise { opacity: 1 !important; transform: none !important; }
}

/* keep the post's prose styles from leaking into the cards */
.afl { color: var(--ink) !important; }
.afl :is(p, li) { margin: 0; font-size: inherit; line-height: inherit; }
.afl a { color: #a5f3fc !important; }
.afl code { background: rgba(255,255,255,.08) !important; color: #e0e7ff !important; padding: .1em .35em !important; border-radius: 5px !important; font-size: .92em !important; }
.afl .afl-cap, .afl .afl-panel, .afl .afl-fallback { color: var(--mute) !important; }
.afl .afl-panel b, .afl .afl-cap b, .afl .afl-step-title { color: var(--ink) !important; }
.afl .afl-map div > span:first-child { color: var(--ink) !important; }
.prose .afl p, .afl p { margin: 0 !important; font-size: 14px !important; line-height: 1.55 !important; color: var(--mute) !important; }
.prose .afl p.afl-cap, .afl p.afl-cap { margin-top: 10px !important; font-size: 13.5px !important; }
.prose .afl p.afl-q, .afl p.afl-q { color: var(--ink) !important; font-weight: 700 !important; font-size: 15px !important; margin: 4px 0 8px !important; }
.afl .afl-map p .fit { color: var(--ok) !important; }
.afl .afl-map p .brk { color: var(--no) !important; }
.prose .afl :is(h4, ul, li) { font-size: 14px !important; }
