/* ============================================================
   CRCL Research Deck — Design System
   Hedge-fund research note × Bloomberg terminal × editorial
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap');

/* ---------- Tokens ---------- */
:root {
  /* Ground / surfaces — warm-tinted near-black */
  --ground:        oklch(15% 0.006 55);
  --ground-deep:   oklch(11% 0.005 55);
  --surface:       oklch(19% 0.007 55);
  --surface-2:     oklch(22% 0.008 55);
  --hairline:      oklch(30% 0.010 55);
  --hairline-soft: oklch(25% 0.008 55);

  /* Text — warm off-white */
  --text:          oklch(94% 0.010 70);
  --text-strong:   oklch(98% 0.012 75);
  --text-mute:     oklch(72% 0.014 60);
  --text-faint:    oklch(54% 0.012 55);

  /* Accents */
  --bull:          oklch(78% 0.135 78);          /* warm amber */
  --bull-soft:     oklch(78% 0.135 78 / 0.16);
  --bull-line:     oklch(78% 0.135 78 / 0.4);
  --bear:          oklch(60% 0.115 35);          /* desaturated copper/rust */
  --bear-soft:     oklch(60% 0.115 35 / 0.16);
  --bear-line:     oklch(60% 0.115 35 / 0.4);
  --neutral:       oklch(62% 0.018 55);          /* warm gray */
  --neutral-soft:  oklch(62% 0.018 55 / 0.16);
  --binary:        oklch(70% 0.085 240);         /* cool slate-blue, used SPARINGLY for binary catalysts */
  --binary-soft:   oklch(70% 0.085 240 / 0.16);

  /* Conviction tiers */
  --tier-starter:  var(--neutral);
  --tier-add:      var(--bull);
  --tier-fatpitch: oklch(82% 0.16 75);

  /* Typography */
  --serif: 'Spectral', 'Source Serif 4', Georgia, serif;
  --sans:  'Geist', system-ui, -apple-system, sans-serif;
  --mono:  'Geist Mono', 'IBM Plex Mono', ui-monospace, monospace;

  /* Type scale (fixed rem for app/deck context) */
  --t-xs:   0.6875rem;   /* 11px */
  --t-sm:   0.8125rem;   /* 13px */
  --t-base: 0.9375rem;   /* 15px */
  --t-md:   1.0625rem;   /* 17px */
  --t-lg:   1.3125rem;   /* 21px */
  --t-xl:   1.6875rem;   /* 27px */
  --t-2xl:  2.25rem;     /* 36px */
  --t-3xl:  3rem;        /* 48px */
  --t-4xl:  4.25rem;     /* 68px */
  --t-display: clamp(3.5rem, 8vw, 6.5rem);

  /* Spacing (4pt) */
  --s-1:  0.25rem;
  --s-2:  0.5rem;
  --s-3:  0.75rem;
  --s-4:  1rem;
  --s-5:  1.5rem;
  --s-6:  2rem;
  --s-7:  3rem;
  --s-8:  4rem;
  --s-9:  6rem;

  /* Layout */
  --col:  72rem;
  --col-wide: 88rem;
  --col-prose: 38rem;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.25, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ground);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--t-base);
  line-height: 1.55;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible {
  outline: 1px solid var(--bull);
  outline-offset: 2px;
}

p { margin: 0 0 var(--s-4) 0; max-width: 65ch; }

::selection { background: var(--bull-soft); color: var(--text-strong); }

/* ---------- Typography ---------- */
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.mono  { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tnum  { font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--mono);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  font-weight: 500;
}

.h1, h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: var(--t-3xl);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text-strong);
  margin: 0;
}
.h2, h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: var(--t-2xl);
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--text-strong);
  margin: 0 0 var(--s-4) 0;
}
.h3, h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--t-xl);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text-strong);
  margin: 0 0 var(--s-3) 0;
}
.h4, h4 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: var(--t-md);
  line-height: 1.25;
  color: var(--text-strong);
  margin: 0 0 var(--s-2) 0;
}

.lead {
  font-family: var(--serif);
  font-size: var(--t-md);
  line-height: 1.55;
  color: var(--text);
  font-style: italic;
  font-weight: 400;
}

