/* support: card-fx — cards v2 (2026-11-05), the shared card body for card-grid, kpi-trio, counter, split-compare, quote
   and field-review (card-fx.js). Tokens only: every colour is a tenant token or a color-mix of tokens with
   transparent (an alpha step, never a hue). No glow, no blur filter, no gradient fill. D-017: a border OR a shadow,
   never both — the card separates by a two-layer ink-tinted shadow (light) or the dark card ring + near-black depth
   (studio / on-dark); the signal edge is a one-time stroke trace that leaves.
   CSS defaults ARE the end state (reduced motion skips every tween): bar stub drawn, edge gone, masks open.
   © Dudoxx UG / Acceleate Consulting - Walid Boudabbous <walid@acceleate.com> */

/* ---- card body: depth from tokens ----------------------------------------------------------------------------------- */
.stage {
  --cfx-shade: var(--brand-color-fg);                       /* light: ink-navy tinted shadow (hue of the brand ink) */
  --cfx-ring: transparent; --cfx-toplight: transparent;
  --cfx-ground: var(--brand-color-bg);
  --cfx-well: var(--brand-color-tint-cobalt, color-mix(in oklch, var(--accent) 9%, var(--card)));
}
.stage.on-dark, .scene.look-studio, .look-studio .scene-beat {
  --cfx-shade: var(--brand-color-dark-bg-recessed, var(--brand-color-fg));
  --cfx-ring: var(--brand-color-dark-card-ring, color-mix(in oklch, var(--brand-color-bg) 10%, transparent));
  --cfx-toplight: color-mix(in oklch, var(--brand-color-dark-fg, var(--brand-color-bg)) 14%, transparent); /* the inner top-light rule */
  --cfx-ground: var(--lk-ground, var(--brand-color-dark-bg, var(--brand-color-fg)));
  --cfx-well: var(--brand-color-dark-tint-cobalt, color-mix(in oklch, var(--accent) 16%, var(--card)));
}
.scene.look-porcelain, .scene.look-editorial {
  --cfx-shade: var(--brand-color-fg); --cfx-ring: transparent; --cfx-toplight: transparent; --cfx-ground: var(--brand-color-bg);
  --cfx-well: var(--brand-color-tint-cobalt, color-mix(in oklch, var(--accent) 9%, var(--card)));
}

/* the deck (card-fx.js) paints transform + opacity from t; CSS holds the end state (reduced motion = this) */
.cfx-card {
  --cfx-on: 0; --cfx-dim: 0; --cfx-bar: 1; --cfx-ping: 0;
  position: relative; z-index: 1; overflow: clip; transform-origin: 50% 100%;
}
.cfx-card.cfx-is-on { z-index: 3; }
.cfx-card, .cfx-card[data-hit], html.skin-depth .cfx-card, html.skin-depth .cfx-card[data-hit] {
  box-shadow:
    inset 0 0 0 1px var(--cfx-ring),
    inset 0 1px 0 0 var(--cfx-toplight),
    0 calc(0.12cqw + var(--cfx-on) * 0.35cqw) calc(0.3cqw + var(--cfx-on) * 0.6cqw) color-mix(in oklch, var(--cfx-shade) calc(9% + var(--cfx-on) * 5%), transparent),
    0 calc(0.7cqw + var(--cfx-on) * 1.4cqw) calc(2cqw + var(--cfx-on) * 2.6cqw) calc(-0.5cqw) color-mix(in oklch, var(--cfx-shade) calc(18% + var(--cfx-on) * 14%), transparent),
    0 0 0 calc(var(--cfx-on) * 0.18cqw) var(--accent);
}
/* the muted kpi tile and the muted split panel stay recessed: no lift shadow, a ring only (they are the BEFORE) */
.cfx-card.kpi-tile--before, .cfx-card.split-panel:not(.is-primary) {
  box-shadow: inset 0 0 0 1px var(--rule), 0 0 0 calc(var(--cfx-on) * 0.18cqw) var(--accent);
}

/* ---- the in-card layers ------------------------------------------------------------------------------------------ */
.cfx-veil { position: absolute; inset: 0; z-index: 6; pointer-events: none; border-radius: inherit; background: var(--cfx-ground);
  opacity: calc(var(--cfx-dim) * 0.5); }
