/* AA — week 5 animation extras (anim-w5.js). Every selector is prefixed .w5- */
@media (min-width: 641px) {
  .anim.w5-wide .ct { grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr); }
}
.anim .w5-text { font-family: var(--font-mono); font-size: .75rem; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 8px; padding: .38rem .6rem; min-height: 32px; width: 9rem; max-width: 100%; }
.anim .w5-text:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.anim input[type=number].w5-winp { width: 8.5rem; }
.anim .anim-opts button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* Task 1 — call cards */
.anim .w5-calls { display: grid; gap: .5rem; }
.anim .w5-call { border: 1px solid var(--border); border-radius: 10px; padding: .45rem .6rem .55rem; background: var(--surface); transition: border-color .2s, opacity .2s; }
.anim .w5-call.run { border-color: var(--blue); }
.anim .w5-call.done { border-color: var(--green); }
.anim .w5-call.wait { opacity: .55; }
.anim .w5-call-h { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem; font-family: var(--font-mono); font-size: .7rem; color: var(--muted); }
.anim .w5-call-h b { color: var(--green); }
.anim .w5-call .arr { margin-top: .35rem; }

/* Tasks 2–3 — stopwatch bars */
.anim .w5-bench { display: grid; gap: .3rem; font-family: var(--font-mono); font-size: .66rem; color: var(--muted); }
.anim .w5-bh, .anim .w5-brow { display: grid; grid-template-columns: 4.6rem minmax(0, 1fr); gap: .5rem; align-items: center; }
.anim .w5-brow em { grid-column: 2; font-style: normal; margin-top: -.15rem; min-height: 1em; }
.anim .w5-brow.on > span { color: var(--heading); }
.anim .w5-track { height: 16px; border-radius: 4px; background: var(--bg-soft); border: 1px solid var(--border); overflow: hidden; display: flex; }
.anim .w5-seg { height: 100%; transition: width .35s ease; }
.anim .w5-seg.s { background: var(--blue); }
.anim .w5-seg.b { background: var(--accent); }
.anim .w5-seg.run { animation: w5-pulse .8s ease-in-out infinite; }
.anim .w5-k { display: inline-block; width: .8rem; height: .5rem; border-radius: 2px; margin: 0 .2rem 0 .5rem; vertical-align: middle; }
.anim .w5-k.s { background: var(--blue); } .anim .w5-k.b { background: var(--accent); }
.anim .w5-k.min { background: var(--green); } .anim .w5-k.mean { background: var(--red); }
@keyframes w5-pulse { 50% { opacity: .45; } }

/* Task 4 — bars with summary lines */
.anim .vbars.w5-vbars { position: relative; margin-bottom: 1.3rem; }
.anim .w5-vbars .vb.w5-pulse { animation: w5-pulse .8s ease-in-out infinite; }
.anim .w5-line { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--green); pointer-events: none; transition: bottom .3s ease; }
.anim .w5-line.mean { border-top-color: var(--red); }
.anim .w5-line.rest { border-top-style: dashed; }
.anim .w5-legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-family: var(--font-mono); font-size: .64rem; color: var(--text); }
.anim .w5-legend .w5-k { margin-left: 0; }

/* Task 5 — dot strips */
.anim .w5-strips { display: grid; gap: .6rem; }
.anim .w5-strip-h { display: flex; justify-content: space-between; gap: .5rem; font-family: var(--font-mono); font-size: .68rem; color: var(--muted); flex-wrap: wrap; }
.anim .w5-strip-h b { color: var(--accent); }
.anim .w5-axis { position: relative; height: 26px; margin: .25rem 7px 0; border-bottom: 1px solid var(--border-strong); background: repeating-linear-gradient(90deg, var(--border) 0 1px, transparent 1px 25%); }
.anim .w5-dot { position: absolute; top: 6px; width: 13px; height: 13px; margin-left: -6.5px; border-radius: 50%; background: var(--accent); opacity: .75; transition: left .3s ease; }
.anim .w5-dot.cur { background: var(--blue); opacity: 1; box-shadow: 0 0 0 3px var(--blue-soft); }
.anim .w5-scale { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: .6rem; color: var(--muted); }

/* Task 6 — noise lanes + calculator */
.anim .w5-lanes { display: grid; gap: .7rem; }
.anim .w5-lane { border: 1px solid var(--border); border-radius: 10px; padding: .45rem .6rem; background: var(--surface); }
.anim .w5-lane.on { border-color: var(--blue); }
.anim .w5-lane-h { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .4rem; font-family: var(--font-mono); font-size: .68rem; color: var(--muted); }
.anim .w5-lane-h b { color: var(--accent); }
.anim .w5-nbars { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; height: 76px; margin: .35rem 0 1rem; }
.anim .w5-nb { position: relative; display: flex; align-items: flex-end; background: var(--bg-soft); border-radius: 3px; }
.anim .w5-nb i { display: block; width: 100%; background: var(--red); border-radius: 3px 3px 0 0; transition: height .25s ease; }
.anim .w5-nb.cur i { background: var(--blue); }
.anim .w5-nb span { position: absolute; bottom: -1rem; left: 0; right: 0; text-align: center; font-family: var(--font-mono); font-size: .55rem; color: var(--muted); }
.anim .w5-lane-note { font-family: var(--font-mono); font-size: .6rem; color: var(--muted); }
.anim .w5-calc { margin-top: .9rem; border-top: 1px solid var(--border); padding-top: .7rem; }
.anim .w5-calc .anim-opts { margin: .4rem 0 .5rem; }
.anim .w5-cbar { height: 14px; border-radius: 6px; background: var(--blue-soft); border: 1px solid var(--border); overflow: hidden; }
.anim .w5-cfill { height: 100%; background: var(--red); transition: width .2s ease; }
.anim p.w5-cout { font-size: .85rem; margin: .4rem 0 0; }
.anim p.w5-cout strong { color: var(--heading); font-weight: 500; }
@media (max-width: 560px) {
  .anim .w5-nb span { font-size: .45rem; }
}

/* stacked CodeTrace for the timing tasks: full-width code, variables | output below */
.anim.w5-stack .ct { grid-template-columns: minmax(0, 1fr); }
.anim.w5-stack .ct-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); grid-template-rows: auto 1fr; grid-auto-flow: column; gap: .35rem .8rem; }
.anim.w5-stack .ct-out { white-space: pre; overflow-x: auto; }
.anim.w5-stack .ct-code { max-height: 300px; }
@media (max-width: 640px) {
  .anim.w5-stack .ct-side { grid-template-columns: minmax(0, 1fr); grid-auto-flow: row; grid-template-rows: none; }
}