/* ---------- Decision frame (the persistent header strip) ---------- */
.frame {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklch, var(--ground-deep), transparent 8%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
}
.frame-inner {
  max-width: var(--col-wide);
  margin: 0 auto;
  padding: var(--s-3) var(--s-6);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-6);
}
.frame-mark {
  font-family: var(--serif);
  font-size: var(--t-md);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-strong);
}
.frame-mark .ticker {
  font-family: var(--mono);
  font-size: var(--t-sm);
  color: var(--text-faint);
  margin-left: var(--s-2);
  letter-spacing: 0.05em;
}
.frame-meta {
  display: flex;
  gap: var(--s-6);
  justify-content: center;
  flex-wrap: wrap;
}
.frame-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
}
.frame-meta-label {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-faint);
}
.frame-meta-val {
  font-family: var(--mono);
  font-size: var(--t-sm);
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.frame-meta-val.bull { color: var(--bull); }
.frame-meta-val.bear { color: var(--bear); }
.frame-nav {
  display: flex;
  gap: var(--s-4);
  font-family: var(--mono);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
}
.frame-nav a {
  padding: var(--s-1) 0;
  border-bottom: 1px solid transparent;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.frame-nav a:hover { color: var(--text-strong); border-bottom-color: var(--bull); }
.frame-nav a.active { color: var(--text-strong); border-bottom-color: var(--bull); }

/* ---------- Layout ---------- */
.shell {
  max-width: var(--col-wide);
  margin: 0 auto;
  padding: var(--s-7) var(--s-6) var(--s-9);
}
.shell-narrow {
  max-width: var(--col);
  margin: 0 auto;
  padding: var(--s-7) var(--s-6) var(--s-9);
}
.section {
  margin-block: var(--s-9);
  padding-top: var(--s-7);
  border-top: 1px solid var(--hairline);
}
.section-head {
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: var(--s-5);
  margin-bottom: var(--s-6);
  align-items: baseline;
}
.section-num {
  font-family: var(--mono);
  font-size: var(--t-sm);
  color: var(--text-faint);
  letter-spacing: 0.12em;
}
.prose { max-width: 65ch; color: var(--text); }
.prose p { margin: 0 0 var(--s-4) 0; }
.prose strong { color: var(--text-strong); font-weight: 600; }
.prose em.attr {
  font-style: normal;
  font-family: var(--mono);
  font-size: var(--t-xs);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: block;
  margin-top: var(--s-2);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-6); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-5); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }
@media (max-width: 800px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .section-head { grid-template-columns: 1fr; gap: var(--s-2); }
  .frame-inner { grid-template-columns: 1fr; gap: var(--s-3); }
  .frame-meta { gap: var(--s-4); }
}

/* ---------- Cards / boxes ---------- */
.box {
  background: var(--surface);
  border: 1px solid var(--hairline);
  padding: var(--s-5);
}
.box-tight { padding: var(--s-4); }
.box-loose { padding: var(--s-6); }

/* Verdict bar (the conviction header) */
.verdict {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border: 1px solid var(--hairline);
  background: var(--surface);
}
.verdict-cell {
  padding: var(--s-4);
  border-right: 1px solid var(--hairline-soft);
}
.verdict-cell:last-child { border-right: none; }
.verdict-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  margin-bottom: var(--s-2);
}
.verdict-val {
  font-family: var(--serif);
  font-size: var(--t-lg);
  font-weight: 500;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}
.verdict-val.bull { color: var(--bull); }
.verdict-val.bear { color: var(--bear); }
.verdict-sub {
  margin-top: var(--s-1);
  font-family: var(--mono);
  font-size: var(--t-xs);
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
}

/* Conviction gauge — 5 segment */
.gauge {
  display: flex;
  gap: 3px;
  margin-top: var(--s-2);
}
.gauge-seg {
  height: 6px;
  flex: 1;
  background: var(--hairline);
}
.gauge-seg.on { background: var(--bull); }
.gauge-seg.partial { background: linear-gradient(to right, var(--bull) 50%, var(--hairline) 50%); }

