/* ════════════════════════════════════════════════════════════════════
   Cards + tags + tone helpers
   ════════════════════════════════════════════════════════════════════ */

.card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  transition: border-color .3s ease, transform .3s ease;
}
.card-hover:hover, .card.hoverable:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.card-title {
  font-size: 14px; font-weight: 600; color: var(--foreground);
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.card-title .muted { color: var(--muted-foreground); font-weight: 400; }

.card-subtitle {
  margin-bottom: 8px; font-size: 11px; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: .08em;
}

/* ── No-fund-access empty-state banner ─────────────────────────────── */
.no-fund-banner {
  border-color: var(--status-dev);
  background: linear-gradient(180deg, rgba(248,168,0,.05), transparent);
}
.no-fund-banner-title {
  font-size: 14px; font-weight: 600;
  color: var(--status-dev);
  letter-spacing: .02em;
  margin-bottom: 6px;
}
.no-fund-banner-body {
  font-size: 12.5px; color: var(--muted-foreground); line-height: 1.5;
  max-width: 60ch;
}

/* ── Obfuscation disclaimer banner ─────────────────────────────────
   Same chrome as .no-fund-banner but a calmer blue tone — this is a
   "heads up" rather than a "broken state". Stays hidden until AppShell
   stamps data-obf-active on <html>. */
.obfuscation-banner {
  border-color: var(--ring);
  background: linear-gradient(180deg, rgba(59,130,246,.06), transparent);
}
.obfuscation-banner-title {
  font-size: 14px; font-weight: 600;
  color: var(--ring);
  letter-spacing: .02em;
  margin-bottom: 6px;
}
.obfuscation-banner-body {
  font-size: 12.5px; color: var(--muted-foreground); line-height: 1.5;
  max-width: 70ch;
}

/* Chart subtitle swap — chart cards keep the dollar copy by default and
   swap to the obfuscated copy ("% of NAV", "indexed") when the user is
   viewing under obf. Saves the chart code from poking innerText. */
.chart-subtitle-default { display: inline; }
.chart-subtitle-obf     { display: none; }
:root[data-obf-active][data-obf-flags~="prices"] .chart-subtitle-default { display: none; }
:root[data-obf-active][data-obf-flags~="prices"] .chart-subtitle-obf     { display: inline; }

/* Bucket chip — used in obfuscated tables in place of $ values to
   convey "tiny / small / medium / large / huge" relative magnitude. */
.bucket-chip {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 8px; border-radius: var(--radius);
  font-size: 11px; font-family: var(--font-mono); font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-tinted);
  color: var(--muted-foreground);
}

/* ── Tag (matches Badge variant=secondary) ─────────────────────────── */
.tag {
  display: inline-flex; align-items: center; justify-content: center;
  /* vertical-align:middle so two adjacent .tag elements (e.g. ticker
   * badge with icon + OVR badge without) center-align with each other
   * instead of baseline-aligning. Without this, the icon-bearing badge
   * is taller and pushes its baseline down, leaving the shorter OVR
   * tag visually stranded above it. */
  vertical-align: middle;
  padding: 2px 8px; border-radius: var(--radius);
  font-size: 11px; font-family: var(--font-mono); font-weight: 500;
  border: 1px solid transparent;
  background: var(--secondary); color: var(--secondary-foreground);
}
.tag.good { color: var(--profit);  border-color: rgba(81,193,72,.25); background: rgba(81,193,72,.08); }
.tag.warn { color: var(--chart-3); border-color: rgba(249,156,0,.25); background: rgba(249,156,0,.08); }
.tag.bad  { color: var(--loss);    border-color: rgba(228,0,20,.25);  background: rgba(228,0,20,.08); }

/* ── OTC valuation badges ──────────────────────────────────────────────
 *
 * Used by core/otc-badges.js to surface "this thing is part of an active
 * OTC deal and the mark/discount you see here was computed from the
 * unified timeline cache". Three variants share the same amber/cyan tone
 * family so they read as a coherent set across pages:
 *
 *   • .tag-otc-disc — discount pill ("−16.3%")
 *   • .tag-otc-mark — corrected mark price ("$0.42 (−16%)")
 *   • .tag-otc-link — cross-page "OTC" indicator chip
 *
 * Tone choice: cyan (chart-2) — distinct from the green/amber/red of
 * good/warn/bad so the OTC family doesn't get visually confused with
 * P&L sign cues.
 */
