/* ===== before/after: score, live guides, cursor demo ===== */
.fix-track { height: 520vh; }
.fix-head { align-items: center; }
.fix-title { display: grid; gap: var(--space-xs); margin-right: auto; min-width: 0; }
.fix-title .fix-note { min-height: 1.5em; }
.fix-score { display: inline-flex; align-items: center; gap: var(--space-md); min-height: 56px; padding: var(--space-2xs) var(--space-lg) var(--space-2xs) var(--space-2xs); border: 1px solid var(--glass-edge); border-radius: var(--radius-pill); background: var(--glass); }
.fix-score > span { display: grid; gap: var(--space-3xs); }
.fix-score b { font: 500 var(--text-xl)/1 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.fix-score small { font-size: 12px; color: var(--color-muted); }
.fix-issues b { color: var(--risk); }
.fix.is-clean .fix-issues b { color: var(--ok); }
.fix-ring { width: 46px; height: 46px; rotate: -90deg; }
.fix-ring circle { fill: none; stroke: var(--tint-2); stroke-width: 3; }
.fix-ring .fix-ring-v { stroke: var(--opal-2); stroke-linecap: round; stroke-dasharray: 41 100; transition: stroke-dasharray 200ms linear; }

.fix-rail li { padding: 0; }
.fix-rail button { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: var(--space-xs); width: 100%; min-height: 48px; padding: 0 var(--space-md); border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.fix-rail button i { font: 500 12px/1 var(--font-outlier); font-style: normal; color: var(--color-muted); }
.fix-rail button code { justify-self: end; }
.fix-rail button:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; border-radius: inherit; }
.fix-rail li:hover { border-color: var(--color-rule-2); }

/* the CRM screen: five columns and a few more parts */
.ui-tr { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 0.9fr) minmax(0, 0.8fr); }
.ui-val { font-variant-numeric: tabular-nums; text-align: right; font-weight: calc(600 - 100 * var(--t)); }
.ui.is-gen .ui-val { text-align: left; }
.ui-nav span em { margin-left: auto; padding: 0 var(--space-2xs); min-width: 20px; border-radius: calc(2px + 98px * var(--p2, 0)); font: 600 11px/18px var(--font-body); font-style: normal; text-align: center; color: color-mix(in oklab, var(--gen-blue-ink) calc(var(--c) * 100%), var(--color-paper)); background: color-mix(in oklab, var(--gen-red) calc(var(--c) * 100%), var(--opal-2)); }

/* live guides */
.fx-guides > * { position: absolute; pointer-events: none; font: 500 12px/1 var(--font-outlier); white-space: nowrap; }
.gm { color: var(--guide); }
.gm-h { height: 10px; translate: 0 -50%; border-inline: 1px solid var(--guide); }
.gm-h::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--guide); }
.gm-v { width: 10px; border-block: 1px solid var(--guide); }
.gm-v::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 1px solid var(--guide); }
.gm em { position: absolute; padding: var(--space-3xs) var(--space-2xs); border-radius: 4px; background: var(--guide); color: var(--color-paper); font-style: normal; }
.gm-h em { left: 50%; top: -20px; translate: -50% 0; }
.gm-v em { left: 16px; top: 50%; translate: 0 -50%; }
.gl { top: 0; bottom: 0; border-left: 1px dashed var(--guide-2); }
.gd { height: 0; border-top: 1px solid var(--guide); }
.gt { translate: 0 -50%; padding: var(--space-2xs) var(--space-xs); border-radius: 6px; background: var(--hud-bg); border: 1px solid var(--glass-edge); color: var(--guide); display: inline-flex; align-items: center; gap: var(--space-xs); }
.gt-type, .gt-sw, .gt-curve { color: var(--color-ink-2); }
.gt-ok { color: var(--ok); }
.gt-bad { color: var(--risk); }
.gt-sw, .gt-curve { translate: 0 0; }
.gt-sw i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--glass-edge); }
.gt-curve svg { width: 28px; height: 16px; fill: none; stroke: var(--opal-2); stroke-width: 1.5; }

/* step five: a cursor shows the finished screen answering a click */
.ui-cursor, .ui-toast { position: absolute; z-index: 4; opacity: 0; pointer-events: none; }
.ui-toast { right: var(--space-lg); bottom: var(--space-lg); display: inline-flex; align-items: center; gap: var(--space-xs); min-height: 40px; padding: 0 var(--space-md); border-radius: 12px; background: var(--color-ink); color: var(--color-paper); font: 500 13px/1 var(--font-body); box-shadow: 0 10px 30px var(--btn-glow); }
.ui-toast svg { width: 16px; height: 16px; }

