/* ============================================================
   FinancialFeed case study — KPI tiles, charts, engine flow.
   Loaded after styles.css on projects/financialfeed.html only.
   Chart colours validated (dataviz validate_palette, dark mode,
   surface #101218): blue #3a93ec · orange #e0703a.
   ============================================================ */
.ff {
  --ff-s1: #3a93ec;
  --ff-s2: #e0703a;
  --ff-surface: rgba(16, 18, 24, 0.86);
  --ff-grid: rgba(255, 255, 255, 0.07);
  --ff-ref: rgba(255, 255, 255, 0.22);
}

/* ---- KPI tiles ----------------------------------------------- */
.ff-kpis {
  width: var(--wrap); margin: clamp(1.5rem, 4vw, 3rem) auto clamp(1rem, 3vw, 2rem);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4);
}
.ff-kpi {
  border: 1px solid var(--hairline); border-radius: 16px; padding: var(--space-5);
  background: var(--ff-surface); display: flex; flex-direction: column; gap: var(--space-2);
}
.ff-kpi__v {
  font-family: var(--font-display); font-weight: 600; font-size: clamp(2rem, 4.2vw, 3.1rem);
  line-height: 1; letter-spacing: -0.02em; color: var(--snow);
}
.ff-kpi__l { font-size: 0.95rem; color: var(--ash); line-height: 1.4; }
.ff-kpi__s { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ash-dim); letter-spacing: 0.02em; margin-top: auto; }
html[dir="rtl"] .ff-kpi__v { font-weight: 700; letter-spacing: normal; }
@media (max-width: 900px) { .ff-kpis { grid-template-columns: repeat(2, 1fr); } }

/* ---- chart card ---------------------------------------------- */
.ff-chartsec { width: var(--wrap); margin: 0 auto; padding: 0 0 clamp(3rem, 7vw, 5.5rem); }
.ff-chart {
  position: relative; border: 1px solid var(--hairline); border-radius: 20px;
  background: var(--ff-surface); padding: clamp(1.1rem, 2.6vw, 2rem);
}
.ff-chart__head { display: flex; flex-wrap: wrap; gap: var(--space-5); justify-content: space-between; align-items: flex-end; margin-bottom: var(--space-5); }
.ff-chart__title { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.4rem, 2.6vw, 2.1rem); letter-spacing: -0.02em; line-height: 1.1; margin: var(--space-3) 0 var(--space-3); }
html[dir="rtl"] .ff-chart__title { font-weight: 800; letter-spacing: normal; }
.ff-chart__sub { color: var(--ash); max-width: 62ch; line-height: 1.55; font-size: 0.98rem; }
.ff-chart__plot { position: relative; width: 100%; }
.ff-chart__plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.ff-chart__plot svg:focus { outline: none; }
.ff-chart__plot svg:focus-visible { outline: 2px solid var(--ion); outline-offset: 6px; border-radius: 6px; }
.ff-chart__axis { margin-top: var(--space-2); text-align: center; font-family: var(--font-mono); font-size: 0.72rem; color: var(--ash-dim); letter-spacing: 0.04em; }
.ff-chart__foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-3) var(--space-5); margin-top: var(--space-5); align-items: baseline; }
.ff-chart__src { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ash-dim); line-height: 1.6; max-width: 70ch; }

/* callouts beside/under a chart */
.ff-callouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); margin-top: var(--space-5); }
.ff-callout { border-top: 1px solid var(--hairline-2); padding-top: var(--space-4); color: var(--ash); line-height: 1.5; font-size: 0.95rem; }
.ff-callout b { display: block; font-family: var(--font-display); font-weight: 600; font-size: clamp(1.5rem, 2.6vw, 2rem); color: var(--snow); letter-spacing: -0.01em; margin-bottom: var(--space-1); }
html[dir="rtl"] .ff-callout b { font-weight: 700; letter-spacing: normal; }
@media (max-width: 720px) { .ff-callouts { grid-template-columns: 1fr; } }

/* legend: line keys, text in text tokens (never series colour) */
.ff-legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); font-size: 0.88rem; color: var(--ash); }
.ff-legend span { display: inline-flex; align-items: center; gap: 8px; }
.ff-legend i { display: inline-block; width: 18px; height: 2px; border-radius: 2px; background: var(--c); }

