/* Fold line drawing ("How it folds"): /folding#how-it-folds (full), Home and One Touch (compact), Travel (static poses).
   Behaviour in fold-drawing.js; notes in docs/implementation-fold-drawing.md. Loads after brand.css.
   Colours come from the brand.css tokens (with literal fallbacks), never from the bike-colour theme. The stage keeps
   its box from the SVG's width/height (3:2) and the step captions share one grid cell, so nothing moves the layout
   while it plays.

   Blocks   .fd (full: head / main / poses)  .fd--compact (Home, One Touch: stage + buttons; poses only without JS)
   Parts    .fd__head .fd__copy .fd__main .fd__figure .fd__stage .fd__steps/.fd__step .fd__note .fd__controls
            .fd__toggle (brand .sb-toggles) .fd__scrub .fd__ticks .fd__poses/.fd-pose .fd__ctas
   Art      .fd-art (any generated drawing)  .fd-art--paper / .fd-on-ink ancestor (light lines for ink grounds)  .fd-wide__art (360×240 static) */

/* ---------- Drawing colours: ink = currentColor, chrome parts inherit the muted stroke ---------- */
.fd-art {
  --fd-ink: var(--sb-ink, #1E201D); --fd-muted: var(--sb-ink-2, #55594F); --fd-paper: var(--sb-paper, #F4F1E8);
  --fd-accent: var(--sb-red, #D93A18); --fd-line: var(--sb-line, #D3CEBF);
  display: block; width: 100%; height: auto; color: var(--fd-ink); stroke: var(--fd-muted);
}
.fd-art--paper, .fd-on-ink .fd-art {
  --fd-ink: var(--sb-paper, #F4F1E8); --fd-muted: var(--sb-ink-muted, #B9B6AA); --fd-paper: var(--sb-ink, #1E201D);
  --fd-line: var(--sb-ink-line, #3A3D37);
}
.fd-art .pf { fill: var(--fd-paper); }
.fd-art .mf { fill: var(--fd-muted); }
.fd-art .ac { stroke: var(--fd-accent); }
.fd-art .fd-gnd { stroke: var(--fd-line); }
.fd-fx .fd-cue-ring { fill: none; stroke: var(--fd-accent); stroke-width: 1.4; }
.fd-fx .fd-cue-dot { fill: var(--fd-accent); fill-opacity: .92; stroke: var(--fd-paper); stroke-width: 1.4; }
.fd-fx line { stroke: var(--fd-accent); stroke-width: 2; stroke-linecap: round; }

/* ---------- Layout ---------- */
.fd { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "main" "poses" "ctas"; gap: 28px; align-items: start; }
.fd__head { grid-area: head; min-width: 0; }
.fd__copy { margin-top: 18px; max-width: 36rem; }
.fd__main { grid-area: main; min-width: 0; }
.fd__figure { margin: 0; }
.fd__stage { position: relative; background: var(--sb-paper, #F4F1E8); border: 1px solid var(--sb-line, #D3CEBF); }
@media (min-width: 1024px) {
  .fd:not(.fd--compact) {
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); grid-template-rows: auto auto 1fr;
    grid-template-areas: "head main" "poses main" "ctas main"; gap: 32px 64px;
  }
}

/* ---------- Step captions follow the playback (aria-hidden; [data-fd-status] announces the result) ---------- */
.fd__figure figcaption { padding-top: 14px; }
.fd__steps { display: grid; margin: 0; }
.fd__step { grid-area: 1 / 1; visibility: hidden; opacity: 0; --bi-lead-size: 1.25rem; --bi-sub-size: .9375rem; --bi-sub-color: var(--sb-muted); }
.fd__step.is-on { visibility: visible; opacity: 1; }
.fd__step > [lang="en"] { font-style: italic; font-weight: 800; line-height: 1.25; }
.fd__step > [lang|="zh"] { line-height: 1.5; }
.fd__note { margin-top: 14px; font-size: .875rem; line-height: 1.65; color: var(--sb-muted); }
.fd__note > [lang|="zh"] { display: block; margin-top: 4px; }
[data-lang="zh"] .fd__note { display: flex; flex-direction: column; }
[data-lang="zh"] .fd__note > [lang|="zh"] { order: -1; margin: 0 0 4px; }

/* ---------- Controls (JS only: step captions and slider are hidden without it; the buttons stay inert-but-true) ---------- */
.fd__controls { display: grid; gap: 20px; margin-top: 22px; }
.fd__toggle { --sb-toggle-n: 3; }
.fd__toggle .sb-toggle { min-height: 52px; padding-inline: 14px; }
.fd__toggle .sb-bi { align-items: center; text-align: center; --bi-gap: 0; line-height: 1.15; }
/* brand .sb-toggle is sand when not pressed: on a sand section give it the paper ground so all three read as buttons. */
.sb-surface--sand .fd__toggle .sb-toggle:not([aria-pressed="true"])::before { background: var(--sb-paper, #F4F1E8); }
.fd__toggle .sb-toggle:focus-visible { outline: 3px solid var(--sb-focus, #1E201D); outline-offset: 3px; }
.fd__scrub { display: grid; gap: 6px; }
.fd__scrub label { font-weight: 700; font-size: var(--sb-fs-label, .75rem); letter-spacing: .14em; text-transform: uppercase; }
.fd__scrub label [lang|="zh"] { letter-spacing: .04em; font-size: .8125rem; }
.fd__scrub input {
  display: block; width: 100%; height: 44px; margin: 0; background: transparent; accent-color: var(--sb-ink, #1E201D); cursor: pointer;
}
.fd__scrub input:focus-visible { outline: 3px solid var(--sb-focus, #1E201D); outline-offset: 2px; }
.fd__ticks { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; font-size: .8125rem; line-height: 1.4; color: var(--sb-muted); }
.fd__ticks > span:nth-child(2) { text-align: center; }
.fd__ticks > span:last-child { text-align: right; }
.fd__ticks [lang|="zh"] { display: block; }
html:not(.js) :is(.fd__steps, .fd__scrub, .fd__toggle) { display: none; }

/* ---------- The static poses: the whole story without JS ---------- */
.fd__poses { grid-area: poses; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.fd-pose { min-width: 0; display: grid; grid-template-columns: 96px minmax(0, 1fr); grid-template-rows: auto 1fr; column-gap: 14px; align-items: start; }
.fd-pose__art { grid-row: 1 / 3; border: 1px solid var(--sb-line, #D3CEBF); background: var(--sb-paper, #F4F1E8); }
.fd-pose__label { margin-top: 6px; --bi-lead-size: 1rem; --bi-sub-size: .875rem; --bi-sub-color: var(--sb-muted); }
.fd-pose__label > [lang="en"] { font-style: italic; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; }
.fd-pose__src { margin-top: 4px; font-size: .8125rem; line-height: 1.55; color: var(--sb-muted); }
.fd-pose__src > [lang|="zh"] { display: block; margin-top: 2px; font-size: .875rem; }
[data-lang="zh"] .fd-pose__src { display: flex; flex-direction: column; }
[data-lang="zh"] .fd-pose__src > [lang|="zh"] { order: -1; margin: 0 0 2px; }
@media (min-width: 700px) {
  .fd__poses { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .fd__poses--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fd-pose { display: block; }
  .fd-pose__label { margin-top: 10px; }
}

.fd__ctas { grid-area: ctas; display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Compact (Home, One Touch): stage + buttons with JS; the static poses instead without it ---------- */
.fd--compact { grid-template-areas: "head" "main" "poses" "ctas"; }
.fd--compact .fd__main { max-width: 640px; }
.fd--compact .fd__controls { margin-top: 16px; }
.fd--compact .fd__toggle.fd__toggle--2 { --sb-toggle-n: 2; }
html.js .fd--compact .fd__poses { display: none; }
html:not(.js) .fd--compact .fd__main { display: none; }
@media (min-width: 1024px) {
  .fd--compact { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); grid-template-areas: "head main" "ctas main" "poses poses"; gap: 24px 64px; }
  .fd--compact .fd__ctas { align-self: start; }
}

/* ---------- Static wide pose (360×240): Travel boot scene, Home fold button ---------- */
.fd-wide__art { overflow: visible; }

@media (prefers-reduced-motion: no-preference) {
  .fd__step { transition: opacity .2s ease, visibility 0s .2s; }
  .fd__step.is-on { transition: opacity .2s ease; }
}

/* Keep the demonstration and its controls ahead of the detailed instructions. */
.fd:not(.fd--compact) { grid-template-areas: "head" "main" "explanation" "poses" "ctas"; }
.fd__explanation { grid-area: explanation; margin-top: 0; }
.fd__head .sb-h2 { font-style: normal; font-weight: 600; letter-spacing: -.04em; text-transform: none; }
.fd__stage { border-radius: 20px; overflow: hidden; padding: 12px; }
.fd__step > [lang="en"] { font-style: normal; font-weight: 600; }
.fd__controls { gap: 16px; }
.fd__toggle { gap: 4px; padding: 4px; border: 1px solid var(--sb-line); border-radius: 18px; background: var(--sb-paper); }
.fd__toggle .sb-toggle { padding-inline: 8px; font-style: normal; }
.fd__toggle .sb-toggle::before { clip-path: none; border-radius: 13px; }
.fd__scrub { padding: 16px 18px; border: 1px solid var(--sb-line); border-radius: 18px; background: var(--sb-paper); }
.fd__scrub input { accent-color: var(--sb-red); }
.fd__note { margin-top: 0; padding-top: 14px; border-top: 1px solid var(--sb-line); }
.fd-pose__art { border-radius: 12px; overflow: hidden; }
@media (min-width: 1024px) {
  .fd:not(.fd--compact) { grid-template-areas: "head main" "explanation main" "poses main" "ctas main"; grid-template-rows: auto auto auto 1fr; }
}
