/* Young Bull · /research + /research/:ticker shared styles
   Universe wall (108-ticker filterable grid with cluster-tinted cards),
   in-page dossier panel (slides from right on card click), per-ticker
   parametric page (used by ticker.html), and sparkline strokes.

   Token contract: relies on /styles/yb.css for --layer-* hues + --gold +
   --ink-* + --bg* etc. Stays compatible with both data-yb-theme="dark"
   and "light".

   Per HANDOFF.md Phase 2: ship the v4 universe wall + dossier panel +
   ticker.html parametric template. Cards tint by canonical_layer hue,
   sparklines use rAF + CSS transition NOT anime.js width-tween (pitfall
   #11). Hash deep-link /research#MU opens the MU dossier on load.

   2026-05-16 ship.
*/

/* ────────────────────────────────────────────────────────────────
   UNIVERSE WALL (research.html)
   ──────────────────────────────────────────────────────────────── */

.rs-universe {
  padding: 32px 0 96px;
}

.rs-universe-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.rs-universe-head .label {
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute, #8a8e96);
}
.rs-universe-head .count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink, #f4f1e8);
  letter-spacing: 0.06em;
}

/* Wall grid: dense, narrow cards tinted by canonical_layer hue. */
.rs-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
}

@media (max-width: 720px) {
  .rs-wall { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
}

/* Card: compact, cluster-tinted, animated in via cascade. */
.rs-tile {
  --tint: var(--layer-current, var(--gold));
  --wash: var(--layer-current-wash, rgba(212, 168, 67, 0.08));
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 14px 12px 12px;
  background: var(--bg-elev, #1a1a1a);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.08));
  border-radius: 3px;
  text-decoration: none;
  color: var(--ink, #f4f1e8);
  cursor: pointer;
  min-height: 116px;
  overflow: hidden;
  transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1),
              border-color 160ms cubic-bezier(0.22, 1, 0.36, 1),
              background 160ms cubic-bezier(0.22, 1, 0.36, 1);

  /* Entry animation — staggered via inline animation-delay from JS */
  opacity: 0;
  transform: translateY(8px);
  animation: rs-tile-in 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes rs-tile-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Left tint band — the canonical_layer color */
.rs-tile::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--tint);
  transition: width 160ms cubic-bezier(0.22, 1, 0.36, 1);
}
.rs-tile:hover {
  transform: translateY(-2px);
  border-color: var(--tint);
  background: linear-gradient(135deg, var(--wash) 0%, var(--bg-elev, #1a1a1a) 65%);
}
.rs-tile:hover::before { width: 5px; }
.rs-tile:focus-visible {
  outline: 1px solid var(--tint);
  outline-offset: -1px;
}

.rs-tile .rs-tile-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}
.rs-tile .rs-tile-tk {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--gold, #d4a843);
}
.rs-tile.is-anchor .rs-tile-tk { color: var(--tint); }

.rs-tile .rs-tile-badge {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--tint);
  border: 1px solid var(--tint);
  padding: 1px 5px;
  border-radius: 2px;
  white-space: nowrap;
}
.rs-tile .rs-tile-badge.muted {
  color: var(--ink-mute, #8a8e96);
  border-color: var(--ink-mute, #8a8e96);
  border-style: dashed;
}

.rs-tile .rs-tile-name {
  font-size: 11.5px;
  color: var(--ink-body, var(--ink));
  line-height: 1.3;
  margin-top: 6px;
  /* Clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rs-tile .rs-tile-foot {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-mute, #8a8e96);
}
.rs-tile .rs-tile-ly { color: var(--ink-mute, #8a8e96); }
.rs-tile .rs-tile-pct {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
  color: var(--ink-mute, #8a8e96);
}
.rs-tile .rs-tile-pct.gain { color: var(--gain, #5a9a4a); }
.rs-tile .rs-tile-pct.loss { color: var(--loss, #c4423f); }

.rs-tile.has-research::after {
  content: '';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 2px var(--bg-elev, #1a1a1a), 0 0 8px rgba(212, 168, 67, 0.55);
}

/* Heart watchlist button — bottom-right corner of every tile.
   Outline heart by default, filled gold when on the user's watchlist.
   Doesn't trigger the tile's openDossier handler (event delegation
   inside research.html stops propagation). */
.rs-tile-watch {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.10));
  color: var(--ink-mute, #8a8e96);
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  padding: 0;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.rs-tile-watch:hover {
  color: var(--gold, #d4a843);
  border-color: var(--gold, #d4a843);
  background: rgba(212, 168, 67, 0.08);
  transform: scale(1.08);
}
.rs-tile-watch[aria-pressed="true"] {
  color: var(--gold, #d4a843);
  border-color: var(--gold, #d4a843);
  background: rgba(212, 168, 67, 0.14);
}
/* Anchor / held tiles get the dot indicator at top-right; nudge the
   heart so the two don't fight. */
.rs-tile.has-research .rs-tile-watch { bottom: 8px; }

/* Paper portfolio: add-to-portfolio button (next to the heart, bottom-left).
   Plus glyph when not added, filled gold check when added. */
.rs-tile-paper {
  position: absolute;
  bottom: 8px;
  right: 40px;
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.10));
  color: var(--ink-mute, #8a8e96);
  border-radius: 50%;
  font-size: 13px;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  padding: 0;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.rs-tile-paper:hover {
  color: var(--gold, #d4a843);
  border-color: var(--gold, #d4a843);
  background: rgba(212, 168, 67, 0.08);
  transform: scale(1.08);
}
.rs-tile-paper[aria-pressed="true"] {
  color: var(--gold, #d4a843);
  border-color: var(--gold, #d4a843);
  background: rgba(212, 168, 67, 0.20);
}

/* "Build Your Portfolio" CTA strip — sits below the stats, the
   conversion hook. */
.rs-build-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 24px;
  padding: 18px 22px;
  border: 1px solid var(--gold, #d4a843);
  background: linear-gradient(90deg, rgba(212, 168, 67, 0.10) 0%, rgba(212, 168, 67, 0.02) 70%);
  text-decoration: none;
  border-radius: 3px;
  transition: background 160ms ease, transform 160ms ease;
}
.rs-build-cta:hover {
  background: linear-gradient(90deg, rgba(212, 168, 67, 0.16) 0%, rgba(212, 168, 67, 0.04) 70%);
  transform: translateY(-1px);
}
.rs-build-text { display: flex; flex-direction: column; gap: 6px; }
.rs-build-label {
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold, #d4a843);
  font-weight: 600;
}
.rs-build-sub {
  font-size: 13.5px;
  color: var(--ink-body, var(--ink));
  line-height: 1.4;
}
.rs-build-arrow {
  font-size: 22px;
  color: var(--gold, #d4a843);
  font-family: var(--mono);
  flex-shrink: 0;
}

/* Paper portfolio coverage grid — one row per of 10 layers with a
   filled bar showing the user's coverage as a fraction of the universe
   in that layer. Empty layers get a contrarian "no coverage yet" stripe. */
.rs-coverage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.rs-coverage-row {
  --tint: var(--layer-current, var(--gold));
  --wash: var(--layer-current-wash, rgba(212, 168, 67, 0.08));
  padding: 14px 16px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.10));
  background: var(--bg-elev, #1a1a1a);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 3px solid var(--tint);
}
.rs-coverage-row.empty { opacity: 0.55; border-left-style: dashed; }
.rs-coverage-row .lyr {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
}
.rs-coverage-row .lyr .lbl {
  font-size: 11.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--tint);
  font-weight: 600;
}
.rs-coverage-row .lyr .frac {
  font-size: 11px;
  color: var(--ink-mute, #8a8e96);
  font-variant-numeric: tabular-nums;
}
.rs-coverage-row .lyr .frac strong { color: var(--ink); font-weight: 700; }
.rs-coverage-row .bar {
  height: 4px;
  background: var(--bg, #0c0d10);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  border-radius: 1px;
}
.rs-coverage-row .bar .fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--tint);
  width: 0;
  transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
}
.rs-coverage-row .tks {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim, var(--ink-body));
  letter-spacing: 0.04em;
  line-height: 1.5;
  min-height: 18px;
}
.rs-coverage-row .tks .miss { color: var(--ink-mute, #8a8e96); font-style: italic; }

/* Loading / empty states */
.rs-wall-loading,
.rs-wall-empty {
  grid-column: 1 / -1;
  padding: 56px 24px;
  border: 1px dashed var(--line);
  border-radius: 3px;
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0.06em;
}

/* ────────────────────────────────────────────────────────────────
   DOSSIER PANEL (in-page right slide on card click)
   ──────────────────────────────────────────────────────────────── */

.rs-dossier {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(640px, 100vw);
  background: var(--bg-elev, #1a1a1a);
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 64px rgba(0, 0, 0, 0.45);
  transform: translateX(100%);
  transition: transform 360ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 80;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.rs-dossier.is-open {
  transform: translateX(0);
}

.rs-dossier-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
  z-index: 79;
}
.rs-dossier-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.rs-dossier-head {
  position: relative;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--wash, transparent) 0%, transparent 100%);
}
.rs-dossier-head::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--tint, var(--gold));
}

.rs-dossier-eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: flex;
  align-items: center;
  gap: 10px;
}
.rs-dossier-eyebrow .layer-chip {
  color: var(--tint, var(--gold));
}

.rs-dossier-tk {
  font-family: var(--mono);
  font-size: clamp(40px, 5vw, 56px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--tint, var(--gold));
  margin: 8px 0 4px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.rs-dossier-name {
  font-size: 16px;
  color: var(--ink);
  line-height: 1.4;
}

.rs-dossier-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-mute);
  cursor: pointer;
  font-size: 16px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 160ms ease, border-color 160ms ease;
}
.rs-dossier-close:hover {
  color: var(--gold);
  border-color: var(--gold);
}

.rs-dossier-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px 32px;
}

.rs-dossier-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.5;
}
.rs-dossier-row:first-of-type { border-top: 0; }
.rs-dossier-row .lbl {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  align-self: start;
  padding-top: 2px;
}
.rs-dossier-row .val { color: var(--ink); }
.rs-dossier-row .val.dim { color: var(--ink-mute); }

.rs-dossier-thesis {
  margin-top: 18px;
  padding: 16px;
  background: var(--wash, rgba(212, 168, 67, 0.05));
  border-left: 2px solid var(--tint, var(--gold));
  font-family: var(--serif, Georgia, serif);
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--ink);
}

.rs-dossier-cta {
  margin-top: 22px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.rs-dossier-cta a {
  padding: 11px 16px;
  background: var(--tint, var(--gold));
  color: var(--bg, #0c0d10);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  text-decoration: none;
  border-radius: 2px;
  transition: filter 120ms ease;
}
.rs-dossier-cta a:hover { filter: brightness(1.1); }
.rs-dossier-cta a.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.rs-dossier-cta a.ghost:hover { border-color: var(--tint, var(--gold)); color: var(--tint, var(--gold)); }

/* ────────────────────────────────────────────────────────────────
   SPARKLINE (used in dossier + ticker.html hero)
   ──────────────────────────────────────────────────────────────── */

.rs-sparkline {
  width: 100%;
  height: 56px;
  overflow: visible;
  display: block;
  margin-top: 12px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 400ms cubic-bezier(0.22, 1, 0.36, 1),
              transform 400ms cubic-bezier(0.22, 1, 0.36, 1);
}
.rs-sparkline.is-drawn,
.rs-sparkline[data-ready="1"] {
  opacity: 1;
  transform: translateY(0);
}
.rs-sparkline .axis {
  stroke: var(--line);
  stroke-width: 1;
}
.rs-sparkline .path {
  fill: none;
  stroke: var(--tint, var(--gold));
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.rs-sparkline .fill {
  fill: var(--wash, rgba(212, 168, 67, 0.08));
}
.rs-sparkline .endcap {
  fill: var(--tint, var(--gold));
}

/* ────────────────────────────────────────────────────────────────
   TICKER.HTML PARAMETRIC PAGE
   ──────────────────────────────────────────────────────────────── */

.tk-hero {
  padding: clamp(56px, 8vw, 96px) 0 24px;
  position: relative;
}
.tk-hero::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: radial-gradient(circle at 0% 0%, var(--wash, transparent) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}
.tk-hero .container { position: relative; z-index: 1; }

.tk-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.tk-eyebrow .layer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tint, var(--gold));
  display: inline-block;
}
.tk-eyebrow .layer-name { color: var(--tint, var(--gold)); font-weight: 600; }

.tk-tkname {
  font-family: var(--mono);
  font-size: clamp(56px, 9vw, 128px);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--tint, var(--gold));
  line-height: 0.9;
  margin: 18px 0 8px;
  font-variant-numeric: tabular-nums;
}
.tk-company {
  font-family: var(--serif, Georgia, serif);
  font-size: clamp(20px, 2.4vw, 28px);
  color: var(--ink);
  font-style: italic;
  margin: 0 0 22px;
  font-weight: 400;
}

.tk-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0;
  border-top: 1px solid var(--tint, var(--gold));
  border-bottom: 1px solid var(--tint, var(--gold));
  max-width: 720px;
  margin: 28px 0 24px;
}
.tk-stats .cell {
  padding: 14px 16px;
  border-right: 1px solid var(--line);
  font-family: var(--mono);
}
.tk-stats .cell:last-child { border-right: 0; }
.tk-stats .lbl {
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: block;
  margin-bottom: 6px;
}
.tk-stats .val {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.tk-stats .val.gold { color: var(--tint, var(--gold)); }
.tk-stats .val.gain { color: var(--gain, #5a9a4a); }
.tk-stats .val.loss { color: var(--loss, #c4423f); }

@media (max-width: 540px) {
  .tk-stats { grid-template-columns: repeat(2, 1fr); }
  .tk-stats .cell:nth-child(2) { border-right: 0; }
  .tk-stats .cell:nth-child(n+3) { border-top: 1px solid var(--line); }
}

.tk-thesis {
  max-width: 680px;
  padding: 24px 28px;
  background: var(--wash, rgba(212, 168, 67, 0.04));
  border-left: 3px solid var(--tint, var(--gold));
  margin: 24px 0 36px;
  font-family: var(--serif, Georgia, serif);
  font-size: 18px;
  line-height: 1.65;
  color: var(--ink);
}
.tk-thesis em {
  font-style: italic;
  color: var(--ink-body, var(--ink));
}

.tk-section {
  padding: 36px 0;
  border-top: 1px solid var(--line);
}
.tk-section h2 {
  font-family: var(--serif, Georgia, serif);
  font-size: clamp(22px, 2.6vw, 30px);
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 16px;
}
.tk-section .section-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--tint, var(--gold));
  margin-bottom: 10px;
  display: block;
}
.tk-section p,
.tk-section li {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-body, var(--ink));
  max-width: 64ch;
}
.tk-section ul { padding-left: 18px; margin: 8px 0; }
.tk-section li { margin: 6px 0; }

/* Kill-vectors list — each is a structural risk callout */
.tk-killvectors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.tk-killvectors .kv {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--loss, #c4423f);
  background: var(--bg-elev);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-body, var(--ink));
}
.tk-killvectors .kv strong {
  color: var(--loss, #c4423f);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

.tk-empty-state {
  padding: 56px 28px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 4px;
  color: var(--ink-mute);
  font-size: 14px;
}

/* Mobile: dossier becomes full-width bottom sheet */
@media (max-width: 720px) {
  .rs-dossier {
    width: 100%;
    height: 92vh;
    top: auto;
    bottom: 0;
    border-left: 0;
    border-top: 1px solid var(--line);
    transform: translateY(100%);
  }
  .rs-dossier.is-open { transform: translateY(0); }
}

/* Reduced motion: kill animations */
@media (prefers-reduced-motion: reduce) {
  .rs-tile { animation: none; opacity: 1; transform: none; }
  .rs-dossier { transition: none; }
  .rs-sparkline .path,
  .rs-sparkline .fill,
  .rs-sparkline .endcap { transition: none; }
}