/* ---------- Tables ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: var(--t-sm);
  border-top: 1px solid var(--hairline);
}
.table th, .table td {
  padding: var(--s-3) var(--s-4);
  text-align: left;
  border-bottom: 1px solid var(--hairline-soft);
  vertical-align: top;
}
.table th {
  font-family: var(--mono);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  font-weight: 500;
  background: var(--ground-deep);
}
.table td.num { font-variant-numeric: tabular-nums; text-align: right; font-family: var(--mono); }
.table td.bull { color: var(--bull); }
.table td.bear { color: var(--bear); }
.table tr:hover td { background: color-mix(in oklch, var(--surface), transparent 50%); }

/* ---------- Tags / pills ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 3px var(--s-2);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-mute);
  border: 1px solid var(--hairline);
  background: var(--ground-deep);
}
.tag.bull { color: var(--bull); border-color: var(--bull-line); }
.tag.bear { color: var(--bear); border-color: var(--bear-line); }
.tag.binary { color: var(--binary); border-color: oklch(70% 0.085 240 / 0.4); }
.tag.solid-bull { background: var(--bull-soft); color: var(--bull); border-color: var(--bull-line); }
.tag.solid-bear { background: var(--bear-soft); color: var(--bear); border-color: var(--bear-line); }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--hairline);
  padding: var(--s-6);
  margin-top: var(--s-9);
}
.footer-inner {
  max-width: var(--col-wide);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-5);
  font-family: var(--mono);
  font-size: var(--t-xs);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.footer a { color: var(--text-mute); border-bottom: 1px solid var(--hairline); }
.footer a:hover { color: var(--bull); border-bottom-color: var(--bull); }

/* ---------- Page tile (cohort hub style) ---------- */
.tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--hairline);
  padding: var(--s-5);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
  position: relative;
}
.tile:hover {
  border-color: var(--bull-line);
  background: var(--surface-2);
}
.tile-num {
  font-family: var(--mono);
  font-size: var(--t-xs);
  color: var(--text-faint);
  letter-spacing: 0.16em;
}
.tile-title {
  font-family: var(--serif);
  font-size: var(--t-lg);
  font-weight: 500;
  color: var(--text-strong);
  margin-top: var(--s-3);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.tile-teaser {
  margin-top: var(--s-3);
  font-size: var(--t-sm);
  color: var(--text-mute);
  line-height: 1.55;
}
.tile-arrow {
  position: absolute;
  top: var(--s-5);
  right: var(--s-5);
  font-family: var(--mono);
  color: var(--text-faint);
  transition: color 0.2s var(--ease), transform 0.2s var(--ease);
}
.tile:hover .tile-arrow { color: var(--bull); transform: translateX(2px); }

/* ---------- Quote / pull-quote ---------- */
.quote {
  border-left: 0;
  padding-left: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--t-md);
  line-height: 1.5;
  color: var(--text);
  position: relative;
  padding-block: var(--s-2);
}
.quote::before {
  content: "";
  display: block;
  width: 32px;
  height: 1px;
  background: var(--bull);
  margin-bottom: var(--s-3);
}
.quote-attr {
  display: block;
  margin-top: var(--s-3);
  font-family: var(--mono);
  font-style: normal;
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
}

/* ---------- SVG defaults ---------- */
svg { display: block; }
svg text {
  font-family: var(--mono);
  fill: var(--text-mute);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
svg .label-serif {
  font-family: var(--serif);
  font-style: normal;
  font-size: 13px;
  fill: var(--text-strong);
}
svg .axis-line { stroke: var(--hairline); stroke-width: 1; }
svg .grid-line { stroke: var(--hairline-soft); stroke-width: 1; stroke-dasharray: 2 3; }
svg .data-bull { fill: var(--bull); }
svg .data-bear { fill: var(--bear); }
svg .data-neutral { fill: var(--neutral); }

/* ---------- Mermaid theming hooks ---------- */
.mermaid-frame {
  background: var(--ground-deep);
  border: 1px solid var(--hairline);
  padding: var(--s-5);
  overflow-x: auto;
}
.mermaid { font-family: var(--mono) !important; }
.mermaid svg { max-width: 100%; height: auto; }

/* ---------- Utility ---------- */
.muted { color: var(--text-mute); }
.faint { color: var(--text-faint); }
.strong { color: var(--text-strong); }
.bull { color: var(--bull); }
.bear { color: var(--bear); }
.binary { color: var(--binary); }
.center { text-align: center; }
.right { text-align: right; }
.mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mt-5 { margin-top: var(--s-5); }
.mt-6 { margin-top: var(--s-6); }
.mt-7 { margin-top: var(--s-7); }
.mb-3 { margin-bottom: var(--s-3); }
.mb-4 { margin-bottom: var(--s-4); }
.mb-5 { margin-bottom: var(--s-5); }
.mb-6 { margin-bottom: var(--s-6); }

/* Page-load fade-in */
@media (prefers-reduced-motion: no-preference) {
  .fade-in {
    animation: fadeIn 0.6s var(--ease) both;
  }
  .fade-in-d1 { animation-delay: 0.1s; }
  .fade-in-d2 { animation-delay: 0.2s; }
  .fade-in-d3 { animation-delay: 0.3s; }
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}