/* svg marks */
.ff-grid { stroke: var(--ff-grid); stroke-width: 1; }
.ff-tick { fill: var(--ash); font-family: var(--font-mono); font-size: 11px; }
.ff-lbl { fill: var(--snow); font-family: var(--font-body); font-size: 12px; font-weight: 500; }
.ff-lbl--soft { fill: var(--ash); font-weight: 400; }
.ff-ref { stroke: var(--ff-ref); stroke-width: 1; }
.ff-zone { fill: rgba(58, 147, 236, 0.07); }
.ff-bar { fill: var(--ff-s1); transition: fill 0.15s ease; }
.ff-bar.is-hot { fill: #6cb2f5; }
.ff-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ff-area { fill-opacity: 0.12; }
.ff-dot { stroke: #101218; stroke-width: 2; }
.ff-cross { stroke: rgba(255, 255, 255, 0.35); stroke-width: 1; }
.ff-hit { fill: transparent; }

/* draw-in (disabled for reduced motion) */
.ff-anim .ff-bar { transform-box: fill-box; transform-origin: 50% 100%; transform: scaleY(0); transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1), fill 0.15s ease; }
.ff-anim.is-in .ff-bar { transform: scaleY(1); }
.ff-anim .ff-line { transition: stroke-dashoffset 1.6s cubic-bezier(0.22, 1, 0.36, 1); }
.ff-anim .ff-fade { opacity: 0; transition: opacity 0.6s ease 0.9s; }
.ff-anim.is-in .ff-fade { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .ff-anim .ff-bar { transform: none; transition: fill 0.15s ease; }
  .ff-anim .ff-line { transition: none; stroke-dashoffset: 0 !important; }
  .ff-anim .ff-fade { opacity: 1; transition: none; }
}

/* tooltip: value leads, label follows */
.ff-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px; max-width: 260px;
  padding: 0.6rem 0.75rem; border-radius: 10px; border: 1px solid var(--hairline-2);
  background: rgba(10, 12, 18, 0.94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
  opacity: 0; transform: translateY(4px); transition: opacity 0.12s ease, transform 0.12s ease;
  font-size: 0.82rem; color: var(--ash); line-height: 1.45;
}
.ff-tip.is-on { opacity: 1; transform: none; }
.ff-tip__h { font-family: var(--font-mono); font-size: 0.7rem; color: var(--ash-dim); margin-bottom: 4px; letter-spacing: 0.03em; }
.ff-tip__row { display: flex; align-items: center; gap: 8px; }
.ff-tip__row i { width: 12px; height: 2px; border-radius: 2px; background: var(--c); flex: none; }
.ff-tip__row b { color: var(--snow); font-weight: 600; font-variant-numeric: tabular-nums; }
.ff-tip__row + .ff-tip__row { margin-top: 3px; }

/* table view: every value reachable without hovering */
.ff-table { margin-top: var(--space-4); }
.ff-table summary { cursor: pointer; font-family: var(--font-mono); font-size: 0.74rem; color: var(--ion); letter-spacing: 0.03em; width: max-content; }
.ff-table summary:hover { color: var(--ion-bright); }
.ff-table__wrap { max-height: 280px; overflow: auto; margin-top: var(--space-3); border: 1px solid var(--hairline); border-radius: 10px; }
.ff-table table { width: 100%; border-collapse: collapse; font-size: 0.82rem; color: var(--ash); }
.ff-table th, .ff-table td { padding: 0.45rem 0.8rem; text-align: start; border-bottom: 1px solid var(--hairline); font-variant-numeric: tabular-nums; }
.ff-table th { color: var(--snow); font-weight: 500; position: sticky; top: 0; background: #0f1117; }

/* feature media that is a chart, not a screenshot */
.ff-mediachart { border: 1px solid var(--hairline); border-radius: 16px; background: var(--ff-surface); padding: clamp(1rem, 2vw, 1.5rem); }
.ff-mediachart .ff-chart__title { font-size: clamp(1.1rem, 1.8vw, 1.35rem); margin-top: 0; }
.ff-mediachart .ff-chart__sub { font-size: 0.88rem; margin-bottom: var(--space-4); }

/* engine flow diagram */
.ff-flow { width: var(--wrap); margin: 0 auto; padding: 0 0 clamp(3rem, 6vw, 5rem); }
.ff-flow svg { width: 100%; height: auto; display: block; }
.ff-flow .arch-box { fill: var(--slate); stroke: var(--hairline-2); }
.ff-flow .arch-box--accent { fill: rgba(45, 128, 217, 0.12); stroke: var(--ion-dim); }
.ff-flow .arch-t { fill: var(--snow); font-family: var(--font-body); font-weight: 500; }
.ff-flow .arch-s { fill: var(--ash); font-family: var(--font-mono); }
.ff-flow .arch-n { fill: var(--ion); font-family: var(--font-mono); }
.ff-flow .arch-line { stroke: var(--hairline-2); stroke-width: 1.5; fill: none; }
.ff-flow .arch-loop { stroke: var(--ion-dim); stroke-width: 1.5; fill: none; }
.ff-flow .arch-head { fill: var(--hairline-2); }
.ff-flow .arch-head--loop { fill: var(--ion-dim); }
html[dir="rtl"] .ff-flow text { direction: rtl; unicode-bidi: plaintext; }

/* a phone-shaped frame for the mobile shot */
.ff-phone { max-width: 300px; margin-inline: auto; border-radius: 36px; padding: 10px; border: 1px solid var(--hairline-2); background: #0b0d12; box-shadow: 0 40px 90px -40px rgba(45, 128, 217, 0.4); }
.ff-phone .shot__img { border-radius: 28px; }
.ff-phone.shot { overflow: hidden; }

@media (max-width: 720px) {
  .ff-flow { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ff-flow svg { min-width: 640px; }
  .ff-chart__head { align-items: flex-start; }
}

.ff-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
