/* ============================================================================
   KIRGA — SPARK: how the pictures look, and the depth the surfaces gained.

   Loaded AFTER tokens.css and kirga.css and BEFORE motion.css, so:
     · every colour here resolves through the metric families in tokens.css
       (a chart never names a hex — that is how a chart survives light mode and
       how "gold means money won" stays true inside a drawing too), and
     · motion.css still has the last word on prefers-reduced-motion.

   Two halves:
     1. the four shapes js/spark.js draws
     2. the depth pass — the app was flat navy rectangles on flat navy, which
        reads as honest but also as unfinished, and gave the eye nothing to
        follow. Light now falls on it.
   ==========================================================================*/

/* ============================ 1. THE SHAPES ============================== */

/* NO BARE `.spark` BASE CLASS HERE, deliberately. kirga.css:574 already owns
   `.spark { display:block; width:100%; height:40px }` — a sparkline primitive
   with no caller anywhere in the app, left over from an earlier design. I wore
   that class on these shapes and inherited its height:40px, which pinned the
   donut's container to 40px while its 132px dial and 148px legend rendered
   outside the card, over the section beneath. Each shape carries its own base
   instead, so neither class can reach the other.
   If that dead rule is ever removed, nothing here needs to change. */
.spark-flow, .spark-line, .spark-donut { display: block; width: 100%; }
/* Charts carry real money. Market mode blurs money everywhere else; a drawing
   of the same figure must blur with it or it becomes the leak. */
.market-mode .spark-flow .money,
.market-mode .spark-line .money,
.market-mode .spark-ring .money,
.market-mode .spark-donut .money { filter: blur(6px); }

