/* cu-factors.css: section 3 of /child-custody/ — 法庭考慮的六個因素.
   A copy of public/components/mt-s2.css (贍養費 v4 section 2, the precept "Process Orbit"), renamed
   s2- -> cf- and scoped to .cu. What differs (WORK-ORDER.md section 3):
   - SAND ground #E8DCC3 (not green): ink text, ink ruler + ticks, amber dot (ink ring so it reads on sand).
     Muted text is rgba(16,32,27,.68) on sand; the contrast probe measures it.
   - SIX stops; the runway is 0.6 screen per step (5 x 0.6 = 3.0 screens = 1.5 x 贍養費's 2.0), written
     by cu-factors.js on measure (it reads the step count from the markup).
   - three art layers per scene, bottom -> top: INK (base) · LINES (draw-in mask) · AMBER (bloom).
     No video loop this round.

   1. DEFAULT = FINAL STATE. Without JS or under reduced motion cu-factors.js never adds .cf-armed /
      .is-pinned: title block, then the six steps stacked, each with its composed still. No pin, no dial.
   2. ONE WRITER PER PROPERTY. cu-factors.js writes, per frame: the dial group's SVG transform, the lit
      arc + ticks paths, each ruler label's transform + opacity, the odometer transform, the art zoom,
      every scene's opacity / visibility / transform, its lines' mask position and its amber's opacity /
      transform. On resize only: the layout custom properties (--cf-*), the SVG geometry, the step-line
      masks. Everything below is derived from those or a class-keyed one-shot tween on OTHER properties.
   3. ONE TYPE SCALE: H2 = site .h2; step titles .cu-h3; numbers .cu-num; label/intro/body .cu-*. */

.cu .cu-factors {
  --cf-ease: cubic-bezier(0.08, 0.78, 0.56, 1);
  --cf-ink: #10201B;
  --cf-mute: rgba(16,32,27,.68);
  --cf-num-fs: clamp(48px, 4.4vw, 76px);
  --cf-row: calc(var(--cf-num-fs) * 2.2);
  position: relative; padding: 140px 0 0; background: var(--cu-sand); color: var(--cf-ink);
}
.cu .cu-factors .cu-label, .cu .cu-factors .cu-intro, .cu .cu-factors .cu-body { color: var(--cf-mute); }
.cu .cu-factors .h2 { margin: 12px 0 0; color: var(--cf-ink); }
/* the H2 may only break BETWEEN its two phrases, never inside one, at any width */
.cu .cf-ph { display: inline-block; white-space: nowrap; }

/* ================= the static reading (default, reduced motion, no JS) ================= */
.cu .cf-stage { width: min(var(--wrap), calc(100% - 2 * var(--pad))); margin-inline: auto; }
.cu .cf-dial, .cu .cf-art, .cu .cf-odo { display: none; }
.cu .cf-head { max-width: 640px; }
.cu .cf-copy { margin-top: 56px; }
.cu .cf-list { display: grid; gap: 72px; margin: 0; padding: 0; list-style: none; }
.cu .cf-step { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: 1fr auto auto auto 1fr; column-gap: clamp(28px, 4vw, 64px); align-content: center; }
.cu .cf-step > * { grid-column: 1; }
.cu .cf-count-row { grid-row: 2; }
.cu .cf-h3 { grid-row: 3; }
.cu .cf-text { grid-row: 4; }
/* the composed still: the three layers stacked in one box of the art's own ratio */
.cu .cf-still { grid-column: 2; grid-row: 1 / -1; align-self: center; margin: 0; position: relative; aspect-ratio: 4 / 3; }
.cu .cf-still img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.cu .cf-count-row { display: flex; align-items: center; gap: 16px; }
.cu .cf-num { font-size: 56px; color: var(--cf-ink); }
.cu .cf-count {
  display: inline-block; padding: 5px 12px 4px; border: 1px solid rgba(16,32,27,.34); border-radius: 999px;
  font-family: var(--sans); font-weight: 400; font-size: 13px; line-height: 1.3; letter-spacing: .08em; color: var(--cf-mute);
  white-space: nowrap;
}
.cu .cf-h3 { margin: 14px 0 0; color: var(--cf-ink); white-space: nowrap; }
.cu .cf-text { margin: 10px 0 0; max-width: 30em; text-wrap: pretty; }

