/* Wireside comic strip: layout and motion. Direction C tokens (design/system/c/tokens.css) must be loaded first.
   Stills are the resting state: with no JavaScript, or under prefers-reduced-motion, nothing below the layout applies.
   Only transform and opacity move. Design owner, 10 Nov 2026. */

/* ---------- layout ---------- */
.how { padding: var(--s-9) var(--gutter); max-width: var(--max); margin: 0 auto; }
/* the next section (the count line) is on the same white ground and brings its own top padding: one gap, not two */
.how { padding-bottom: 0; }
.how-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4); margin: 0 0 var(--s-6); }
.how h2 { margin: 0; font-size: var(--t-h2); font-weight: var(--w-display); font-variation-settings: "opsz" 96, "wdth" 80; line-height: var(--lh-h2); letter-spacing: var(--track-h2); }
/* her Dave line: a small caption under the strip, the joke's credit line */
.how-caption { margin: var(--s-4) 0 0; font-size: var(--t-small); color: var(--muted); font-style: italic; text-wrap: balance; }
/* the strip is its own pause control (Lina, 11 Nov: "it shouldn't have like the pause or play button"; WCAG 2.2.2,
   qa/2026-11-11-comic-no-pause.md): a see-through button over the four acts. Tap, click, Enter or Space pauses and
   plays. A small pill shows the state: always while paused, and on keyboard focus while playing. Hidden until the
   script runs, so with no script or under reduced motion there is nothing to press and nothing moves. */
