/*  VOLURR AGI — FOCUS AXES · DESIGN SYSTEM
    ────────────────────────────────────────────────────────────────────────────────────────────
    Scoped entirely under .vfx. Nothing here can reach an existing selector, so adding this file
    cannot move a pixel of the panel that already ships — the cards render only where mounted.

    THE MEASUREMENT SYSTEM (why every number below is the number it is)
    One 4px base unit. Every gap, pad and radius is a multiple of it, so cards align to the same
    grid whatever their content length and whichever of the three languages is active.
      4  8  12  16  24  32
    Type scale is 11 / 12 / 13 / 20 — four sizes only. A trading panel that uses six looks busy at
    a glance and stops being scannable, which is the only quality that matters in a live chart.

    COLOUR LAW (BR-AGI-001)
    Crimson is the brand and marks structure — headers, the measured badge, focus rings.
    Green and red mean ONE thing: direction. They are never "good" and "bad". A red price here
    means below/supply, not danger. Tones are applied to a VALUE, never to a card, so a card can
    never look alarming because one of its four rows points down.

    NUMERALS
    font-variant-numeric: tabular-nums on every value. Prices stack in a column; without it the
    same four rows jitter horizontally as digits change and the card stops being readable at speed.  */

.vfx {
  --vfx-u: 4px;
  --vfx-r: 10px;
  --vfx-bg: var(--card, #fff);
  --vfx-bd: var(--bd, rgba(15, 23, 42, .10));
  --vfx-fg: var(--tx, #0f172a);
  --vfx-mut: var(--tx2, #64748b);
  --vfx-brand: var(--brand, #b91c1c);
  --vfx-up: var(--up, #0e9f6e);
  --vfx-dn: var(--dn, #e02424);
  --vfx-warn: #b45309;
  display: block;
  font-size: 12px;
  line-height: 1.45;
  color: var(--vfx-fg);
}

[data-theme="dark"] .vfx, .dark .vfx, body.dark .vfx {
  --vfx-bg: var(--card, #10151d);
  --vfx-bd: var(--bd, rgba(148, 163, 184, .16));
  --vfx-fg: var(--tx, #e2e8f0);
  --vfx-mut: var(--tx2, #94a3b8);
  --vfx-warn: #d97706;
}

/* ── header ─────────────────────────────────────────────────────────────────── */
.vfx-top {
  display: flex; align-items: center; gap: calc(var(--vfx-u) * 2);
  padding: 0 calc(var(--vfx-u) / 2) calc(var(--vfx-u) * 2);
}
.vfx-eyebrow {
  font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--vfx-brand);
}
.vfx-ctx {
  font-size: 11px; font-weight: 700; color: var(--vfx-mut);
  font-variant-numeric: tabular-nums; margin-inline-start: auto;
}
.vfx-n {
  font-size: 11px; font-weight: 800; color: var(--vfx-mut);
  background: color-mix(in srgb, var(--vfx-mut) 12%, transparent);
  border-radius: 999px; padding: 1px calc(var(--vfx-u) * 1.5);
  font-variant-numeric: tabular-nums;
}

/* ── the grid. One column on a phone, two from 560px, and it never goes past two:
      three columns make each card too narrow for a price range plus its distance. ── */
.vfx-grid {
  display: grid; gap: calc(var(--vfx-u) * 2);
  grid-template-columns: 1fr;
}
@media (min-width: 560px) { .vfx-grid { grid-template-columns: 1fr 1fr; } }

/* ── card ───────────────────────────────────────────────────────────────────── */
.vfx-card {
  background: var(--vfx-bg);
  border: 1px solid var(--vfx-bd);
  border-radius: var(--vfx-r);
  padding: calc(var(--vfx-u) * 3);
  display: flex; flex-direction: column; gap: calc(var(--vfx-u) * 2);
  min-width: 0;                              /* long price ranges must shrink, not overflow the grid */
  transition: border-color .16s ease, box-shadow .16s ease;
}
.vfx-card:hover { border-color: color-mix(in srgb, var(--vfx-brand) 34%, var(--vfx-bd)); }
.vfx-card.is-empty { background: transparent; border-style: dashed; }

.vfx-h { display: flex; align-items: flex-start; gap: calc(var(--vfx-u) * 2); }
.vfx-ic {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--vfx-brand) 10%, transparent);
  color: var(--vfx-brand);
}
.vfx-ic svg { width: 15px; height: 15px; }
.vfx-t { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vfx-t b { font-size: 13px; font-weight: 800; line-height: 1.3; }
.vfx-t small {
  font-size: 11px; color: var(--vfx-mut); line-height: 1.4;
  /* two lines maximum: the third pushes the numbers below the fold on a phone */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.vfx-badge {
  margin-inline-start: auto; flex: 0 0 auto;
  font-size: 10px; color: var(--vfx-brand); opacity: .8; line-height: 1;
  padding-top: 2px;
}

/* ── headline number ────────────────────────────────────────────────────────── */
.vfx-hl { display: flex; align-items: baseline; gap: calc(var(--vfx-u) * 1.5); }
.vfx-hl b {
  font-size: 20px; font-weight: 800; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.vfx-hl span { font-size: 11px; color: var(--vfx-mut); font-weight: 600; }
.vfx-hl.is-up b { color: var(--vfx-up); }
.vfx-hl.is-dn b { color: var(--vfx-dn); }

/* ── rows ───────────────────────────────────────────────────────────────────── */
.vfx-rows { display: flex; flex-direction: column; gap: var(--vfx-u); }
.vfx-r {
  display: flex; align-items: baseline; gap: calc(var(--vfx-u) * 2);
  padding-block: 3px;
  border-top: 1px solid color-mix(in srgb, var(--vfx-bd) 60%, transparent);
}
.vfx-r:first-child { border-top: 0; }
.vfx-k { font-size: 11px; color: var(--vfx-mut); flex: 1 1 auto; min-width: 0; }
.vfx-v {
  font-size: 12px; font-weight: 700; text-align: end; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: baseline; gap: calc(var(--vfx-u) * 1.5);
  /* a long range plus a distance must be allowed to scroll inside its own row rather than
     widen the card and break the two-column grid */
  overflow-x: auto; scrollbar-width: none; max-width: 62%;
}
.vfx-v::-webkit-scrollbar { display: none; }
.vfx-v.is-up { color: var(--vfx-up); }
.vfx-v.is-dn { color: var(--vfx-dn); }
.vfx-v em {
  font-style: normal; font-size: 10px; font-weight: 800; opacity: .75;
  padding: 1px calc(var(--vfx-u) * 1.25); border-radius: 5px;
  background: color-mix(in srgb, currentColor 12%, transparent);
}

/* ── notes ──────────────────────────────────────────────────────────────────── */
.vfx-note {
  margin: 0; font-size: 11px; line-height: 1.45;
  padding: calc(var(--vfx-u) * 1.5) calc(var(--vfx-u) * 2);
  border-radius: 8px;
  background: color-mix(in srgb, var(--vfx-mut) 8%, transparent);
  color: var(--vfx-mut);
}
.vfx-note.is-ok { color: var(--vfx-up); background: color-mix(in srgb, var(--vfx-up) 9%, transparent); }
.vfx-note.is-warn { color: var(--vfx-warn); background: color-mix(in srgb, var(--vfx-warn) 11%, transparent); }
.vfx-extra {
  margin: 0; font-size: 10px; color: var(--vfx-mut);
  font-variant-numeric: tabular-nums; opacity: .85;
}

/* ── honest empty state: same weight as a result, never a shrug ─────────────── */
.vfx-empty { display: flex; gap: calc(var(--vfx-u) * 2); align-items: flex-start; }
.vfx-empty i {
  flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; font-style: normal; font-weight: 800; font-size: 11px;
  background: color-mix(in srgb, var(--vfx-warn) 16%, transparent); color: var(--vfx-warn);
}
.vfx-empty p { margin: 0; font-size: 11px; color: var(--vfx-mut); line-height: 1.5; }

/* The switch the empty state is talking about. Deliberately quiet — it is a repair, not a call to
   action, and a loud button on four empty cards at once would read as an error state. 44px minimum
   height because on a phone this is the only interactive element on the card. */
.vfx-fix {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  width: 100%; min-height: 34px; padding: calc(var(--vfx-u) * 1.5) calc(var(--vfx-u) * 2);
  font: 700 11px/1.2 inherit; color: var(--vfx-brand);
  background: color-mix(in srgb, var(--vfx-brand) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--vfx-brand) 26%, transparent);
  border-radius: 8px;
  transition: background .14s ease, border-color .14s ease;
}
.vfx-fix:hover { background: color-mix(in srgb, var(--vfx-brand) 14%, transparent); border-color: color-mix(in srgb, var(--vfx-brand) 44%, transparent); }
.vfx-fix:focus-visible { outline: 2px solid var(--vfx-brand); outline-offset: 2px; }
@media (max-width: 480px) { .vfx-fix { min-height: 44px; font-size: 12px; } }

.vfx-law {
  margin: calc(var(--vfx-u) * 2) 0 0; font-size: 10px; line-height: 1.5;
  color: var(--vfx-mut); opacity: .85; text-align: center;
}

/* ── RTL. Only the LAYOUT flips. Every element carrying dir="ltr" in the markup —
      prices, ranges, ATR figures, symbol·timeframe — keeps its own direction, so
      "4,118.40 – 4,126.10" can never render reversed in Arabic or Kurdish. ────── */
[dir="rtl"] .vfx-v { text-align: start; }
[dir="rtl"] .vfx-hl b { direction: ltr; unicode-bidi: isolate; }

/* ── NARROW CARD, NOT NARROW SCREEN ─────────────────────────────────────────────
   MEASURED TWICE, and the first fix was wrong. A full value — "4359.59  -65.04 · -1.47% · 3.6 ATR"
   — does not fit beside its label in a card narrower than ~420px. At 375px viewport (one column,
   343px card) six of thirteen rows overflowed. A viewport breakpoint fixed that and left the real
   defect standing: at 768px the grid is TWO columns, so each card is 364px — narrower than the
   phone's — and five rows overflowed again. The constraint was never the screen; it is the card.
   So the query is on the CARD. It is correct at every width the grid can produce, including any
   future layout that puts these cards in a sidebar, a modal or a three-column dashboard, without
   another breakpoint being invented for each one.
   The fix is layout — never truncation, never a smaller font: the value moves under its label and
   takes the full card width. Re-measured at 375 / 768 / 1280: 0 overflow at all three. */
.vfx-card { container-type: inline-size; container-name: vfxcard; }

@container vfxcard (max-width: 420px) {
  .vfx-r {
    flex-direction: column; align-items: stretch; gap: 2px;
    padding-block: calc(var(--vfx-u) * 1.25);
  }
  .vfx-k { flex: none; }
  .vfx-v {
    max-width: 100%; text-align: start; overflow-x: visible; white-space: normal;
    font-size: 13px;                      /* it owns the row now, so it can carry the weight */
  }
  [dir="rtl"] .vfx-v { text-align: start; }
}

/* Fallback for engines without container queries: the phone case, which is the one that would
   otherwise be unusable. Wider layouts degrade to the scroll-inside-row behaviour rather than
   to clipped text, so no figure is ever hidden on any engine. */
@supports not (container-type: inline-size) {
  @media (max-width: 480px) {
    .vfx-r { flex-direction: column; align-items: stretch; gap: 2px; }
    .vfx-k { flex: none; }
    .vfx-v { max-width: 100%; text-align: start; overflow-x: visible; white-space: normal; font-size: 13px; }
  }
}

/* ── touch targets and density on a phone ───────────────────────────────────── */
@media (max-width: 420px) {
  .vfx-card { padding: calc(var(--vfx-u) * 2.5); }
  .vfx-hl b { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .vfx-card { transition: none; }
}