.cfx-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; height: 0.36cqw; pointer-events: none; background: var(--accent);
  transform-origin: 0 50%; transform: scaleX(calc(var(--cfx-bar) * (0.16 + 0.84 * var(--cfx-on)))); }
/* the stroke run: a 16 % signal segment travels once around the edge, painted from t; never a full border */
.cfx-edge { position: absolute; inset: 0; z-index: 5; width: 100%; height: 100%; overflow: visible; pointer-events: none; opacity: 0; }
.cfx-edge rect { fill: none; stroke: var(--signal); stroke-width: 0.36cqw; stroke-linecap: round; rx: 1.2cqw; ry: 1.2cqw; }

/* ---- the tint-well header band: display icon / numeral + an optional visual ---------------------------------------- */
.cfx-band { position: relative; display: flex; align-items: center; gap: 1.4cqw; min-height: 0; padding: 1.2cqw 1.3cqw; border-radius: 0.9cqw;
  background: var(--cfx-well); }
.cfx-band > .cfx-viz { flex: 1 1 auto; align-self: stretch; display: flex; flex-direction: column; justify-content: flex-end; }
.cfx-band .ik.ik--tile { --ik-size: 4.6cqw; background: var(--card); box-shadow: 0 0.2cqw 0.6cqw color-mix(in oklch, var(--cfx-shade) 14%, transparent), 0 0 0 calc(var(--ik-emph) * var(--ik-size) * 0.06) var(--ik-ink); }
.cfx-band .ik .ik-g { stroke-width: 1.15; } /* 2.2 px at 1080p on a 4.6cqw tile */
.cfx-ico--static { display: grid; place-items: center; width: 4.6cqw; aspect-ratio: 1; border-radius: 28%; background: var(--card); color: var(--brand-color-link, var(--accent)); }
.look-studio .cfx-ico--static, .stage.on-dark .cfx-ico--static { color: var(--brand-color-dark-link, var(--accent)); }
.cfx-ico--static svg { width: 56%; height: 56%; stroke-width: 1.6; }
.cfx-numeral { font-family: var(--face-head); font-size: 4.2cqw; font-weight: 700; line-height: 1; letter-spacing: -0.03em; color: var(--brand-color-link, var(--accent));
  font-variant-numeric: tabular-nums; padding-block: 0.1em; }
.look-studio .cfx-numeral, .stage.on-dark .cfx-numeral { color: var(--brand-color-dark-link, var(--accent)); }

/* ---- stacked chips ------------------------------------------------------------------------------------------------ */
.cfx-chips { display: flex; flex-wrap: wrap; gap: 0.5cqw; align-content: flex-start; }
.cfx-stack-chip { display: inline-flex; align-items: center; gap: 0.5em; padding: 0.3em 0.8em; border-radius: 99em; background: var(--card);
  font-size: var(--fs-label); font-weight: 600; line-height: 1.2; color: var(--ink); white-space: nowrap; transform-origin: 0 50%;
  box-shadow: 0 0.1cqw 0.3cqw color-mix(in oklch, var(--cfx-shade) 12%, transparent); }
.cfx-stack-chip::before { content: ''; width: 0.5cqw; aspect-ratio: 1; border-radius: 50%; background: var(--signal); flex: 0 0 auto; }

/* ---- text masks ---------------------------------------------------------------------------------------------------- */
.cfx-mask { overflow: clip; overflow-clip-margin: 0.12em; }
.cfx-in { display: block; text-wrap: inherit; will-change: transform; }

