/* ============================================================
   components.css — design-system component styles.
   Each section corresponds to one render_* function in
   public/inc/components.php. Add new components here as the
   library grows. Per Implementation v2 §1.3.
   ============================================================ */


/* ============================================================
   AVATAR — 4 expert-type variants.
   Drawn per design-system/preview/component-expert-avatars.html
   and Implementation v2 §1.0 directive.
   ============================================================ */

.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  line-height: 1;
  letter-spacing: -0.005em;
  user-select: none;
  overflow: hidden;
}
.avatar__label { display: inline-block; line-height: 1; }

.avatar--sm { width: 32px; height: 32px; flex-basis: 32px; font-size: 12px; }
.avatar--lg { width: 72px; height: 72px; flex-basis: 72px; font-size: 22px; }

/* Hedge fund manager — ink-900 background, mono 3-letter code in cream */
.avatar--fund {
  background: var(--ink-900);
  color: var(--cream-50);
  font-family: var(--mono-brand);
  font-weight: 500;
  font-size: 14px;
}
.avatar--fund.avatar--lg { font-size: 22px; }
.avatar--fund.avatar--sm { font-size: 10px; }

/* Politician — pastel party background, serif initials.
   D = pastel blue + dark blue ink. R = pastel red + dark red ink.
   I = independent (rare). 'unknown' = no party data; visually distinct from
   insider via slate tone (--cat-politician). */