@media (max-width: 60rem) {
  .fix-track { height: auto; }
  .fix-score { min-height: 48px; padding-right: var(--space-md); }
  .fix-rail button { grid-template-columns: minmax(0, 1fr); justify-items: center; padding: 0 var(--space-2xs); }
  .fix-rail button i, .fix-rail button code { display: none; }
  .ui-tr { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 0.9fr); }
  .ui-tr > :nth-child(3), .ui-tr > :nth-child(5) { display: none; }
  .ui-cursor { display: none; }
}
.gt-side { translate: -100% -50%; }
.gt-below { translate: -100% 0; }
.ui-n { justify-self: start; }
.ui.is-gen:not(.is-left) .ui-n { justify-self: center; }

/* ===== round three: staggered waves, a scan band, a calmer before, a richer after ===== */
/* the script sets --P1..--P5 on the screen; each block reads them with its own delay, so changes travel as a wave */
.ui { --dw: 0; --p1: var(--P1, 0); --p2: var(--P2, 0); --p3: var(--P3, 0); --p4: var(--P4, 0); --p5: var(--P5, 0); }
.ui .fx-el {
  --p1: clamp(0, calc((var(--P1, 0) - var(--dw, 0) * 0.45) / 0.55), 1);
  --p2: clamp(0, calc((var(--P2, 0) - var(--dw, 0) * 0.45) / 0.55), 1);
  --p3: clamp(0, calc((var(--P3, 0) - var(--dw, 0) * 0.45) / 0.55), 1);
  --p4: clamp(0, calc((var(--P4, 0) - var(--dw, 0) * 0.45) / 0.55), 1);
  --g: calc(1 - var(--p1)); --a: calc(1 - var(--p2)); --t: var(--p3); --c: calc(1 - var(--p4));
}

/* the skill passing over the screen */
.fx-scan { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; border-radius: calc(6px + 14px * var(--P2, 0)); }
.fx-scan::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 34%; translate: calc(var(--sx, 0) * 400% - 120%) 0; opacity: var(--so, 0); background: linear-gradient(90deg, transparent, var(--opal-1a) 40%, var(--opal-2a) 60%, transparent); }

/* before: a plain default, not a broken one; boxes and shadows everywhere, after: one lit edge */
.ui-stat { box-shadow: inset 0 1px 0 color-mix(in oklab, var(--tint-3) calc(var(--p4, 0) * 100%), transparent), 0 2px 6px color-mix(in oklab, var(--gen-shadow) calc(var(--c) * 100%), transparent); }
.ui-table { box-shadow: 0 2px 6px color-mix(in oklab, var(--gen-shadow) calc(var(--c) * 100%), transparent); }

/* company avatars: a small square in the default, a lettered circle in the system */
.ui-name i { display: inline-grid; place-items: center; width: calc(8px + 16px * var(--p4, 0)); height: calc(8px + 16px * var(--p4, 0)); border-radius: calc(1px + 12px * var(--p2, 0)); font: 600 calc(10px * var(--p4, 0))/1 var(--font-body); font-style: normal; color: var(--opal-ink); background: color-mix(in oklab, var(--gen-blue) calc(var(--c) * 100%), var(--av, var(--opal-1))); overflow: hidden; }

/* sparklines draw in on the motion step */
.ui .ui-spark { display: block; width: 100%; height: calc(22px * var(--P5, 0)); margin-top: calc(var(--space-2xs) * var(--P5, 0)); overflow: visible; }
.ui-stat:nth-child(2) .ui-stat:nth-child(3) 
/* the finished screen answers the pointer */
.ui:not(.is-gen) .ui-tr:not(.ui-th) { transition: background-color var(--dur-short) var(--ease-out); }
.ui:not(.is-gen) .ui-tr:not(.ui-th):hover { background: var(--tint-1); }
.ui:not(.is-gen) .ui-btn { transition: box-shadow var(--dur-short) var(--ease-out); }
.ui:not(.is-gen) .ui-btn:hover { box-shadow: 0 0 0 4px var(--opal-1a); }
.ui:not(.is-gen) .ui-stat { transition: border-color var(--dur-short) var(--ease-out); }
.ui:not(.is-gen) .ui-stat:hover { border-color: var(--color-rule-2); }
@media (prefers-reduced-motion: reduce) { .fx-scan { display: none; } }