/* ---- shared mini visuals ------------------------------------------------------------------------------------------- */
.cfx-viz { position: relative; display: block; min-width: 0; }
.cfx-track { position: relative; display: block; height: 0.5cqw; border-radius: 99em; background: var(--recess); }
.cfx-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; border-radius: inherit; background: var(--accent); transform-origin: 0 50%; }
.cfx-tick { position: absolute; top: -0.45cqw; bottom: -0.45cqw; width: 0.16cqw; margin-left: -0.08cqw; background: var(--ink); }
.cfx-spark { display: block; width: 100%; height: 4.2cqw; overflow: visible; }
.cfx-spark .cfx-spark-base { fill: none; stroke: var(--rule); stroke-width: 1; vector-effect: non-scaling-stroke; }
.cfx-spark .cfx-spark-line { fill: none; stroke: var(--accent); stroke-width: 0.26cqw; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.cfx-ring { display: block; width: 100%; height: 100%; overflow: visible; transform: rotate(-90deg); }
.cfx-ring circle { fill: none; stroke-width: 3.2; }
.cfx-ring .cfx-ring-track { stroke: var(--recess); }
.cfx-ring .cfx-ring-arc { stroke: var(--accent); stroke-linecap: round; }
/* the live point: a solid dot + a ping ring (scale <= 2.4 on a 0.7cqw dot, alpha falls to 0: a ripple, not a glow) */
.cfx-dot { position: absolute; z-index: 2; width: 0.8cqw; aspect-ratio: 1; margin: -0.4cqw 0 0 -0.4cqw; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0.18cqw var(--card); pointer-events: none; }
.cfx-dot::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 0.14cqw var(--accent);
  transform: scale(calc(1 + var(--cfx-ping, 0) * 1.6)); opacity: calc((1 - var(--cfx-ping, 0)) * min(1, var(--cfx-ping, 0) * 40)); }
.cfx-chip { display: inline-flex; align-items: center; gap: 0.4em; justify-self: start; padding: 0.22em 0.75em; border-radius: 99em;
  font-family: var(--face-mono); font-size: var(--fs-label); font-weight: 600; line-height: 1.25; white-space: nowrap;
  background: var(--brand-color-tint-cobalt, var(--recess)); color: var(--brand-color-link, var(--accent)); }
.cfx-chip svg { width: 0.95em; height: 0.95em; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.cfx-chip--good { background: var(--brand-color-tint-success, var(--recess)); color: var(--brand-color-success, var(--ink)); }
.cfx-chip--bad { background: var(--brand-color-tint-warning, var(--recess)); color: var(--ink); }
.stage.on-dark .cfx-chip, .look-studio .cfx-chip { background: var(--brand-color-dark-tint-cobalt, var(--recess)); color: var(--brand-color-dark-link, var(--accent)); }
.stage.on-dark .cfx-chip--good, .look-studio .cfx-chip--good { background: var(--brand-color-dark-tint-success, var(--recess)); color: var(--brand-color-dark-success, var(--ink)); }
.stage.on-dark .cfx-chip--bad, .look-studio .cfx-chip--bad { background: var(--brand-color-dark-tint-warning, var(--recess)); color: var(--brand-color-dark-warning, var(--ink)); }

/* bars: columns grow with the count; the last one is the live point */
.cfx-bars { display: flex; align-items: flex-end; gap: 0.35cqw; height: 100%; min-height: 3.6cqw; }
.cfx-bars-col { flex: 1 1 0; height: var(--h); border-radius: 0.25cqw 0.25cqw 0.1cqw 0.1cqw; background: color-mix(in oklch, var(--accent) 38%, var(--card)); transform-origin: 50% 100%; }
.cfx-bars-col.is-last { background: var(--accent); }
.kpi-viz--bars { height: 4.6cqw; }
/* viz frames (CARD_FX.viz: kpi-trio tiles, counter) */
.kpi-viz { margin-top: 0.6cqw; }
.kpi-viz--track .cfx-track, .kpi-viz--rule .cfx-track { height: 0.5cqw; }
.kpi-viz--rule .cfx-track { background: var(--rule); }
.kpi-viz--spark { height: 4.2cqw; }
.kpi-viz--spark .cfx-dot { margin: -0.4cqw 0 0 -0.4cqw; }
@media (max-width: 600px) and (orientation: portrait) {
  .stage .kpi-viz--spark { height: 5.5cqw; }
  .stage .kpi-viz--track .cfx-track, .stage .kpi-viz--rule .cfx-track { height: 1.2cqw; }
  .stage .cfx-dot { width: 2cqw; margin: -1cqw 0 0 -1cqw; }
  .stage .cfx-bar { height: 0.9cqw; }
  .stage .cfx-edge rect { stroke-width: 0.9cqw; }
}
@media (prefers-reduced-motion: reduce) { .cfx-in { will-change: auto; } }