.tag.tag-otc {
  color: var(--chart-2);
  border-color: rgba(56, 178, 172, 0.30);
  background: rgba(56, 178, 172, 0.08);
}
.tag.tag-otc-mark { font-weight: 600; }
.tag.tag-otc-link {
  /* Slightly tighter padding for the cross-page indicator — it's meant
   * to slot inline with row content as a "this is OTC" cue, not a
   * primary value display. */
  padding: 1px 6px;
  font-size: 10px;
  letter-spacing: 0.04em;
}
/* Clickable OTC badge — the d_agg pill / corrected-mark badge on a
 * Positions-breakdown OTC row opens the per-ticker "deals + vesting
 * tranches" popup. Gets a pointer cursor + a brighter hover/focus state
 * so the affordance reads as interactive, distinct from the static
 * badges. A trailing caret hints "this expands". */
.tag.tag-otc-clickable {
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, filter 0.12s ease;
}
.tag.tag-otc-clickable::after {
  content: "›";
  margin-left: 3px;
  opacity: 0.55;
  font-weight: 700;
}
.tag.tag-otc-clickable:hover,
.tag.tag-otc-clickable:focus-visible {
  /* Tone-agnostic hover — brighten + border up to the badge's own tone
     (currentColor), so cyan / amber / green pills all read as interactive
     without per-tone overrides. */
  filter: brightness(1.14);
  border-color: currentColor;
  outline: none;
}
.tag.tag-otc-clickable:focus-visible {
  box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 35%, transparent);
}

/* ── OTC status tone ───────────────────────────────────────────────────
 * Overrides the base cyan .tag-otc so the Mark column encodes status by
 * colour:
 *   • amber  = discounted (a haircut on value) — discount pills +
 *              discounted corrected marks.
 *   • green  = MtM (full spot, no discount) — the "MtM" pill + MtM marks.
 * Placed after .tag-otc so it wins on equal specificity. */
.tag.tag-otc-tone-disc {
  color: var(--status-dev);
  border-color: color-mix(in srgb, var(--status-dev) 38%, transparent);
  background: color-mix(in srgb, var(--status-dev) 11%, transparent);
}
.tag.tag-otc-tone-mtm {
  color: var(--profit);
  border-color: color-mix(in srgb, var(--profit) 32%, transparent);
  background: color-mix(in srgb, var(--profit) 9%, transparent);
}

/* ── APR badge (capital-time-weighted return) ──────────────────────────
 * Deliberately NEUTRAL — APR is not a status, so it keeps the base .tag
 * grey/dark surface (theme-aware) instead of joining the amber/green OTC
 * family. The sign gets only a SLIGHT green/red tint so a profitable vs
 * losing deal reads at a glance without shouting. Click opens the
 * auditable APR inspector. */
.tag.tag-apr { font-weight: 600; }
.tag.tag-apr-tone-pos {
  border-color: color-mix(in srgb, var(--profit) 40%, var(--border, transparent));
  background: color-mix(in srgb, var(--profit) 10%, var(--secondary));
}
.tag.tag-apr-tone-neg {
  border-color: color-mix(in srgb, var(--loss) 40%, var(--border, transparent));
  background: color-mix(in srgb, var(--loss) 10%, var(--secondary));
}
.tag.tag-apr-clickable {
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, filter 0.12s ease;
}
.tag.tag-apr-clickable::after {
  content: "›";
  margin-left: 3px;
  opacity: 0.55;
  font-weight: 700;
}
.tag.tag-apr-clickable:hover,
.tag.tag-apr-clickable:focus-visible {
  filter: brightness(1.14);
  border-color: currentColor;
  outline: none;
}
.tag.tag-apr-clickable:focus-visible {
  box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 35%, transparent);
}

/* ── APR inspector popup (apr-popup.js) ───────────────────────────────── */
.apr-popup { min-width: 340px; max-width: 460px; font-size: 13px; }
.apr-popup .apr-section {
  border: 1px solid var(--border, rgba(128, 128, 128, 0.2));
  border-radius: 8px;
  padding: 4px 10px;
  margin-bottom: 10px;
  /* Solid surface (not translucent) so the numbers read clearly over the
   * modal backdrop — same readability treatment as the OTC discount popup. */
  background: var(--surface-2);
}
.apr-popup .apr-apr { background: var(--surface-3); }
.apr-popup .apr-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
  align-items: baseline;
}
.apr-popup .apr-lbl { color: var(--text-muted, inherit); }
.apr-popup .apr-val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.apr-popup .apr-head {
  font-weight: 700;
  border-bottom: 1px solid var(--border, rgba(128, 128, 128, 0.2));
  padding-bottom: 4px;
}
.apr-popup .apr-total {
  border-top: 1px solid var(--border, rgba(128, 128, 128, 0.25));
  margin-top: 2px;
  padding-top: 6px;
  font-weight: 700;
}
.apr-popup .apr-total .apr-lbl { color: inherit; }
.apr-popup .apr-primary .apr-val { color: var(--chart-4); }
.apr-popup .apr-muted .apr-lbl,
.apr-popup .apr-muted .apr-val { color: var(--text-muted, inherit); font-weight: 500; }
.apr-popup .tip-formula {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-muted, inherit);
  border-left: 2px solid var(--border, rgba(128, 128, 128, 0.35));
  padding: 6px 10px;
  margin-bottom: 10px;
  border-radius: 0 6px 6px 0;
  background: var(--surface-2);
}