/* sparklines: a gradient tail under the line, dashed guides, a lit end point */
.ui .ui-spark { height: calc(30px * var(--P5, 0)); }
.ui-spark .sp-a { stop-color: var(--sp, var(--opal-2)); stop-opacity: 0.35; }
.ui-spark .sp-b { stop-color: var(--sp, var(--opal-2)); stop-opacity: 0; }
.ui-spark .sp-area { opacity: var(--P5, 0); transition: opacity var(--dur-long) var(--ease-out); }
.ui-spark .sp-line { fill: none; stroke: var(--sp, var(--opal-2)); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 100 100; stroke-dashoffset: calc(100 - 100 * var(--P5, 0)); }
.ui-spark .sp-grid { stroke: var(--tint-2); stroke-width: 0.6; stroke-dasharray: 1.5 2.5; }
.ui-stat:nth-child(2) { --sp: var(--opal-1); }
.ui-stat:nth-child(3) { --sp: var(--opal-3); }
@media (prefers-reduced-motion: no-preference) { .ui.is-alive 
/* the demo cursor: an arrow with a soft trailing ring and a ripple on click */
.ui-cursor, .ui-ripple { position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; opacity: 0; transition: opacity var(--dur-long) var(--ease-out); }
.ui.is-touring .ui-cursor { opacity: 1; }
.ui-cursor { width: 32px; height: 32px; margin: -5px 0 0 -6px; }
.ui-cursor svg { width: 32px; height: 32px; fill: var(--color-ink); stroke: var(--color-paper); stroke-width: 1.4; stroke-linejoin: round; filter: drop-shadow(0 4px 10px var(--gen-shadow)); transition: scale 160ms var(--ease-out); transform-origin: 20% 15%; }
.ui-cursor.is-press svg { scale: 0.82; }
.ui-ripple { width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; border: 1.5px solid var(--opal-2); }
.ui-ripple.is-on { animation: ui-ripple 600ms var(--ease-out); }
@keyframes ui-ripple { 0% { opacity: 1; scale: 0.6; } 100% { opacity: 0; scale: 5; } }
.ui-toast { transition: opacity var(--dur-long) var(--ease-out), translate var(--dur-long) var(--ease-out); translate: 0 10px; }
.ui-toast.is-on { opacity: 1; translate: 0 0; }

/* the screen's answers, driven by the demo cursor as well as by a real pointer */
.ui:not(.is-gen) .ui-tr.is-demo-hover { background: var(--tint-1); }
.ui:not(.is-gen) .ui-btn.is-demo-hover { box-shadow: 0 0 0 4px var(--opal-1a); }
.ui:not(.is-gen) .ui-stat.is-demo-hover { border-color: var(--color-rule-2); }
.ui:not(.is-gen) .ui-nav span.is-demo-hover { background: var(--tint-1); color: var(--color-ink); }
.ui:not(.is-gen) .ui-pill.is-demo-hover { box-shadow: 0 0 0 3px var(--tint-2); }
.ui .is-demo-press { scale: 0.96; transition: scale 120ms var(--ease-out); }
.ui-pill, .ui-btn, .ui-nav span { transition: scale 200ms var(--ease-out), box-shadow var(--dur-short) var(--ease-out), background-color var(--dur-short) var(--ease-out); }

.ui-spark .sp-bar { fill: var(--tint-3); transform-box: fill-box; transform-origin: 50% 100%; scale: 1 var(--P5, 0); }
.ui-spark .sp-bar.is-now { fill: var(--sp, var(--opal-2)); }
.ui-spark .sp-target { stroke: var(--sp, var(--opal-2)); stroke-width: 0.8; stroke-dasharray: 2 2.5; opacity: calc(var(--P5, 0) * 0.55); }
@media (prefers-reduced-motion: no-preference) { .ui-spark .sp-bar { transition: scale 500ms var(--ease-out); } .ui-spark rect:nth-child(4) { transition-delay: 40ms; } .ui-spark rect:nth-child(6) { transition-delay: 80ms; } .ui-spark rect:nth-child(8) { transition-delay: 120ms; } }

.fix-score { background: var(--color-paper-2); }
.fix-rail li { background: var(--color-paper-2); }