.strip-wrap { position: relative; }
.how-toggle { position: absolute; inset: 0; z-index: 2; margin: 0; padding: 0; border: 0; border-radius: var(--r-card); background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.how-toggle[hidden] { display: none; }
.how-toggle:focus-visible { outline: var(--focus-ring); outline-offset: 4px; }
.how-cue { position: absolute; top: calc(100% + 8px); right: 0; display: none; align-items: center; gap: 8px; min-height: 28px; padding: 0 12px; border: 2px solid var(--ink); border-radius: var(--r-pill); background: var(--white); color: var(--ink); font: var(--w-bold) 13px/1 var(--font); }
.how-cue::before { content: ""; width: 8px; height: 10px; border-left: 3px solid var(--ink); border-right: 3px solid var(--ink); box-sizing: border-box; }
.hw-paused .how-cue::before { width: 0; height: 0; border: 0; border-left: 9px solid var(--ink); border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.hw-paused .how-cue, .how-toggle:focus-visible .how-cue { display: inline-flex; }
/* on a phone the four acts are stacked, so the pill sits at the bottom of the screen while any act is in view */
@media (max-width: 700px) {
  .how-cue { position: fixed; top: auto; right: var(--gutter); bottom: 16px; z-index: 30; }
  .how:not(.hw-inview) .how-cue { display: none; }
  .how-cue-more { display: none; } /* a short pill, so it covers as little of an act as possible (Quality, 11 Nov) */
}
/* held (pointer over the strip, or keyboard focus on it): every act freezes where it is */
.hw-anim.hw-hold .panel [class^="a"] { animation-play-state: paused !important; }
/* paused: every act shows its still */
.hw-anim.hw-paused .panel [class^="a"] { animation: none !important; }
.how .strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; list-style: none; margin: 0; padding: 0; }
.how .panel { background: var(--sky); border: var(--border) solid var(--ink); border-radius: var(--r-card); overflow: hidden; aspect-ratio: 400 / 360; }
.how .panel svg { display: block; width: 100%; height: 100%; }
.how .panel text { font-family: var(--font); font-variation-settings: "opsz" 24, "wdth" 92; }
.how .crow .ink, .how .crow .pupil { fill: var(--ink); }
.how .crow .eye { fill: var(--white); }
.how .crow .accent { fill: var(--dot); }
.how .crow .limb { fill: none; stroke: var(--ink); stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 700px) {
  .how { padding: var(--s-7) var(--gutter) 0; }
  .how-head { margin-bottom: var(--s-5); }
  .how .strip { grid-template-columns: 1fr; gap: 12px; }
}

/* ---------- motion: only when comic-strip.js has added .hw-anim ---------- */
/* every hook waits at its first frame until its panel scrolls into view (.in), plays, rests on the still, and the
   script restarts it every 8 s while the panel stays in view */
.hw-anim .panel [class^="a"] { animation-play-state: paused; animation-fill-mode: both; animation-timing-function: var(--ease); }
.hw-anim .panel.in [class^="a"] { animation-play-state: running; }
/* restart for the loop (comic-strip.js): no animation for one frame */
.hw-anim .panel.hw-reset [class^="a"] { animation: none !important; }

/* act one: Dave runs on the spot for three seconds, papers and coffee trail behind, the clock hand turns, the phone blinks */
.hw-anim .a1-run { animation-name: hw-bob; animation-duration: 300ms; animation-iteration-count: 10; }
.hw-anim .a1-line { animation-name: hw-line; animation-duration: 600ms; animation-iteration-count: 5; animation-timing-function: linear; animation-delay: calc(var(--i) * 90ms); }
.hw-anim .a1-paper { animation-name: hw-paper; animation-duration: 1000ms; animation-iteration-count: 3; animation-delay: calc(var(--i) * 120ms); }
.hw-anim .a1-hand { transform-origin: 338px 74px; animation-name: hw-spin; animation-duration: 3000ms; animation-timing-function: linear; }
.hw-anim .a1-dot { animation-name: hw-blink; animation-duration: 500ms; animation-iteration-count: 6; animation-timing-function: steps(1); }

/* act two: the five life chips land, then the cards drop in one by one until they crowd the frame, then "events" three times */
.hw-anim .a2-chip { transform-box: fill-box; transform-origin: 50% 50%; animation-name: hw-pop; animation-duration: var(--d-move); animation-delay: calc(var(--i) * var(--stagger)); }
.hw-anim .a2-card { animation-name: hw-drop; animation-duration: var(--d-move); animation-delay: calc(500ms + var(--i) * 35ms); }
.hw-anim .a2-ev { transform-box: fill-box; transform-origin: 50% 50%; animation-name: hw-land; animation-duration: var(--d-move); animation-delay: calc(2900ms + var(--i) * 160ms); }
.hw-anim .a2-you ellipse[fill="#111111"] { transform-box: fill-box; transform-origin: 50% 50%; animation-name: hw-shrink; animation-duration: 2600ms; animation-delay: 400ms; }

/* act three: the pile sinks and fades, the crow lands on the wire, three picks rise onto it, Dave gives a small hop */
.hw-anim .a3-pile { animation-name: hw-sink; animation-duration: var(--d-land); }
.hw-anim .a3-crow { animation-name: hw-crow; animation-duration: var(--d-land); animation-delay: 500ms; }
.hw-anim .a3-pick { animation-name: hw-rise; animation-duration: var(--d-land); animation-delay: calc(1150ms + var(--i) * 160ms); }
.hw-anim .a3-you { animation-name: hw-hop; animation-duration: var(--d-move); animation-delay: 1900ms; }

/* act four: calm. The bubble pops in once, Dave breathes twice with the crow on his shoulder, nothing else moves */
.hw-anim .a4-bubble { transform-box: fill-box; transform-origin: 85% 100%; animation-name: hw-pop; animation-duration: var(--d-move); animation-delay: 300ms; }
.hw-anim .a4-you { transform-box: fill-box; transform-origin: 50% 100%; animation-name: hw-breathe; animation-duration: 2200ms; animation-iteration-count: 2; animation-timing-function: ease-in-out; animation-delay: 700ms; }

@keyframes hw-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes hw-line { 0% { transform: translateX(46px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateX(0); opacity: 1; } }
@keyframes hw-paper { 0% { transform: translate(90px, 14px); opacity: 0; } 25% { opacity: 1; } 100% { transform: translate(0, 0); opacity: 1; } }
@keyframes hw-spin { to { transform: rotate(360deg); } }
@keyframes hw-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes hw-pop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes hw-drop { from { transform: translateY(-46px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes hw-land { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes hw-shrink { from { transform: scale(1.9, 2.7); } to { transform: scale(1, 1); } }
@keyframes hw-sink { from { transform: translateY(-22px); opacity: 0.95; } to { transform: translateY(0); opacity: 0.28; } }
@keyframes hw-crow { 0% { transform: translate(130px, -230px); } 70% { transform: translate(0, 4px); } 100% { transform: translate(0, 0); } }
@keyframes hw-rise { from { transform: translateY(150px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes hw-hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes hw-breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1, 1.018); } }

/* belt and braces: even if .hw-anim is present, reduced motion shows the stills */
@media (prefers-reduced-motion: reduce) {
  .hw-anim .panel [class^="a"] { animation: none !important; }
}
