/* ---- Teaching: a loop of the idea each course teaches -------------------
   The section's claim is that every concept gets an animation, so the cards
   make that claim instead of describing it. Each card runs the one idea its
   course is about, in that site's own accent colour, in plain CSS. */
.viz {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 58px;
  margin-inline: auto;
  margin-bottom: 0.15rem;
}
.viz i, .viz b, .viz s, .viz u, .viz em { display: block; }
.viz b, .viz i { border-radius: 4px; background: color-mix(in oklab, var(--viz) 16%, transparent); }

/* DrillLab — each completed step removes another layer of guidance */
.viz--drill { width: 100%; }
.drill-stairs {
  position: relative;
  display: flex;
  width: 100%;
  max-width: 158px;
  height: 48px;
  align-items: flex-end;
  gap: 3px;
}
.drill-stairs i {
  flex: 1;
  border: 1px solid color-mix(in oklab, var(--viz) 22%, var(--border));
  border-radius: 4px 4px 2px 2px;
  background: color-mix(in oklab, var(--viz) 7%, transparent);
}
.drill-stairs i:nth-child(1) { height: 9px; animation: drillStageOne 5s ease-in-out infinite; }
.drill-stairs i:nth-child(2) { height: 17px; animation: drillStageTwo 5s ease-in-out infinite; }
.drill-stairs i:nth-child(3) { height: 25px; animation: drillStageThree 5s ease-in-out infinite; }
.drill-stairs i:nth-child(4) { height: 33px; animation: drillStageFour 5s ease-in-out infinite; }
.drill-stairs s {
  position: absolute;
  left: calc(12.5% - 4px);
  bottom: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--viz);
  box-shadow: 0 0 10px color-mix(in oklab, var(--viz) 55%, transparent);
  animation: drillClimb 5s cubic-bezier(.45, 0, .2, 1) infinite;
}
@keyframes drillClimb {
  0% { left: calc(12.5% - 4px); bottom: 12px; opacity: 0; }
  6%,16% { left: calc(12.5% - 4px); bottom: 12px; opacity: 1; }
  28%,38% { left: calc(37.5% - 4px); bottom: 20px; opacity: 1; }
  50%,60% { left: calc(62.5% - 4px); bottom: 28px; opacity: 1; }
  72%,88% { left: calc(87.5% - 4px); bottom: 36px; opacity: 1; }
  94%,100% { left: calc(87.5% - 4px); bottom: 36px; opacity: 0; }
}
@keyframes drillStageOne {
  0%,100% { background: color-mix(in oklab, var(--viz) 7%, transparent); border-color: color-mix(in oklab, var(--viz) 22%, var(--border)); }
  6%,90% { background: color-mix(in oklab, var(--viz) 25%, transparent); border-color: color-mix(in oklab, var(--viz) 52%, var(--border)); }
}
@keyframes drillStageTwo {
  0%,24%,100% { background: color-mix(in oklab, var(--viz) 7%, transparent); border-color: color-mix(in oklab, var(--viz) 22%, var(--border)); }
  28%,90% { background: color-mix(in oklab, var(--viz) 25%, transparent); border-color: color-mix(in oklab, var(--viz) 52%, var(--border)); }
}
@keyframes drillStageThree {
  0%,46%,100% { background: color-mix(in oklab, var(--viz) 7%, transparent); border-color: color-mix(in oklab, var(--viz) 22%, var(--border)); }
  50%,90% { background: color-mix(in oklab, var(--viz) 25%, transparent); border-color: color-mix(in oklab, var(--viz) 52%, var(--border)); }
}
@keyframes drillStageFour {
  0%,68%,100% { background: color-mix(in oklab, var(--viz) 7%, transparent); border-color: color-mix(in oklab, var(--viz) 22%, var(--border)); }
  72%,90% { background: color-mix(in oklab, var(--viz) 25%, transparent); border-color: color-mix(in oklab, var(--viz) 52%, var(--border)); }
}

/* DataData — a pointer walking an array, each cell lighting as it lands */
.viz--array i { width: 20px; height: 20px; animation: vizArray 3.6s infinite; }
.viz--array i:nth-child(1) { animation-delay: 0s }
.viz--array i:nth-child(2) { animation-delay: .18s }
.viz--array i:nth-child(3) { animation-delay: .36s }
.viz--array i:nth-child(4) { animation-delay: .54s }
.viz--array i:nth-child(5) { animation-delay: .72s }
.viz--array i:nth-child(6) { animation-delay: .90s }
@keyframes vizArray {
  0%, 4%   { background: var(--viz); transform: translateY(-4px); }
  16%,100% { background: color-mix(in oklab, var(--viz) 16%, transparent); transform: none; }
}

/* AlgoAlgo — a binary search closing in from both ends */
.viz--bisect { position: relative; width: 100%; max-width: 168px; }
.viz--bisect u { position: absolute; left: 0; right: 0; height: 2px; border-radius: 2px;
                 background: color-mix(in oklab, var(--viz) 18%, transparent); }