/* ---- flow: two quantities compared ------------------------------------- */
.spark-flow { display: grid; gap: 10px; }
.spark-flow-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 5px;
}
.spark-flow-label {
  font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600;
}
.spark-flow-value { font-size: 17px; font-weight: 700; color: var(--kpi-ink, var(--ink)); }
.spark-flow-track {
  height: 10px; border-radius: 999px; background: var(--surface-sunken);
  overflow: hidden; position: relative;
}
.spark-flow-fill {
  display: block; height: 100%; width: var(--w, 0%); border-radius: 999px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--kpi-fill, var(--brand)) 72%, transparent),
    var(--kpi-fill, var(--brand)));
  transform-origin: left center;
  animation: kg-flow-in var(--t-slow, 320ms) var(--ease-out, ease) both;
}
@keyframes kg-flow-in { from { width: 0; } to { width: var(--w, 0%); } }
.spark-note { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

/* ---- line: one quantity over time --------------------------------------- */
.spark-line svg { display: block; width: 100%; height: auto; overflow: visible; }
.spark-stop-a { stop-color: var(--kpi-fill, var(--brand)); stop-opacity: .34; }
.spark-stop-b { stop-color: var(--kpi-fill, var(--brand)); stop-opacity: 0; }
.spark-stroke {
  fill: none; stroke: var(--kpi-ink, var(--brand-ink)); stroke-width: 2.25;
  stroke-linecap: round; stroke-linejoin: round;
  /* Drawn on, left to right, the way a line of figures is read. The dash
     length is deliberately far longer than any path this ever renders. */
  stroke-dasharray: 1200; stroke-dashoffset: 1200;
  animation: kg-draw var(--t-lazy, 520ms) var(--ease-out, ease) forwards;
  vector-effect: non-scaling-stroke;
}
@keyframes kg-draw { to { stroke-dashoffset: 0; } }
.spark-area { animation: kg-fade var(--t-slow, 320ms) var(--ease-out, ease) both; }
.spark-dot {
  fill: var(--kpi-ink, var(--brand-ink));
  stroke: var(--surface); stroke-width: 2;
  animation: kg-pop var(--t-base, 240ms) var(--ease-spring, ease) both;
  animation-delay: var(--t-lazy, 520ms);
}

/* ---- ring: progress toward a target ------------------------------------- */
.spark-ring { position: relative; width: var(--size, 96px); height: var(--size, 96px); }
.spark-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.spark-ring circle { fill: none; }
.spark-ring-track { stroke: var(--surface-sunken); }
.spark-ring-fill {
  stroke: var(--kpi-fill, var(--brand)); stroke-linecap: round;
  stroke-dashoffset: var(--off, 0);
  animation: kg-ring-fill var(--t-lazy, 520ms) var(--ease-out, ease) both;
}
@keyframes kg-ring-fill { from { stroke-dashoffset: var(--dash); } to { stroke-dashoffset: var(--off); } }
.spark-ring-centre {
  position: absolute; inset: 0; display: grid; place-items: center;
  text-align: center; line-height: 1.15;
}

/* ---- donut: a whole split into parts ------------------------------------ */
.spark-donut { display: grid; gap: 16px; grid-template-columns: auto 1fr; align-items: center; }
@media (max-width: 380px) { .spark-donut { grid-template-columns: 1fr; justify-items: center; } }
.spark-donut-dial { position: relative; width: var(--size, 132px); height: var(--size, 132px); }
.spark-donut-dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.spark-donut circle { fill: none; }
.spark-donut-track { stroke: var(--surface-sunken); }
.spark-arc {
  stroke: var(--kpi-fill, var(--brand));
  transform: rotate(var(--rot, 0deg)); transform-origin: center;
  animation: kg-arc-in var(--t-base, 240ms) var(--ease-out, ease) both;
  /* Each slice lands after the one before it, so the eye follows the split
     being built rather than meeting a finished pie. */
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes kg-arc-in { from { opacity: 0; stroke-dasharray: 0 9999; } }
.spark-donut-centre { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.spark-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; min-width: 0; }
.spark-legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.spark-key {
  flex: 0 0 auto; width: 10px; height: 10px; border-radius: 3px;
  background: var(--kpi-fill, var(--brand));
}
.spark-legend-name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spark-legend-val { margin-left: auto; font-weight: 700; color: var(--ink); white-space: nowrap; }

/* ======================= 2. THE DEPTH PASS =============================== */

/* ---- the hero figure gets an atmosphere --------------------------------
   One card on VIEW states the whole position. It was the same flat fill as a
   list row, so nothing on the screen said "start here". A slow aura behind it
   does — and it is drawn with a gradient rather than a shadow so it costs no
   layout and no repaint of anything else.
   Deliberately NOT gold: the halo is brand teal wherever it appears on VIEW,
   because gold on a balance would claim the balance was won.                */
.kpi.hero, .card.hero { position: relative; overflow: hidden; }
/* On ::before, NOT ::after. tokens.css:251 gives .kpi a full-bleed tint wash on
   ::before and its 4px colour spine on ::after — I put this on ::after first and
   it ate the spine, turning the whole card into one saturated block. The aura is
   layered OVER the tint rather than replacing it, so a hero keeps its family
   colour. */
.kpi.hero::before, .card.hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(60% 55% at 50% 12%,
      color-mix(in srgb, var(--brand) 20%, transparent) 0%, transparent 72%),
    var(--kpi-tint, transparent);
  animation: kg-breathe 9s var(--ease-out, ease) infinite alternate;
}
@keyframes kg-breathe {
  from { transform: translate3d(-6%, -2%, 0) scale(1); opacity: .75; }
  to   { transform: translate3d(6%, 2%, 0) scale(1.12); opacity: 1; }
}

/* ---- cards stop being flat ---------------------------------------------
   A one-degree gradient and a hairline top highlight. Barely visible alone;
   together they give every surface an up direction, which is what "polished"
   actually is at this scale.                                                */
.card, .kpi {
  background-image: linear-gradient(180deg,
    color-mix(in srgb, #fff 4%, transparent) 0%, transparent 38%);
}
[data-theme="light"] .card, [data-theme="light"] .kpi {
  background-image: linear-gradient(180deg,
    color-mix(in srgb, #fff 70%, transparent) 0%, transparent 46%);
}

/* ---- the metric spine becomes a gradient -------------------------------
   .kpi already carried a 4px colour spine. A flat bar reads as a rule; a
   gradient reads as light falling on an edge.                              */
.kpi { position: relative; }
/* ::after is the spine (tokens.css:256). ::before is the tint wash and is
   341px wide — putting this gradient there painted the entire card. */
.kpi::after {
  background-image: linear-gradient(180deg,
    var(--kpi-fill, var(--brand)) 0%,
    color-mix(in srgb, var(--kpi-fill, var(--brand)) 45%, transparent) 100%);
}

/* The money-won moment is NOT defined here. kit.js ui.winBurst already owns
   it — gold particles, asked for by GUARD, GOALS, AJO, onboarding and VIEW,
   and gated on KG.motion.ok('celebrate') so a reduced-motion request or a
   struggling phone drops it first. A second celebration primitive would be a
   second answer to "what does winning look like". */

/* ---- reduced motion: every drawing lands finished ----------------------
   Not "slower" and not "faded in" — FINISHED. Somebody who asked the system
   for less motion is not asking for a gentler version of the same sweep.
   Each animation is replaced by its END state explicitly, because animation:
   none on a keyframe that supplies the value (stroke-dashoffset, width) would
   leave the element at its FROM state — an empty ring and a zero-width bar,
   i.e. a chart stating a figure that is not true.                           */
@media (prefers-reduced-motion: reduce) {
  .spark-flow-fill,
  .spark-area, .spark-dot, .spark-arc,
  .kpi.hero::before, .card.hero::before { animation: none !important; }
  .spark-flow-fill { width: var(--w, 0%); }
  .spark-stroke { animation: none !important; stroke-dashoffset: 0; }
  .spark-ring-fill { animation: none !important; stroke-dashoffset: var(--off, 0); }
  .spark-arc { opacity: 1; stroke-dasharray: var(--dash); }
}

/* ---- the landing nav must fit a 360px phone ----------------------------
   .land-nav is flex + space-between with no wrap, .btn is white-space:nowrap
   and body is overflow-x:hidden — so at 360px (the commonest Nigerian
   mid-range Android width) the nav measured 504px and the primary CTA, "Get
   started — free", sat entirely outside the viewport at x=360..505 with no way
   to scroll to it. The front door of the product was not on the screen; only
   the hero button below the fold still worked. At 375px it was a 15px sliver.

   Three things, all needed. Wrapping alone leaves the row 504px wide because
   the brand block does not shrink; shrinking alone still overflows once the
   Console button is present.
------------------------------------------------------------------------ */
@media (max-width: 480px) {
  .land-nav { flex-wrap: wrap; row-gap: 8px; padding: 10px 14px; }
  /* The wordmark block may give up room; the buttons may not. */
  .land-nav > .row:first-child { min-width: 0; flex: 1 1 auto; }
  .land-nav > .row:first-child .badge { display: none; }   /* "by Korevra" is on the page below */
  .land-nav > .row:last-child { flex: 0 0 auto; }
  /* The operator console is not a customer's door. It was shown to every
     visitor, and tapping it spends ~380 KB of a metered connection loading a
     screen they cannot use. */
  .land-nav [data-portal="admin"] { display: none; }
}