.avatar--politician {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 16px;
}
.avatar--politician.avatar--lg { font-size: 26px; }
.avatar--politician.avatar--sm { font-size: 13px; }
.avatar--politician.party--d       { background: #DCE4F0; color: #1B3A6C; }
.avatar--politician.party--r       { background: #F0DCDC; color: #6C1B1B; }
.avatar--politician.party--i       { background: #E8E2D2; color: #4A3D2A; }
.avatar--politician.party--unknown { background: #D5DBE0; color: #3A4452; }

/* D/R/I pill overlay — small uppercase letter in the top-left corner.
   Inverse contrast: party-fg as background, party-bg as text. */
.avatar__pill {
  position: absolute;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 9px/1 var(--mono);
  letter-spacing: 0;
}
.avatar--lg .avatar__pill { width: 18px; height: 18px; font-size: 11px; }
.avatar--sm .avatar__pill { width: 11px; height: 11px; font-size: 8px; }
.avatar__pill--d { background: #1B3A6C; color: #DCE4F0; }
.avatar__pill--r { background: #6C1B1B; color: #F0DCDC; }
.avatar__pill--i { background: #4A3D2A; color: #E8E2D2; }

/* Insider (Form 4) — cream-deep background, serif initials. Per design system
   --avatar-bg #E5DFD2 + --avatar-fg #4A3D2A (matches preview/component-expert-avatars.html). */
.avatar--insider {
  background: #E5DFD2;
  color: #4A3D2A;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 16px;
}
.avatar--insider.avatar--lg { font-size: 26px; }
.avatar--insider.avatar--sm { font-size: 13px; }

/* Activist (13D/G) — aubergine background, mono 2-letter code in cream */
.avatar--activist {
  background: var(--accent);
  color: var(--cream-50);
  font-family: var(--mono-brand);
  font-weight: 500;
  font-size: 14px;
}
.avatar--activist.avatar--lg { font-size: 20px; }
.avatar--activist.avatar--sm { font-size: 10px; }


/* ============================================================
   FEED CHIPS — pill-style filter chips (homepage + events).
   ACTIVE = black solid bg + cream text.
   INACTIVE = transparent bg + hairline outline.
   ============================================================ */
.feed-chips {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.feed-chip {
  display: inline-block;
  font: 500 var(--t-micro) var(--mono);
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  padding: 5px 10px;
  border: 1px solid var(--cream-400);
  background: transparent;
  color: var(--ink-700);
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.feed-chip:hover {
  border-color: var(--ink-900);
  color: var(--ink-900);
}
.feed-chip--active {
  background: var(--ink-900);
  color: var(--cream-50);
  border-color: var(--ink-900);
}
.feed-chip--active:hover { color: var(--cream-50); }

/* ============================================================
   FEED — continuous editorial list, hairline separators.
   Reference: design-system/preview/component-gated-row.html
   plus design-system/ui_kits/web/index.html homepage feed.
   ============================================================ */

.feed {
  display: flex;
  flex-direction: column;
}

.feed-row {
  display: grid;
  /* avatar | name+meta | action | ticker | size | right-stack
     Name (1fr) widened by shaving ~68px from the four fixed-width columns
     on the right so insider/congress names (e.g. "Doyle Janeen Noel",
     "Hamilton Janice M", "Katz Mark Stephen") fit without ellipsis at
     standard row widths. Trade-off: the ticker column's issuer line
     (company name) truncates more aggressively — acceptable since the
     ticker symbol is the canonical identifier. */
  grid-template-columns: 48px 1fr 88px 80px 88px 64px;
  column-gap: var(--s-5);
  align-items: center;
  padding: var(--s-5) 0;
  border-top: var(--hairline);
}
.feed-row:first-of-type { border-top: 0; }

.feed-row__identity { min-width: 0; }
.feed-row__name {
  font: 600 var(--t-body) var(--serif);
  color: var(--ink-900);
  letter-spacing: -0.005em;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feed-row__name a { color: inherit; text-decoration: none; }
.feed-row__name a:hover { color: var(--accent); }

.feed-row__meta {
  font: 400 var(--t-meta) var(--sans);
  color: var(--fg-meta);
  margin-top: 2px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-row__action {
  font: 600 var(--t-micro) var(--mono);
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-900);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.feed-row__action--buy::before  { content: "▲"; color: var(--cat-fund); }
.feed-row__action--sell::before { content: "▼"; color: var(--rust, #8B3A0E); }
.feed-row__action--hold::before { content: "■"; color: var(--ink-500); }
/* 13D/G ownership disclosure — no buy/sell direction, no arrow. */
.feed-row__action--disclosed { color: var(--ink-700); }

.feed-row__ticker {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;          /* allow ellipsis on the issuer line below */
  overflow: hidden;
  text-align: right;
}
.feed-row__ticker-sym {
  font: 700 var(--t-body-l) var(--mono);
  color: var(--ink-900);
  letter-spacing: 0.01em;
  line-height: 1.2;
}
/* Anchor wrapping the ticker cell when the row has a real symbol —
   carries the same hover-to-accent treatment as the filer-name link
   (see .feed-row__name a above). Layout matches .feed-row__ticker so
   the two-line stack is preserved. */
.feed-row__ticker-link {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  transition: color 80ms var(--ease);
}
.feed-row__ticker-link:hover .feed-row__ticker-sym,
.feed-row__ticker-link:hover .feed-row__ticker-issuer { color: var(--accent); }
.feed-row__ticker-issuer {
  font: 400 var(--t-meta) var(--sans);
  color: var(--fg-meta);
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 13F filing-event rows carry a multi-clause summary text ("12 new · 34
   increased · 18 trimmed · 9 exited") in the ticker cell instead of a
   ticker+issuer pair. The default 94px ticker column truncates that string
   to "Initial portfolio · …". Widen the summary column to ~260px (large
   enough for the worst realistic 4-bucket case) by borrowing width from the
   size cell (which only renders "N pos" for 13F rows — much shorter than
   the trade-side "+1.4M sh" or "$32M · S"). */
.feed-row.feed-row--13f-filing {
  grid-template-columns: 48px 1fr 110px 260px 80px 74px;
}
.feed-row--13f-filing .feed-row__ticker--summary {
  width: 100%;
}
.feed-row--13f-filing .feed-row__ticker-sym--summary {
  /* "13F filed" stays as a small label above the summary line. Use the
     muted/meta type instead of the bold ticker-style mono so the summary
     line below reads as the primary content of the cell. */
  font: 600 var(--t-micro) var(--mono);
  letter-spacing: var(--tr-caps);
  color: var(--fg-meta);
  text-transform: uppercase;
}
.feed-row--13f-filing .feed-row__ticker-issuer {
  /* In the regular ticker cell this carries the issuer name with ellipsis
     truncation. In the 13F-filing variant it carries the multi-clause
     summary; the cell is wide enough now that ellipsis should rarely fire,
     but if a worst-case 3-digit-bucket row appears we still clip cleanly. */
  color: var(--ink-700);
  font-weight: 500;
}

.feed-row__size {
  font: 500 var(--t-meta) var(--mono);
  color: var(--ink-700);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.feed-row__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.feed-row__time {
  font: 400 var(--t-micro) var(--mono);
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}
.feed-row__form {
  font: 600 10px var(--mono);
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--fg-meta);
}

/* Feed editorial line (above feed, for Free users only).
   "Free users see filings 24 hours after they post on EDGAR. Pro members
   see them within 15 minutes. · view all →" */
.feed-prompt {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--s-3);
  padding: var(--s-5) 0 var(--s-5);
  border-bottom: var(--hairline);
  margin-bottom: var(--s-4);
  font: 400 var(--t-body-s) var(--sans);
  color: var(--ink-700);
}
.feed-prompt strong { font-weight: 600; color: var(--ink-900); }
.feed-prompt a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
  margin-left: auto;
}
.feed-prompt a:hover { text-decoration-color: var(--accent); }


/* ============================================================
   KPI STRIP — generic stat row for expert detail / dashboard.
   Reference: design-system/ui_kits/web/KPIStrip.jsx
   ============================================================ */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--s-7);
  padding: var(--s-6) 0;
  border-top: var(--hairline);
  border-bottom: var(--hairline);
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  min-width: 0;
}

.kpi__label {
  font: 600 var(--t-micro)/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--fg-meta);
}

.kpi__value {
  font: 500 var(--t-display-s)/1 var(--mono);
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.kpi__sub {
  font: 400 var(--t-body-s)/1.3 var(--sans);
  color: var(--fg-meta);
}

.kpi__value--positive { color: var(--cat-fund); }
.kpi__value--negative { color: var(--rust, #8B3A0E); }


/* ============================================================
   FOLLOW BUTTON
   ============================================================ */

.follow-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 500 var(--t-body-s) var(--sans);
  padding: 4px 12px;
  border: 1px solid var(--ink-900);
  background: transparent;
  color: var(--ink-900);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.follow-btn:hover {
  background: var(--ink-900);
  color: var(--cream-50);
}
.follow-btn[aria-pressed="true"] {
  background: var(--ink-900);
  color: var(--cream-50);
}
.follow-btn[aria-pressed="true"]:hover {
  background: var(--accent);
  border-color: var(--accent);
}
.follow-btn[aria-busy="true"] {
  opacity: 0.6;
  pointer-events: none;
}


/* ============================================================
   Mobile reductions
   ============================================================ */
@media (max-width: 720px) {
  .feed-row {
    grid-template-columns: 32px 1fr auto;
    grid-template-areas:
      "av name action"
      "av meta  ticker"
      ".  right right";
    row-gap: 4px;
    column-gap: var(--s-4);
  }
  .feed-row .avatar { grid-area: av; width: 32px; height: 32px; flex-basis: 32px; font-size: 12px; }
  .feed-row__identity { grid-area: name; }
  .feed-row__meta { grid-area: meta; }
  .feed-row__action { grid-area: action; justify-self: end; }
  .feed-row__ticker { grid-area: ticker; justify-self: end; }
  .feed-row__size, .feed-row__right { grid-area: right; }
  .feed-row__size { justify-self: start; }
  .feed-row__right { flex-direction: row; gap: var(--s-4); align-items: center; }
}

/* ============================================================
   LOAD-MORE — shared "Load more →" button + caption used on
   every list page (experts-funds, experts-activists,
   experts-congress, experts-clusters, events.php).
   Lives in components.css because it loads on every page —
   events.php has no $pageCss so it doesn't pick up
   experts-dashboard.css. Driven by /assets/js/load-more.js.

   Layout intent:
     - "Showing X of N" caption sits LEFT-ALIGNED, tight under
       the table (just below the hairline rule).
     - "Load more →" button sits CENTERED below it.
     - The two are not a centered stack — caption goes flush
       left; the button alone is the centered control.
   ============================================================ */
.load-more {
  display: flex;
  flex-direction: column;
  align-items: stretch;     /* caption fills width, button self-centers */
  gap: 16px;
  padding: 12px 0 0;        /* tight under the table */
  margin-top: 16px;
  border-top: 1px solid var(--cream-300);
}
.load-more__caption {
  font: 500 11px var(--mono);
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  font-variant-numeric: tabular-nums;
  margin: 0;
  text-align: left;         /* sit flush-left under the last row */
}
.load-more__shown,
.load-more__total {
  color: var(--ink-700);
}
.load-more__btn {
  align-self: center;       /* button alone is centered */
  font: 600 11px var(--mono);
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-900);
  background: transparent;
  border: 1px solid var(--ink-900);
  padding: 10px 20px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.load-more__btn:hover {
  background: var(--ink-900);
  color: var(--cream-50);
}
.load-more__btn:disabled {
  opacity: 0.55;
  cursor: progress;
  background: transparent;
  color: var(--ink-900);
}
.load-more__error {
  font: 400 italic 13px/1.4 var(--serif);
  color: var(--cat-activist, #8A1B2E);
  margin: 0;
  text-align: left;
}
.load-more--exhausted {
  /* Only the caption renders here — no button. Same flush-left rhythm. */
  padding: 12px 0 0;
}