.viz--bisect b { position: absolute; width: 3px; height: 16px; border-radius: 2px; background: var(--viz); }
.viz--bisect b.lo { left: 0;  animation: vizLo 3.4s cubic-bezier(.6,0,.4,1) infinite; }
.viz--bisect b.hi { right: 0; animation: vizHi 3.4s cubic-bezier(.6,0,.4,1) infinite; }
.viz--bisect s { position: absolute; left: 50%; width: 8px; height: 8px; margin-left: -4px;
                 border-radius: 50%; background: var(--viz); opacity: 0;
                 animation: vizMid 3.4s infinite; }
@keyframes vizLo  { 0%,8% { left: 0 }   58%,100% { left: calc(50% - 14px) } }
@keyframes vizHi  { 0%,8% { right: 0 }  58%,100% { right: calc(50% - 14px) } }
@keyframes vizMid { 0%,55% { opacity: 0; transform: scale(.4) } 70%,88% { opacity: 1; transform: scale(1) } 100% { opacity: 0 } }

/* TSer — a value becomes a type: the result stays readable while inference runs */
.viz--type { width: 100%; gap: 7px; font-family: var(--mono); }
.type-code, .type-result {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 44px;
  border: 1px solid color-mix(in oklab, var(--viz) 24%, var(--border));
  border-radius: 7px;
  background: color-mix(in oklab, var(--viz) 7%, transparent);
}
.type-code { flex: 1; min-width: 0; padding: 5px 7px; color: var(--text-faint); font-size: 8px; line-height: 1.25; }
.type-code b { width: max-content; padding: 0; color: var(--text); background: none; font-size: 13px; }
.type-arrow { color: var(--viz); font: 700 13px var(--mono); animation: vizInfer 3.2s infinite; }
.type-result { width: 62px; padding: 4px 6px; opacity: .42; transform: translateX(-4px); animation: vizType 3.2s infinite; }
.type-result small { color: var(--text-faint); font-size: 7px; line-height: 1; }
.type-result strong { color: var(--viz); font-size: 10px; line-height: 1.45; }
@keyframes vizInfer {
  0%,18%,100% { opacity: .25; transform: translateX(-3px) }
  34%,72% { opacity: 1; transform: translateX(2px) }
}
@keyframes vizType {
  0%,20%,100% { opacity: .42; transform: translateX(-4px); box-shadow: none }
  38%,76% { opacity: 1; transform: none; box-shadow: 0 0 18px color-mix(in oklab, var(--viz) 20%, transparent) }
}

/* APIer — a labelled request goes out; a labelled response comes back */
.viz--rtt { width: 100%; max-width: 190px; gap: 7px; font-family: var(--mono); }
.api-node {
  display: grid;
  place-items: center;
  width: 42px;
  height: 30px;
  border: 1px solid color-mix(in oklab, var(--viz) 27%, var(--border));
  border-radius: 7px;
  color: var(--text-dim);
  background: color-mix(in oklab, var(--viz) 8%, transparent);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: .08em;
}
.api-lane { position: relative; flex: 1; height: 34px; }
.api-lane::before, .api-lane::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: color-mix(in oklab, var(--viz) 22%, transparent);
}
.api-lane::before { top: 9px; }
.api-lane::after { bottom: 9px; }
.api-request, .api-response {
  position: absolute;
  z-index: 1;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--viz);
  font: 700 7px var(--mono);
  font-style: normal;
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--viz) 22%, transparent);
}
.api-request { top: 3px; left: 0; animation: vizRequest 3.8s cubic-bezier(.45,0,.55,1) infinite; }
.api-response { bottom: 3px; right: 0; animation: vizResponse 3.8s cubic-bezier(.45,0,.55,1) infinite; }
@keyframes vizRequest {
  0%,8% { left: 0; opacity: 0 }
  14% { opacity: 1 }
  42%,52% { left: calc(100% - 27px); opacity: 1 }
  58%,100% { left: calc(100% - 27px); opacity: 0 }
}
@keyframes vizResponse {
  0%,46% { right: 0; opacity: 0 }
  54% { opacity: 1 }
  84%,92% { right: calc(100% - 27px); opacity: 1 }
  100% { right: calc(100% - 27px); opacity: 0 }
}

/* RedisVisual — most reads stop at the cache; some fall through to the store */
.viz--cache { position: relative; width: 100%; max-width: 158px; }
.viz--cache b { width: 15px; height: 20px; }
.viz--cache b.hit { animation: vizHit 4s infinite; }
.viz--cache b.db  { margin-left: auto; }
.viz--cache u { flex: 1; height: 1.5px; background: color-mix(in oklab, var(--viz) 16%, transparent); }
.viz--cache s { position: absolute; left: 17px; width: 6px; height: 6px; border-radius: 50%;
                background: var(--viz); animation: vizRead 4s infinite; }