/* ── Token icon slot — single source of truth for icon framing ───────
 *
 * Visual contract (matches Token DD's .tdd-img-circle):
 *   • Wrapper IS the circle. Theme-aware backfill (var(--surface-elevated))
 *     so an empty / failed-to-load state still reads as a coin-shaped
 *     placeholder rather than a hole in the layout.
 *   • Inner <img> object-fit: cover so off-square logos crop neatly to
 *     the circle, never letterboxed.
 *   • Width starts at 0 so a renderer that emits a slot for an unknown
 *     ticker doesn't reserve empty space; expands to 1em the moment the
 *     icon paints (or to the missing state, which collapses again).
 *
 * Used by every ticker surface: tickerBadge() in tables, the deal-card
 * head + Fund Admin reference input, the backtest form's ticker input,
 * the CEX Positions tab's CEX symbol cells. The deal-card icon variant
 * (.deal-card-icon, defined in pages/deals.css) overrides the size only.
 */
.ticker-badge { gap: 0; }
.ticker-icon {
  /* Always a perfect circle from the moment the slot mounts. Width and
   * height are both pinned to the same value so border-radius:50% reads
   * as a circle at every frame — no squash/stretch animation between
   * "loading" and "loaded" states.
   *
   * Previously the slot started at width:0 and CSS-transitioned to its
   * target width on paint. During the transition border-radius:50% on
   * a non-square box rendered as an ellipse, which surfaced visibly as:
   *   • Deal-card icon morphing while the user types the ticker
   *   • Analysis hero icon flexing on deal-switch
   *   • Timeline tooltip jittering as the icon settled into place
   *   • Chart legend / tooltip icons appearing wider-than-tall
   *
   * The "collapse on miss" behaviour still works via .ticker-icon--missing
   * which forces width back to 0 (no transition, snaps closed), so an
   * unknown ticker's slot disappears cleanly without leaving a hollow
   * placeholder circle. */
  display: inline-flex; align-items: center; justify-content: center;
  width: 1em; height: 1em;
  margin: 0; margin-right: 5px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--surface-elevated);
  flex: 0 0 auto;
}
.ticker-icon--missing {
  width: 0 !important; height: 0 !important;
  margin-right: 0 !important;
  background: transparent !important;
}
.ticker-icon img {
  width: 100%; height: 100%;
  display: block;
  object-fit: cover;     /* crop to fill the circle — no letterbox */
  border-radius: 0;      /* circle is on the wrapper, not the img */
  background: transparent;
}
/* Hide the broken-image glyph if the URL 404s mid-paint. */
.ticker-icon img:not([src]),
.ticker-icon img[src=""] { display: none; }

/* CEX symbol cell — icon + mono symbol text in a row. Used by the
 * funding/closed-pnl/timeline tables on the CEX Positions tab. */
.cex-sym {
  display: inline-flex; align-items: center;
}
.cex-sym .ticker-icon[data-icon-painted] { margin-right: 6px; }

/* ── Tone helpers (PnL etc.) ──────────────────────────────────────── */
.muted   { color: var(--muted-foreground); }
.small   { font-size: 11px; }
.num     { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.pos     { color: var(--profit); }
.neg     { color: var(--loss); }
.bt-pos  { color: var(--profit); }
.bt-neg  { color: var(--loss); }

/* Generic pill (used by deal-summary, anywhere we need a chip) */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius);
  background: var(--secondary); border: 1px solid var(--border);
  font-size: 11px; font-family: var(--font-mono);
}
.pill .pill-label {
  color: var(--muted-foreground); font-size: 9px;
  text-transform: uppercase; letter-spacing: .1em;
}
.pill.primary {
  background: var(--surface-tinted); border-color: var(--border-strong);
  color: var(--foreground); font-weight: 600;
}