/* the ask under the section (the wireframe's one line + button, never a 7th stop) */
.cu .cf-ask { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 16px 24px; padding: 56px 0 120px; text-align: center; }
.cu .cf-ask-line { margin: 0; font-family: var(--sans); font-weight: 400; font-size: 16px; line-height: 1.8; color: var(--cf-mute); }

/* FIX 1 R6: with JS on and motion allowed (html.cu-js, set by an inline script in the page head before
   first layout) the six composed stills stay display:none, so their lazy images are never fetched, until
   cu-factors.js either pins the section (stills never needed) or chooses the static reading (.cf-static).
   Under reduced motion or with JS off html.cu-js is never set and the stills show as before. */
html.cu-js .cu-factors:not(.cf-static) .cf-still { display: none; }

/* ================= armed (JS on, motion allowed) ================= */
.cu .cu-factors.cf-armed { padding: 0; }
.cu .cf-pin.is-pinned { height: calc(var(--screen) * 4); }
.cu .is-pinned .cf-stage { position: sticky; top: 0; width: auto; height: var(--screen); margin: 0; overflow: hidden; }

.cu .is-pinned .cf-dial { display: block; position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.cu .cf-arc, .cu .cf-ticks { fill: none; stroke: rgba(16,32,27,.30); stroke-width: 1; }
.cu .cf-lit { stroke: var(--cf-ink); }
.cu .cf-brackets { fill: none; stroke: rgba(16,32,27,.55); stroke-width: 1; }
.cu .cf-dot { fill: #E9A93A; stroke: var(--cf-ink); stroke-width: 1; }
.cu .cf-cap { font-family: var(--sans); font-weight: 400; font-size: 13px; letter-spacing: .12em; fill: var(--cf-ink); dominant-baseline: central; }

.cu .is-pinned .cf-head { position: absolute; left: var(--cf-l); top: var(--cf-head-t); width: var(--cf-head-w); max-width: none; }
.cu .is-pinned .cf-head .cu-intro { margin-top: 12px; max-width: 34em; }

.cu .is-pinned .cf-copy { position: absolute; left: var(--cf-l); top: var(--cf-copy-t); width: var(--cf-col); margin: 0; display: grid; }
.cu .is-pinned .cf-odo {
  display: block; grid-area: 1 / 1; align-self: start; justify-self: start; height: var(--cf-row); overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 16%, #000 84%, transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0%, #000 16%, #000 84%, transparent 100%);
}
.cu .cf-odo-col { will-change: transform; }
.cu .cf-odo-col > span { display: block; height: var(--cf-row); line-height: var(--cf-row); font-size: var(--cf-num-fs); color: var(--cf-ink); white-space: nowrap; }
.cu .is-pinned .cf-list { grid-area: 1 / 1; display: grid; gap: 0; }
/* align-content:start is load-bearing (mt-s2.css): centred shorter steps sat 14px lower */
.cu .is-pinned .cf-step { grid-area: 1 / 1; display: block; align-content: start; visibility: hidden; }
.cu .is-pinned .cf-step.is-on { visibility: visible; }
.cu .is-pinned .cf-still, .cu .is-pinned .cf-num { display: none; }
.cu .is-pinned .cf-count-row { height: var(--cf-row); padding-left: calc(var(--cf-odo-w, 1.3em) + 18px); }
.cu .is-pinned .cf-h3 { margin-top: 2px; }

/* step change (precept one-shot): outgoing cut (no transition), incoming pill fades up 14px, then each
   rendered line slides up inside its own mask, +90ms per line (inline delay) */
.cu .is-pinned .cf-count { opacity: 0; transform: translateY(14px); transition: none; }
.cu .is-pinned .is-on .cf-count { opacity: 1; transform: none; transition: opacity .76s var(--cf-ease), transform .76s var(--cf-ease); }
.cu .cf-ln { display: block; overflow: hidden; }
.cu .cf-ln-i { display: block; }
.cu .is-pinned .cf-ln-i { transform: translateY(110%); transition: none; }
.cu .is-pinned .is-on .cf-ln-i { transform: none; transition: transform .76s var(--cf-ease); }

/* the art: right column (stacked layouts: between title and step text); a fitted box of the art's own
   ratio, pre-shrunk by the zoom so the zoomed art stays in its lane */
.cu .is-pinned .cf-art { display: block; position: absolute; left: var(--cf-art-l); top: var(--cf-art-t); width: var(--cf-art-w); height: var(--cf-art-h); }
.cu .cf-zoom { position: absolute; inset: 0; transform-origin: 50% 50%; will-change: transform; }
/* scene change is SCROLL-LINKED (cu-factors.js, from each scene's approach p = 1 - |u - k|): opacity
   smoothstep(p), drift 16px -> 0 / scale 1.02 -> 1, the lines' draw-in mask (fully drawn by p = .6),
   the amber bloom over the last 40%. Nothing here transitions those; values below = before frame 1. */
.cu .cf-scene { position: absolute; inset: 0; opacity: 0; visibility: hidden; transform-origin: 50% 50%; }
.cu .cf-scene > img, .cu .cf-amber-b, .cu .cf-amber-b > img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.cu .cf-lines {
  -webkit-mask-image: linear-gradient(to bottom right, #000 45%, transparent 55%);
          mask-image: linear-gradient(to bottom right, #000 45%, transparent 55%);
  -webkit-mask-size: 300% 300%; mask-size: 300% 300%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: 83% 83%; mask-position: 83% 83%;
}
.cu .cf-amber { opacity: 0; transform: scale(.85); will-change: transform, opacity; }
/* the amber breathes while a step is settled (.is-settled): opacity 1 <-> .9, scale 1 <-> 1.02, 3s, on
   the WRAPPER so it never shares a property with the bloom on the img inside it */
.cu .cf-scene.is-settled .cf-amber-b { animation: cf-breathe 3s ease-in-out infinite; }
@keyframes cf-breathe { 0%, 100% { opacity: 1; transform: none; } 50% { opacity: .9; transform: scale(1.02); } }

/* ================= phone (< 768): thin arc on the left edge, labels hidden ================= */
@media (max-width: 767px) {
  .cu .cu-factors { padding: 80px 0 0; --cf-num-fs: 36px; --cf-row: calc(var(--cf-num-fs) * 1.8); }
  .cu .cf-copy { margin-top: 36px; }
  .cu .cf-list { gap: 48px; }
  .cu .cf-step { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .cu .cf-step > * { grid-row: auto; }
  .cu .cf-still { grid-column: 1; grid-row: auto; order: -1; margin-bottom: 16px; }
  .cu .cf-num { font-size: 40px; }
  .cu .cf-cap { display: none; }
  .cu .cu-factors .cu-intro { font-size: 15px; line-height: 1.7; }
  .cu .cf-text { font-size: 15px; line-height: 1.7; }
  .cu .is-pinned .cf-count-row { padding-left: calc(var(--cf-odo-w, 1.3em) + 12px); }
  .cu .is-pinned .cf-head .cu-intro { margin-top: 8px; }
  .cu .is-pinned .cf-h3 { margin-top: 0; }
  .cu .is-pinned .cf-text { margin-top: 6px; }
  .cu .cf-ask { padding: 40px 0 80px; }
  .cu .cf-ask-line { font-size: 15px; }
}
@media (max-width: 767px) and (max-height: 700px) {
  .cu .cu-factors { --cf-num-fs: 32px; --cf-row: calc(var(--cf-num-fs) * 1.7); }
  .cu .cu-factors .cu-intro, .cu .cf-text { font-size: 14px; line-height: 1.6; }
  .cu .is-pinned .cf-head .cu-intro { margin-top: 6px; }
  .cu .cu-factors .h2 { margin-top: 6px; }
}
@media (min-width: 768px) and (max-width: 1099px) {
  .cu .cu-factors { --cf-num-fs: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .cu .cf-scene, .cu .cf-lines, .cu .cf-amber, .cu .cf-count, .cu .cf-ln-i { transition: none !important; }
  .cu .cf-amber-b { animation: none !important; }
}