@keyframes vizRead {
  0%,4%    { left: 17px; opacity: 1 }
  20%,30%  { left: 50px; opacity: 1 }     /* reaches the cache */
  40%      { left: 17px; opacity: .35 }   /* served from cache */
  55%      { left: 50px; opacity: 1 }
  72%      { left: calc(100% - 22px) }    /* a miss goes on to the store */
  92%,100% { left: 17px; opacity: 1 }
}
@keyframes vizHit {
  0%,18%   { background: color-mix(in oklab, var(--viz) 16%, transparent) }
  24%,34%  { background: var(--viz) }
  44%,100% { background: color-mix(in oklab, var(--viz) 16%, transparent) }
}

/* AgentLab — the messages array grows, then the loop starts another turn */
.viz--grow { width: 100%; gap: 8px; font-family: var(--mono); }
.agent-stack { display: flex; flex: 1; flex-direction: column; gap: 3px; }
.agent-stack i {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 14px;
  padding: 1px 4px;
  border: 1px solid color-mix(in oklab, var(--viz) 18%, var(--border));
  border-radius: 4px;
  color: var(--text-faint);
  background: color-mix(in oklab, var(--viz) 7%, transparent);
  font: 7px var(--mono);
  font-style: normal;
  opacity: .22;
  transform: translateY(4px);
  animation: vizMessage 4.2s infinite;
}
.agent-stack i:nth-child(2) { animation-delay: .5s; }
.agent-stack i:nth-child(3) { animation-delay: 1s; }
.agent-stack b {
  display: grid;
  place-items: center;
  width: 11px;
  height: 10px;
  border-radius: 3px;
  color: var(--surface);
  background: var(--viz);
  font-size: 6px;
}
.agent-loop {
  padding: 5px 6px;
  border: 1px solid color-mix(in oklab, var(--viz) 24%, var(--border));
  border-radius: 999px;
  color: var(--viz);
  background: color-mix(in oklab, var(--viz) 8%, transparent);
  font: 700 7px var(--mono);
  white-space: nowrap;
  animation: vizLoop 4.2s infinite;
}
@keyframes vizMessage {
  0%,8% { opacity: .22; transform: translateY(4px) }
  18%,68% { opacity: 1; transform: none }
  82%,100% { opacity: .22; transform: translateY(-2px) }
}
@keyframes vizLoop {
  0%,50% { opacity: .35; transform: rotate(0) }
  64%,78% { opacity: 1; transform: rotate(-5deg); box-shadow: 0 0 16px color-mix(in oklab, var(--viz) 20%, transparent) }
  90%,100% { opacity: .35; transform: rotate(0); box-shadow: none }
}

/* Bug Museum — move from the failing state to the tested fix */
.viz--museum { width: 100%; max-width: 174px; gap: 8px; font-family: var(--mono); }
.museum-case {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 46px;
  border: 1px solid color-mix(in oklab, var(--viz) 24%, var(--border));
  border-radius: 8px;
  background: color-mix(in oklab, var(--viz) 7%, transparent);
}
.museum-case b {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: var(--surface);
  background: var(--viz);
  font-size: 12px;
  line-height: 1;
}
.museum-case small {
  margin-top: 4px;
  color: var(--text-faint);
  font-size: 6px;
  line-height: 1;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.museum-arrow {
  color: var(--viz);
  font: 700 13px var(--mono);
  animation: museumArrow 4.2s ease-in-out infinite;
}
.museum-case--broken { animation: museumBroken 4.2s ease-in-out infinite; }
.museum-case--fixed { animation: museumFixed 4.2s ease-in-out infinite; }
.museum-case--fixed b { background: var(--viz-fixed); }
.museum-case--fixed small { color: var(--viz-fixed); }
@keyframes museumBroken {
  0%,22%,100% { border-color: var(--viz); box-shadow: 0 0 18px color-mix(in oklab, var(--viz) 22%, transparent); opacity: 1; }
  40%,88% { border-color: color-mix(in oklab, var(--viz) 20%, var(--border)); box-shadow: none; opacity: .55; }
}
@keyframes museumArrow {
  0%,24%,100% { opacity: .25; transform: translateX(-2px); }
  38%,74% { opacity: 1; transform: translateX(2px); }
  88% { opacity: .25; transform: translateX(2px); }
}
@keyframes museumFixed {
  0%,44%,100% { border-color: color-mix(in oklab, var(--viz-fixed) 20%, var(--border)); box-shadow: none; opacity: .55; }
  56%,88% { border-color: var(--viz-fixed); box-shadow: 0 0 18px color-mix(in oklab, var(--viz-fixed) 22%, transparent); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .viz i, .viz b, .viz s, .viz u, .viz em, .viz span, .viz s::after { animation: none !important; }
  .type-result, .agent-stack i, .agent-loop { opacity: 1; transform: none; }
  .museum-case--broken { opacity: .55; box-shadow: none; }
  .museum-case--fixed { opacity: 1; border-color: var(--viz-fixed); }
}
